[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [artikulate] src: Port to KConfigDialog.
From: Andreas Cord-Landwehr <cordlandwehr () kde ! org>
Date: 2013-05-25 11:52:24
Message-ID: 20130525115224.874B6A6071 () git ! kde ! org
[Download RAW message or body]
Git commit 641a16920aeeafebea3b24a59582fc0f18d8bc52 by Andreas Cord-Landwehr.
Committed on 23/05/2013 at 20:47.
Pushed by cordlandwehr into branch 'master'.
Port to KConfigDialog.
M +5 -5 src/CMakeLists.txt
M +1 -1 src/artikulate.kcfg
M +22 -15 src/mainwindow.cpp
M +0 -1 src/mainwindow.h
D +0 -74 src/ui/resourcesdialog.cpp
A +80 -0 src/ui/resourcesdialogpage.cpp [License: GPL (v2/3)]
R +13 -10 src/ui/resourcesdialogpage.h [from: src/ui/resourcesdialog.h - 070% \
similarity] R +8 -28 src/ui/resourcesdialogpage.ui [from: \
src/ui/resourcesdialog.ui - 077% similarity] R +17 -12 \
src/ui/sounddevicedialogpage.cpp [from: src/ui/sounddevicedialog.cpp - 071% \
similarity] R +13 -9 src/ui/sounddevicedialogpage.h [from: \
src/ui/sounddevicedialog.h - 074% similarity] R +2 -2 \
src/ui/sounddevicedialogpage.ui [from: src/ui/sounddevicedialog.ui - 098% similarity]
http://commits.kde.org/artikulate/641a16920aeeafebea3b24a59582fc0f18d8bc52
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 25bf0b4..015390b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -56,7 +56,7 @@ set(artikulateCore_SRCS
ui/newcoursedialog.cpp
)
kde4_add_ui_files(artikulateCore_SRCS
- ui/sounddevicedialog.ui
+ ui/newcoursedialog.ui
)
kde4_add_kcfg_files(artikulateCore_SRCS settings.kcfgc)
kde4_add_library(artikulatecore SHARED ${artikulateCore_SRCS})
@@ -95,14 +95,14 @@ set(artikulate_SRCS
models/phonemeunitmodel.cpp
models/skeletonmodel.cpp
- ui/sounddevicedialog.cpp
- ui/resourcesdialog.cpp
+ ui/sounddevicedialogpage.cpp
+ ui/resourcesdialogpage.cpp
declarativeitems/applicationbackground.cpp
)
kde4_add_ui_files(artikulate_SRCS
- ui/resourcesdialog.ui
- ui/sounddevicedialog.ui
+ ui/resourcesdialogpage.ui
+ ui/sounddevicedialogpage.ui
)
kde4_add_kcfg_files(artikulate_SRCS settings.kcfgc)
kde4_add_executable(artikulate ${artikulate_SRCS})
diff --git a/src/artikulate.kcfg b/src/artikulate.kcfg
index 7162a04..1251c56 100644
--- a/src/artikulate.kcfg
+++ b/src/artikulate.kcfg
@@ -8,7 +8,7 @@
<group name="artikulate">
<entry name="UseCourseRepository" type="Bool">
<label>If enabled, course files are only read from the local contributor \
repository</label>
- <default>true</default>
+ <default> false </default>
</entry>
<entry name="CourseRepositoryPath" type="Path">
<label>Path to local contributor repository</label>
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index bd00058..20c0c66 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Andreas Cord-Landwehr <cordlandwehr@gmail.com>
+ * Copyright 2013 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -19,8 +19,8 @@
*/
#include "mainwindow.h"
-#include "ui/resourcesdialog.h"
-#include "ui/sounddevicedialog.h"
+#include "ui/resourcesdialogpage.h"
+#include "ui/sounddevicedialogpage.h"
#include "core/resourcemanager.h"
#include "core/profile.h"
#include "models/languagemodel.h"
@@ -37,6 +37,7 @@
#include <KStandardDirs>
#include <kdeclarative.h>
#include <KMenu>
+#include <KConfigDialog>
#include <KDebug>
#include <QGraphicsObject>
@@ -76,16 +77,11 @@ MainWindow::MainWindow()
m_actionCollection->addAction("editor", editorAction);
m_menu->addAction(editorAction);
- KAction *settingsAction = new KAction(i18n("Course Settings"), this);
+ KAction *settingsAction = new KAction(i18n("Settings"), this);
connect(settingsAction, SIGNAL(triggered()), SLOT(showSettingsDialog()));
m_actionCollection->addAction("settings", settingsAction);
m_menu->addAction(settingsAction);
- KAction *settingsSoundAction = new KAction(i18n("Sound Settings"), this);
- connect(settingsSoundAction, SIGNAL(triggered()), \
SLOT(showSettingsSoundDialog()));
- m_actionCollection->addAction("settingsSound", settingsSoundAction);
- m_menu->addAction(settingsSoundAction);
-
m_menu->addSeparator();
KHelpMenu *helpMenu = new KHelpMenu(m_menu, KCmdLineArgs::aboutData(), false, \
m_actionCollection); @@ -136,12 +132,23 @@ void MainWindow::showMenu(int xPos, int \
yPos)
void MainWindow::showSettingsDialog()
{
- QPointer<ResourcesDialog> dialog = new ResourcesDialog(m_resourceManager);
- dialog->exec();
-}
+ if (KConfigDialog::showDialog("settings")) {
+ return;
+ }
+ QPointer<KConfigDialog> dialog = new KConfigDialog(this, "settings", \
Settings::self()); +
+ ResourcesDialogPage *resourceDialog = new \
ResourcesDialogPage(m_resourceManager); + SoundDeviceDialogPage *soundDialog = new \
SoundDeviceDialogPage(); + resourceDialog->loadSettings();
+ soundDialog->loadSettings();
+
+ dialog->addPage(soundDialog, i18nc("@item:inmenu", "Sound Devices"), \
"audio-headset", i18nc("@title:tab", "Sound Device Settings"), true); + \
dialog->addPage(resourceDialog, i18nc("@item:inmenu", "Course Resources"), \
"repository", i18nc("@title:tab", "Resource Repository Settings"), true); +
+// connect(dialog, SIGNAL(settingsChanged(const QString&)), resourceDialog, \
SLOT(loadSettings())); +// connect(dialog, SIGNAL(settingsChanged(const \
QString&)), soundDialog, SLOT(loadSettings())); + connect(dialog, \
SIGNAL(accepted()), resourceDialog, SLOT(saveSettings())); + connect(dialog, \
SIGNAL(accepted()), soundDialog, SLOT(saveSettings()));
-void MainWindow::showSettingsSoundDialog()
-{
- QPointer<SoundDeviceDialog> dialog = new SoundDeviceDialog();
dialog->exec();
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 0532f73..9a780c0 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -60,7 +60,6 @@ public slots:
void showCourseEditor();
void closeCourseEditor();
void showSettingsDialog();
- void showSettingsSoundDialog();
private:
QDeclarativeView *m_view;
diff --git a/src/ui/resourcesdialog.cpp b/src/ui/resourcesdialog.cpp
deleted file mode 100644
index 8bcb390..0000000
--- a/src/ui/resourcesdialog.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2013 Andreas Cord-Landwehr <cordlandwehr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License or (at your option) version 3 or any later version
- * accepted by the membership of KDE e.V. (or its successor approved
- * by the membership of KDE e.V.), which shall act as a proxy
- * defined in Section 14 of version 3 of the license.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resourcesdialog.h"
-#include "core/resourcemanager.h"
-#include "core/language.h"
-#include "core/skeleton.h"
-#include "core/course.h"
-#include "settings.h"
-
-#include <KLocale>
-#include <QUuid>
-
-ResourcesDialog::ResourcesDialog(ResourceManager *m_resourceManager)
- : KDialog(0)
- , m_resourceManager(m_resourceManager)
-{
- setPlainCaption(i18n("Course Resources"));
- setButtons(KDialog::Ok | KDialog::Cancel);
- setDefaultButton(KDialog::Ok);
-
- QWidget *widget = new QWidget(this);
- ui = new Ui::ResourcesDialog;
-
- ui->setupUi(widget);
- setMainWidget(widget);
-
- // setup Ui with stored settings
- ui->repositoryUrl->setPath(Settings::courseRepositoryPath());
- if (Settings::useCourseRepository()) {
- ui->radioRepository->setChecked(true);
- } else {
- ui->radioRepository->setChecked(false);
- }
- ui->repositoryUrl->setEnabled(ui->radioRepository->isChecked());
- ui->restartInfo->setVisible(false);
-
- // activate path selector only if repository should be used
- connect(ui->radioRepository, SIGNAL(toggled(bool)), ui->repositoryUrl, \
SLOT(setEnabled(bool)));
- connect(this, SIGNAL(okClicked()), this, SLOT(saveSettings()));
-
- // show restart info if anything is changed
- connect(ui->radioIntalledCourses, SIGNAL(toggled(bool)), ui->restartInfo, \
SLOT(setVisible(bool)));
- connect(ui->radioRepository, SIGNAL(toggled(bool)), ui->restartInfo, \
SLOT(setVisible(bool)));
-}
-
-ResourcesDialog::~ResourcesDialog()
-{
- delete ui;
-}
-
-void ResourcesDialog::saveSettings()
-{
- // save settings
- Settings::setUseCourseRepository(ui->radioRepository->isChecked());
- Settings::setCourseRepositoryPath(ui->repositoryUrl->text());
-}
diff --git a/src/ui/resourcesdialogpage.cpp b/src/ui/resourcesdialogpage.cpp
new file mode 100644
index 0000000..2b4315c
--- /dev/null
+++ b/src/ui/resourcesdialogpage.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2013 Andreas Cord-Landwehr <cordlandwehr@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "resourcesdialogpage.h"
+#include "core/resourcemanager.h"
+#include "core/language.h"
+#include "core/skeleton.h"
+#include "core/course.h"
+#include "settings.h"
+
+#include <KLocale>
+#include <QUuid>
+
+ResourcesDialogPage::ResourcesDialogPage(ResourceManager *m_resourceManager)
+ : QWidget(0)
+ , m_resourceManager(m_resourceManager)
+ , m_restartNeeded(false)
+{
+ ui = new Ui::ResourcesDialogPage;
+ ui->setupUi(this);
+
+ // activate path selector only if repository should be used
+ connect(ui->kcfg_UseCourseRepository, SIGNAL(toggled(bool)), this, \
SLOT(updateHints())); + connect(ui->kcfg_CourseRepositoryPath, \
SIGNAL(textChanged(QString)), this, SLOT(updateHints())); +
+ updateHints();
+}
+
+ResourcesDialogPage::~ResourcesDialogPage()
+{
+ delete ui;
+}
+
+void ResourcesDialogPage::updateHints()
+{
+ if (ui->kcfg_UseCourseRepository->isChecked() != Settings::useCourseRepository()
+ || ui->kcfg_UseCourseRepository->text() != Settings::courseRepositoryPath() \
) + {
+ m_restartNeeded = true;
+ } else {
+ m_restartNeeded = false;
+ }
+ ui->restartInfo->setVisible(m_restartNeeded);
+ ui->kcfg_CourseRepositoryPath->setEnabled(ui->kcfg_UseCourseRepository->isChecked());
+}
+
+void ResourcesDialogPage::loadSettings()
+{
+ // setup Ui with stored settings
+ ui->kcfg_CourseRepositoryPath->setText(Settings::courseRepositoryPath());
+ ui->kcfg_UseCourseRepository->setChecked(Settings::useCourseRepository());
+
+ ui->kcfg_CourseRepositoryPath->setEnabled(ui->kcfg_UseCourseRepository->isChecked());
+ ui->restartInfo->setVisible(false);
+}
+
+void ResourcesDialogPage::saveSettings()
+{
+ // save settings
+ Settings::setUseCourseRepository(ui->kcfg_UseCourseRepository->isChecked());
+ Settings::setCourseRepositoryPath(ui->kcfg_CourseRepositoryPath->text());
+ Settings::self()->writeConfig();
+}
diff --git a/src/ui/resourcesdialog.h b/src/ui/resourcesdialogpage.h
similarity index 70%
rename from src/ui/resourcesdialog.h
rename to src/ui/resourcesdialogpage.h
index c46831a..f2f3a04 100644
--- a/src/ui/resourcesdialog.h
+++ b/src/ui/resourcesdialogpage.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Andreas Cord-Landwehr <cordlandwehr@gmail.com>
+ * Copyright 2013 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -18,30 +18,33 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef RESOURCESDIALOG_H
-#define RESOURCESDIALOG_H
+#ifndef RESOURCESDIALOGPAGE_H
+#define RESOURCESDIALOGPAGE_H
-#include "ui_resourcesdialog.h"
-#include <KDialog>
+#include "ui_resourcesdialogpage.h"
+#include <QWidget>
class ResourceManager;
class Course;
-class ResourcesDialog :
- public KDialog
+class ResourcesDialogPage :
+ public QWidget
{
Q_OBJECT
public:
- explicit ResourcesDialog(ResourceManager *resourceMgr);
- virtual ~ResourcesDialog();
+ explicit ResourcesDialogPage(ResourceManager *resourceMgr);
+ virtual ~ResourcesDialogPage();
public slots:
void saveSettings();
+ void loadSettings();
+ void updateHints();
private:
- Ui::ResourcesDialog *ui;
+ Ui::ResourcesDialogPage *ui;
ResourceManager *m_resourceManager;
+ bool m_restartNeeded;
};
#endif
diff --git a/src/ui/resourcesdialog.ui b/src/ui/resourcesdialogpage.ui
similarity index 77%
rename from src/ui/resourcesdialog.ui
rename to src/ui/resourcesdialogpage.ui
index 10dd700..e2e32ce 100644
--- a/src/ui/resourcesdialog.ui
+++ b/src/ui/resourcesdialogpage.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>ResourcesDialog</class>
- <widget class="QWidget" name="ResourcesDialog">
+ <class>ResourcesDialogPage</class>
+ <widget class="QWidget" name="ResourcesDialogPage">
<property name="geometry">
<rect>
<x>0</x>
@@ -54,15 +54,8 @@
<item>
<widget class="KButtonGroup" name="kbuttongroup">
<layout class="QGridLayout" name="gridLayout">
- <item row="2" column="0">
- <widget class="QRadioButton" name="radioRepository">
- <property name="text">
- <string>Use contributor repository</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="KUrlRequester" name="repositoryUrl">
+ <item row="1" column="0">
+ <widget class="KUrlRequester" name="kcfg_CourseRepositoryPath">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -78,25 +71,12 @@
</widget>
</item>
<item row="0" column="0">
- <widget class="QRadioButton" name="radioIntalledCourses">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ <widget class="QCheckBox" name="kcfg_UseCourseRepository">
+ <property name="toolTip">
+ <string>Use this option only if you are a course contributor and you are \
working on a course repository.</string> </property>
<property name="text">
- <string>Use installed courses</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="Line" name="line">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <string>Use contributor repository</string>
</property>
</widget>
</item>
diff --git a/src/ui/sounddevicedialog.cpp b/src/ui/sounddevicedialogpage.cpp
similarity index 71%
rename from src/ui/sounddevicedialog.cpp
rename to src/ui/sounddevicedialogpage.cpp
index e5a34dc..4270087 100644
--- a/src/ui/sounddevicedialog.cpp
+++ b/src/ui/sounddevicedialogpage.cpp
@@ -18,26 +18,31 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "sounddevicedialog.h"
+#include "sounddevicedialogpage.h"
+#include "settings.h"
#include <KLocale>
#include <QUuid>
-SoundDeviceDialog::SoundDeviceDialog()
- : KDialog(0)
+SoundDeviceDialogPage::SoundDeviceDialogPage()
+ : QWidget(0)
{
- setPlainCaption(i18n("Sound Device Settings"));
- setButtons(KDialog::Ok | KDialog::Cancel);
- setDefaultButton(KDialog::Ok);
+ ui = new Ui::SoundDeviceDialogPage;
+ ui->setupUi(this);
+}
- QWidget *widget = new QWidget(this);
- ui = new Ui::SoundDeviceDialog;
+SoundDeviceDialogPage::~SoundDeviceDialogPage()
+{
+ delete ui;
+}
- ui->setupUi(widget);
- setMainWidget(widget);
+void SoundDeviceDialogPage::loadSettings()
+{
+ //TODO
}
-SoundDeviceDialog::~SoundDeviceDialog()
+void SoundDeviceDialogPage::saveSettings()
{
- delete ui;
+ //TODO
+ Settings::self()->writeConfig();
}
diff --git a/src/ui/sounddevicedialog.h b/src/ui/sounddevicedialogpage.h
similarity index 74%
rename from src/ui/sounddevicedialog.h
rename to src/ui/sounddevicedialogpage.h
index 8fd9616..46d145d 100644
--- a/src/ui/sounddevicedialog.h
+++ b/src/ui/sounddevicedialogpage.h
@@ -18,23 +18,27 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef SOUNDDEVICEDIALOG_H
-#define SOUNDDEVICEDIALOG_H
+#ifndef SOUNDDEVICEDIALOGPAGE_H
+#define SOUNDDEVICEDIALOGPAGE_H
-#include "ui_sounddevicedialog.h"
-#include <KDialog>
+#include "ui_sounddevicedialogpage.h"
+#include <QWidget>
-class SoundDeviceDialog :
- public KDialog
+class SoundDeviceDialogPage :
+ public QWidget
{
Q_OBJECT
public:
- SoundDeviceDialog();
- ~SoundDeviceDialog();
+ SoundDeviceDialogPage();
+ ~SoundDeviceDialogPage();
+
+public slots:
+ void saveSettings();
+ void loadSettings();
private:
- Ui::SoundDeviceDialog *ui;
+ Ui::SoundDeviceDialogPage *ui;
};
#endif
diff --git a/src/ui/sounddevicedialog.ui b/src/ui/sounddevicedialogpage.ui
similarity index 98%
rename from src/ui/sounddevicedialog.ui
rename to src/ui/sounddevicedialogpage.ui
index 4c75383..7b07dae 100644
--- a/src/ui/sounddevicedialog.ui
+++ b/src/ui/sounddevicedialogpage.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>SoundDeviceDialog</class>
- <widget class="QWidget" name="SoundDeviceDialog">
+ <class>SoundDeviceDialogPage</class>
+ <widget class="QWidget" name="SoundDeviceDialogPage">
<property name="geometry">
<rect>
<x>0</x>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic