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 #include #include +#include +#include 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"; } diff --git a/desktop-widgets/preferences/preferencesdialog.h b/desktop-widgets/preferences/preferencesdialog.h index a1db94b43..dcc97bf94 100644 --- a/desktop-widgets/preferences/preferencesdialog.h +++ b/desktop-widgets/preferences/preferencesdialog.h @@ -8,6 +8,7 @@ class AbstractPreferencesWidget; class QListWidget; class QStackedWidget; class QDialogButtonBox; +class QAbstractButton; class PreferencesDialogV2 : public QDialog { Q_OBJECT @@ -20,7 +21,7 @@ private: void cancelRequested(); void applyRequested(); void defaultsRequested(); - + void buttonClicked(QAbstractButton *btn); QList pages; QListWidget *pagesList; QStackedWidget *pagesStack;