X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Ffontssettingspage.cpp;h=38c149cef61657c46259feb89a5f884a031bfe2e;hp=3a9843e3e4c268d802253eb68496d7550f6f8988;hb=a71a4cc60303b29f493d9d0b6636f00473c4eaf6;hpb=4bfbd8dcbcb398302aaad0b6707c561760d7a7ac diff --git a/src/qtui/settingspages/fontssettingspage.cpp b/src/qtui/settingspages/fontssettingspage.cpp index 3a9843e3..38c149ce 100644 --- a/src/qtui/settingspages/fontssettingspage.cpp +++ b/src/qtui/settingspages/fontssettingspage.cpp @@ -47,68 +47,85 @@ FontsSettingsPage::FontsSettingsPage(QWidget *parent) connect(mapper, SIGNAL(mapped(QWidget *)), this, SLOT(chooseFont(QWidget *))); + connect(ui.customAppFonts, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); + connect(ui.checkTopic, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); + connect(ui.checkNickList, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); + connect(ui.checkBufferView, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); + connect(ui.checkNicks, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); + connect(ui.checkTimestamp, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); + load(); } -bool FontsSettingsPage::hasChanged() const { - - return false; +bool FontsSettingsPage::hasDefaults() const { + return true; } void FontsSettingsPage::defaults() { load(Settings::Default); - + widgetHasChanged(); } void FontsSettingsPage::load() { load(Settings::Custom); - changeState(false); + setChangedState(false); } void FontsSettingsPage::load(Settings::Mode mode) { QTextCharFormat chatFormat = QtUi::style()->format(UiStyle::None, mode); - setFont(ui.demoChatMessages, chatFormat.font()); + initLabel(ui.demoChatMessages, chatFormat.font()); QTextCharFormat nicksFormat = QtUi::style()->format(UiStyle::Sender, mode); if(nicksFormat.hasProperty(QTextFormat::FontFamily)) { - setFont(ui.demoNicks, nicksFormat.font()); + initLabel(ui.demoNicks, nicksFormat.font()); ui.checkNicks->setChecked(true); } else { - setFont(ui.demoNicks, chatFormat.font()); + initLabel(ui.demoNicks, chatFormat.font()); ui.checkNicks->setChecked(false); } QTextCharFormat timestampFormat = QtUi::style()->format(UiStyle::Timestamp, mode); if(timestampFormat.hasProperty(QTextFormat::FontFamily)) { - setFont(ui.demoTimestamp, timestampFormat.font()); + initLabel(ui.demoTimestamp, timestampFormat.font()); ui.checkTimestamp->setChecked(true); } else { - setFont(ui.demoTimestamp, chatFormat.font()); + initLabel(ui.demoTimestamp, chatFormat.font()); ui.checkTimestamp->setChecked(false); } + setChangedState(false); } void FontsSettingsPage::save() { QTextCharFormat chatFormat = QtUi::style()->format(UiStyle::None); chatFormat.setFont(ui.demoChatMessages->font()); QtUi::style()->setFormat(UiStyle::None, chatFormat, Settings::Custom); - if(ui.checkNicks->checkState() == Qt::Checked) { - QTextCharFormat nicksFormat = QtUi::style()->format(UiStyle::Sender); - nicksFormat.setFont(ui.demoNicks->font()); - QtUi::style()->setFormat(UiStyle::Sender, nicksFormat, Settings::Custom); - } - if(ui.checkTimestamp->checkState() == Qt::Checked) { - QTextCharFormat timestampFormat = QtUi::style()->format(UiStyle::Timestamp); - timestampFormat.setFont(ui.demoTimestamp->font()); - QtUi::style()->setFormat(UiStyle::Timestamp, timestampFormat, Settings::Custom); - } - changeState(false); + + //FIXME: actually remove font properties from the formats + QTextCharFormat nicksFormat = QtUi::style()->format(UiStyle::Sender); + if(ui.checkNicks->checkState() == Qt::Checked) nicksFormat.setFont(ui.demoNicks->font()); + else nicksFormat.setFont(chatFormat.font()); + QtUi::style()->setFormat(UiStyle::Sender, nicksFormat, Settings::Custom); + + QTextCharFormat timestampFormat = QtUi::style()->format(UiStyle::Timestamp); + if(ui.checkTimestamp->checkState() == Qt::Checked) timestampFormat.setFont(ui.demoTimestamp->font()); + else timestampFormat.setFont(chatFormat.font()); + QtUi::style()->setFormat(UiStyle::Timestamp, timestampFormat, Settings::Custom); + + setChangedState(false); +} + +void FontsSettingsPage::widgetHasChanged() { + if(!hasChanged()) setChangedState(true); +} + +void FontsSettingsPage::initLabel(QLabel *label, const QFont &font) { + setFont(label, font); } void FontsSettingsPage::setFont(QLabel *label, const QFont &font) { - QFontInfo fontInfo(font); label->setFont(font); - label->setText(QString("%1 %2").arg(fontInfo.family()).arg(fontInfo.pointSize())); + label->setText(QString("%1 %2").arg(font.family()).arg(font.pointSize())); + widgetHasChanged(); } void FontsSettingsPage::chooseFont(QWidget *widget) {