X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingsdlg.cpp;h=0b372f62f49f167d6f8f748bf7e6a65117669c21;hp=1e8a59b1e28fa175bccf75b5a91ad9d4f9a308b1;hb=52cba0963e0714f4d58296a20d02164b57f9f4ba;hpb=9a6a8478bdd8c7c5bb4ff1fa3de9510863d65a97 diff --git a/src/qtui/settingsdlg.cpp b/src/qtui/settingsdlg.cpp index 1e8a59b1..0b372f62 100644 --- a/src/qtui/settingsdlg.cpp +++ b/src/qtui/settingsdlg.cpp @@ -65,8 +65,9 @@ void SettingsDlg::registerSettingsPage(SettingsPage *sp) { QTreeWidgetItem *item = new QTreeWidgetItem(cat, QStringList(sp->title())); treeItems[sp] = item; pages[QString("%1$%2").arg(sp->category(), sp->title())] = sp; + pageIsLoaded[sp] = false; // TESTING - //selectPage(sp->category(), sp->title()); + // selectPage(sp->category(), sp->title()); } void SettingsDlg::selectPage(const QString &cat, const QString &title) { @@ -77,6 +78,10 @@ void SettingsDlg::selectPage(const QString &cat, const QString &title) { ui.settingsTree->setCurrentItem(0); return; } + if(!pageIsLoaded[sp]) { + sp->load(); + pageIsLoaded[sp] = true; + } if(sp != currentPage() && currentPage() != 0 && currentPage()->hasChanged()) { int ret = QMessageBox::warning(this, tr("Save changes"), tr("There are unsaved changes on the current configuration page. Would you like to apply your changes now?"), @@ -90,7 +95,7 @@ void SettingsDlg::selectPage(const QString &cat, const QString &title) { if(sp != currentPage()) { ui.pageTitle->setText(sp->title()); ui.settingsStack->setCurrentWidget(sp); - ui.settingsStack->setMinimumSize(sp->sizeHint()); // we don't want our page shrinked, use scrollbars instead... + ui.settingsStack->setMinimumSize(sp->minimumSizeHint()); // we don't want our page shrinked, use scrollbars instead... _currentPage = sp; } ui.settingsTree->setCurrentItem(treeItems[sp]); @@ -112,7 +117,6 @@ void SettingsDlg::itemSelected() { void SettingsDlg::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()); @@ -121,7 +125,9 @@ void SettingsDlg::setButtonStates() { void SettingsDlg::buttonClicked(QAbstractButton *button) { switch(ui.buttonBox->standardButton(button)) { case QDialogButtonBox::Ok: - if(applyChanges()) accept(); + if(currentPage() && currentPage()->hasChanged()) { + if(applyChanges()) accept(); + } else accept(); break; case QDialogButtonBox::Apply: applyChanges(); @@ -169,7 +175,7 @@ void SettingsDlg::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) { + if(ret == QMessageBox::RestoreDefaults) { currentPage()->defaults(); } }