X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fsettingspage.cpp;h=152428d457f5086f389956497342fcf17e460097;hp=009ab4cc4ad04bd82e11de13b68eae1a29035fb2;hb=8f2ee00f4edef1693628d3af0bdee84d725eb754;hpb=695758015a80eb8c158a9ac4c0f1c0b547e70df3 diff --git a/src/uisupport/settingspage.cpp b/src/uisupport/settingspage.cpp index 009ab4cc..152428d4 100644 --- a/src/uisupport/settingspage.cpp +++ b/src/uisupport/settingspage.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -24,13 +24,16 @@ #include #include #include +#include +#include "fontselector.h" #include "uisettings.h" +#include "widgethelpers.h" -SettingsPage::SettingsPage(const QString &category, const QString &title, QWidget *parent) +SettingsPage::SettingsPage(QString category, QString title, QWidget *parent) : QWidget(parent), - _category(category), - _title(title), + _category(std::move(category)), + _title(std::move(title)), _changed(false), _autoWidgetsChanged(false) { @@ -50,40 +53,53 @@ void SettingsPage::setChangedState(bool hasChanged_) void SettingsPage::load(QCheckBox *box, bool checked) { - box->setProperty("StoredValue", checked); + box->setProperty("storedValue", checked); box->setChecked(checked); } bool SettingsPage::hasChanged(QCheckBox *box) { - return box->property("StoredValue").toBool() != box->isChecked(); + return box->property("storedValue").toBool() != box->isChecked(); } void SettingsPage::load(QComboBox *box, int index) { - box->setProperty("StoredValue", index); + box->setProperty("storedValue", index); box->setCurrentIndex(index); } bool SettingsPage::hasChanged(QComboBox *box) { - return box->property("StoredValue").toInt() != box->currentIndex(); + return box->property("storedValue").toInt() != box->currentIndex(); } void SettingsPage::load(QSpinBox *box, int value) { - box->setProperty("StoredValue", value); + box->setProperty("storedValue", value); box->setValue(value); } bool SettingsPage::hasChanged(QSpinBox *box) { - return box->property("StoredValue").toInt() != box->value(); + return box->property("storedValue").toInt() != box->value(); +} + + +void SettingsPage::load(FontSelector *box, QFont value) +{ + box->setProperty("storedValue", value); + box->setSelectedFont(value); +} + + +bool SettingsPage::hasChanged(FontSelector *box) +{ + return box->property("storedValue").value() != box->selectedFont(); } @@ -97,21 +113,8 @@ void SettingsPage::initAutoWidgets() // we need to climb the QObject tree recursively findAutoWidgets(this, &_autoWidgets); - foreach(QObject *widget, _autoWidgets) { - if (widget->inherits("ColorButton")) - connect(widget, SIGNAL(colorChanged(QColor)), SLOT(autoWidgetHasChanged())); - else if (widget->inherits("QAbstractButton") || widget->inherits("QGroupBox")) - connect(widget, SIGNAL(toggled(bool)), SLOT(autoWidgetHasChanged())); - else if (widget->inherits("QLineEdit") || widget->inherits("QTextEdit")) - connect(widget, SIGNAL(textChanged(const QString &)), SLOT(autoWidgetHasChanged())); - else if (widget->inherits("QComboBox")) - connect(widget, SIGNAL(currentIndexChanged(int)), SLOT(autoWidgetHasChanged())); - else if (widget->inherits("QSpinBox")) - connect(widget, SIGNAL(valueChanged(int)), SLOT(autoWidgetHasChanged())); - else if (widget->inherits("FontSelector")) - connect(widget, SIGNAL(fontChanged(QFont)), SLOT(autoWidgetHasChanged())); - else - qWarning() << "SettingsPage::init(): Unknown autoWidget type" << widget->metaObject()->className(); + if (!connectToWidgetsChangedSignals(_autoWidgets, this, &SettingsPage::autoWidgetHasChanged)) { + qWarning() << "SettingsPage::initAutoWidgets(): Unsupported auto widget type(s)!"; } }