From 1ecc5390c9713d87f621f6cba17f28bbd0a0265b Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Mon, 15 Jan 2024 14:00:25 -0700 Subject: [PATCH] Move shared settings to it's own file --- shared/liboxide/liboxide.cpp | 14 -- shared/liboxide/liboxide.h | 199 +-------------------------- shared/liboxide/liboxide.pro | 2 + shared/liboxide/oxide_sentry.cpp | 2 +- shared/liboxide/sharedsettings.cpp | 16 +++ shared/liboxide/sharedsettings.h | 212 +++++++++++++++++++++++++++++ 6 files changed, 232 insertions(+), 213 deletions(-) create mode 100644 shared/liboxide/sharedsettings.cpp create mode 100644 shared/liboxide/sharedsettings.h diff --git a/shared/liboxide/liboxide.cpp b/shared/liboxide/liboxide.cpp index 0de01519b..81cc510c8 100644 --- a/shared/liboxide/liboxide.cpp +++ b/shared/liboxide/liboxide.cpp @@ -121,18 +121,4 @@ namespace Oxide { } return result->gr_gid; } - SharedSettings::~SharedSettings(){} - O_SETTINGS_PROPERTY_BODY(SharedSettings, int, General, version) - O_SETTINGS_PROPERTY_BODY(SharedSettings, bool, General, firstLaunch, true) - O_SETTINGS_PROPERTY_BODY(SharedSettings, bool, General, telemetry, false) - O_SETTINGS_PROPERTY_BODY(SharedSettings, bool, General, applicationUsage, false) - O_SETTINGS_PROPERTY_BODY(SharedSettings, bool, General, crashReport, true) - O_SETTINGS_PROPERTY_BODY(SharedSettings, bool, General, lockOnSuspend, true) - O_SETTINGS_PROPERTY_BODY(SharedSettings, int, General, autoSleep, 5) - O_SETTINGS_PROPERTY_BODY(SharedSettings, int, General, autoLock, 5) - O_SETTINGS_PROPERTY_BODY(SharedSettings, QString, Lockscreen, pin) - O_SETTINGS_PROPERTY_BODY(SharedSettings, QString, Lockscreen, onLogin) - O_SETTINGS_PROPERTY_BODY(SharedSettings, QString, Lockscreen, onFailedLogin) } - -#include "moc_liboxide.cpp" diff --git a/shared/liboxide/liboxide.h b/shared/liboxide/liboxide.h index 46413a9dd..184603f4c 100644 --- a/shared/liboxide/liboxide.h +++ b/shared/liboxide/liboxide.h @@ -20,6 +20,7 @@ #include "debug.h" #include "devicesettings.h" #include "xochitlsettings.h" +#include "sharedsettings.h" #if defined(LIBOXIDE_LIBRARY) #include "oxide_sentry.h" #else @@ -46,11 +47,6 @@ Q_IMPORT_PLUGIN(QsgEpaperPlugin) #ifndef APP_VERSION #define APP_VERSION VERSION #endif -/*! - * \def sharedSettings() - * \brief Get the Oxide::SharedSettings instance - */ -#define sharedSettings Oxide::SharedSettings::instance() /*! * \brief The main Oxide namespace @@ -135,198 +131,5 @@ namespace Oxide { * \snippet examples/oxide.cpp getGID */ LIBOXIDE_EXPORT gid_t getGID(const QString& name); - - /*! - * \brief Shared settings for Oxide - */ - class LIBOXIDE_EXPORT SharedSettings : public SettingsFile { - Q_OBJECT - /*! - * \fn instance - * \brief Get the static instance of this class. You should use the sharedSettings macro instead. - * \return The static instance - * \sa sharedSettings - */ - // cppcheck-suppress uninitMemberVarPrivate - O_SETTINGS(SharedSettings, "/home/root/.config/Eeems/shared.conf") - /*! - * \property version - * \brief Current version of the settings file - * \sa set_version, versionChanged - */ - /*! - * \fn versionChanged - * \brief If the version number has changed - */ - O_SETTINGS_PROPERTY(int, General, version) - /*! - * \property firstLaunch - * \brief If this is the first time that things have been run - * \sa set_firstLaunch, firstLaunchChanged - */ - /*! - * \fn set_firstLaunch - * \param _arg_firstLaunch - * \brief Change the state of firstLaunch - */ - /*! - * \fn firstLaunchChanged - * \brief If firstLaunch has changed - */ - O_SETTINGS_PROPERTY(bool, General, firstLaunch, true) - /*! - * \property telemetry - * \brief If telemetry reporting is enabled or not - * \sa set_telemetry, telemetryChanged - */ - /*! - * \fn set_telemetry - * \param _arg_telemetry - * \brief Enable or disable telemetry reporting - */ - /*! - * \fn telemetryChanged - * \brief If telemetry reporting has been enabled or disabled - */ - O_SETTINGS_PROPERTY(bool, General, telemetry, false) - /*! - * \property applicationUsage - * \brief If application usage reporting is enabled or not - * \sa set_applicationUsage, applicationUsageChanged - */ - /*! - * \fn set_applicationUsage - * \param _arg_applicationUsage - * \brief Enable or disable application usage reporting - */ - /*! - * \fn applicationUsageChanged - * \brief If application usage reporting has been enabled or disabled - */ - O_SETTINGS_PROPERTY(bool, General, applicationUsage, false) - /*! - * \property crashReport - * \brief If crash reporting is enabled or not - * \sa set_crashReport, crashReportChanged - */ - /*! - * \fn set_crashReport - * \param _arg_crashReport - * \brief Enable or disable crash reporting - */ - /*! - * \fn crashReportChanged - * \brief If crash reporting has been enabled or disabled - */ - O_SETTINGS_PROPERTY(bool, General, crashReport, true) - /*! - * \property lockOnSuspend - * \brief If the device should lock on suspend or not - * \sa set_lockOnSuspend, lockOnSuspendChanged - */ - /*! - * \fn set_lockOnSuspend - * \param _arg_lockOnSuspend - * \brief Enable or disable locking on suspend - */ - /*! - * \fn lockOnSuspendChanged - * \brief If lock on suspend has been enabled or disabled - */ - O_SETTINGS_PROPERTY(bool, General, lockOnSuspend, true) - /*! - * \property autoSleep - * \brief How long without activity before the device should suspend - * \sa set_autoSleep, autoSleepChanged - */ - /*! - * \fn set_autoSleep - * \param _arg_autoSleep - * \brief Change autoSleep - */ - /*! - * \fn autoSleepChanged - * \brief If autoSleep has been changed - */ - O_SETTINGS_PROPERTY(int, General, autoSleep, 5) - /*! - * \property autoLock - * \brief How long without activity before the device should suspend - * \sa set_autoLock, autoLockChanged - */ - /*! - * \fn set_autoLock - * \param _arg_autoLock - * \brief Change autoLock - */ - /*! - * \fn autoLockChanged - * \brief If autoLock has been changed - */ - O_SETTINGS_PROPERTY(int, General, autoLock, 5) - /*! - * \property pin - * \brief The lockscreen pin - * \sa set_pin, pinChanged - */ - /*! - * \fn set_pin - * \param _arg_pin - * \brief Change lockscreen pin - */ - /*! - * \fn has_pin - * \brief Change lockscreen pin - * \return If the lockscreen pin is set - */ - /*! - * \fn pinChanged - * \brief If the lockscreen pin has been changed - */ - O_SETTINGS_PROPERTY(QString, Lockscreen, pin) - /*! - * \property onLogin - * \brief The lockscreen onLogin - * \sa set_onLogin, onLoginChanged - */ - /*! - * \fn set_onLogin - * \param _arg_onLogin - * \brief Change lockscreen onLogin - */ - /*! - * \fn has_onLogin - * \brief If lockscreen onLogin has been set - * \return If the lockscreen onLogin is set - */ - /*! - * \fn onLoginChanged - * \brief If the lockscreen onLogin has been changed - */ - O_SETTINGS_PROPERTY(QString, Lockscreen, onLogin) - /*! - * \property onFailedLogin - * \brief The lockscreen onFailedLogin - * \sa set_onFailedLogin, onFailedLoginChanged - */ - /*! - * \fn set_onFailedLogin - * \param _arg_onFailedLogin - * \brief Change lockscreen onFailedLogin - */ - /*! - * \fn has_onFailedLogin - * \brief If lockscreen onFailedLogin has been set - * \return If the lockscreen onFailedLogin is set - */ - /*! - * \fn onFailedLoginChanged - * \brief If the lockscreen onFailedLogin has been changed - */ - O_SETTINGS_PROPERTY(QString, Lockscreen, onFailedLogin) - - private: - ~SharedSettings(); - }; } /*! @} */ diff --git a/shared/liboxide/liboxide.pro b/shared/liboxide/liboxide.pro index d4aaca090..d0645d2d7 100644 --- a/shared/liboxide/liboxide.pro +++ b/shared/liboxide/liboxide.pro @@ -32,6 +32,7 @@ SOURCES += \ oxideqml.cpp \ power.cpp \ settingsfile.cpp \ + sharedsettings.cpp \ slothandler.cpp \ sysobject.cpp \ signalhandler.cpp \ @@ -52,6 +53,7 @@ HEADERS += \ power.h \ json.h \ settingsfile.h \ + sharedsettings.h \ slothandler.h \ sysobject.h \ signalhandler.h \ diff --git a/shared/liboxide/oxide_sentry.cpp b/shared/liboxide/oxide_sentry.cpp index 8aaaa2abe..3be3427ab 100644 --- a/shared/liboxide/oxide_sentry.cpp +++ b/shared/liboxide/oxide_sentry.cpp @@ -1,5 +1,5 @@ #include "oxide_sentry.h" -#include "liboxide.h" +#include "sharedsettings.h" #include #include diff --git a/shared/liboxide/sharedsettings.cpp b/shared/liboxide/sharedsettings.cpp new file mode 100644 index 000000000..e98eda536 --- /dev/null +++ b/shared/liboxide/sharedsettings.cpp @@ -0,0 +1,16 @@ +#include "sharedsettings.h" + +namespace Oxide{ + SharedSettings::~SharedSettings(){} + O_SETTINGS_PROPERTY_BODY(SharedSettings, int, General, version) + O_SETTINGS_PROPERTY_BODY(SharedSettings, bool, General, firstLaunch, true) + O_SETTINGS_PROPERTY_BODY(SharedSettings, bool, General, telemetry, false) + O_SETTINGS_PROPERTY_BODY(SharedSettings, bool, General, applicationUsage, false) + O_SETTINGS_PROPERTY_BODY(SharedSettings, bool, General, crashReport, true) + O_SETTINGS_PROPERTY_BODY(SharedSettings, bool, General, lockOnSuspend, true) + O_SETTINGS_PROPERTY_BODY(SharedSettings, int, General, autoSleep, 5) + O_SETTINGS_PROPERTY_BODY(SharedSettings, int, General, autoLock, 5) + O_SETTINGS_PROPERTY_BODY(SharedSettings, QString, Lockscreen, pin) + O_SETTINGS_PROPERTY_BODY(SharedSettings, QString, Lockscreen, onLogin) + O_SETTINGS_PROPERTY_BODY(SharedSettings, QString, Lockscreen, onFailedLogin) +} diff --git a/shared/liboxide/sharedsettings.h b/shared/liboxide/sharedsettings.h new file mode 100644 index 000000000..ff1ecc155 --- /dev/null +++ b/shared/liboxide/sharedsettings.h @@ -0,0 +1,212 @@ +/*! + * \addtogroup Oxide + * \brief The shared settings class + * @{ + * \file + */ +#pragma once +#include "liboxide_global.h" +#include "settingsfile.h" + +/*! + * \def sharedSettings() + * \brief Get the Oxide::SharedSettings instance + */ +#define sharedSettings Oxide::SharedSettings::instance() + +namespace Oxide{ + /*! + * \brief Shared settings for Oxide + */ + class LIBOXIDE_EXPORT SharedSettings : public SettingsFile { + Q_OBJECT + /*! + * \fn instance + * \brief Get the static instance of this class. You should use the sharedSettings macro instead. + * \return The static instance + * \sa sharedSettings + */ + // cppcheck-suppress uninitMemberVarPrivate + O_SETTINGS(SharedSettings, "/home/root/.config/Eeems/shared.conf") + /*! + * \property version + * \brief Current version of the settings file + * \sa set_version, versionChanged + */ + /*! + * \fn versionChanged + * \brief If the version number has changed + */ + O_SETTINGS_PROPERTY(int, General, version) + /*! + * \property firstLaunch + * \brief If this is the first time that things have been run + * \sa set_firstLaunch, firstLaunchChanged + */ + /*! + * \fn set_firstLaunch + * \param _arg_firstLaunch + * \brief Change the state of firstLaunch + */ + /*! + * \fn firstLaunchChanged + * \brief If firstLaunch has changed + */ + O_SETTINGS_PROPERTY(bool, General, firstLaunch, true) + /*! + * \property telemetry + * \brief If telemetry reporting is enabled or not + * \sa set_telemetry, telemetryChanged + */ + /*! + * \fn set_telemetry + * \param _arg_telemetry + * \brief Enable or disable telemetry reporting + */ + /*! + * \fn telemetryChanged + * \brief If telemetry reporting has been enabled or disabled + */ + O_SETTINGS_PROPERTY(bool, General, telemetry, false) + /*! + * \property applicationUsage + * \brief If application usage reporting is enabled or not + * \sa set_applicationUsage, applicationUsageChanged + */ + /*! + * \fn set_applicationUsage + * \param _arg_applicationUsage + * \brief Enable or disable application usage reporting + */ + /*! + * \fn applicationUsageChanged + * \brief If application usage reporting has been enabled or disabled + */ + O_SETTINGS_PROPERTY(bool, General, applicationUsage, false) + /*! + * \property crashReport + * \brief If crash reporting is enabled or not + * \sa set_crashReport, crashReportChanged + */ + /*! + * \fn set_crashReport + * \param _arg_crashReport + * \brief Enable or disable crash reporting + */ + /*! + * \fn crashReportChanged + * \brief If crash reporting has been enabled or disabled + */ + O_SETTINGS_PROPERTY(bool, General, crashReport, true) + /*! + * \property lockOnSuspend + * \brief If the device should lock on suspend or not + * \sa set_lockOnSuspend, lockOnSuspendChanged + */ + /*! + * \fn set_lockOnSuspend + * \param _arg_lockOnSuspend + * \brief Enable or disable locking on suspend + */ + /*! + * \fn lockOnSuspendChanged + * \brief If lock on suspend has been enabled or disabled + */ + O_SETTINGS_PROPERTY(bool, General, lockOnSuspend, true) + /*! + * \property autoSleep + * \brief How long without activity before the device should suspend + * \sa set_autoSleep, autoSleepChanged + */ + /*! + * \fn set_autoSleep + * \param _arg_autoSleep + * \brief Change autoSleep + */ + /*! + * \fn autoSleepChanged + * \brief If autoSleep has been changed + */ + O_SETTINGS_PROPERTY(int, General, autoSleep, 5) + /*! + * \property autoLock + * \brief How long without activity before the device should suspend + * \sa set_autoLock, autoLockChanged + */ + /*! + * \fn set_autoLock + * \param _arg_autoLock + * \brief Change autoLock + */ + /*! + * \fn autoLockChanged + * \brief If autoLock has been changed + */ + O_SETTINGS_PROPERTY(int, General, autoLock, 5) + /*! + * \property pin + * \brief The lockscreen pin + * \sa set_pin, pinChanged + */ + /*! + * \fn set_pin + * \param _arg_pin + * \brief Change lockscreen pin + */ + /*! + * \fn has_pin + * \brief Change lockscreen pin + * \return If the lockscreen pin is set + */ + /*! + * \fn pinChanged + * \brief If the lockscreen pin has been changed + */ + O_SETTINGS_PROPERTY(QString, Lockscreen, pin) + /*! + * \property onLogin + * \brief The lockscreen onLogin + * \sa set_onLogin, onLoginChanged + */ + /*! + * \fn set_onLogin + * \param _arg_onLogin + * \brief Change lockscreen onLogin + */ + /*! + * \fn has_onLogin + * \brief If lockscreen onLogin has been set + * \return If the lockscreen onLogin is set + */ + /*! + * \fn onLoginChanged + * \brief If the lockscreen onLogin has been changed + */ + O_SETTINGS_PROPERTY(QString, Lockscreen, onLogin) + /*! + * \property onFailedLogin + * \brief The lockscreen onFailedLogin + * \sa set_onFailedLogin, onFailedLoginChanged + */ + /*! + * \fn set_onFailedLogin + * \param _arg_onFailedLogin + * \brief Change lockscreen onFailedLogin + */ + /*! + * \fn has_onFailedLogin + * \brief If lockscreen onFailedLogin has been set + * \return If the lockscreen onFailedLogin is set + */ + /*! + * \fn onFailedLoginChanged + * \brief If the lockscreen onFailedLogin has been changed + */ + O_SETTINGS_PROPERTY(QString, Lockscreen, onFailedLogin) + + private: + ~SharedSettings(); + }; +} + +/*! @} */