From 09e964ea3cd4995374dd7adb33256f3cefd47032 Mon Sep 17 00:00:00 2001 From: Shane Synan Date: Wed, 13 Jun 2018 22:45:41 -0500 Subject: [PATCH] client: add FontSelector SettingsPage::hasChanged 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 | 14 ++++++++++++++ src/uisupport/settingspage.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/uisupport/settingspage.cpp b/src/uisupport/settingspage.cpp index bb9d9344..9be56bd9 100644 --- a/src/uisupport/settingspage.cpp +++ b/src/uisupport/settingspage.cpp @@ -25,6 +25,8 @@ #include #include +#include "fontselector.h" + #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(); } + + +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(); } diff --git a/src/uisupport/settingspage.h b/src/uisupport/settingspage.h index 7fd95ccd..667c9087 100644 --- a/src/uisupport/settingspage.h +++ b/src/uisupport/settingspage.h @@ -26,6 +26,7 @@ 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. @@ -115,6 +116,8 @@ public: 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. -- 2.20.1