X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fappearancesettingspage.cpp;h=315643344175674654a05c812839ce8221641118;hp=692d8adef7bf68163e01ad197771e260f7d367ad;hb=3abd4b7d5ab303f8d990c104748e5d5aef4db355;hpb=694f9bfbf7f1af19108461c7e00d133e55082bce diff --git a/src/qtui/settingspages/appearancesettingspage.cpp b/src/qtui/settingspages/appearancesettingspage.cpp index 692d8ade..31564334 100644 --- a/src/qtui/settingspages/appearancesettingspage.cpp +++ b/src/qtui/settingspages/appearancesettingspage.cpp @@ -1,11 +1,11 @@ /*************************************************************************** - * Copyright (C) 2005-09 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 * * 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,37 +15,40 @@ * 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" +#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_WS_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;