client: add FontSelector SettingsPage::hasChanged
authorShane Synan <digitalcircuit36939@gmail.com>
Thu, 14 Jun 2018 03:45:41 +0000 (22:45 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 16 Jun 2018 19:20:42 +0000 (21:20 +0200)
Add support for FontSelector in SettingsPage::hasChanged(), allowing
one to easily test if a specific font selector has changed since last
save.

This allows for optimizing stylesheet updates to only happen when
relevant settings are changed.

src/uisupport/settingspage.cpp
src/uisupport/settingspage.h

index bb9d934..9be56bd 100644 (file)
@@ -25,6 +25,8 @@
 #include <QSpinBox>
 #include <QVariant>
 
 #include <QSpinBox>
 #include <QVariant>
 
+#include "fontselector.h"
+
 #include "uisettings.h"
 
 SettingsPage::SettingsPage(const QString &category, const QString &title, QWidget *parent)
 #include "uisettings.h"
 
 SettingsPage::SettingsPage(const QString &category, const QString &title, QWidget *parent)
@@ -85,6 +87,18 @@ 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<QFont>() != box->selectedFont();
 }
 
 
 }
 
 
index 7fd95cc..667c908 100644 (file)
@@ -26,6 +26,7 @@
 class QCheckBox;
 class QComboBox;
 class QSpinBox;
 class QCheckBox;
 class QComboBox;
 class QSpinBox;
+class FontSelector;
 
 //! A SettingsPage is a page in the settings dialog.
 /** The SettingsDlg provides suitable standard buttons, such as Ok, Apply, Cancel, Restore Defaults and Reset.
 
 //! A SettingsPage is a page in the settings dialog.
 /** The SettingsDlg provides suitable standard buttons, such as Ok, Apply, Cancel, Restore Defaults and Reset.
@@ -115,6 +116,8 @@ public:
     static bool hasChanged(QComboBox *box);
     static void load(QSpinBox *box, int value);
     static bool hasChanged(QSpinBox *box);
     static bool hasChanged(QComboBox *box);
     static void load(QSpinBox *box, int value);
     static bool hasChanged(QSpinBox *box);
+    static void load(FontSelector *box, QFont value);
+    static bool hasChanged(FontSelector *box);
 
 public slots:
     //! Save settings to permanent storage.
 
 public slots:
     //! Save settings to permanent storage.