Commit 50dd985e authored by Sebastian Gottfried's avatar Sebastian Gottfried
Browse files

Qt5: Fix Layout Of Custom Lesson Editor Dialog

Port to QDialog with QButtonBox in it.
parent 14876596
......@@ -77,7 +77,7 @@ set(ktouch_SRCS
editor/charactersviewdelegate.cpp
trainingconfigwidget.cpp
colorsconfigwidget.cpp
customlessoneditorwidget.cpp
customlessoneditordialog.cpp
)
# compile UI files
......@@ -93,7 +93,7 @@ qt5_wrap_ui(ktouch_SRCS
ui/lessontexteditor.ui
ui/keyboardlayouteditor.ui
ui/keyboardlayoutpropertieswidget.ui
ui/customlessoneditorwidget.ui
ui/customlessoneditordialog.ui
)
if (X11_Xkbfile_FOUND)
......
......@@ -15,7 +15,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "customlessoneditorwidget.h"
#include "customlessoneditordialog.h"
#include <QPushButton>
#include "core/keyboardlayout.h"
#include "core/key.h"
......@@ -23,9 +25,9 @@
#include "core/lesson.h"
#include "editor/lessontexthighlighter.h"
CustomLessonEditorWidget::CustomLessonEditorWidget(QWidget* parent) :
QWidget(parent),
Ui::CustomLessonEditorWidget(),
CustomLessonEditorDialog::CustomLessonEditorDialog(QWidget* parent) :
QDialog(parent),
Ui::CustomLessonEditorDialog(),
m_lesson(0),
m_keyboardLayout(0)
{
......@@ -33,14 +35,15 @@ CustomLessonEditorWidget::CustomLessonEditorWidget(QWidget* parent) :
connect(m_titleLineEdit, SIGNAL(textChanged(QString)), SLOT(onTitleChanged()));
connect(m_lessonTextEditor->textEdit(), SIGNAL(textChanged()), SLOT(onTextChanged()));
connect(this, &CustomLessonEditorDialog::validChanged, m_buttonBox->button(QDialogButtonBox::Ok), &QPushButton::setEnabled);
}
Lesson* CustomLessonEditorWidget::lesson() const
Lesson* CustomLessonEditorDialog::lesson() const
{
return m_lesson;
}
void CustomLessonEditorWidget::setLesson(Lesson* lesson)
void CustomLessonEditorDialog::setLesson(Lesson* lesson)
{
if (lesson != m_lesson)
{
......@@ -62,12 +65,12 @@ void CustomLessonEditorWidget::setLesson(Lesson* lesson)
}
}
KeyboardLayout* CustomLessonEditorWidget::keyboardLayout() const
KeyboardLayout* CustomLessonEditorDialog::keyboardLayout() const
{
return m_keyboardLayout;
}
void CustomLessonEditorWidget::setKeyboardLayout(KeyboardLayout* keyboardLayout)
void CustomLessonEditorDialog::setKeyboardLayout(KeyboardLayout* keyboardLayout)
{
if (keyboardLayout != m_keyboardLayout)
{
......@@ -86,7 +89,7 @@ void CustomLessonEditorWidget::setKeyboardLayout(KeyboardLayout* keyboardLayout)
}
}
void CustomLessonEditorWidget::updateTitle()
void CustomLessonEditorDialog::updateTitle()
{
const QString title = m_lesson->title();
......@@ -96,7 +99,7 @@ void CustomLessonEditorWidget::updateTitle()
}
}
void CustomLessonEditorWidget::updateText()
void CustomLessonEditorDialog::updateText()
{
const QString text = m_lesson->text();
......@@ -106,7 +109,7 @@ void CustomLessonEditorWidget::updateText()
}
}
void CustomLessonEditorWidget::updateAllowedCharacters()
void CustomLessonEditorDialog::updateAllowedCharacters()
{
if (!m_keyboardLayout || !m_keyboardLayout->isValid())
{
......@@ -134,7 +137,7 @@ void CustomLessonEditorWidget::updateAllowedCharacters()
m_lessonTextEditor->highlighter()->setAllowedCharacters(chars);
}
void CustomLessonEditorWidget::onTitleChanged()
void CustomLessonEditorDialog::onTitleChanged()
{
if (!m_lesson)
return;
......@@ -144,7 +147,7 @@ void CustomLessonEditorWidget::onTitleChanged()
emitValidChanged();
}
void CustomLessonEditorWidget::onTextChanged()
void CustomLessonEditorDialog::onTextChanged()
{
if (!m_lesson)
return;
......@@ -154,7 +157,7 @@ void CustomLessonEditorWidget::onTextChanged()
emitValidChanged();
}
void CustomLessonEditorWidget::emitValidChanged()
void CustomLessonEditorDialog::emitValidChanged()
{
const QString title = m_lesson->title();
const QString text = m_lesson->text();
......
......@@ -16,21 +16,21 @@
*/
#ifndef CUSTOMLESSONEDITORWIDGET_H
#define CUSTOMLESSONEDITORWIDGET_H
#ifndef CUSTOMLESSONEDITORDIALOG_H
#define CUSTOMLESSONEDITORDIALOG_H
#include <QWidget>
#include <QDialog>
#include "ui_customlessoneditorwidget.h"
#include "ui_customlessoneditordialog.h"
class Lesson;
class KeyboardLayout;
class CustomLessonEditorWidget : public QWidget, private Ui::CustomLessonEditorWidget
class CustomLessonEditorDialog : public QDialog, private Ui::CustomLessonEditorDialog
{
Q_OBJECT
public:
explicit CustomLessonEditorWidget(QWidget* parent = 0);
explicit CustomLessonEditorDialog(QWidget* parent = 0);
Lesson* lesson() const;
void setLesson(Lesson* lesson);
KeyboardLayout* keyboardLayout() const;
......@@ -49,4 +49,4 @@ private:
KeyboardLayout* m_keyboardLayout;
};
#endif // CUSTOMLESSONEDITORWIDGET_H
#endif // CUSTOMLESSONEDITORDIALOG_H
......@@ -40,7 +40,7 @@
#include "preferences.h"
#include "trainingconfigwidget.h"
#include "colorsconfigwidget.h"
#include "customlessoneditorwidget.h"
#include "customlessoneditordialog.h"
#ifdef KTOUCH_BUILD_WITH_X11
#include "x11_helper.h"
......@@ -112,19 +112,10 @@ void MainWindow::showResourceEditor()
bool MainWindow::showCustomLessonDialog(Lesson* lesson, KeyboardLayout* keyboardLayout)
{
QDialog* dialog = new QDialog(this);
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, dialog);
CustomLessonEditorWidget* editor = new CustomLessonEditorWidget(buttonBox);
buttonBox->setWindowTitle(i18n("Edit Custom Lesson"));
connect(editor, &CustomLessonEditorWidget::validChanged, buttonBox->button(QDialogButtonBox::Ok), &QPushButton::setEnabled);
editor->setLesson(lesson);
editor->setKeyboardLayout(keyboardLayout);
CustomLessonEditorDialog* dialog = new CustomLessonEditorDialog(this);
dialog->setLesson(lesson);
dialog->setKeyboardLayout(keyboardLayout);
bool result = dialog->exec() == QDialog::Accepted;
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CustomLessonEditorDialog</class>
<widget class="QDialog" name="CustomLessonEditorDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>601</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="m_titleLabel">
<property name="text">
<string>Title:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KLineEdit" name="m_titleLineEdit"/>
</item>
</layout>
</item>
<item>
<spacer name="m_verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="LessonTextEditor" name="m_lessonTextEditor" native="true"/>
</item>
<item>
<widget class="QDialogButtonBox" name="m_buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
<customwidget>
<class>LessonTextEditor</class>
<extends>QWidget</extends>
<header>editor/lessontexteditor.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>m_buttonBox</sender>
<signal>accepted()</signal>
<receiver>CustomLessonEditorDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_buttonBox</sender>
<signal>rejected()</signal>
<receiver>CustomLessonEditorDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment