X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fappearancesettingspage.cpp;h=8ab7ce39bab249047532b4b9fa30a892f595eaaa;hp=9a699120a7d9b30dd271c189b5709f48328657b7;hb=983164018267de71e92c025ff81e4f10b8ddc5b0;hpb=ab16c77fe03b73a863d9b52b11919bcbac903f58 diff --git a/src/qtui/settingspages/appearancesettingspage.cpp b/src/qtui/settingspages/appearancesettingspage.cpp index 9a699120..8ab7ce39 100644 --- a/src/qtui/settingspages/appearancesettingspage.cpp +++ b/src/qtui/settingspages/appearancesettingspage.cpp @@ -27,7 +27,9 @@ #include "qtuistyle.h" #include "util.h" +#include #include +#include #include #include #include @@ -37,6 +39,7 @@ AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent) _fontsChanged(false) { ui.setupUi(this); + initAutoWidgets(); initStyleComboBox(); initLanguageComboBox(); @@ -55,13 +58,11 @@ AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent) mapper = new QSignalMapper(this); connect(mapper, SIGNAL(mapped(QWidget *)), this, SLOT(chooseFont(QWidget *))); - connect(ui.chooseChatView, SIGNAL(clicked()), mapper, SLOT(map())); - connect(ui.chooseBufferView, SIGNAL(clicked()), mapper, SLOT(map())); connect(ui.chooseInputLine, SIGNAL(clicked()), mapper, SLOT(map())); - mapper->setMapping(ui.chooseChatView, ui.demoChatView); - mapper->setMapping(ui.chooseBufferView, ui.demoBufferView); mapper->setMapping(ui.chooseInputLine, ui.demoInputLine); + + connect(ui.chooseStyleSheet, SIGNAL(clicked()), SLOT(chooseStyleSheet())); } void AppearanceSettingsPage::initStyleComboBox() { @@ -90,9 +91,7 @@ void AppearanceSettingsPage::defaults() { loadFonts(Settings::Default); _fontsChanged = true; - ui.showWebPreview->setChecked(true); - ui.showUserStateIcons->setChecked(true); - + SettingsPage::defaults(); widgetHasChanged(); } @@ -120,14 +119,9 @@ void AppearanceSettingsPage::load() { 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()); - loadFonts(Settings::Custom); + SettingsPage::load(); setChangedState(false); } @@ -139,14 +133,6 @@ void AppearanceSettingsPage::loadFonts(Settings::Mode mode) { inputLineFont = s.value("InputLine", QFont()).value(); setFont(ui.demoInputLine, inputLineFont); - QFont bufferViewFont; - if(mode == Settings::Custom) - bufferViewFont = s.value("BufferView", QFont()).value(); - setFont(ui.demoBufferView, bufferViewFont); - - QTextCharFormat chatFormat = QtUi::style()->format(UiStyle::None, mode); - setFont(ui.demoChatView, chatFormat.font()); - _fontsChanged = false; } @@ -165,12 +151,6 @@ void AppearanceSettingsPage::save() { uiSettings.setValue("Locale", selectedLocale()); } - ChatViewSettings chatViewSettings; - chatViewSettings.enableWebPreview(ui.showWebPreview->isChecked()); - - BufferSettings bufferSettings; - bufferSettings.enableUserStateIcons(ui.showUserStateIcons->isChecked()); - // Fonts QtUiStyleSettings fontSettings("Fonts"); if(ui.demoInputLine->font() != QApplication::font()) @@ -178,19 +158,16 @@ void AppearanceSettingsPage::save() { else fontSettings.setValue("InputLine", ""); - if(ui.demoBufferView->font() != QApplication::font()) - fontSettings.setValue("BufferView", ui.demoBufferView->font()); - else - fontSettings.setValue("BufferView", ""); - - QTextCharFormat chatFormat = QtUi::style()->format(UiStyle::None); - chatFormat.setFont(ui.demoChatView->font()); - QtUi::style()->setFormat(UiStyle::None, chatFormat, Settings::Custom); - _fontsChanged = false; - load(); + bool needsStyleReload = + ui.useCustomStyleSheet->isChecked() != ui.useCustomStyleSheet->property("storedValue").toBool() + || (ui.useCustomStyleSheet->isChecked() && ui.customStyleSheetPath->text() != ui.customStyleSheetPath->property("storedValue").toString()); + + SettingsPage::save(); setChangedState(false); + if(needsStyleReload) + QtUi::style()->reload(); } QLocale AppearanceSettingsPage::selectedLocale() const { @@ -221,11 +198,17 @@ void AppearanceSettingsPage::chooseFont(QWidget *widget) { bool ok; QFont font = QFontDialog::getFont(&ok, label->font()); if(ok) { - setFont(label, font); _fontsChanged = true; + setFont(label, font); } } +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()); } @@ -237,8 +220,5 @@ bool AppearanceSettingsPage::testHasChanged() { if(selectedLocale() != QLocale()) return true; // QLocale() returns the default locale (manipulated via loadTranslation()) - if(SettingsPage::hasChanged(ui.showWebPreview)) return true; - if(SettingsPage::hasChanged(ui.showUserStateIcons)) return true; - return false; }