X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fappearancesettingspage.cpp;h=315643344175674654a05c812839ce8221641118;hp=58178158898759bb874153f3d63c9bd642ff47bd;hb=3abd4b7d5ab303f8d990c104748e5d5aef4db355;hpb=0a43227b8cd44625f4881cc1545d42c8c8a4876c diff --git a/src/qtui/settingspages/appearancesettingspage.cpp b/src/qtui/settingspages/appearancesettingspage.cpp index 58178158..31564334 100644 --- a/src/qtui/settingspages/appearancesettingspage.cpp +++ b/src/qtui/settingspages/appearancesettingspage.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,32 +20,35 @@ #include "appearancesettingspage.h" +#include +#include +#include +#include +#include + #include "buffersettings.h" #include "qtui.h" #include "qtuisettings.h" #include "qtuistyle.h" -#include -#include -#include -#include -#include AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent) : SettingsPage(tr("Interface"), QString(), parent) { ui.setupUi(this); -#ifdef Q_OS_MAC - ui.minimizeOnClose->hide(); -#endif #ifdef QT_NO_SYSTEMTRAYICON ui.useSystemTrayIcon->hide(); #endif +#if QT_VERSION < 0x050000 + // We don't support overriding the system icon theme with Qt4 + ui.overrideSystemIconTheme->hide(); +#endif initAutoWidgets(); initStyleComboBox(); initLanguageComboBox(); + initIconThemeComboBox(); foreach(QComboBox *comboBox, findChildren()) { connect(comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged())); @@ -98,6 +101,16 @@ void AppearanceSettingsPage::initLanguageComboBox() } } +void AppearanceSettingsPage::initIconThemeComboBox() +{ + auto availableThemes = QtUi::instance()->availableIconThemes(); + + ui.iconThemeComboBox->addItem(tr("Automatic"), QString{}); + for (auto &&p : QtUi::instance()->availableIconThemes()) { + ui.iconThemeComboBox->addItem(p.second, p.first); + } +} + void AppearanceSettingsPage::defaults() { @@ -134,6 +147,17 @@ void AppearanceSettingsPage::load() ui.languageComboBox->setProperty("storedValue", ui.languageComboBox->currentIndex()); Quassel::loadTranslation(selectedLocale()); + // IconTheme + QString icontheme = UiStyleSettings{}.value("Icons/FallbackTheme", QString{}).toString(); + if (icontheme.isEmpty()) { + ui.iconThemeComboBox->setCurrentIndex(0); + } + else { + auto idx = ui.iconThemeComboBox->findData(icontheme); + ui.iconThemeComboBox->setCurrentIndex(idx > 0 ? idx : 0); + } + ui.iconThemeComboBox->setProperty("storedValue", ui.iconThemeComboBox->currentIndex()); + // bufferSettings: BufferSettings bufferSettings; int redirectTarget = bufferSettings.userNoticesTarget(); @@ -159,6 +183,7 @@ void AppearanceSettingsPage::load() void AppearanceSettingsPage::save() { QtUiSettings uiSettings; + UiStyleSettings styleSettings; if (ui.styleComboBox->currentIndex() < 1) { uiSettings.setValue("Style", QString("")); @@ -177,6 +202,18 @@ void AppearanceSettingsPage::save() } ui.languageComboBox->setProperty("storedValue", ui.languageComboBox->currentIndex()); + bool needsIconThemeRefresh = ui.iconThemeComboBox->currentIndex() != ui.iconThemeComboBox->property("storedValue").toInt() + || ui.overrideSystemIconTheme->isChecked() != ui.overrideSystemIconTheme->property("storedValue").toBool(); + + auto iconTheme = selectedIconTheme(); + if (iconTheme.isEmpty()) { + styleSettings.remove("Icons/FallbackTheme"); + } + else { + styleSettings.setValue("Icons/FallbackTheme", iconTheme); + } + 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()); @@ -213,6 +250,8 @@ void AppearanceSettingsPage::save() setChangedState(false); if (needsStyleReload) QtUi::style()->reload(); + if (needsIconThemeRefresh) + QtUi::instance()->refreshIconTheme(); } @@ -231,6 +270,12 @@ QLocale AppearanceSettingsPage::selectedLocale() const } +QString AppearanceSettingsPage::selectedIconTheme() const +{ + return ui.iconThemeComboBox->itemData(ui.iconThemeComboBox->currentIndex()).toString(); +} + + void AppearanceSettingsPage::chooseStyleSheet() { QString dir = ui.customStyleSheetPath->property("storedValue").toString(); @@ -255,6 +300,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;