From d530e209b37fd4881a490bbfa8af39cd70fd325a Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 11 Apr 2026 02:10:20 +1000 Subject: [PATCH] feat: add c++ settings --- plugin/src/Caelestia/CMakeLists.txt | 4 +- plugin/src/Caelestia/Config/CMakeLists.txt | 27 ++ .../src/Caelestia/Config/advancedconfig.hpp | 235 ++++++++++++++++++ .../src/Caelestia/Config/appearanceconfig.hpp | 207 +++++++++++++++ .../src/Caelestia/Config/backgroundconfig.hpp | 74 ++++++ plugin/src/Caelestia/Config/barconfig.hpp | 133 ++++++++++ plugin/src/Caelestia/Config/borderconfig.hpp | 26 ++ plugin/src/Caelestia/Config/config.cpp | 138 ++++++++++ plugin/src/Caelestia/Config/config.hpp | 94 +++++++ plugin/src/Caelestia/Config/configobject.cpp | 107 ++++++++ plugin/src/Caelestia/Config/configobject.hpp | 63 +++++ .../Caelestia/Config/controlcenterconfig.hpp | 17 ++ .../src/Caelestia/Config/dashboardconfig.hpp | 36 +++ plugin/src/Caelestia/Config/generalconfig.hpp | 60 +++++ .../src/Caelestia/Config/launcherconfig.hpp | 46 ++++ plugin/src/Caelestia/Config/lockconfig.hpp | 19 ++ plugin/src/Caelestia/Config/notifsconfig.hpp | 25 ++ plugin/src/Caelestia/Config/osdconfig.hpp | 19 ++ plugin/src/Caelestia/Config/serviceconfig.hpp | 32 +++ plugin/src/Caelestia/Config/sessionconfig.hpp | 49 ++++ plugin/src/Caelestia/Config/sidebarconfig.hpp | 17 ++ plugin/src/Caelestia/Config/userpaths.hpp | 26 ++ .../src/Caelestia/Config/utilitiesconfig.hpp | 56 +++++ plugin/src/Caelestia/Config/winfoconfig.hpp | 17 ++ 24 files changed, 1526 insertions(+), 1 deletion(-) create mode 100644 plugin/src/Caelestia/Config/CMakeLists.txt create mode 100644 plugin/src/Caelestia/Config/advancedconfig.hpp create mode 100644 plugin/src/Caelestia/Config/appearanceconfig.hpp create mode 100644 plugin/src/Caelestia/Config/backgroundconfig.hpp create mode 100644 plugin/src/Caelestia/Config/barconfig.hpp create mode 100644 plugin/src/Caelestia/Config/borderconfig.hpp create mode 100644 plugin/src/Caelestia/Config/config.cpp create mode 100644 plugin/src/Caelestia/Config/config.hpp create mode 100644 plugin/src/Caelestia/Config/configobject.cpp create mode 100644 plugin/src/Caelestia/Config/configobject.hpp create mode 100644 plugin/src/Caelestia/Config/controlcenterconfig.hpp create mode 100644 plugin/src/Caelestia/Config/dashboardconfig.hpp create mode 100644 plugin/src/Caelestia/Config/generalconfig.hpp create mode 100644 plugin/src/Caelestia/Config/launcherconfig.hpp create mode 100644 plugin/src/Caelestia/Config/lockconfig.hpp create mode 100644 plugin/src/Caelestia/Config/notifsconfig.hpp create mode 100644 plugin/src/Caelestia/Config/osdconfig.hpp create mode 100644 plugin/src/Caelestia/Config/serviceconfig.hpp create mode 100644 plugin/src/Caelestia/Config/sessionconfig.hpp create mode 100644 plugin/src/Caelestia/Config/sidebarconfig.hpp create mode 100644 plugin/src/Caelestia/Config/userpaths.hpp create mode 100644 plugin/src/Caelestia/Config/utilitiesconfig.hpp create mode 100644 plugin/src/Caelestia/Config/winfoconfig.hpp diff --git a/plugin/src/Caelestia/CMakeLists.txt b/plugin/src/Caelestia/CMakeLists.txt index 211cbb56..01f43b21 100644 --- a/plugin/src/Caelestia/CMakeLists.txt +++ b/plugin/src/Caelestia/CMakeLists.txt @@ -12,12 +12,13 @@ set(QT_QML_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/qml") qt_standard_project_setup(REQUIRES 6.9) function(qml_module arg_TARGET) - cmake_parse_arguments(PARSE_ARGV 1 arg "" "URI" "SOURCES;LIBRARIES") + cmake_parse_arguments(PARSE_ARGV 1 arg "" "URI" "SOURCES;QML_FILES;LIBRARIES") qt_add_qml_module(${arg_TARGET} URI ${arg_URI} VERSION ${VERSION} SOURCES ${arg_SOURCES} + QML_FILES ${arg_QML_FILES} ) qt_query_qml_module(${arg_TARGET} @@ -58,6 +59,7 @@ qml_module(caelestia ) add_subdirectory(Components) +add_subdirectory(Config) add_subdirectory(Internal) add_subdirectory(Models) add_subdirectory(Services) diff --git a/plugin/src/Caelestia/Config/CMakeLists.txt b/plugin/src/Caelestia/Config/CMakeLists.txt new file mode 100644 index 00000000..9351ec41 --- /dev/null +++ b/plugin/src/Caelestia/Config/CMakeLists.txt @@ -0,0 +1,27 @@ +qml_module(caelestia-config + URI Caelestia.Config + SOURCES + config.hpp config.cpp + configobject.hpp + advancedconfig.hpp + appearanceconfig.hpp + backgroundconfig.hpp + barconfig.hpp + borderconfig.hpp + controlcenterconfig.hpp + dashboardconfig.hpp + generalconfig.hpp + launcherconfig.hpp + lockconfig.hpp + notifsconfig.hpp + osdconfig.hpp + serviceconfig.hpp + sessionconfig.hpp + sidebarconfig.hpp + userpaths.hpp + utilitiesconfig.hpp + winfoconfig.hpp + configobject.cpp + LIBRARIES + Qt::Quick +) diff --git a/plugin/src/Caelestia/Config/advancedconfig.hpp b/plugin/src/Caelestia/Config/advancedconfig.hpp new file mode 100644 index 00000000..57352a32 --- /dev/null +++ b/plugin/src/Caelestia/Config/advancedconfig.hpp @@ -0,0 +1,235 @@ +#pragma once + +#include "configobject.hpp" + +#include + +namespace caelestia::config { + +class AnimCurves : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(QList, emphasized) + CONFIG_PROPERTY(QList, emphasizedAccel) + CONFIG_PROPERTY(QList, emphasizedDecel) + CONFIG_PROPERTY(QList, standard) + CONFIG_PROPERTY(QList, standardAccel) + CONFIG_PROPERTY(QList, standardDecel) + CONFIG_PROPERTY(QList, expressiveFastSpatial) + CONFIG_PROPERTY(QList, expressiveDefaultSpatial) + CONFIG_PROPERTY(QList, expressiveSlowSpatial) + +public: + explicit AnimCurves(QObject* parent = nullptr) + : ConfigObject(parent) + , m_emphasized({ 0.05, 0, 2.0 / 15.0, 0.06, 1.0 / 6.0, 0.4, 5.0 / 24.0, 0.82, 0.25, 1, 1, 1 }) + , m_emphasizedAccel({ 0.3, 0, 0.8, 0.15, 1, 1 }) + , m_emphasizedDecel({ 0.05, 0.7, 0.1, 1, 1, 1 }) + , m_standard({ 0.2, 0, 0, 1, 1, 1 }) + , m_standardAccel({ 0.3, 0, 1, 1, 1, 1 }) + , m_standardDecel({ 0, 0, 0, 1, 1, 1 }) + , m_expressiveFastSpatial({ 0.42, 1.67, 0.21, 0.9, 1, 1 }) + , m_expressiveDefaultSpatial({ 0.38, 1.21, 0.22, 1, 1, 1 }) + , m_expressiveSlowSpatial({ 0.39, 1.29, 0.35, 0.98, 1, 1 }) {} +}; + +class AdvancedAppearance : public ConfigObject { + Q_OBJECT + CONFIG_SUBOBJECT(AnimCurves, curves) + +public: + explicit AdvancedAppearance(QObject* parent = nullptr) + : ConfigObject(parent) + , m_curves(new AnimCurves(this)) {} +}; + +class BarSizes : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(int, innerWidth, 40) + CONFIG_PROPERTY(int, windowPreviewSize, 400) + CONFIG_PROPERTY(int, trayMenuWidth, 300) + CONFIG_PROPERTY(int, batteryWidth, 250) + CONFIG_PROPERTY(int, networkWidth, 320) + CONFIG_PROPERTY(int, kbLayoutWidth, 320) + +public: + explicit BarSizes(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class AdvancedDashboard : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, showDashboard, true) + CONFIG_PROPERTY(bool, showMedia, true) + CONFIG_PROPERTY(bool, showPerformance, true) + CONFIG_PROPERTY(bool, showWeather, true) + + Q_PROPERTY(int tabIndicatorHeight READ tabIndicatorHeight CONSTANT) + Q_PROPERTY(int tabIndicatorSpacing READ tabIndicatorSpacing CONSTANT) + Q_PROPERTY(int infoWidth READ infoWidth CONSTANT) + Q_PROPERTY(int infoIconSize READ infoIconSize CONSTANT) + Q_PROPERTY(int dateTimeWidth READ dateTimeWidth CONSTANT) + Q_PROPERTY(int mediaWidth READ mediaWidth CONSTANT) + Q_PROPERTY(int mediaProgressSweep READ mediaProgressSweep CONSTANT) + Q_PROPERTY(int mediaProgressThickness READ mediaProgressThickness CONSTANT) + Q_PROPERTY(int resourceProgessThickness READ resourceProgessThickness CONSTANT) + Q_PROPERTY(int weatherWidth READ weatherWidth CONSTANT) + Q_PROPERTY(int mediaCoverArtSize READ mediaCoverArtSize CONSTANT) + Q_PROPERTY(int mediaVisualiserSize READ mediaVisualiserSize CONSTANT) + Q_PROPERTY(int resourceSize READ resourceSize CONSTANT) + +public: + explicit AdvancedDashboard(QObject* parent = nullptr) + : ConfigObject(parent) {} + + [[nodiscard]] static int tabIndicatorHeight() { return 3; } + + [[nodiscard]] static int tabIndicatorSpacing() { return 5; } + + [[nodiscard]] static int infoWidth() { return 200; } + + [[nodiscard]] static int infoIconSize() { return 25; } + + [[nodiscard]] static int dateTimeWidth() { return 110; } + + [[nodiscard]] static int mediaWidth() { return 200; } + + [[nodiscard]] static int mediaProgressSweep() { return 180; } + + [[nodiscard]] static int mediaProgressThickness() { return 8; } + + [[nodiscard]] static int resourceProgessThickness() { return 10; } + + [[nodiscard]] static int weatherWidth() { return 250; } + + [[nodiscard]] static int mediaCoverArtSize() { return 150; } + + [[nodiscard]] static int mediaVisualiserSize() { return 80; } + + [[nodiscard]] static int resourceSize() { return 200; } +}; + +class LauncherSizes : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(int, itemWidth, 600) + CONFIG_PROPERTY(int, itemHeight, 57) + CONFIG_PROPERTY(int, wallpaperWidth, 280) + CONFIG_PROPERTY(int, wallpaperHeight, 200) + +public: + explicit LauncherSizes(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class NotifsSizes : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(int, width, 400) + CONFIG_PROPERTY(int, image, 41) + CONFIG_PROPERTY(int, badge, 20) + +public: + explicit NotifsSizes(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class OsdSizes : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(int, sliderWidth, 30) + CONFIG_PROPERTY(int, sliderHeight, 150) + +public: + explicit OsdSizes(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class SessionSizes : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(int, button, 80) + +public: + explicit SessionSizes(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class SidebarSizes : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(int, width, 430) + +public: + explicit SidebarSizes(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class UtilitiesSizes : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(int, width, 430) + CONFIG_PROPERTY(int, toastWidth, 430) + +public: + explicit UtilitiesSizes(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class LockSizes : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(qreal, heightMult, 0.7) + CONFIG_PROPERTY(qreal, ratio, 16.0 / 9.0) + CONFIG_PROPERTY(int, centerWidth, 600) + +public: + explicit LockSizes(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class WInfoSizes : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(qreal, heightMult, 0.7) + CONFIG_PROPERTY(qreal, detailsWidth, 500) + +public: + explicit WInfoSizes(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class ControlCenterSizes : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(qreal, heightMult, 0.7) + CONFIG_PROPERTY(qreal, ratio, 16.0 / 9.0) + +public: + explicit ControlCenterSizes(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class AdvancedConfig : public ConfigObject { + Q_OBJECT + CONFIG_SUBOBJECT(AdvancedAppearance, appearance) + CONFIG_SUBOBJECT(BarSizes, bar) + CONFIG_SUBOBJECT(AdvancedDashboard, dashboard) + CONFIG_SUBOBJECT(LauncherSizes, launcher) + CONFIG_SUBOBJECT(NotifsSizes, notifs) + CONFIG_SUBOBJECT(OsdSizes, osd) + CONFIG_SUBOBJECT(SessionSizes, session) + CONFIG_SUBOBJECT(SidebarSizes, sidebar) + CONFIG_SUBOBJECT(UtilitiesSizes, utilities) + CONFIG_SUBOBJECT(LockSizes, lock) + CONFIG_SUBOBJECT(WInfoSizes, winfo) + CONFIG_SUBOBJECT(ControlCenterSizes, controlCenter) + +public: + explicit AdvancedConfig(QObject* parent = nullptr) + : ConfigObject(parent) + , m_appearance(new AdvancedAppearance(this)) + , m_bar(new BarSizes(this)) + , m_dashboard(new AdvancedDashboard(this)) + , m_launcher(new LauncherSizes(this)) + , m_notifs(new NotifsSizes(this)) + , m_osd(new OsdSizes(this)) + , m_session(new SessionSizes(this)) + , m_sidebar(new SidebarSizes(this)) + , m_utilities(new UtilitiesSizes(this)) + , m_lock(new LockSizes(this)) + , m_winfo(new WInfoSizes(this)) + , m_controlCenter(new ControlCenterSizes(this)) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/appearanceconfig.hpp b/plugin/src/Caelestia/Config/appearanceconfig.hpp new file mode 100644 index 00000000..4d4acc08 --- /dev/null +++ b/plugin/src/Caelestia/Config/appearanceconfig.hpp @@ -0,0 +1,207 @@ +#pragma once + +#include "configobject.hpp" + +#include + +namespace caelestia::config { + +class AppearanceRounding : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(qreal, scale, 1) + + Q_PROPERTY(int small READ small NOTIFY scaleChanged) + Q_PROPERTY(int normal READ normal NOTIFY scaleChanged) + Q_PROPERTY(int large READ large NOTIFY scaleChanged) + Q_PROPERTY(int full READ full NOTIFY scaleChanged) + +public: + explicit AppearanceRounding(QObject* parent = nullptr) + : ConfigObject(parent) {} + + [[nodiscard]] int small() const { return static_cast(12 * m_scale); } + + [[nodiscard]] int normal() const { return static_cast(17 * m_scale); } + + [[nodiscard]] int large() const { return static_cast(25 * m_scale); } + + [[nodiscard]] int full() const { return static_cast(1000 * m_scale); } +}; + +class AppearanceSpacing : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(qreal, scale, 1) + + Q_PROPERTY(int small READ small NOTIFY scaleChanged) + Q_PROPERTY(int smaller READ smaller NOTIFY scaleChanged) + Q_PROPERTY(int normal READ normal NOTIFY scaleChanged) + Q_PROPERTY(int larger READ larger NOTIFY scaleChanged) + Q_PROPERTY(int large READ large NOTIFY scaleChanged) + +public: + explicit AppearanceSpacing(QObject* parent = nullptr) + : ConfigObject(parent) {} + + [[nodiscard]] int small() const { return static_cast(7 * m_scale); } + + [[nodiscard]] int smaller() const { return static_cast(10 * m_scale); } + + [[nodiscard]] int normal() const { return static_cast(12 * m_scale); } + + [[nodiscard]] int larger() const { return static_cast(15 * m_scale); } + + [[nodiscard]] int large() const { return static_cast(20 * m_scale); } +}; + +class AppearancePadding : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(qreal, scale, 1) + + Q_PROPERTY(int small READ small NOTIFY scaleChanged) + Q_PROPERTY(int smaller READ smaller NOTIFY scaleChanged) + Q_PROPERTY(int normal READ normal NOTIFY scaleChanged) + Q_PROPERTY(int larger READ larger NOTIFY scaleChanged) + Q_PROPERTY(int large READ large NOTIFY scaleChanged) + +public: + explicit AppearancePadding(QObject* parent = nullptr) + : ConfigObject(parent) {} + + [[nodiscard]] int small() const { return static_cast(5 * m_scale); } + + [[nodiscard]] int smaller() const { return static_cast(7 * m_scale); } + + [[nodiscard]] int normal() const { return static_cast(10 * m_scale); } + + [[nodiscard]] int larger() const { return static_cast(12 * m_scale); } + + [[nodiscard]] int large() const { return static_cast(15 * m_scale); } +}; + +class FontFamily : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(QString, sans, QStringLiteral("Rubik")) + CONFIG_PROPERTY(QString, mono, QStringLiteral("CaskaydiaCove NF")) + CONFIG_PROPERTY(QString, material, QStringLiteral("Material Symbols Rounded")) + CONFIG_PROPERTY(QString, clock, QStringLiteral("Rubik")) + +public: + explicit FontFamily(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class FontSize : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(qreal, scale, 1) + + Q_PROPERTY(int small READ small NOTIFY scaleChanged) + Q_PROPERTY(int smaller READ smaller NOTIFY scaleChanged) + Q_PROPERTY(int normal READ normal NOTIFY scaleChanged) + Q_PROPERTY(int larger READ larger NOTIFY scaleChanged) + Q_PROPERTY(int large READ large NOTIFY scaleChanged) + Q_PROPERTY(int extraLarge READ extraLarge NOTIFY scaleChanged) + +public: + explicit FontSize(QObject* parent = nullptr) + : ConfigObject(parent) {} + + [[nodiscard]] int small() const { return static_cast(11 * m_scale); } + + [[nodiscard]] int smaller() const { return static_cast(12 * m_scale); } + + [[nodiscard]] int normal() const { return static_cast(13 * m_scale); } + + [[nodiscard]] int larger() const { return static_cast(15 * m_scale); } + + [[nodiscard]] int large() const { return static_cast(18 * m_scale); } + + [[nodiscard]] int extraLarge() const { return static_cast(28 * m_scale); } +}; + +class AppearanceFont : public ConfigObject { + Q_OBJECT + CONFIG_SUBOBJECT(FontFamily, family) + CONFIG_SUBOBJECT(FontSize, size) + +public: + explicit AppearanceFont(QObject* parent = nullptr) + : ConfigObject(parent) + , m_family(new FontFamily(this)) + , m_size(new FontSize(this)) {} +}; + +class AnimDurations : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(qreal, scale, 1) + + Q_PROPERTY(int small READ small NOTIFY scaleChanged) + Q_PROPERTY(int normal READ normal NOTIFY scaleChanged) + Q_PROPERTY(int large READ large NOTIFY scaleChanged) + Q_PROPERTY(int extraLarge READ extraLarge NOTIFY scaleChanged) + Q_PROPERTY(int expressiveFastSpatial READ expressiveFastSpatial NOTIFY scaleChanged) + Q_PROPERTY(int expressiveDefaultSpatial READ expressiveDefaultSpatial NOTIFY scaleChanged) + Q_PROPERTY(int expressiveSlowSpatial READ expressiveSlowSpatial NOTIFY scaleChanged) + +public: + explicit AnimDurations(QObject* parent = nullptr) + : ConfigObject(parent) {} + + [[nodiscard]] int small() const { return static_cast(200 * m_scale); } + + [[nodiscard]] int normal() const { return static_cast(400 * m_scale); } + + [[nodiscard]] int large() const { return static_cast(600 * m_scale); } + + [[nodiscard]] int extraLarge() const { return static_cast(1000 * m_scale); } + + [[nodiscard]] int expressiveFastSpatial() const { return static_cast(350 * m_scale); } + + [[nodiscard]] int expressiveDefaultSpatial() const { return static_cast(500 * m_scale); } + + [[nodiscard]] int expressiveSlowSpatial() const { return static_cast(650 * m_scale); } +}; + +class AppearanceAnim : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(qreal, mediaGifSpeedAdjustment, 300) + CONFIG_PROPERTY(qreal, sessionGifSpeed, 0.7) + CONFIG_SUBOBJECT(AnimDurations, durations) + +public: + explicit AppearanceAnim(QObject* parent = nullptr) + : ConfigObject(parent) + , m_durations(new AnimDurations(this)) {} +}; + +class AppearanceTransparency : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, enabled, false) + CONFIG_PROPERTY(qreal, base, 0.85) + CONFIG_PROPERTY(qreal, layers, 0.4) + +public: + explicit AppearanceTransparency(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class AppearanceConfig : public ConfigObject { + Q_OBJECT + CONFIG_SUBOBJECT(AppearanceRounding, rounding) + CONFIG_SUBOBJECT(AppearanceSpacing, spacing) + CONFIG_SUBOBJECT(AppearancePadding, padding) + CONFIG_SUBOBJECT(AppearanceFont, font) + CONFIG_SUBOBJECT(AppearanceAnim, anim) + CONFIG_SUBOBJECT(AppearanceTransparency, transparency) + +public: + explicit AppearanceConfig(QObject* parent = nullptr) + : ConfigObject(parent) + , m_rounding(new AppearanceRounding(this)) + , m_spacing(new AppearanceSpacing(this)) + , m_padding(new AppearancePadding(this)) + , m_font(new AppearanceFont(this)) + , m_anim(new AppearanceAnim(this)) + , m_transparency(new AppearanceTransparency(this)) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/backgroundconfig.hpp b/plugin/src/Caelestia/Config/backgroundconfig.hpp new file mode 100644 index 00000000..32440cc3 --- /dev/null +++ b/plugin/src/Caelestia/Config/backgroundconfig.hpp @@ -0,0 +1,74 @@ +#pragma once + +#include "configobject.hpp" + +#include + +namespace caelestia::config { + +class DesktopClockBackground : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, enabled, false) + CONFIG_PROPERTY(qreal, opacity, 0.7) + CONFIG_PROPERTY(bool, blur, true) + +public: + explicit DesktopClockBackground(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class DesktopClockShadow : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, enabled, true) + CONFIG_PROPERTY(qreal, opacity, 0.7) + CONFIG_PROPERTY(qreal, blur, 0.4) + +public: + explicit DesktopClockShadow(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class DesktopClock : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, enabled, false) + CONFIG_PROPERTY(qreal, scale, 1.0) + CONFIG_PROPERTY(QString, position, QStringLiteral("bottom-right")) + CONFIG_PROPERTY(bool, invertColors, false) + CONFIG_SUBOBJECT(DesktopClockBackground, background) + CONFIG_SUBOBJECT(DesktopClockShadow, shadow) + +public: + explicit DesktopClock(QObject* parent = nullptr) + : ConfigObject(parent) + , m_background(new DesktopClockBackground(this)) + , m_shadow(new DesktopClockShadow(this)) {} +}; + +class BackgroundVisualiser : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, enabled, false) + CONFIG_PROPERTY(bool, autoHide, true) + CONFIG_PROPERTY(bool, blur, false) + CONFIG_PROPERTY(qreal, rounding, 1) + CONFIG_PROPERTY(qreal, spacing, 1) + +public: + explicit BackgroundVisualiser(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class BackgroundConfig : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, enabled, true) + CONFIG_PROPERTY(bool, wallpaperEnabled, true) + CONFIG_SUBOBJECT(DesktopClock, desktopClock) + CONFIG_SUBOBJECT(BackgroundVisualiser, visualiser) + +public: + explicit BackgroundConfig(QObject* parent = nullptr) + : ConfigObject(parent) + , m_desktopClock(new DesktopClock(this)) + , m_visualiser(new BackgroundVisualiser(this)) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/barconfig.hpp b/plugin/src/Caelestia/Config/barconfig.hpp new file mode 100644 index 00000000..712c047f --- /dev/null +++ b/plugin/src/Caelestia/Config/barconfig.hpp @@ -0,0 +1,133 @@ +#pragma once + +#include "configobject.hpp" + +#include +#include +#include + +namespace caelestia::config { + +class BarScrollActions : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, workspaces, true) + CONFIG_PROPERTY(bool, volume, true) + CONFIG_PROPERTY(bool, brightness, true) + +public: + explicit BarScrollActions(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class BarPopouts : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, activeWindow, true) + CONFIG_PROPERTY(bool, tray, true) + CONFIG_PROPERTY(bool, statusIcons, true) + +public: + explicit BarPopouts(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class BarWorkspaces : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(int, shown, 5) + CONFIG_PROPERTY(bool, activeIndicator, true) + CONFIG_PROPERTY(bool, occupiedBg, false) + CONFIG_PROPERTY(bool, showWindows, true) + CONFIG_PROPERTY(bool, showWindowsOnSpecialWorkspaces, true) + CONFIG_PROPERTY(int, maxWindowIcons, 0) + CONFIG_PROPERTY(bool, activeTrail, false) + CONFIG_PROPERTY(bool, perMonitorWorkspaces, true) + CONFIG_PROPERTY(QString, label, QStringLiteral(" ")) + CONFIG_PROPERTY(QString, occupiedLabel, QStringLiteral("\U000f06af")) + CONFIG_PROPERTY(QString, activeLabel, QStringLiteral("\U000f06af")) + CONFIG_PROPERTY(QString, capitalisation, QStringLiteral("preserve")) + CONFIG_PROPERTY(QVariantList, specialWorkspaceIcons) + CONFIG_PROPERTY(QVariantList, windowIcons) + +public: + explicit BarWorkspaces(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class BarActiveWindow : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, compact, false) + CONFIG_PROPERTY(bool, inverted, false) + CONFIG_PROPERTY(bool, showOnHover, true) + +public: + explicit BarActiveWindow(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class BarTray : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, background, false) + CONFIG_PROPERTY(bool, recolour, false) + CONFIG_PROPERTY(bool, compact, false) + CONFIG_PROPERTY(QVariantList, iconSubs) + CONFIG_PROPERTY(QStringList, hiddenIcons) + +public: + explicit BarTray(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class BarStatus : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, showAudio, false) + CONFIG_PROPERTY(bool, showMicrophone, false) + CONFIG_PROPERTY(bool, showKbLayout, false) + CONFIG_PROPERTY(bool, showNetwork, true) + CONFIG_PROPERTY(bool, showWifi, true) + CONFIG_PROPERTY(bool, showBluetooth, true) + CONFIG_PROPERTY(bool, showBattery, true) + CONFIG_PROPERTY(bool, showLockStatus, true) + +public: + explicit BarStatus(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class BarClock : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, background, false) + CONFIG_PROPERTY(bool, showDate, false) + CONFIG_PROPERTY(bool, showIcon, true) + +public: + explicit BarClock(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class BarConfig : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, persistent, true) + CONFIG_PROPERTY(bool, showOnHover, true) + CONFIG_PROPERTY(int, dragThreshold, 20) + CONFIG_SUBOBJECT(BarScrollActions, scrollActions) + CONFIG_SUBOBJECT(BarPopouts, popouts) + CONFIG_SUBOBJECT(BarWorkspaces, workspaces) + CONFIG_SUBOBJECT(BarActiveWindow, activeWindow) + CONFIG_SUBOBJECT(BarTray, tray) + CONFIG_SUBOBJECT(BarStatus, status) + CONFIG_SUBOBJECT(BarClock, clock) + CONFIG_PROPERTY(QVariantList, entries) + CONFIG_PROPERTY(QStringList, excludedScreens) + +public: + explicit BarConfig(QObject* parent = nullptr) + : ConfigObject(parent) + , m_scrollActions(new BarScrollActions(this)) + , m_popouts(new BarPopouts(this)) + , m_workspaces(new BarWorkspaces(this)) + , m_activeWindow(new BarActiveWindow(this)) + , m_tray(new BarTray(this)) + , m_status(new BarStatus(this)) + , m_clock(new BarClock(this)) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/borderconfig.hpp b/plugin/src/Caelestia/Config/borderconfig.hpp new file mode 100644 index 00000000..9bc2966c --- /dev/null +++ b/plugin/src/Caelestia/Config/borderconfig.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include "configobject.hpp" + +#include + +namespace caelestia::config { + +class BorderConfig : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(int, thickness, 10) + CONFIG_PROPERTY(int, rounding, 25) + + Q_PROPERTY(int minThickness READ minThickness CONSTANT) + Q_PROPERTY(int clampedThickness READ clampedThickness NOTIFY thicknessChanged) + +public: + explicit BorderConfig(QObject* parent = nullptr) + : ConfigObject(parent) {} + + [[nodiscard]] static int minThickness() { return 2; } + + [[nodiscard]] int clampedThickness() const { return std::max(minThickness(), m_thickness); } +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/config.cpp b/plugin/src/Caelestia/Config/config.cpp new file mode 100644 index 00000000..01df3704 --- /dev/null +++ b/plugin/src/Caelestia/Config/config.cpp @@ -0,0 +1,138 @@ +#include "config.hpp" + +#include +#include +#include +#include +#include +#include +#include + +namespace caelestia::config { + +static GlobalConfig* s_instance = nullptr; + +GlobalConfig::GlobalConfig(QObject* parent) + : ConfigObject(parent) + , m_appearance(new AppearanceConfig(this)) + , m_general(new GeneralConfig(this)) + , m_background(new BackgroundConfig(this)) + , m_bar(new BarConfig(this)) + , m_border(new BorderConfig(this)) + , m_dashboard(new DashboardConfig(this)) + , m_controlCenter(new ControlCenterConfig(this)) + , m_launcher(new LauncherConfig(this)) + , m_notifs(new NotifsConfig(this)) + , m_osd(new OsdConfig(this)) + , m_session(new SessionConfig(this)) + , m_winfo(new WInfoConfig(this)) + , m_lock(new LockConfig(this)) + , m_utilities(new UtilitiesConfig(this)) + , m_sidebar(new SidebarConfig(this)) + , m_services(new ServiceConfig(this)) + , m_paths(new UserPaths(this)) + , m_advanced(new AdvancedConfig(this)) { + s_instance = this; + + m_configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + + QStringLiteral("/caelestia/shell.json"); + + m_saveTimer.setSingleShot(true); + m_saveTimer.setInterval(500); + connect(&m_saveTimer, &QTimer::timeout, this, &GlobalConfig::writeToFile); + + m_cooldownTimer.setSingleShot(true); + m_cooldownTimer.setInterval(2000); + connect(&m_cooldownTimer, &QTimer::timeout, this, [this] { + m_recentlySaved = false; + emit recentlySavedChanged(); + }); + + connect(&m_watcher, &QFileSystemWatcher::fileChanged, this, &GlobalConfig::onFileChanged); + + reload(); + + if (QFile::exists(m_configPath)) { + m_watcher.addPath(m_configPath); + } +} + +GlobalConfig* GlobalConfig::instance() { + return s_instance; +} + +bool GlobalConfig::recentlySaved() const { + return m_recentlySaved; +} + +void GlobalConfig::save() { + m_saveTimer.start(); + m_recentlySaved = true; + emit recentlySavedChanged(); + m_cooldownTimer.start(); +} + +void GlobalConfig::reload() { + QFile file(m_configPath); + + if (!file.open(QIODevice::ReadOnly)) { + qWarning() << "Config: failed to open" << m_configPath; + return; + } + + load(file.readAll()); +} + +void GlobalConfig::load(const QByteArray& contents) { + QJsonParseError error{}; + auto doc = QJsonDocument::fromJson(contents, &error); + + if (error.error != QJsonParseError::NoError) { + qWarning() << "Config: failed to parse JSON:" << error.errorString(); + return; + } + + loadFromJson(doc.object()); +} + +void GlobalConfig::onFileChanged() { + if (!m_watcher.files().contains(m_configPath)) { + m_watcher.addPath(m_configPath); + } + + if (!m_recentlySaved) { + reload(); + } +} + +void GlobalConfig::writeToFile() { + QDir().mkpath(QFileInfo(m_configPath).absolutePath()); + + QFile file(m_configPath); + + if (!file.open(QIODevice::WriteOnly)) { + qWarning() << "Config: failed to write" << m_configPath; + return; + } + + file.write(QJsonDocument(toJsonObject()).toJson(QJsonDocument::Indented)); +} + +// Config + +Config::Config(QQuickItem* parent) + : QQuickItem(parent) {} + +Config* Config::qmlAttachedProperties(QObject* object) { + auto* item = qobject_cast(object); + + while (item) { + if (auto* config = qobject_cast(item)) + return config; + item = item->parentItem(); + } + + return nullptr; +} + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/config.hpp b/plugin/src/Caelestia/Config/config.hpp new file mode 100644 index 00000000..e989d4c3 --- /dev/null +++ b/plugin/src/Caelestia/Config/config.hpp @@ -0,0 +1,94 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +#include "advancedconfig.hpp" +#include "appearanceconfig.hpp" +#include "backgroundconfig.hpp" +#include "barconfig.hpp" +#include "borderconfig.hpp" +#include "controlcenterconfig.hpp" +#include "dashboardconfig.hpp" +#include "generalconfig.hpp" +#include "launcherconfig.hpp" +#include "lockconfig.hpp" +#include "notifsconfig.hpp" +#include "osdconfig.hpp" +#include "serviceconfig.hpp" +#include "sessionconfig.hpp" +#include "sidebarconfig.hpp" +#include "userpaths.hpp" +#include "utilitiesconfig.hpp" +#include "winfoconfig.hpp" + +namespace caelestia::config { + +class GlobalConfig : public ConfigObject { + Q_OBJECT + QML_ELEMENT + QML_SINGLETON + + CONFIG_SUBOBJECT(AppearanceConfig, appearance) + CONFIG_SUBOBJECT(GeneralConfig, general) + CONFIG_SUBOBJECT(BackgroundConfig, background) + CONFIG_SUBOBJECT(BarConfig, bar) + CONFIG_SUBOBJECT(BorderConfig, border) + CONFIG_SUBOBJECT(DashboardConfig, dashboard) + CONFIG_SUBOBJECT(ControlCenterConfig, controlCenter) + CONFIG_SUBOBJECT(LauncherConfig, launcher) + CONFIG_SUBOBJECT(NotifsConfig, notifs) + CONFIG_SUBOBJECT(OsdConfig, osd) + CONFIG_SUBOBJECT(SessionConfig, session) + CONFIG_SUBOBJECT(WInfoConfig, winfo) + CONFIG_SUBOBJECT(LockConfig, lock) + CONFIG_SUBOBJECT(UtilitiesConfig, utilities) + CONFIG_SUBOBJECT(SidebarConfig, sidebar) + CONFIG_SUBOBJECT(ServiceConfig, services) + CONFIG_SUBOBJECT(UserPaths, paths) + CONFIG_SUBOBJECT(AdvancedConfig, advanced) + + Q_PROPERTY(bool recentlySaved READ recentlySaved NOTIFY recentlySavedChanged) + +public: + explicit GlobalConfig(QObject* parent = nullptr); + + static GlobalConfig* instance(); + + [[nodiscard]] bool recentlySaved() const; + + Q_INVOKABLE void save(); + Q_INVOKABLE void reload(); + +signals: + void recentlySavedChanged(); + +private: + void load(const QByteArray& contents); + void onFileChanged(); + void writeToFile(); + + bool m_recentlySaved = false; + QString m_configPath; + QFileSystemWatcher m_watcher; + QTimer m_saveTimer; + QTimer m_cooldownTimer; +}; + +class Config : public QQuickItem { + Q_OBJECT + QML_ELEMENT + QML_ATTACHED(Config) + +public: + explicit Config(QQuickItem* parent = nullptr); + + static Config* qmlAttachedProperties(QObject* object); +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/configobject.cpp b/plugin/src/Caelestia/Config/configobject.cpp new file mode 100644 index 00000000..7533b0f5 --- /dev/null +++ b/plugin/src/Caelestia/Config/configobject.cpp @@ -0,0 +1,107 @@ +#include "configobject.hpp" + +#include +#include +#include +#include +#include +#include + +namespace caelestia::config { + +Q_LOGGING_CATEGORY(lcConfig, "caelestia.config", QtInfoMsg) + +ConfigObject::ConfigObject(QObject* parent) + : QObject(parent) {} + +void ConfigObject::loadFromJson(const QJsonObject& obj) { + const auto* meta = metaObject(); + + for (int i = meta->propertyOffset(); i < meta->propertyCount(); ++i) { + auto prop = meta->property(i); + const auto key = QString::fromUtf8(prop.name()); + + if (!obj.contains(key)) + continue; + + const auto jsonVal = obj.value(key); + + // Recurse into sub-objects + auto current = prop.read(this); + auto* subObj = current.value(); + + if (subObj) { + subObj->loadFromJson(jsonVal.toObject()); + continue; + } + + // Skip read-only properties + if (!prop.isWritable()) + continue; + + // Handle QStringList explicitly (QJsonArray → QStringList needs manual conversion) + if (prop.metaType().id() == QMetaType::QStringList) { + QStringList list; + const auto jsonArr = jsonVal.toArray(); + for (const auto& v : jsonArr) + list.append(v.toString()); + prop.write(this, QVariant::fromValue(list)); + continue; + } + + // For all other types, let Qt's variant conversion handle it + prop.write(this, jsonVal.toVariant()); + } +} + +QJsonObject ConfigObject::toJsonObject() const { + QJsonObject obj; + const auto* meta = metaObject(); + + for (int i = meta->propertyOffset(); i < meta->propertyCount(); ++i) { + const auto prop = meta->property(i); + + if (!prop.isReadable()) + continue; + + const auto key = QString::fromUtf8(prop.name()); + const auto value = prop.read(this); + + // Recurse into sub-objects + if (value.canView()) { + auto* const subObj = value.value(); + if (subObj) + obj.insert(key, subObj->toJsonObject()); + else + qCWarning(lcConfig, "Unable to get sub-object when serializing config object"); + continue; + } + + // Skip read-only properties (computed values) + if (!prop.isWritable()) + continue; + + // Handle QStringList explicitly + if (prop.metaType().id() == QMetaType::QStringList) { + QJsonArray arr; + const auto strList = value.toStringList(); + for (const auto& s : strList) + arr.append(s); + obj.insert(key, arr); + continue; + } + + // Handle QVariantList explicitly + if (prop.metaType().id() == QMetaType::QVariantList) { + obj.insert(key, QJsonArray::fromVariantList(value.toList())); + continue; + } + + // Default case + obj.insert(key, QJsonValue::fromVariant(value)); + } + + return obj; +} + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/configobject.hpp b/plugin/src/Caelestia/Config/configobject.hpp new file mode 100644 index 00000000..2f8f443e --- /dev/null +++ b/plugin/src/Caelestia/Config/configobject.hpp @@ -0,0 +1,63 @@ +#pragma once + +#include +#include +#include + +#include + +// Declares a serialized config property with getter, setter (change-detected), signal, and member. +#define CONFIG_PROPERTY(Type, name, ...) \ + Q_PROPERTY(Type name READ name WRITE set_##name NOTIFY name##Changed) \ + \ +public: \ + [[nodiscard]] Type name() const { \ + return m_##name; \ + } \ + void set_##name(const Type& val) { \ + if (caelestia::config::ConfigObject::updateMember(m_##name, val)) \ + emit name##Changed(); \ + } \ + Q_SIGNAL void name##Changed(); \ + \ +private: \ + Type m_##name __VA_OPT__(= __VA_ARGS__); + +// Declares a CONSTANT sub-object property. Initialize the member in the constructor. +#define CONFIG_SUBOBJECT(Type, name) \ + Q_PROPERTY(caelestia::config::Type* name READ name CONSTANT) \ + \ +public: \ + [[nodiscard]] Type* name() const { \ + return m_##name; \ + } \ + \ +private: \ + Type* m_##name = nullptr; + +namespace caelestia::config { + +class ConfigObject : public QObject { + Q_OBJECT + QML_ANONYMOUS + +public: + explicit ConfigObject(QObject* parent = nullptr); + + void loadFromJson(const QJsonObject& obj); + [[nodiscard]] QJsonObject toJsonObject() const; + + template static bool updateMember(T& member, const T& value) { + if constexpr (std::is_floating_point_v) { + if (qFuzzyCompare(member + 1.0, value + 1.0)) + return false; + } else { + if (member == value) + return false; + } + member = value; + return true; + } +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/controlcenterconfig.hpp b/plugin/src/Caelestia/Config/controlcenterconfig.hpp new file mode 100644 index 00000000..d827f7cc --- /dev/null +++ b/plugin/src/Caelestia/Config/controlcenterconfig.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include "configobject.hpp" + +namespace caelestia::config { + +// ControlCenterConfig has no serialized properties (serializer returns {}) +// All properties are in AdvancedConfig.controlCenter +class ControlCenterConfig : public ConfigObject { + Q_OBJECT + +public: + explicit ControlCenterConfig(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/dashboardconfig.hpp b/plugin/src/Caelestia/Config/dashboardconfig.hpp new file mode 100644 index 00000000..f6b97ac6 --- /dev/null +++ b/plugin/src/Caelestia/Config/dashboardconfig.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include "configobject.hpp" + +namespace caelestia::config { + +class DashboardPerformance : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, showBattery, true) + CONFIG_PROPERTY(bool, showGpu, true) + CONFIG_PROPERTY(bool, showCpu, true) + CONFIG_PROPERTY(bool, showMemory, true) + CONFIG_PROPERTY(bool, showStorage, true) + CONFIG_PROPERTY(bool, showNetwork, true) + +public: + explicit DashboardPerformance(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class DashboardConfig : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, enabled, true) + CONFIG_PROPERTY(bool, showOnHover, true) + CONFIG_PROPERTY(int, mediaUpdateInterval, 500) + CONFIG_PROPERTY(int, resourceUpdateInterval, 1000) + CONFIG_PROPERTY(int, dragThreshold, 50) + CONFIG_SUBOBJECT(DashboardPerformance, performance) + +public: + explicit DashboardConfig(QObject* parent = nullptr) + : ConfigObject(parent) + , m_performance(new DashboardPerformance(this)) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/generalconfig.hpp b/plugin/src/Caelestia/Config/generalconfig.hpp new file mode 100644 index 00000000..8ccc9089 --- /dev/null +++ b/plugin/src/Caelestia/Config/generalconfig.hpp @@ -0,0 +1,60 @@ +#pragma once + +#include "configobject.hpp" + +#include +#include +#include + +namespace caelestia::config { + +class GeneralApps : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(QStringList, terminal, { QStringLiteral("foot") }) + CONFIG_PROPERTY(QStringList, audio, { QStringLiteral("pavucontrol") }) + CONFIG_PROPERTY(QStringList, playback, { QStringLiteral("mpv") }) + CONFIG_PROPERTY(QStringList, explorer, { QStringLiteral("thunar") }) + +public: + explicit GeneralApps(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class GeneralIdle : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, lockBeforeSleep, true) + CONFIG_PROPERTY(bool, inhibitWhenAudio, true) + CONFIG_PROPERTY(QVariantList, timeouts) + +public: + explicit GeneralIdle(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class GeneralBattery : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(QVariantList, warnLevels) + CONFIG_PROPERTY(int, criticalLevel, 3) + +public: + explicit GeneralBattery(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class GeneralConfig : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(QString, logo) + CONFIG_PROPERTY(QStringList, excludedScreens) + CONFIG_SUBOBJECT(GeneralApps, apps) + CONFIG_SUBOBJECT(GeneralIdle, idle) + CONFIG_SUBOBJECT(GeneralBattery, battery) + +public: + explicit GeneralConfig(QObject* parent = nullptr) + : ConfigObject(parent) + , m_apps(new GeneralApps(this)) + , m_idle(new GeneralIdle(this)) + , m_battery(new GeneralBattery(this)) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/launcherconfig.hpp b/plugin/src/Caelestia/Config/launcherconfig.hpp new file mode 100644 index 00000000..d430ae60 --- /dev/null +++ b/plugin/src/Caelestia/Config/launcherconfig.hpp @@ -0,0 +1,46 @@ +#pragma once + +#include "configobject.hpp" + +#include +#include +#include + +namespace caelestia::config { + +class LauncherUseFuzzy : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, apps, false) + CONFIG_PROPERTY(bool, actions, false) + CONFIG_PROPERTY(bool, schemes, false) + CONFIG_PROPERTY(bool, variants, false) + CONFIG_PROPERTY(bool, wallpapers, false) + +public: + explicit LauncherUseFuzzy(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class LauncherConfig : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, enabled, true) + CONFIG_PROPERTY(bool, showOnHover, false) + CONFIG_PROPERTY(int, maxShown, 7) + CONFIG_PROPERTY(int, maxWallpapers, 9) + CONFIG_PROPERTY(QString, specialPrefix, QStringLiteral("@")) + CONFIG_PROPERTY(QString, actionPrefix, QStringLiteral(">")) + CONFIG_PROPERTY(bool, enableDangerousActions, false) + CONFIG_PROPERTY(int, dragThreshold, 50) + CONFIG_PROPERTY(bool, vimKeybinds, false) + CONFIG_PROPERTY(QStringList, favouriteApps) + CONFIG_PROPERTY(QStringList, hiddenApps) + CONFIG_SUBOBJECT(LauncherUseFuzzy, useFuzzy) + CONFIG_PROPERTY(QVariantList, actions) + +public: + explicit LauncherConfig(QObject* parent = nullptr) + : ConfigObject(parent) + , m_useFuzzy(new LauncherUseFuzzy(this)) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/lockconfig.hpp b/plugin/src/Caelestia/Config/lockconfig.hpp new file mode 100644 index 00000000..a15c722a --- /dev/null +++ b/plugin/src/Caelestia/Config/lockconfig.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "configobject.hpp" + +namespace caelestia::config { + +class LockConfig : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, recolourLogo, false) + CONFIG_PROPERTY(bool, enableFprint, true) + CONFIG_PROPERTY(int, maxFprintTries, 3) + CONFIG_PROPERTY(bool, hideNotifs, false) + +public: + explicit LockConfig(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/notifsconfig.hpp b/plugin/src/Caelestia/Config/notifsconfig.hpp new file mode 100644 index 00000000..61c9bb9e --- /dev/null +++ b/plugin/src/Caelestia/Config/notifsconfig.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "configobject.hpp" + +#include + +namespace caelestia::config { + +class NotifsConfig : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, expire, true) + CONFIG_PROPERTY(QString, fullscreen, QStringLiteral("on")) + CONFIG_PROPERTY(int, defaultExpireTimeout, 5000) + CONFIG_PROPERTY(qreal, clearThreshold, 0.3) + CONFIG_PROPERTY(int, expandThreshold, 20) + CONFIG_PROPERTY(bool, actionOnClick, false) + CONFIG_PROPERTY(int, groupPreviewNum, 3) + CONFIG_PROPERTY(bool, openExpanded, false) + +public: + explicit NotifsConfig(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/osdconfig.hpp b/plugin/src/Caelestia/Config/osdconfig.hpp new file mode 100644 index 00000000..71cc27b4 --- /dev/null +++ b/plugin/src/Caelestia/Config/osdconfig.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "configobject.hpp" + +namespace caelestia::config { + +class OsdConfig : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, enabled, true) + CONFIG_PROPERTY(int, hideDelay, 2000) + CONFIG_PROPERTY(bool, enableBrightness, true) + CONFIG_PROPERTY(bool, enableMicrophone, false) + +public: + explicit OsdConfig(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/serviceconfig.hpp b/plugin/src/Caelestia/Config/serviceconfig.hpp new file mode 100644 index 00000000..131314c1 --- /dev/null +++ b/plugin/src/Caelestia/Config/serviceconfig.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include "configobject.hpp" + +#include +#include + +namespace caelestia::config { + +class ServiceConfig : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(QString, weatherLocation) + CONFIG_PROPERTY(bool, useFahrenheit, false) + CONFIG_PROPERTY(bool, useFahrenheitPerformance, false) + CONFIG_PROPERTY(bool, useTwelveHourClock, false) + CONFIG_PROPERTY(QString, gpuType) + CONFIG_PROPERTY(int, visualiserBars, 45) + CONFIG_PROPERTY(qreal, audioIncrement, 0.1) + CONFIG_PROPERTY(qreal, brightnessIncrement, 0.1) + CONFIG_PROPERTY(qreal, maxVolume, 1.0) + CONFIG_PROPERTY(bool, smartScheme, true) + CONFIG_PROPERTY(QString, defaultPlayer, QStringLiteral("Spotify")) + CONFIG_PROPERTY(QVariantList, playerAliases) + CONFIG_PROPERTY(bool, showLyrics, false) + CONFIG_PROPERTY(QString, lyricsBackend, QStringLiteral("Auto")) + +public: + explicit ServiceConfig(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/sessionconfig.hpp b/plugin/src/Caelestia/Config/sessionconfig.hpp new file mode 100644 index 00000000..af609512 --- /dev/null +++ b/plugin/src/Caelestia/Config/sessionconfig.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include "configobject.hpp" + +#include +#include + +namespace caelestia::config { + +class SessionIcons : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(QString, logout, QStringLiteral("logout")) + CONFIG_PROPERTY(QString, shutdown, QStringLiteral("power_settings_new")) + CONFIG_PROPERTY(QString, hibernate, QStringLiteral("downloading")) + CONFIG_PROPERTY(QString, reboot, QStringLiteral("cached")) + +public: + explicit SessionIcons(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class SessionCommands : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(QStringList, logout, { QStringLiteral("loginctl"), QStringLiteral("terminate-user"), QString() }) + CONFIG_PROPERTY(QStringList, shutdown, { QStringLiteral("systemctl"), QStringLiteral("poweroff") }) + CONFIG_PROPERTY(QStringList, hibernate, { QStringLiteral("systemctl"), QStringLiteral("hibernate") }) + CONFIG_PROPERTY(QStringList, reboot, { QStringLiteral("systemctl"), QStringLiteral("reboot") }) + +public: + explicit SessionCommands(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class SessionConfig : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, enabled, true) + CONFIG_PROPERTY(int, dragThreshold, 30) + CONFIG_PROPERTY(bool, vimKeybinds, false) + CONFIG_SUBOBJECT(SessionIcons, icons) + CONFIG_SUBOBJECT(SessionCommands, commands) + +public: + explicit SessionConfig(QObject* parent = nullptr) + : ConfigObject(parent) + , m_icons(new SessionIcons(this)) + , m_commands(new SessionCommands(this)) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/sidebarconfig.hpp b/plugin/src/Caelestia/Config/sidebarconfig.hpp new file mode 100644 index 00000000..71041cfb --- /dev/null +++ b/plugin/src/Caelestia/Config/sidebarconfig.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include "configobject.hpp" + +namespace caelestia::config { + +class SidebarConfig : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, enabled, true) + CONFIG_PROPERTY(int, dragThreshold, 80) + +public: + explicit SidebarConfig(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/userpaths.hpp b/plugin/src/Caelestia/Config/userpaths.hpp new file mode 100644 index 00000000..ec0b4880 --- /dev/null +++ b/plugin/src/Caelestia/Config/userpaths.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include "configobject.hpp" + +#include +#include +#include + +namespace caelestia::config { + +class UserPaths : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(QString, wallpaperDir, + QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + QStringLiteral("/Wallpapers")) + CONFIG_PROPERTY(QString, lyricsDir, QDir::homePath() + QStringLiteral("/Music/lyrics/")) + CONFIG_PROPERTY(QString, sessionGif, QStringLiteral("root:/assets/kurukuru.gif")) + CONFIG_PROPERTY(QString, mediaGif, QStringLiteral("root:/assets/bongocat.gif")) + CONFIG_PROPERTY(QString, noNotifsPic, QStringLiteral("root:/assets/dino.png")) + CONFIG_PROPERTY(QString, lockNoNotifsPic, QStringLiteral("root:/assets/dino.png")) + +public: + explicit UserPaths(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/utilitiesconfig.hpp b/plugin/src/Caelestia/Config/utilitiesconfig.hpp new file mode 100644 index 00000000..98da47ed --- /dev/null +++ b/plugin/src/Caelestia/Config/utilitiesconfig.hpp @@ -0,0 +1,56 @@ +#pragma once + +#include "configobject.hpp" + +#include +#include + +namespace caelestia::config { + +class UtilitiesToasts : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, configLoaded, true) + CONFIG_PROPERTY(QString, fullscreen, QStringLiteral("off")) + CONFIG_PROPERTY(bool, chargingChanged, true) + CONFIG_PROPERTY(bool, gameModeChanged, true) + CONFIG_PROPERTY(bool, dndChanged, true) + CONFIG_PROPERTY(bool, audioOutputChanged, true) + CONFIG_PROPERTY(bool, audioInputChanged, true) + CONFIG_PROPERTY(bool, capsLockChanged, true) + CONFIG_PROPERTY(bool, numLockChanged, true) + CONFIG_PROPERTY(bool, kbLayoutChanged, true) + CONFIG_PROPERTY(bool, kbLimit, true) + CONFIG_PROPERTY(bool, vpnChanged, true) + CONFIG_PROPERTY(bool, nowPlaying, false) + +public: + explicit UtilitiesToasts(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class UtilitiesVpn : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, enabled, false) + CONFIG_PROPERTY(QVariantList, provider) + +public: + explicit UtilitiesVpn(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +class UtilitiesConfig : public ConfigObject { + Q_OBJECT + CONFIG_PROPERTY(bool, enabled, true) + CONFIG_PROPERTY(int, maxToasts, 4) + CONFIG_SUBOBJECT(UtilitiesToasts, toasts) + CONFIG_SUBOBJECT(UtilitiesVpn, vpn) + CONFIG_PROPERTY(QVariantList, quickToggles) + +public: + explicit UtilitiesConfig(QObject* parent = nullptr) + : ConfigObject(parent) + , m_toasts(new UtilitiesToasts(this)) + , m_vpn(new UtilitiesVpn(this)) {} +}; + +} // namespace caelestia::config diff --git a/plugin/src/Caelestia/Config/winfoconfig.hpp b/plugin/src/Caelestia/Config/winfoconfig.hpp new file mode 100644 index 00000000..91f2f234 --- /dev/null +++ b/plugin/src/Caelestia/Config/winfoconfig.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include "configobject.hpp" + +namespace caelestia::config { + +// WInfoConfig has no serialized properties (serializer returns {}) +// All properties are in AdvancedConfig.winfo +class WInfoConfig : public ConfigObject { + Q_OBJECT + +public: + explicit WInfoConfig(QObject* parent = nullptr) + : ConfigObject(parent) {} +}; + +} // namespace caelestia::config