X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fappearancesettingspage.cpp;h=0b33f0f4e0066d27de55cd5f9a0e6e7f2cb350c5;hb=09d19fe065125ccc6e406fa325d675387788ab3c;hp=ab39344aa43dd46a2f8d39a6975cbaefadc70db2;hpb=3f354bcce2cecfe88a46de90cbf94ffd1bc7c506;p=quassel.git diff --git a/src/qtui/settingspages/appearancesettingspage.cpp b/src/qtui/settingspages/appearancesettingspage.cpp index ab39344a..0b33f0f4 100644 --- a/src/qtui/settingspages/appearancesettingspage.cpp +++ b/src/qtui/settingspages/appearancesettingspage.cpp @@ -20,23 +20,18 @@ #include "appearancesettingspage.h" -#include "buffersettings.h" -#include "chatviewsettings.h" #include "qtui.h" #include "qtuisettings.h" #include "qtuistyle.h" -#include "util.h" #include -#include #include -#include -#include #include +#include +#include AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent) - : SettingsPage(tr("Interface"), QString(), parent), - _fontsChanged(false) + : SettingsPage(tr("Interface"), QString(), parent) { ui.setupUi(this); initAutoWidgets(); @@ -50,13 +45,6 @@ AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent) connect(checkBox, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); } - mapper = new QSignalMapper(this); - connect(mapper, SIGNAL(mapped(QWidget *)), this, SLOT(chooseFont(QWidget *))); - - connect(ui.chooseInputLine, SIGNAL(clicked()), mapper, SLOT(map())); - - mapper->setMapping(ui.chooseInputLine, ui.demoInputLine); - connect(ui.chooseStyleSheet, SIGNAL(clicked()), SLOT(chooseStyleSheet())); } @@ -83,9 +71,6 @@ void AppearanceSettingsPage::initLanguageComboBox() { void AppearanceSettingsPage::defaults() { ui.styleComboBox->setCurrentIndex(0); - loadFonts(Settings::Default); - _fontsChanged = true; - SettingsPage::defaults(); widgetHasChanged(); } @@ -114,23 +99,10 @@ void AppearanceSettingsPage::load() { ui.languageComboBox->setProperty("storedValue", ui.languageComboBox->currentIndex()); Quassel::loadTranslation(selectedLocale()); - loadFonts(Settings::Custom); - SettingsPage::load(); setChangedState(false); } -void AppearanceSettingsPage::loadFonts(Settings::Mode mode) { - QtUiStyleSettings s("Fonts"); - - QFont inputLineFont; - if(mode == Settings::Custom) - inputLineFont = s.value("InputLine", QFont()).value(); - setFont(ui.demoInputLine, inputLineFont); - - _fontsChanged = false; -} - void AppearanceSettingsPage::save() { QtUiSettings uiSettings; @@ -146,15 +118,6 @@ void AppearanceSettingsPage::save() { uiSettings.setValue("Locale", selectedLocale()); } - // Fonts - QtUiStyleSettings fontSettings("Fonts"); - if(ui.demoInputLine->font() != QApplication::font()) - fontSettings.setValue("InputLine", ui.demoInputLine->font()); - else - fontSettings.setValue("InputLine", ""); - - _fontsChanged = false; - bool needsStyleReload = ui.useCustomStyleSheet->isChecked() != ui.useCustomStyleSheet->property("storedValue").toBool() || (ui.useCustomStyleSheet->isChecked() && ui.customStyleSheetPath->text() != ui.customStyleSheetPath->property("storedValue").toString()); @@ -178,28 +141,14 @@ QLocale AppearanceSettingsPage::selectedLocale() const { return locale; } -void AppearanceSettingsPage::setFont(QLabel *label, const QFont &font_) { - QFont font = font_; - if(font.family().isEmpty()) - font = QApplication::font(); - label->setFont(font); - label->setText(QString("%1 %2").arg(font.family()).arg(font.pointSize())); - widgetHasChanged(); -} - -void AppearanceSettingsPage::chooseFont(QWidget *widget) { - QLabel *label = qobject_cast(widget); - Q_ASSERT(label); - bool ok; - QFont font = QFontDialog::getFont(&ok, label->font()); - if(ok) { - _fontsChanged = true; - setFont(label, font); - } -} - void AppearanceSettingsPage::chooseStyleSheet() { - QString name = QFileDialog::getOpenFileName(this, tr("Please choose a stylesheet file"), QString(), "*.qss"); + 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); } @@ -209,8 +158,6 @@ void AppearanceSettingsPage::widgetHasChanged() { } bool AppearanceSettingsPage::testHasChanged() { - if(_fontsChanged) return true; // comparisons are nasty for now - if(ui.styleComboBox->currentIndex() != ui.styleComboBox->property("storedValue").toInt()) return true; if(selectedLocale() != QLocale()) return true; // QLocale() returns the default locale (manipulated via loadTranslation())