summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/preferences/preferencesdialog.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-09-17 17:53:39 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-30 10:36:49 -0700
commitb7daffbf084c44b099c9d1f84fb3935ce5735b39 (patch)
tree4ece2db53ea4ba00b8e12351efcc434f6fe64fd0 /desktop-widgets/preferences/preferencesdialog.cpp
parentb7a476169d50dbf4d40b134faac5b88cabd4fa17 (diff)
downloadsubsurface-b7daffbf084c44b099c9d1f84fb3935ce5735b39.tar.gz
Preferences: Hook up the dialog buttons and make it work
Since I'm using a dialog created by hand, I also need to hook things by hand. the code is very simple - debug output kept in just to make sure things are indeed working. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/preferences/preferencesdialog.cpp')
-rw-r--r--desktop-widgets/preferences/preferencesdialog.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp
index b2eb77975..e21207761 100644
--- a/desktop-widgets/preferences/preferencesdialog.cpp
+++ b/desktop-widgets/preferences/preferencesdialog.cpp
@@ -8,12 +8,17 @@
#include <QListWidget>
#include <QStackedWidget>
#include <QDialogButtonBox>
+#include <QAbstractButton>
+#include <QDebug>
PreferencesDialogV2::PreferencesDialogV2()
{
pagesList = new QListWidget();
pagesStack = new QStackedWidget();
- buttonBox = new QDialogButtonBox(QDialogButtonBox::Apply|QDialogButtonBox::RestoreDefaults|QDialogButtonBox::Cancel);
+ buttonBox = new QDialogButtonBox(
+ QDialogButtonBox::Save |
+ QDialogButtonBox::RestoreDefaults |
+ QDialogButtonBox::Cancel);
pagesList->setMinimumWidth(120);
pagesList->setMaximumWidth(120);
@@ -21,23 +26,35 @@ PreferencesDialogV2::PreferencesDialogV2()
QHBoxLayout *h = new QHBoxLayout();
h->addWidget(pagesList);
h->addWidget(pagesStack);
-
QVBoxLayout *v = new QVBoxLayout();
v->addLayout(h);
v->addWidget(buttonBox);
setLayout(v);
-
+
addPreferencePage(new PreferencesLanguage());
refreshPages();
+
connect(pagesList, &QListWidget::currentRowChanged,
pagesStack, &QStackedWidget::setCurrentIndex);
+ connect(buttonBox, &QDialogButtonBox::clicked,
+ this, &PreferencesDialogV2::buttonClicked);
}
PreferencesDialogV2::~PreferencesDialogV2()
{
}
+void PreferencesDialogV2::buttonClicked(QAbstractButton* btn)
+{
+ QDialogButtonBox::ButtonRole role = buttonBox->buttonRole(btn);
+ switch(role) {
+ case QDialogButtonBox::AcceptRole : applyRequested(); return;
+ case QDialogButtonBox::RejectRole : cancelRequested(); return;
+ case QDialogButtonBox::ResetRole : defaultsRequested(); return;
+ }
+}
+
bool abstractpreferenceswidget_lessthan(AbstractPreferencesWidget *p1, AbstractPreferencesWidget *p2)
{
return p1->positionHeight() <= p2->positionHeight();
@@ -69,15 +86,15 @@ void PreferencesDialogV2::refreshPages()
void PreferencesDialogV2::applyRequested()
{
- //TODO
+ qDebug() << "Apply Clicked";
}
void PreferencesDialogV2::cancelRequested()
{
- //TODO
+ qDebug() << "Cancel Clicked";
}
void PreferencesDialogV2::defaultsRequested()
{
- //TODO
+ qDebug() << "Defaults Clicked";
}