aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Gottfried <sebastiangottfried@web.de>2015-06-08 10:33:46 (GMT)
committerSebastian Gottfried <sebastiangottfried@web.de>2015-06-08 10:33:46 (GMT)
commit50dd985e525c0489b9de3895445eb02d04e6d5a4 (patch)
tree81acf90189f223f8f14cb98033e236c69ad4cec8
parent148765963503077c1033345a032df84c63d02e25 (diff)
Qt5: Fix Layout Of Custom Lesson Editor Dialog
Port to QDialog with QButtonBox in it.
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/customlessoneditordialog.cpp (renamed from src/customlessoneditorwidget.cpp)31
-rw-r--r--src/customlessoneditordialog.h (renamed from src/customlessoneditorwidget.h)14
-rw-r--r--src/mainwindow.cpp17
-rw-r--r--src/ui/customlessoneditordialog.ui110
5 files changed, 140 insertions, 36 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 161c234..44b99b7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -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)
diff --git a/src/customlessoneditorwidget.cpp b/src/customlessoneditordialog.cpp
index e3cff95..8a9f8da 100644
--- a/src/customlessoneditorwidget.cpp
+++ b/src/customlessoneditordialog.cpp
@@ -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();
diff --git a/src/customlessoneditorwidget.h b/src/customlessoneditordialog.h
index e871e21..9e564c4 100644
--- a/src/customlessoneditorwidget.h
+++ b/src/customlessoneditordialog.h
@@ -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
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 606a724..aff8c7b 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -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;
diff --git a/src/ui/customlessoneditordialog.ui b/src/ui/customlessoneditordialog.ui
new file mode 100644
index 0000000..204b255
--- /dev/null
+++ b/src/ui/customlessoneditordialog.ui
@@ -0,0 +1,110 @@
+<?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>