X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspagedlg.cpp;h=45d473f17fd4c0cef91327803cdb8052cd5da53c;hp=c9c3d0b57bb75afedcf69e9cf4146a384a25da53;hb=e38846f054ad1766f2e91992a57bbaffd33c7c06;hpb=9d54503555534a2c554f09a33df6afa33d6308ec diff --git a/src/qtui/settingspagedlg.cpp b/src/qtui/settingspagedlg.cpp index c9c3d0b5..45d473f1 100644 --- a/src/qtui/settingspagedlg.cpp +++ b/src/qtui/settingspagedlg.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2014 by the Quassel Project * + * Copyright (C) 2005-2019 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,14 +18,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include "settingspagedlg.h" + #include #include -#include "settingspagedlg.h" - -#include "iconloader.h" +#include "icon.h" -SettingsPageDlg::SettingsPageDlg(SettingsPage *page, QWidget *parent) +SettingsPageDlg::SettingsPageDlg(SettingsPage* page, QWidget* parent) : QDialog(parent) { ui.setupUi(this); @@ -37,7 +37,7 @@ SettingsPageDlg::SettingsPageDlg(SettingsPage *page, QWidget *parent) ui.pageTitle->setText(page->title()); setWindowTitle(tr("Configure %1").arg(page->title())); - setWindowIcon(SmallIcon("configure")); + setWindowIcon(icon::get("configure")); // make the scrollarea behave sanely ui.settingsFrame->setWidgetResizable(true); @@ -45,36 +45,35 @@ SettingsPageDlg::SettingsPageDlg(SettingsPage *page, QWidget *parent) updateGeometry(); - connect(page, SIGNAL(changed(bool)), this, SLOT(setButtonStates())); - connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *))); + connect(page, &SettingsPage::changed, this, &SettingsPageDlg::setButtonStates); + connect(ui.buttonBox, &QDialogButtonBox::clicked, this, &SettingsPageDlg::buttonClicked); page->load(); setButtonStates(); } - -SettingsPage *SettingsPageDlg::currentPage() const +SettingsPage* SettingsPageDlg::currentPage() const { return _currentPage; } - void SettingsPageDlg::setButtonStates() { - SettingsPage *sp = currentPage(); + SettingsPage* sp = currentPage(); ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(sp && sp->hasChanged()); ui.buttonBox->button(QDialogButtonBox::Reset)->setEnabled(sp && sp->hasChanged()); ui.buttonBox->button(QDialogButtonBox::RestoreDefaults)->setEnabled(sp && sp->hasDefaults()); } - -void SettingsPageDlg::buttonClicked(QAbstractButton *button) +void SettingsPageDlg::buttonClicked(QAbstractButton* button) { switch (ui.buttonBox->standardButton(button)) { case QDialogButtonBox::Ok: if (currentPage() && currentPage()->hasChanged()) { - if (applyChanges()) accept(); + if (applyChanges()) + accept(); } - else accept(); + else + accept(); break; case QDialogButtonBox::Apply: applyChanges(); @@ -94,10 +93,10 @@ void SettingsPageDlg::buttonClicked(QAbstractButton *button) } } - bool SettingsPageDlg::applyChanges() { - if (!currentPage()) return false; + if (!currentPage()) + return false; if (currentPage()->aboutToSave()) { currentPage()->save(); return true; @@ -105,7 +104,6 @@ bool SettingsPageDlg::applyChanges() return false; } - void SettingsPageDlg::undoChanges() { if (currentPage()) { @@ -113,23 +111,29 @@ void SettingsPageDlg::undoChanges() } } - void SettingsPageDlg::reload() { - if (!currentPage()) return; - int ret = QMessageBox::question(this, tr("Reload Settings"), tr("Do you like to reload the settings, undoing your changes on this page?"), - QMessageBox::Yes|QMessageBox::No, QMessageBox::No); + if (!currentPage()) + return; + int ret = QMessageBox::question(this, + tr("Reload Settings"), + tr("Do you like to reload the settings, undoing your changes on this page?"), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No); if (ret == QMessageBox::Yes) { currentPage()->load(); } } - void SettingsPageDlg::loadDefaults() { - if (!currentPage()) return; - int ret = QMessageBox::question(this, tr("Restore Defaults"), tr("Do you like to restore the default values for this page?"), - QMessageBox::RestoreDefaults|QMessageBox::Cancel, QMessageBox::Cancel); + if (!currentPage()) + return; + int ret = QMessageBox::question(this, + tr("Restore Defaults"), + tr("Do you like to restore the default values for this page?"), + QMessageBox::RestoreDefaults | QMessageBox::Cancel, + QMessageBox::Cancel); if (ret == QMessageBox::RestoreDefaults) { currentPage()->defaults(); }