mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:03:24 +00:00
core: make qPrefAnimations/CloudStorage getters static and inline
Add static and inline to getter in all qPref header files Remove call to GET_PREFERENCE_* in qPrefDisplay.cpp Remove GET_PREFERENCE_* from qPrefPrivate.h 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 <jani@apache.org>
This commit is contained in:
parent
87d8963c78
commit
3eae683b57
4 changed files with 16 additions and 55 deletions
|
@ -1,6 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#ifndef QPREFANIMATIONS_H
|
#ifndef QPREFANIMATIONS_H
|
||||||
#define QPREFANIMATIONS_H
|
#define QPREFANIMATIONS_H
|
||||||
|
#include "core/pref.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ public:
|
||||||
void sync() { loadSync(true); }
|
void sync() { loadSync(true); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int animation_speed() const;
|
static inline int animation_speed() { return prefs.animation_speed; };
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void set_animation_speed(int value);
|
void set_animation_speed(int value);
|
||||||
|
|
|
@ -29,7 +29,6 @@ void qPrefCloudStorage::loadSync(bool doSync)
|
||||||
disk_userid(doSync);
|
disk_userid(doSync);
|
||||||
}
|
}
|
||||||
|
|
||||||
GET_PREFERENCE_TXT(CloudStorage, cloud_base_url);
|
|
||||||
void qPrefCloudStorage::set_cloud_base_url(const QString& value)
|
void qPrefCloudStorage::set_cloud_base_url(const QString& value)
|
||||||
{
|
{
|
||||||
if (value != prefs.cloud_base_url) {
|
if (value != prefs.cloud_base_url) {
|
||||||
|
@ -49,7 +48,6 @@ void qPrefCloudStorage::disk_cloud_base_url(bool doSync)
|
||||||
LOADSYNC_TXT("/cloud_git_url", cloud_git_url);
|
LOADSYNC_TXT("/cloud_git_url", cloud_git_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
GET_PREFERENCE_TXT(CloudStorage, cloud_git_url);
|
|
||||||
void qPrefCloudStorage::set_cloud_git_url(const QString& value)
|
void qPrefCloudStorage::set_cloud_git_url(const QString& value)
|
||||||
{
|
{
|
||||||
if (value != prefs.cloud_git_url) {
|
if (value != prefs.cloud_git_url) {
|
||||||
|
@ -67,7 +65,6 @@ HANDLE_PREFERENCE_TXT(CloudStorage, "/email", cloud_storage_email);
|
||||||
|
|
||||||
HANDLE_PREFERENCE_TXT(CloudStorage, "/email_encoded", cloud_storage_email_encoded);
|
HANDLE_PREFERENCE_TXT(CloudStorage, "/email_encoded", cloud_storage_email_encoded);
|
||||||
|
|
||||||
GET_PREFERENCE_TXT(CloudStorage, cloud_storage_newpassword);
|
|
||||||
void qPrefCloudStorage::set_cloud_storage_newpassword(const QString& value)
|
void qPrefCloudStorage::set_cloud_storage_newpassword(const QString& value)
|
||||||
{
|
{
|
||||||
if (value == prefs.cloud_storage_newpassword)
|
if (value == prefs.cloud_storage_newpassword)
|
||||||
|
@ -79,7 +76,6 @@ void qPrefCloudStorage::set_cloud_storage_newpassword(const QString& value)
|
||||||
emit cloud_storage_newpassword_changed(value);
|
emit cloud_storage_newpassword_changed(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
GET_PREFERENCE_TXT(CloudStorage, cloud_storage_password);
|
|
||||||
void qPrefCloudStorage::set_cloud_storage_password(const QString& value)
|
void qPrefCloudStorage::set_cloud_storage_password(const QString& value)
|
||||||
{
|
{
|
||||||
if (value != prefs.cloud_storage_password) {
|
if (value != prefs.cloud_storage_password) {
|
||||||
|
@ -106,7 +102,6 @@ HANDLE_PREFERENCE_BOOL(CloudStorage, "/save_password_local", save_password_local
|
||||||
|
|
||||||
HANDLE_PREFERENCE_BOOL(CloudStorage, "/save_userid_local", save_userid_local);
|
HANDLE_PREFERENCE_BOOL(CloudStorage, "/save_userid_local", save_userid_local);
|
||||||
|
|
||||||
GET_PREFERENCE_TXT(CloudStorage, userid);
|
|
||||||
SET_PREFERENCE_TXT(CloudStorage, userid);
|
SET_PREFERENCE_TXT(CloudStorage, userid);
|
||||||
void qPrefCloudStorage::disk_userid(bool doSync)
|
void qPrefCloudStorage::disk_userid(bool doSync)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#ifndef QPREFCLOUDSTORAGE_H
|
#ifndef QPREFCLOUDSTORAGE_H
|
||||||
#define QPREFCLOUDSTORAGE_H
|
#define QPREFCLOUDSTORAGE_H
|
||||||
|
#include "core/pref.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
@ -30,19 +31,19 @@ public:
|
||||||
void sync() { loadSync(true); }
|
void sync() { loadSync(true); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const QString cloud_base_url() const;
|
static inline const QString cloud_base_url() { return prefs.cloud_base_url; }
|
||||||
const QString cloud_git_url() const;
|
static inline const QString cloud_git_url() { return prefs.cloud_git_url; }
|
||||||
const QString cloud_storage_email() const;
|
static inline const QString cloud_storage_email() { return prefs.cloud_storage_email; }
|
||||||
const QString cloud_storage_email_encoded() const;
|
static inline const QString cloud_storage_email_encoded() { return prefs.cloud_storage_email_encoded; }
|
||||||
const QString cloud_storage_newpassword() const;
|
static inline const QString cloud_storage_newpassword() { return prefs.cloud_storage_newpassword; }
|
||||||
const QString cloud_storage_password() const;
|
static inline const QString cloud_storage_password() { return prefs.cloud_storage_password; }
|
||||||
const QString cloud_storage_pin() const;
|
static inline const QString cloud_storage_pin() { return prefs.cloud_storage_pin; }
|
||||||
int cloud_timeout() const;
|
static inline int cloud_timeout() { return prefs.cloud_timeout; }
|
||||||
int cloud_verification_status() const;
|
static inline int cloud_verification_status() { return prefs.cloud_verification_status; }
|
||||||
bool git_local_only() const;
|
static inline bool git_local_only() { return prefs.git_local_only; }
|
||||||
bool save_password_local() const;
|
static inline bool save_password_local() { return prefs.save_password_local; }
|
||||||
bool save_userid_local() const;
|
static inline bool save_userid_local() { return prefs.save_userid_local; }
|
||||||
const QString userid() const;
|
static inline const QString userid() { return prefs.userid; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void set_cloud_base_url(const QString& value);
|
void set_cloud_base_url(const QString& value);
|
||||||
|
|
|
@ -115,37 +115,6 @@ void qPref ## usegroup::disk_ ## field(bool doSync) \
|
||||||
LOADSYNC_TXT(name, field); \
|
LOADSYNC_TXT(name, field); \
|
||||||
}
|
}
|
||||||
|
|
||||||
//******* Macros to generate get function
|
|
||||||
#define GET_PREFERENCE_BOOL(usegroup, field) \
|
|
||||||
bool qPref ## usegroup::field () const \
|
|
||||||
{ \
|
|
||||||
return prefs.field; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GET_PREFERENCE_DOUBLE(usegroup, field) \
|
|
||||||
double qPref ## usegroup::field () const \
|
|
||||||
{ \
|
|
||||||
return prefs.field; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GET_PREFERENCE_ENUM(usegroup, type, field) \
|
|
||||||
struct type qPref ## usegroup:: ## field () const \
|
|
||||||
{ \
|
|
||||||
return prefs.field; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GET_PREFERENCE_INT(usegroup, field) \
|
|
||||||
int qPref ## usegroup::field () const \
|
|
||||||
{ \
|
|
||||||
return prefs.field; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GET_PREFERENCE_TXT(usegroup, field) \
|
|
||||||
const QString qPref ## usegroup::field () const \
|
|
||||||
{ \
|
|
||||||
return prefs.field; \
|
|
||||||
}
|
|
||||||
|
|
||||||
//******* Macros to generate set function
|
//******* Macros to generate set function
|
||||||
#define SET_PREFERENCE_BOOL(usegroup, field) \
|
#define SET_PREFERENCE_BOOL(usegroup, field) \
|
||||||
void qPref ## usegroup::set_ ## field (bool value) \
|
void qPref ## usegroup::set_ ## field (bool value) \
|
||||||
|
@ -199,27 +168,22 @@ void qPref ## usegroup::set_ ## field (const QString& value) \
|
||||||
|
|
||||||
//******* Macros to generate set/set/loadsync combined
|
//******* Macros to generate set/set/loadsync combined
|
||||||
#define HANDLE_PREFERENCE_BOOL(usegroup, name, field) \
|
#define HANDLE_PREFERENCE_BOOL(usegroup, name, field) \
|
||||||
GET_PREFERENCE_BOOL(usegroup, field); \
|
|
||||||
SET_PREFERENCE_BOOL(usegroup, field); \
|
SET_PREFERENCE_BOOL(usegroup, field); \
|
||||||
DISK_LOADSYNC_BOOL(usegroup, name, field);
|
DISK_LOADSYNC_BOOL(usegroup, name, field);
|
||||||
|
|
||||||
#define HANDLE_PREFERENCE_DOUBLE(usegroup, name, field) \
|
#define HANDLE_PREFERENCE_DOUBLE(usegroup, name, field) \
|
||||||
GET_PREFERENCE_DOUBLE(usegroup, field); \
|
|
||||||
SET_PREFERENCE_DOUBLE(usegroup, field); \
|
SET_PREFERENCE_DOUBLE(usegroup, field); \
|
||||||
DISK_LOADSYNC_DOUBLE(usegroup, name, field);
|
DISK_LOADSYNC_DOUBLE(usegroup, name, field);
|
||||||
|
|
||||||
#define HANDLE_PREFERENCE_ENUM(usegroup, type, name, field) \
|
#define HANDLE_PREFERENCE_ENUM(usegroup, type, name, field) \
|
||||||
GET_PREFERENCE_ENUM(usegroup, type, field); \
|
|
||||||
SET_PREFERENCE_ENUM(usegroup, type, field); \
|
SET_PREFERENCE_ENUM(usegroup, type, field); \
|
||||||
DISK_LOADSYNC_ENUM(usegroup, name, type, field);
|
DISK_LOADSYNC_ENUM(usegroup, name, type, field);
|
||||||
|
|
||||||
#define HANDLE_PREFERENCE_INT(usegroup, name, field) \
|
#define HANDLE_PREFERENCE_INT(usegroup, name, field) \
|
||||||
GET_PREFERENCE_INT(usegroup, field); \
|
|
||||||
SET_PREFERENCE_INT(usegroup, field); \
|
SET_PREFERENCE_INT(usegroup, field); \
|
||||||
DISK_LOADSYNC_INT(usegroup, name, field);
|
DISK_LOADSYNC_INT(usegroup, name, field);
|
||||||
|
|
||||||
#define HANDLE_PREFERENCE_TXT(usegroup, name, field) \
|
#define HANDLE_PREFERENCE_TXT(usegroup, name, field) \
|
||||||
GET_PREFERENCE_TXT(usegroup, field); \
|
|
||||||
SET_PREFERENCE_TXT(usegroup, field); \
|
SET_PREFERENCE_TXT(usegroup, field); \
|
||||||
DISK_LOADSYNC_TXT(usegroup, name, field);
|
DISK_LOADSYNC_TXT(usegroup, name, field);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue