X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fuisupport%2Fsettingspage.cpp;h=152428d457f5086f389956497342fcf17e460097;hb=61f33c7895e324f6e95034d86897ad2e963653f1;hp=bb9d9344e74f63a26b746047636eacb6cdcbfc03;hpb=6dbccb6a28b1f72347548b31f68031d4cabb594d;p=quassel.git diff --git a/src/uisupport/settingspage.cpp b/src/uisupport/settingspage.cpp index bb9d9344..152428d4 100644 --- a/src/uisupport/settingspage.cpp +++ b/src/uisupport/settingspage.cpp @@ -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) { @@ -85,6 +88,18 @@ bool SettingsPage::hasChanged(QSpinBox *box) { 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(); } @@ -98,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)!"; } }