Fix issues with AppearanceSettingsPage
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 18 Mar 2009 14:26:54 +0000 (15:26 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 18 Mar 2009 14:27:59 +0000 (15:27 +0100)
* Load defaults properly
* Detect changes properly

src/qtui/settingspages/appearancesettingspage.cpp
src/uisupport/settingspage.cpp

index c6a8b45..9a69912 100644 (file)
@@ -33,7 +33,8 @@
 #include <QStyleFactory>
 
 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<QLocale>();
@@ -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;
index 577f168..a1b6f8d 100644 (file)
@@ -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 ***/