/***************************************************************************
- * 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 *
* 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 <QCheckBox>
+#include <QDir>
+#include <QFile>
+#include <QFileDialog>
+#include <QStyleFactory>
+
#include "buffersettings.h"
#include "qtui.h"
#include "qtuisettings.h"
#include "qtuistyle.h"
-#include <QCheckBox>
-#include <QFileDialog>
-#include <QStyleFactory>
-#include <QFile>
-#include <QDir>
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
+
+ // 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<QComboBox *>()) {
connect(comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged()));
}
}
+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()
{
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();
void AppearanceSettingsPage::save()
{
QtUiSettings uiSettings;
+ UiStyleSettings styleSettings;
if (ui.styleComboBox->currentIndex() < 1) {
uiSettings.setValue("Style", QString(""));
}
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());
setChangedState(false);
if (needsStyleReload)
QtUi::style()->reload();
+ if (needsIconThemeRefresh)
+ QtUi::instance()->refreshIconTheme();
}
}
+QString AppearanceSettingsPage::selectedIconTheme() const
+{
+ return ui.iconThemeComboBox->itemData(ui.iconThemeComboBox->currentIndex()).toString();
+}
+
+
void AppearanceSettingsPage::chooseStyleSheet()
{
QString dir = ui.customStyleSheetPath->property("storedValue").toString();
{
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;