aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/preferences
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-10-31 21:02:16 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-02 12:52:15 -0800
commitff57881265a305fe06691b065bc3f0efae88e6b3 (patch)
tree517a07b28aea6446ac904344aeb1b5cd54f4d72f /desktop-widgets/preferences
parent8a3fb854c2b835271cc03ea02e1046f2ec0fd5d5 (diff)
downloadsubsurface-ff57881265a305fe06691b065bc3f0efae88e6b3.tar.gz
Preferences: Remove the old dialog and use the new one
The new preferences dialog still needs a bit of fine tuning but should already work. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/preferences')
-rw-r--r--desktop-widgets/preferences/preferences_network.cpp1
-rw-r--r--desktop-widgets/preferences/preferencesdialog.cpp29
-rw-r--r--desktop-widgets/preferences/preferencesdialog.h8
3 files changed, 25 insertions, 13 deletions
diff --git a/desktop-widgets/preferences/preferences_network.cpp b/desktop-widgets/preferences/preferences_network.cpp
index 000df1e7f..3780a6c91 100644
--- a/desktop-widgets/preferences/preferences_network.cpp
+++ b/desktop-widgets/preferences/preferences_network.cpp
@@ -1,6 +1,5 @@
#include "preferences_network.h"
#include "ui_preferences_network.h"
-#include "preferences.h"
#include "dive.h"
#include "subsurfacewebservices.h"
#include "subsurface-core/prefs-macros.h"
diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp
index 5b4cc560e..d59296519 100644
--- a/desktop-widgets/preferences/preferencesdialog.cpp
+++ b/desktop-widgets/preferences/preferencesdialog.cpp
@@ -16,7 +16,18 @@
#include <QAbstractButton>
#include <QDebug>
-PreferencesDialogV2::PreferencesDialogV2()
+PreferencesDialog* PreferencesDialog::instance()
+{
+ PreferencesDialog *self = new PreferencesDialog();
+ return self;
+}
+
+void PreferencesDialog::emitSettingsChanged()
+{
+ emit settingsChanged();
+}
+
+PreferencesDialog::PreferencesDialog()
{
pagesList = new QListWidget();
pagesStack = new QStackedWidget();
@@ -48,14 +59,14 @@ PreferencesDialogV2::PreferencesDialogV2()
connect(pagesList, &QListWidget::currentRowChanged,
pagesStack, &QStackedWidget::setCurrentIndex);
connect(buttonBox, &QDialogButtonBox::clicked,
- this, &PreferencesDialogV2::buttonClicked);
+ this, &PreferencesDialog::buttonClicked);
}
-PreferencesDialogV2::~PreferencesDialogV2()
+PreferencesDialog::~PreferencesDialog()
{
}
-void PreferencesDialogV2::buttonClicked(QAbstractButton* btn)
+void PreferencesDialog::buttonClicked(QAbstractButton* btn)
{
QDialogButtonBox::ButtonRole role = buttonBox->buttonRole(btn);
switch(role) {
@@ -70,13 +81,13 @@ bool abstractpreferenceswidget_lessthan(AbstractPreferencesWidget *p1, AbstractP
return p1->positionHeight() <= p2->positionHeight();
}
-void PreferencesDialogV2::addPreferencePage(AbstractPreferencesWidget *page)
+void PreferencesDialog::addPreferencePage(AbstractPreferencesWidget *page)
{
pages.push_back(page);
qSort(pages.begin(), pages.end(), abstractpreferenceswidget_lessthan);
}
-void PreferencesDialogV2::refreshPages()
+void PreferencesDialog::refreshPages()
{
// Remove things
pagesList->clear();
@@ -95,7 +106,7 @@ void PreferencesDialogV2::refreshPages()
}
}
-void PreferencesDialogV2::applyRequested()
+void PreferencesDialog::applyRequested()
{
Q_FOREACH(AbstractPreferencesWidget *page, pages) {
page->syncSettings();
@@ -104,7 +115,7 @@ void PreferencesDialogV2::applyRequested()
accept();
}
-void PreferencesDialogV2::cancelRequested()
+void PreferencesDialog::cancelRequested()
{
Q_FOREACH(AbstractPreferencesWidget *page, pages) {
page->refreshSettings();
@@ -112,7 +123,7 @@ void PreferencesDialogV2::cancelRequested()
reject();
}
-void PreferencesDialogV2::defaultsRequested()
+void PreferencesDialog::defaultsRequested()
{
prefs = default_prefs;
Q_FOREACH(AbstractPreferencesWidget *page, pages) {
diff --git a/desktop-widgets/preferences/preferencesdialog.h b/desktop-widgets/preferences/preferencesdialog.h
index 720b94c25..611bd5fac 100644
--- a/desktop-widgets/preferences/preferencesdialog.h
+++ b/desktop-widgets/preferences/preferencesdialog.h
@@ -10,16 +10,18 @@ class QStackedWidget;
class QDialogButtonBox;
class QAbstractButton;
-class PreferencesDialogV2 : public QDialog {
+class PreferencesDialog : public QDialog {
Q_OBJECT
public:
- PreferencesDialogV2();
- virtual ~PreferencesDialogV2();
+ static PreferencesDialog* instance();
+ virtual ~PreferencesDialog();
void addPreferencePage(AbstractPreferencesWidget *page);
void refreshPages();
+ void emitSettingsChanged();
signals:
void settingsChanged();
private:
+ PreferencesDialog();
void cancelRequested();
void applyRequested();
void defaultsRequested();