X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspagedlg.cpp;h=b978df6ef6ab931b395e85e89dfae92af837121d;hp=7d36cf5f2f629c26bf3f869b6fa95e41541a8359;hb=f04db2cb802b1296ca739c823495930c71d3b4ab;hpb=f18d7db990cb23c87fa3586e19b2f8aa5509a66c diff --git a/src/qtui/settingspagedlg.cpp b/src/qtui/settingspagedlg.cpp index 7d36cf5f..b978df6e 100644 --- a/src/qtui/settingspagedlg.cpp +++ b/src/qtui/settingspagedlg.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel IRC Team * + * Copyright (C) 2005-2013 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,93 +15,122 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include +#include + #include "settingspagedlg.h" -SettingsPageDlg::SettingsPageDlg(SettingsPage *page, QWidget *parent) : QDialog(parent) { - ui.setupUi(this); - _currentPage = page; - page->setParent(this); - ui.pageTitle->setText(page->title()); +#include "iconloader.h" + +SettingsPageDlg::SettingsPageDlg(SettingsPage *page, QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + _currentPage = page; + page->setParent(this); + + // make it look more native under Mac OS X: + setWindowFlags(Qt::Sheet); - // make the scrollarea behave sanely - ui.settingsFrame->setWidgetResizable(true); - ui.settingsFrame->setWidget(page); + ui.pageTitle->setText(page->title()); + setWindowTitle(tr("Configure %1").arg(page->title())); + setWindowIcon(SmallIcon("configure")); - updateGeometry(); + // make the scrollarea behave sanely + ui.settingsFrame->setWidgetResizable(true); + ui.settingsFrame->setWidget(page); - connect(page, SIGNAL(changed(bool)), this, SLOT(setButtonStates())); - connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *))); - page->load(); - setButtonStates(); + updateGeometry(); + + connect(page, SIGNAL(changed(bool)), this, SLOT(setButtonStates())); + connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *))); + page->load(); + setButtonStates(); } -SettingsPage *SettingsPageDlg::currentPage() const { - return _currentPage; + +SettingsPage *SettingsPageDlg::currentPage() const +{ + return _currentPage; } -void SettingsPageDlg::setButtonStates() { - SettingsPage *sp = currentPage(); - ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(sp && sp->hasChanged()); - 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::setButtonStates() +{ + 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) { - switch(ui.buttonBox->standardButton(button)) { + +void SettingsPageDlg::buttonClicked(QAbstractButton *button) +{ + switch (ui.buttonBox->standardButton(button)) { case QDialogButtonBox::Ok: - if(applyChanges()) accept(); - break; + if (currentPage() && currentPage()->hasChanged()) { + if (applyChanges()) accept(); + } + else accept(); + break; case QDialogButtonBox::Apply: - applyChanges(); - break; + applyChanges(); + break; case QDialogButtonBox::Cancel: - undoChanges(); - reject(); - break; + undoChanges(); + reject(); + break; case QDialogButtonBox::Reset: - reload(); - break; + reload(); + break; case QDialogButtonBox::RestoreDefaults: - loadDefaults(); - break; + loadDefaults(); + break; default: - break; - } + break; + } } -bool SettingsPageDlg::applyChanges() { - if(!currentPage()) return false; - if(currentPage()->aboutToSave()) { - currentPage()->save(); - return true; - } - return false; + +bool SettingsPageDlg::applyChanges() +{ + if (!currentPage()) return false; + if (currentPage()->aboutToSave()) { + currentPage()->save(); + return true; + } + return false; } -void SettingsPageDlg::undoChanges() { - if(currentPage()) { - currentPage()->load(); - } + +void SettingsPageDlg::undoChanges() +{ + if (currentPage()) { + currentPage()->load(); + } } -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(ret == QMessageBox::Yes) { - currentPage()->load(); - } + +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 (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(ret == QMessageBox::Yes) { - currentPage()->defaults(); - } + +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 (ret == QMessageBox::RestoreDefaults) { + currentPage()->defaults(); + } }