From e4fd091bc38c923853f54902cc873da832619c5d Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Wed, 18 Mar 2009 15:26:54 +0100 Subject: [PATCH] Fix issues with AppearanceSettingsPage * Load defaults properly * Detect changes properly --- .../settingspages/appearancesettingspage.cpp | 20 +++++++++++++------ src/uisupport/settingspage.cpp | 6 +++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/qtui/settingspages/appearancesettingspage.cpp b/src/qtui/settingspages/appearancesettingspage.cpp index c6a8b455..9a699120 100644 --- a/src/qtui/settingspages/appearancesettingspage.cpp +++ b/src/qtui/settingspages/appearancesettingspage.cpp @@ -33,7 +33,8 @@ #include AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent) - : SettingsPage(tr("Appearance"), QString(), parent) + : SettingsPage(tr("Appearance"), QString(), parent), + _fontsChanged(false) { ui.setupUi(this); initStyleComboBox(); @@ -88,6 +89,10 @@ void AppearanceSettingsPage::defaults() { loadFonts(Settings::Default); _fontsChanged = true; + + ui.showWebPreview->setChecked(true); + ui.showUserStateIcons->setChecked(true); + widgetHasChanged(); } @@ -95,13 +100,14 @@ void AppearanceSettingsPage::load() { QtUiSettings uiSettings; // Gui Style - settings["Style"] = uiSettings.value("Style", QString("")); - if(settings["Style"].toString() == "") { + QString style = uiSettings.value("Style", QString("")).toString(); + if(style.isEmpty()) { ui.styleComboBox->setCurrentIndex(0); } else { - ui.styleComboBox->setCurrentIndex(ui.styleComboBox->findText(settings["Style"].toString(), Qt::MatchExactly)); - QApplication::setStyle(settings["Style"].toString()); + ui.styleComboBox->setCurrentIndex(ui.styleComboBox->findText(style, Qt::MatchExactly)); + QApplication::setStyle(style); } + ui.styleComboBox->setProperty("storedValue", ui.styleComboBox->currentIndex()); // Language QLocale locale = uiSettings.value("Locale", QLocale::system()).value(); @@ -111,6 +117,7 @@ void AppearanceSettingsPage::load() { ui.languageComboBox->setCurrentIndex(1); else ui.languageComboBox->setCurrentIndex(ui.languageComboBox->findText(QLocale::languageToString(locale.language()), Qt::MatchExactly)); + ui.languageComboBox->setProperty("storedValue", ui.languageComboBox->currentIndex()); Quassel::loadTranslation(selectedLocale()); ChatViewSettings chatViewSettings; @@ -226,7 +233,8 @@ void AppearanceSettingsPage::widgetHasChanged() { bool AppearanceSettingsPage::testHasChanged() { if(_fontsChanged) return true; // comparisons are nasty for now - if(settings["Style"].toString() != ui.styleComboBox->currentText()) return true; + if(ui.styleComboBox->currentIndex() != ui.styleComboBox->property("storedValue").toInt()) return true; + if(selectedLocale() != QLocale()) return true; // QLocale() returns the default locale (manipulated via loadTranslation()) if(SettingsPage::hasChanged(ui.showWebPreview)) return true; diff --git a/src/uisupport/settingspage.cpp b/src/uisupport/settingspage.cpp index 577f1683..a1b6f8db 100644 --- a/src/uisupport/settingspage.cpp +++ b/src/uisupport/settingspage.cpp @@ -53,7 +53,7 @@ void SettingsPage::load(QCheckBox *box, bool checked) { } bool SettingsPage::hasChanged(QCheckBox *box) { - return box->property("StoredValue").toBool() == box->isChecked(); + return box->property("StoredValue").toBool() != box->isChecked(); } @@ -63,7 +63,7 @@ void SettingsPage::load(QComboBox *box, int index) { } bool SettingsPage::hasChanged(QComboBox *box) { - return box->property("StoredValue").toInt() == box->currentIndex(); + return box->property("StoredValue").toInt() != box->currentIndex(); } void SettingsPage::load(QSpinBox *box, int value) { @@ -72,7 +72,7 @@ void SettingsPage::load(QSpinBox *box, int value) { } bool SettingsPage::hasChanged(QSpinBox *box) { - return box->property("StoredValue").toInt() == box->value(); + return box->property("StoredValue").toInt() != box->value(); } /*** Auto child widget handling ***/ -- 2.20.1