X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fappearancesettingspage.cpp;h=228fe40391888a51fe6fb7ccd75179dadef16ec9;hp=fc4674fdbc42050c80d06bb2ad7a4e3848301d64;hb=d7832127ff8412b09d9fa4e56570d8a890abcbbe;hpb=9996d2489e5e5ca23b0750f39f64d8d4b5990029 diff --git a/src/qtui/settingspages/appearancesettingspage.cpp b/src/qtui/settingspages/appearancesettingspage.cpp index fc4674fd..228fe403 100644 --- a/src/qtui/settingspages/appearancesettingspage.cpp +++ b/src/qtui/settingspages/appearancesettingspage.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel IRC Team * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,18 +20,19 @@ #include "appearancesettingspage.h" -#include "buffersettings.h" -#include "chatviewsettings.h" #include "qtui.h" #include "qtuisettings.h" -#include "util.h" +#include "qtuistyle.h" -#include +#include +#include #include AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent) - : SettingsPage(tr("Appearance"), tr("General"), parent) { + : SettingsPage(tr("Interface"), QString(), parent) +{ ui.setupUi(this); + initAutoWidgets(); initStyleComboBox(); initLanguageComboBox(); @@ -41,6 +42,8 @@ AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent) foreach(QCheckBox *checkBox, findChildren()) { connect(checkBox, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); } + + connect(ui.chooseStyleSheet, SIGNAL(clicked()), SLOT(chooseStyleSheet())); } void AppearanceSettingsPage::initStyleComboBox() { @@ -52,7 +55,7 @@ void AppearanceSettingsPage::initStyleComboBox() { } void AppearanceSettingsPage::initLanguageComboBox() { - QDir i18nDir(":/i18n", "quassel_*.qm"); + QDir i18nDir(Quassel::translationDirPath(), "quassel_*.qm"); foreach(QString translationFile, i18nDir.entryList()) { QString localeName(translationFile.mid(8)); @@ -61,12 +64,12 @@ void AppearanceSettingsPage::initLanguageComboBox() { _locales << locale; ui.languageComboBox->addItem(QLocale::languageToString(locale.language())); } - } void AppearanceSettingsPage::defaults() { ui.styleComboBox->setCurrentIndex(0); + SettingsPage::defaults(); widgetHasChanged(); } @@ -74,13 +77,14 @@ void AppearanceSettingsPage::load() { QtUiSettings uiSettings; // Gui Style - settings["Style"] = uiSettings.value("Style", QString("")); - if(settings["Style"].toString() == "") { + QString style = uiSettings.value("Style", QString("")).toString(); + if(style.isEmpty()) { ui.styleComboBox->setCurrentIndex(0); } else { - ui.styleComboBox->setCurrentIndex(ui.styleComboBox->findText(settings["Style"].toString(), Qt::MatchExactly)); - QApplication::setStyle(settings["Style"].toString()); + ui.styleComboBox->setCurrentIndex(ui.styleComboBox->findText(style, Qt::MatchExactly)); + QApplication::setStyle(style); } + ui.styleComboBox->setProperty("storedValue", ui.styleComboBox->currentIndex()); // Language QLocale locale = uiSettings.value("Locale", QLocale::system()).value(); @@ -90,14 +94,10 @@ void AppearanceSettingsPage::load() { ui.languageComboBox->setCurrentIndex(1); else ui.languageComboBox->setCurrentIndex(ui.languageComboBox->findText(QLocale::languageToString(locale.language()), Qt::MatchExactly)); - loadTranslation(selectedLocale()); - - ChatViewSettings chatViewSettings; - SettingsPage::load(ui.showWebPreview, chatViewSettings.showWebPreview()); - - BufferSettings bufferSettings; - SettingsPage::load(ui.showUserStateIcons, bufferSettings.showUserStateIcons()); + ui.languageComboBox->setProperty("storedValue", ui.languageComboBox->currentIndex()); + Quassel::loadTranslation(selectedLocale()); + SettingsPage::load(); setChangedState(false); } @@ -116,14 +116,14 @@ void AppearanceSettingsPage::save() { uiSettings.setValue("Locale", selectedLocale()); } - ChatViewSettings chatViewSettings; - chatViewSettings.enableWebPreview(ui.showWebPreview->isChecked()); + bool needsStyleReload = + ui.useCustomStyleSheet->isChecked() != ui.useCustomStyleSheet->property("storedValue").toBool() + || (ui.useCustomStyleSheet->isChecked() && ui.customStyleSheetPath->text() != ui.customStyleSheetPath->property("storedValue").toString()); - BufferSettings bufferSettings; - bufferSettings.enableUserStateIcons(ui.showUserStateIcons->isChecked()); - - load(); + SettingsPage::save(); setChangedState(false); + if(needsStyleReload) + QtUi::style()->reload(); } QLocale AppearanceSettingsPage::selectedLocale() const { @@ -139,20 +139,20 @@ QLocale AppearanceSettingsPage::selectedLocale() const { return locale; } +void AppearanceSettingsPage::chooseStyleSheet() { + QString name = QFileDialog::getOpenFileName(this, tr("Please choose a stylesheet file"), QString(), "*.qss"); + if(!name.isEmpty()) + ui.customStyleSheetPath->setText(name); +} + void AppearanceSettingsPage::widgetHasChanged() { setChangedState(testHasChanged()); } bool AppearanceSettingsPage::testHasChanged() { - if(settings["Style"].toString() != ui.styleComboBox->currentText()) return true; - if(selectedLocale() != QLocale()) return true; // QLocale() returns the default locale (manipulated via loadTranslation()) + if(ui.styleComboBox->currentIndex() != ui.styleComboBox->property("storedValue").toInt()) return true; - if(SettingsPage::hasChanged(ui.showWebPreview)) return true; - if(SettingsPage::hasChanged(ui.showUserStateIcons)) return true; + if(selectedLocale() != QLocale()) return true; // QLocale() returns the default locale (manipulated via loadTranslation()) return false; } - - - -