X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fappearancesettingspage.cpp;h=d53cb5fc6753d8b7a5b4b83cbefedd0f0a81e969;hb=240599b5a57b95c64aa0808b4b63ea1aa2ad9947;hp=516c81cc90b63d7a5ad97271761ad0a0f4a9ca24;hpb=9d47d583c703c03c545667ff49f9591bffd01651;p=quassel.git diff --git a/src/qtui/settingspages/appearancesettingspage.cpp b/src/qtui/settingspages/appearancesettingspage.cpp index 516c81cc..d53cb5fc 100644 --- a/src/qtui/settingspages/appearancesettingspage.cpp +++ b/src/qtui/settingspages/appearancesettingspage.cpp @@ -20,33 +20,32 @@ #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 +#include +#include AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent) - : SettingsPage(tr("Appearance"), tr("General"), parent) + : SettingsPage(tr("Interface"), QString(), parent) { ui.setupUi(this); + initAutoWidgets(); initStyleComboBox(); initLanguageComboBox(); -#ifndef HAVE_WEBKIT - ui.showWebPreview->hide(); - ui.showWebPreview->setEnabled(false); -#endif - foreach(QComboBox *comboBox, findChildren()) { connect(comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged())); } foreach(QCheckBox *checkBox, findChildren()) { connect(checkBox, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); } + + connect(ui.chooseStyleSheet, SIGNAL(clicked()), SLOT(chooseStyleSheet())); } void AppearanceSettingsPage::initStyleComboBox() { @@ -58,7 +57,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)); @@ -67,12 +66,12 @@ void AppearanceSettingsPage::initLanguageComboBox() { _locales << locale; ui.languageComboBox->addItem(QLocale::languageToString(locale.language())); } - } void AppearanceSettingsPage::defaults() { ui.styleComboBox->setCurrentIndex(0); + SettingsPage::defaults(); widgetHasChanged(); } @@ -80,13 +79,13 @@ 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)); } + ui.styleComboBox->setProperty("storedValue", ui.styleComboBox->currentIndex()); // Language QLocale locale = uiSettings.value("Locale", QLocale::system()).value(); @@ -96,14 +95,10 @@ void AppearanceSettingsPage::load() { ui.languageComboBox->setCurrentIndex(1); else ui.languageComboBox->setCurrentIndex(ui.languageComboBox->findText(QLocale::languageToString(locale.language()), Qt::MatchExactly)); + ui.languageComboBox->setProperty("storedValue", ui.languageComboBox->currentIndex()); Quassel::loadTranslation(selectedLocale()); - ChatViewSettings chatViewSettings; - SettingsPage::load(ui.showWebPreview, chatViewSettings.showWebPreview()); - - BufferSettings bufferSettings; - SettingsPage::load(ui.showUserStateIcons, bufferSettings.showUserStateIcons()); - + SettingsPage::load(); setChangedState(false); } @@ -114,6 +109,7 @@ void AppearanceSettingsPage::save() { uiSettings.setValue("Style", QString("")); } else { uiSettings.setValue("Style", ui.styleComboBox->currentText()); + QApplication::setStyle(ui.styleComboBox->currentText()); } if(ui.languageComboBox->currentIndex() == 0) { @@ -122,14 +118,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 { @@ -145,20 +141,26 @@ QLocale AppearanceSettingsPage::selectedLocale() const { return locale; } +void AppearanceSettingsPage::chooseStyleSheet() { + QString dir = ui.customStyleSheetPath->property("storedValue").toString(); + if(!dir.isEmpty() && QFile(dir).exists()) + dir = QDir(dir).absolutePath(); + else + dir = QDir(Quassel::findDataFilePath("default.qss")).absolutePath(); + + QString name = QFileDialog::getOpenFileName(this, tr("Please choose a stylesheet file"), dir, "*.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; } - - - -