From 87d8963c788ab4618beea59e15e18982a4ec0373 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Wed, 18 Jul 2018 22:15:07 +0200 Subject: core: make qPrefDisplay getters static and inline Add static and inline to getter in all qPref header files Remove call to GET_PREFERENCE_* in qPrefDisplay.cpp static inline is slightly faster than a function call, but it saves a lot of coding lines (no lines in qPref*.cpp). Getters are a direct reference to struct preferences, so they will normally only be used from QML. Signed-off-by: Jan Iversen --- core/settings/qPrefDisplay.cpp | 2 -- core/settings/qPrefDisplay.h | 11 ++++++----- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'core') diff --git a/core/settings/qPrefDisplay.cpp b/core/settings/qPrefDisplay.cpp index e11930b5e..1579569bf 100644 --- a/core/settings/qPrefDisplay.cpp +++ b/core/settings/qPrefDisplay.cpp @@ -26,7 +26,6 @@ void qPrefDisplay::loadSync(bool doSync) disk_theme(doSync); } -GET_PREFERENCE_TXT(Display, divelist_font); void qPrefDisplay::set_divelist_font(const QString& value) { QString newValue = value; @@ -50,7 +49,6 @@ void qPrefDisplay::disk_divelist_font(bool doSync) setCorrectFont(); } -GET_PREFERENCE_DOUBLE(Display, font_size); void qPrefDisplay::set_font_size(double value) { if (value != prefs.font_size) { diff --git a/core/settings/qPrefDisplay.h b/core/settings/qPrefDisplay.h index cb6b872f9..2d41c4e0d 100644 --- a/core/settings/qPrefDisplay.h +++ b/core/settings/qPrefDisplay.h @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #ifndef QPREFDISPLAY_H #define QPREFDISPLAY_H +#include "core/pref.h" #include @@ -22,11 +23,11 @@ public: void sync() { loadSync(true); } public: - const QString divelist_font() const; - double font_size() const; - bool display_invalid_dives() const; - bool show_developer() const; - const QString theme() const; + static inline const QString divelist_font() {return QString(prefs.divelist_font); }; + static inline double font_size() {return prefs.font_size; }; + static inline bool display_invalid_dives() {return prefs.display_invalid_dives; }; + static inline bool show_developer() {return prefs.show_developer; }; + static inline const QString theme() {return QString(prefs.theme); }; public slots: void set_divelist_font(const QString& value); -- cgit v1.2.3-70-g09d2