X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fappearancesettingspage.cpp;h=1a25533fa7d69249a468ceab3c55072aef9b45a3;hp=0b61893a226300053ff43865b49e65418635b077;hb=911f181e0e179eb51279c0880eb701a43163b8b5;hpb=e50ae7a06fc4e5d3a911c361d30953410deab609 diff --git a/src/qtui/settingspages/appearancesettingspage.cpp b/src/qtui/settingspages/appearancesettingspage.cpp index 0b61893a..1a25533f 100644 --- a/src/qtui/settingspages/appearancesettingspage.cpp +++ b/src/qtui/settingspages/appearancesettingspage.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 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,42 @@ #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 + + // If no system icon theme is given, showing the override option makes no sense. + // Also don't mention a "fallback". + if (QtUi::instance()->systemIconTheme().isEmpty()) { + ui.iconThemeLabel->setText(tr("Icon theme:")); + ui.overrideSystemIconTheme->hide(); + } initAutoWidgets(); initStyleComboBox(); initLanguageComboBox(); + initIconThemeComboBox(); foreach(QComboBox *comboBox, findChildren()) { connect(comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged())); @@ -98,6 +108,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 +154,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 +190,7 @@ void AppearanceSettingsPage::load() void AppearanceSettingsPage::save() { QtUiSettings uiSettings; + UiStyleSettings styleSettings; if (ui.styleComboBox->currentIndex() < 1) { uiSettings.setValue("Style", QString("")); @@ -177,6 +209,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 +257,8 @@ void AppearanceSettingsPage::save() setChangedState(false); if (needsStyleReload) QtUi::style()->reload(); + if (needsIconThemeRefresh) + QtUi::instance()->refreshIconTheme(); } @@ -231,6 +277,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 +307,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;