QTreeWidgetItem *item = new QTreeWidgetItem(cat, QStringList(sp->title()));
treeItems[sp] = item;
pages[QString("%1$%2").arg(sp->category(), sp->title())] = sp;
+ sp->load();
// TESTING
- //selectPage(sp->category(), sp->title());
+ selectPage(sp->category(), sp->title());
}
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]);
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());
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();
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();
}
}