Add Settings option to choose from bundled Icon Themes
authorromibi <romibi@bluewin.ch>
Fri, 15 Jul 2016 19:37:03 +0000 (21:37 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 7 Sep 2016 22:32:03 +0000 (00:32 +0200)
or system default

src/qtui/qtuiapplication.cpp
src/qtui/settingspages/appearancesettingspage.cpp
src/qtui/settingspages/appearancesettingspage.h
src/qtui/settingspages/appearancesettingspage.ui

index 755a032..50c3c71 100644 (file)
@@ -145,9 +145,26 @@ bool QtUiApplication::init()
             return false;
         }
 
             return false;
         }
 
+        // Checking if settings Icon Theme is valid
+        QString savedIcontheme = QtUiSettings().value("IconTheme", QVariant("")).toString();
+#ifndef WITH_OXYGEN
+        if (savedIcontheme == "oxygen")
+            QtUiSettings().remove("IconTheme");
+#endif
+#ifndef WITH_BREEZE
+        if (savedIcontheme == "breeze")
+            QtUiSettings().remove("IconTheme");
+#endif
+#ifndef WITH_BREEZE_DARK
+        if (savedIcontheme == "breezedark")
+            QtUiSettings().remove("IconTheme");
+#endif
+
         // Set the icon theme
         if (Quassel::isOptionSet("icontheme"))
             QIcon::setThemeName(Quassel::optionValue("icontheme"));
         // Set the icon theme
         if (Quassel::isOptionSet("icontheme"))
             QIcon::setThemeName(Quassel::optionValue("icontheme"));
+        else if (QtUiSettings().value("IconTheme", QVariant("")).toString() != "")
+            QIcon::setThemeName(QtUiSettings().value("IconTheme").toString());
         else if (QIcon::themeName().isEmpty())
             // Some platforms don't set a default icon theme; chances are we can find our bundled Oxygen theme though
             QIcon::setThemeName("oxygen");
         else if (QIcon::themeName().isEmpty())
             // Some platforms don't set a default icon theme; chances are we can find our bundled Oxygen theme though
             QIcon::setThemeName("oxygen");
index 5817815..6891c74 100644 (file)
@@ -46,6 +46,7 @@ AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent)
     initAutoWidgets();
     initStyleComboBox();
     initLanguageComboBox();
     initAutoWidgets();
     initStyleComboBox();
     initLanguageComboBox();
+    initIconThemeComboBox();
 
     foreach(QComboBox *comboBox, findChildren<QComboBox *>()) {
         connect(comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged()));
 
     foreach(QComboBox *comboBox, findChildren<QComboBox *>()) {
         connect(comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged()));
@@ -98,6 +99,23 @@ void AppearanceSettingsPage::initLanguageComboBox()
     }
 }
 
     }
 }
 
+void AppearanceSettingsPage::initIconThemeComboBox()
+{
+#if defined WITH_OXYGEN || defined WITH_BREEZE || defined WITH_BREEZE_DARK
+# if defined WITH_OXYGEN
+    ui.iconthemeComboBox->addItem(tr("Oxygen"), QVariant("oxygen"));
+# endif
+# if defined WITH_BREEZE
+    ui.iconthemeComboBox->addItem(tr("Breeze Light"), QVariant("breeze"));
+# endif
+# if defined WITH_BREEZE_DARK
+    ui.iconthemeComboBox->addItem(tr("Breeze Dark"), QVariant("breezedark"));
+# endif
+#else
+    ui.iconthemeComboBox->hide();
+#endif
+}
+
 
 void AppearanceSettingsPage::defaults()
 {
 
 void AppearanceSettingsPage::defaults()
 {
@@ -134,6 +152,14 @@ void AppearanceSettingsPage::load()
     ui.languageComboBox->setProperty("storedValue", ui.languageComboBox->currentIndex());
     Quassel::loadTranslation(selectedLocale());
 
     ui.languageComboBox->setProperty("storedValue", ui.languageComboBox->currentIndex());
     Quassel::loadTranslation(selectedLocale());
 
+    // IconTheme
+    QString icontheme = uiSettings.value("IconTheme", QVariant("")).toString();
+    if (icontheme == "")
+        ui.iconthemeComboBox->setCurrentIndex(0);
+    else
+        ui.iconthemeComboBox->setCurrentIndex(ui.iconthemeComboBox->findData(icontheme));
+    ui.iconthemeComboBox->setProperty("storedValue", ui.iconthemeComboBox->currentIndex());
+
     // bufferSettings:
     BufferSettings bufferSettings;
     int redirectTarget = bufferSettings.userNoticesTarget();
     // bufferSettings:
     BufferSettings bufferSettings;
     int redirectTarget = bufferSettings.userNoticesTarget();
@@ -177,6 +203,15 @@ void AppearanceSettingsPage::save()
     }
     ui.languageComboBox->setProperty("storedValue", ui.languageComboBox->currentIndex());
 
     }
     ui.languageComboBox->setProperty("storedValue", ui.languageComboBox->currentIndex());
 
+    if (selectedIconTheme()=="") {
+        uiSettings.remove("IconTheme");
+    }
+    else {
+        uiSettings.setValue("IconTheme", selectedIconTheme());
+        QIcon::setThemeName(selectedIconTheme());
+    }
+    ui.iconthemeComboBox->setProperty("storedValue", ui.iconthemeComboBox->currentIndex());
+
     bool needsStyleReload =
         ui.useCustomStyleSheet->isChecked() != ui.useCustomStyleSheet->property("storedValue").toBool()
         || (ui.useCustomStyleSheet->isChecked() && ui.customStyleSheetPath->text() != ui.customStyleSheetPath->property("storedValue").toString());
     bool needsStyleReload =
         ui.useCustomStyleSheet->isChecked() != ui.useCustomStyleSheet->property("storedValue").toBool()
         || (ui.useCustomStyleSheet->isChecked() && ui.customStyleSheetPath->text() != ui.customStyleSheetPath->property("storedValue").toString());
@@ -230,6 +265,10 @@ QLocale AppearanceSettingsPage::selectedLocale() const
     return locale;
 }
 
     return locale;
 }
 
+QString AppearanceSettingsPage::selectedIconTheme() const
+{
+    return ui.iconthemeComboBox->itemData(ui.iconthemeComboBox->currentIndex()).toString();
+}
 
 void AppearanceSettingsPage::chooseStyleSheet()
 {
 
 void AppearanceSettingsPage::chooseStyleSheet()
 {
@@ -255,6 +294,7 @@ bool AppearanceSettingsPage::testHasChanged()
 {
     if (ui.styleComboBox->currentIndex() != ui.styleComboBox->property("storedValue").toInt()) return true;
     if (ui.languageComboBox->currentIndex() != ui.languageComboBox->property("storedValue").toInt()) return true;
 {
     if (ui.styleComboBox->currentIndex() != ui.styleComboBox->property("storedValue").toInt()) return true;
     if (ui.languageComboBox->currentIndex() != ui.languageComboBox->property("storedValue").toInt()) return true;
+    if (ui.iconthemeComboBox->currentIndex() != ui.iconthemeComboBox->property("storedValue").toInt()) return true;
 
     if (SettingsPage::hasChanged(ui.userNoticesInStatusBuffer)) return true;
     if (SettingsPage::hasChanged(ui.userNoticesInDefaultBuffer)) return true;
 
     if (SettingsPage::hasChanged(ui.userNoticesInStatusBuffer)) return true;
     if (SettingsPage::hasChanged(ui.userNoticesInDefaultBuffer)) return true;
index 91dc8fc..b1f316b 100644 (file)
@@ -53,7 +53,9 @@ private:
     bool testHasChanged();
     void initStyleComboBox();
     void initLanguageComboBox();
     bool testHasChanged();
     void initStyleComboBox();
     void initLanguageComboBox();
+    void initIconThemeComboBox();
     QLocale selectedLocale() const;
     QLocale selectedLocale() const;
+    QString selectedIconTheme() const;
 
     Ui::AppearanceSettingsPage ui;
     QHash<QString, QVariant> settings;
 
     Ui::AppearanceSettingsPage ui;
     QHash<QString, QVariant> settings;
index c64cb60..0cc4f15 100644 (file)
        </property>
       </spacer>
      </item>
        </property>
       </spacer>
      </item>
+     <item row="2" column="0">
+      <widget class="QLabel" name="label_10">
+       <property name="text">
+        <string>Icon Theme:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <widget class="QComboBox" name="iconthemeComboBox">
+       <property name="toolTip">
+        <string>Choose from the bundled Icon-Themes! May need restart...</string>
+       </property>
+       <item>
+        <property name="text">
+         <string>&lt;System Default&gt;</string>
+        </property>
+       </item>
+      </widget>
+     </item>
     </layout>
    </item>
    <item>
     </layout>
    </item>
    <item>