Disable the highlights page when not connected
[quassel.git] / src / qtui / settingspages / appearancesettingspage.cpp
index 692d8ad..6bb0b26 100644 (file)
@@ -1,11 +1,11 @@
 /***************************************************************************
- *   Copyright (C) 2005-09 by the Quassel Project                          *
+ *   Copyright (C) 2005-2016 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
+ *   (at your option) version 3.                                           *
  *                                                                         *
  *   This program is distributed in the hope that it will be useful,       *
  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
@@ -15,7 +15,7 @@
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
 #include "appearancesettingspage.h"
@@ -36,9 +36,6 @@ AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent)
 {
     ui.setupUi(this);
 
-#ifdef Q_WS_MAC
-    ui.minimizeOnClose->hide();
-#endif
 #ifdef QT_NO_SYSTEMTRAYICON
     ui.useSystemTrayIcon->hide();
 #endif
@@ -46,6 +43,7 @@ AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent)
     initAutoWidgets();
     initStyleComboBox();
     initLanguageComboBox();
+    initIconThemeComboBox();
 
     foreach(QComboBox *comboBox, findChildren<QComboBox *>()) {
         connect(comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged()));
@@ -98,6 +96,25 @@ void AppearanceSettingsPage::initLanguageComboBox()
     }
 }
 
+void AppearanceSettingsPage::initIconThemeComboBox()
+{
+    // TODO Replace by runtime detection
+#if defined WITH_OXYGEN || defined WITH_BREEZE || defined WITH_BREEZE_DARK
+# 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
+# if defined WITH_OXYGEN
+    ui.iconthemeComboBox->addItem(tr("Oxygen"), QVariant("oxygen"));
+# endif
+#else
+    ui.iconthemeLabel->hide();
+    ui.iconthemeComboBox->hide();
+#endif
+}
+
 
 void AppearanceSettingsPage::defaults()
 {
@@ -134,6 +151,14 @@ void AppearanceSettingsPage::load()
     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();
@@ -177,6 +202,15 @@ void AppearanceSettingsPage::save()
     }
     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());
@@ -230,6 +264,10 @@ QLocale AppearanceSettingsPage::selectedLocale() const
     return locale;
 }
 
+QString AppearanceSettingsPage::selectedIconTheme() const
+{
+    return ui.iconthemeComboBox->itemData(ui.iconthemeComboBox->currentIndex()).toString();
+}
 
 void AppearanceSettingsPage::chooseStyleSheet()
 {
@@ -255,6 +293,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.iconthemeComboBox->currentIndex() != ui.iconthemeComboBox->property("storedValue").toInt()) return true;
 
     if (SettingsPage::hasChanged(ui.userNoticesInStatusBuffer)) return true;
     if (SettingsPage::hasChanged(ui.userNoticesInDefaultBuffer)) return true;