From 41ba4f62714fda70c1ce60985ac0c0612ad397a2 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sun, 12 Apr 2026 03:39:58 +1000 Subject: [PATCH] feat: add per monitor enabled prop Enabled prop should be used in favour of general.excludedScreens. The latter has been removed --- README.md | 1 + plugin/src/Caelestia/Config/config.cpp | 9 +++++++++ plugin/src/Caelestia/Config/config.hpp | 4 ++++ plugin/src/Caelestia/Config/generalconfig.hpp | 1 - plugin/src/Caelestia/Config/tokens.cpp | 9 +++++++++ plugin/src/Caelestia/Config/tokens.hpp | 3 +++ services/Screens.qml | 9 ++------- 7 files changed, 28 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8c6763bd..d7e4c7c6 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,7 @@ For example, to disable the bar on DP-1: ```json { + "enabled": true, "appearance": { "anim": { "durations": { diff --git a/plugin/src/Caelestia/Config/config.cpp b/plugin/src/Caelestia/Config/config.cpp index 8a7a5c02..b68f4247 100644 --- a/plugin/src/Caelestia/Config/config.cpp +++ b/plugin/src/Caelestia/Config/config.cpp @@ -1,5 +1,6 @@ #include "config.hpp" #include "configscope.hpp" +#include "monitorconfigmanager.hpp" #include "tokens.hpp" #include @@ -91,6 +92,10 @@ void GlobalConfig::bindAppearanceTokens() { m_tokensBound = true; } +GlobalConfig* GlobalConfig::forScreen(const QString& screen) { + return MonitorConfigManager::instance()->configForScreen(screen); +} + GlobalConfig* GlobalConfig::create(QQmlEngine*, QJSEngine*) { QQmlEngine::setObjectOwnership(instance(), QQmlEngine::CppOwnership); return instance(); @@ -139,6 +144,10 @@ CONFIG_ATTACHED_GETTER(UserPaths, paths) #undef CONFIG_ATTACHED_GETTER +GlobalConfig* Config::forScreen(const QString& screen) { + return GlobalConfig::forScreen(screen); +} + Config* Config::qmlAttachedProperties(QObject* object) { return new Config(ConfigScope::find(object), object); } diff --git a/plugin/src/Caelestia/Config/config.hpp b/plugin/src/Caelestia/Config/config.hpp index 06f5e3e4..1c34f039 100644 --- a/plugin/src/Caelestia/Config/config.hpp +++ b/plugin/src/Caelestia/Config/config.hpp @@ -28,6 +28,7 @@ class GlobalConfig : public RootConfig { QML_ELEMENT QML_SINGLETON + CONFIG_PROPERTY(bool, enabled, true) CONFIG_SUBOBJECT(AppearanceConfig, appearance) CONFIG_SUBOBJECT(GeneralConfig, general) CONFIG_SUBOBJECT(BackgroundConfig, background) @@ -49,6 +50,7 @@ class GlobalConfig : public RootConfig { public: static GlobalConfig* instance(); [[nodiscard]] Q_INVOKABLE GlobalConfig* defaults(); + [[nodiscard]] Q_INVOKABLE static GlobalConfig* forScreen(const QString& screen); static GlobalConfig* create(QQmlEngine*, QJSEngine*); void bindAppearanceTokens(); @@ -114,6 +116,8 @@ public: [[nodiscard]] const ServiceConfig* services() const; [[nodiscard]] const UserPaths* paths() const; + [[nodiscard]] Q_INVOKABLE static GlobalConfig* forScreen(const QString& screen); + static Config* qmlAttachedProperties(QObject* object); signals: diff --git a/plugin/src/Caelestia/Config/generalconfig.hpp b/plugin/src/Caelestia/Config/generalconfig.hpp index 24982e61..32b7df1e 100644 --- a/plugin/src/Caelestia/Config/generalconfig.hpp +++ b/plugin/src/Caelestia/Config/generalconfig.hpp @@ -52,7 +52,6 @@ class GeneralConfig : public ConfigObject { QML_ANONYMOUS CONFIG_PROPERTY(QString, logo) - CONFIG_PROPERTY(QStringList, excludedScreens) CONFIG_PROPERTY(qreal, mediaGifSpeedAdjustment, 300) CONFIG_PROPERTY(qreal, sessionGifSpeed, 0.7) CONFIG_SUBOBJECT(GeneralApps, apps) diff --git a/plugin/src/Caelestia/Config/tokens.cpp b/plugin/src/Caelestia/Config/tokens.cpp index 3f800071..84d3cef7 100644 --- a/plugin/src/Caelestia/Config/tokens.cpp +++ b/plugin/src/Caelestia/Config/tokens.cpp @@ -1,6 +1,7 @@ #include "tokens.hpp" #include "config.hpp" #include "configscope.hpp" +#include "monitorconfigmanager.hpp" #include #include @@ -43,6 +44,10 @@ TokenConfig* TokenConfig::defaults() { return m_defaults; } +TokenConfig* TokenConfig::forScreen(const QString& screen) { + return MonitorConfigManager::instance()->tokensForScreen(screen); +} + TokenConfig* TokenConfig::create(QQmlEngine*, QJSEngine*) { QQmlEngine::setObjectOwnership(instance(), QQmlEngine::CppOwnership); return instance(); @@ -119,6 +124,10 @@ const SizeTokens* Tokens::sizes() const { return global ? global->sizes() : nullptr; } +TokenConfig* Tokens::forScreen(const QString& screen) { + return TokenConfig::forScreen(screen); +} + Tokens* Tokens::qmlAttachedProperties(QObject* object) { return new Tokens(ConfigScope::find(object), object); } diff --git a/plugin/src/Caelestia/Config/tokens.hpp b/plugin/src/Caelestia/Config/tokens.hpp index 462d3f62..2448b737 100644 --- a/plugin/src/Caelestia/Config/tokens.hpp +++ b/plugin/src/Caelestia/Config/tokens.hpp @@ -330,6 +330,7 @@ class TokenConfig : public RootConfig { public: static TokenConfig* instance(); [[nodiscard]] Q_INVOKABLE TokenConfig* defaults(); + [[nodiscard]] Q_INVOKABLE static TokenConfig* forScreen(const QString& screen); static TokenConfig* create(QQmlEngine*, QJSEngine*); private: @@ -369,6 +370,8 @@ public: [[nodiscard]] const AnimTokens* anim() const { return m_anim; } + [[nodiscard]] Q_INVOKABLE static TokenConfig* forScreen(const QString& screen); + static Tokens* qmlAttachedProperties(QObject* object); signals: diff --git a/services/Screens.qml b/services/Screens.qml index 7e1b85df..f902a38d 100644 --- a/services/Screens.qml +++ b/services/Screens.qml @@ -7,14 +7,9 @@ import qs.utils Singleton { id: root - readonly property list screens: { - const excluded = Config.general.excludedScreens; - if (excluded.length === 0) - return Quickshell.screens; - return Quickshell.screens.filter(s => !Strings.testRegexList(excluded, s.name)); - } + readonly property list screens: Quickshell.screens.filter(s => GlobalConfig.forScreen(s.name).enabled) function isExcluded(screen: ShellScreen): bool { - return Strings.testRegexList(Config.general.excludedScreens, screen.name); + return !GlobalConfig.forScreen(screen.name).enabled; } }