diff --git a/Common/SettingsData.qml b/Common/SettingsData.qml index 7559f557..b553460d 100644 --- a/Common/SettingsData.qml +++ b/Common/SettingsData.qml @@ -187,6 +187,7 @@ Singleton { property bool gtkThemingEnabled: false property bool qtThemingEnabled: false + property bool syncModeWithPortal: true property bool showDock: false property bool dockAutoHide: false @@ -428,6 +429,7 @@ Singleton { soundPluggedIn = settings.soundPluggedIn !== undefined ? settings.soundPluggedIn : true gtkThemingEnabled = settings.gtkThemingEnabled !== undefined ? settings.gtkThemingEnabled : false qtThemingEnabled = settings.qtThemingEnabled !== undefined ? settings.qtThemingEnabled : false + syncModeWithPortal = settings.syncModeWithPortal !== undefined ? settings.syncModeWithPortal : true showDock = settings.showDock !== undefined ? settings.showDock : false dockAutoHide = settings.dockAutoHide !== undefined ? settings.dockAutoHide : false dockGroupByApp = settings.dockGroupByApp !== undefined ? settings.dockGroupByApp : false @@ -600,6 +602,7 @@ Singleton { "soundPluggedIn": soundPluggedIn, "gtkThemingEnabled": gtkThemingEnabled, "qtThemingEnabled": qtThemingEnabled, + "syncModeWithPortal": syncModeWithPortal, "showDock": showDock, "dockAutoHide": dockAutoHide, "dockGroupByApp": dockGroupByApp, @@ -696,7 +699,7 @@ Singleton { "notepadFontFamily", "notepadFontSize", "notepadShowLineNumbers", "notepadTransparencyOverride", "notepadLastCustomTransparency", "soundsEnabled", "useSystemSoundTheme", "soundNewNotification", "soundVolumeChanged", "soundPluggedIn", "gtkThemingEnabled", - "qtThemingEnabled", "showDock", "dockAutoHide", "dockGroupByApp", + "qtThemingEnabled", "syncModeWithPortal", "showDock", "dockAutoHide", "dockGroupByApp", "dockOpenOnOverview", "dockPosition", "dockSpacing", "dockBottomGap", "cornerRadius", "notificationOverlayEnabled", "dankBarAutoHide", "dankBarOpenOnOverview", "dankBarVisible", "dankBarSpacing", "dankBarBottomGap", @@ -1474,6 +1477,11 @@ Singleton { } } + function setSyncModeWithPortal(enabled) { + syncModeWithPortal = enabled + saveSettings() + } + function setShowDock(enabled) { showDock = enabled if (enabled && dockPosition === dankBarPosition) { diff --git a/Common/Theme.qml b/Common/Theme.qml index cab225a8..fc5d444d 100644 --- a/Common/Theme.qml +++ b/Common/Theme.qml @@ -381,11 +381,10 @@ Singleton { } const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode) - isLightMode = light if (savePrefs && typeof SessionData !== "undefined" && !isGreeterMode) - SessionData.setLightMode(isLightMode) + SessionData.setLightMode(light) if (!isGreeterMode) { - PortalService.setLightMode(isLightMode) + PortalService.setLightMode(light) generateSystemThemesFromCurrentTheme() } } diff --git a/Modules/ControlCenter/Components/DragDropGrid.qml b/Modules/ControlCenter/Components/DragDropGrid.qml index 884a27cc..ef0e7761 100644 --- a/Modules/ControlCenter/Components/DragDropGrid.qml +++ b/Modules/ControlCenter/Components/DragDropGrid.qml @@ -620,8 +620,9 @@ Column { } case "darkMode": { + const newMode = !SessionData.isLightMode Theme.screenTransition() - Theme.setLightMode(!SessionData.isLightMode) + Theme.setLightMode(newMode) break } case "doNotDisturb": @@ -700,8 +701,9 @@ Column { } case "darkMode": { + const newMode = !SessionData.isLightMode Theme.screenTransition() - Theme.setLightMode(!SessionData.isLightMode) + Theme.setLightMode(newMode) break } case "doNotDisturb": diff --git a/Modules/Settings/ThemeColorsTab.qml b/Modules/Settings/ThemeColorsTab.qml index 67ba2160..5d9f9eda 100644 --- a/Modules/Settings/ThemeColorsTab.qml +++ b/Modules/Settings/ThemeColorsTab.qml @@ -1136,6 +1136,62 @@ Item { } } + StyledRect { + width: parent.width + height: portalSyncSection.implicitHeight + Theme.spacingL * 2 + radius: Theme.cornerRadius + color: Theme.surfaceContainerHigh + border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, + Theme.outline.b, 0.2) + border.width: 0 + + Row { + id: portalSyncSection + + anchors.fill: parent + anchors.margins: Theme.spacingL + spacing: Theme.spacingM + + DankIcon { + name: "sync" + size: Theme.iconSize + color: Theme.primary + anchors.verticalCenter: parent.verticalCenter + } + + Column { + width: parent.width - Theme.iconSize - Theme.spacingM - syncToggle.width - Theme.spacingM + spacing: Theme.spacingXS + anchors.verticalCenter: parent.verticalCenter + + StyledText { + text: I18n.tr("Sync Mode with Portal") + font.pixelSize: Theme.fontSizeLarge + font.weight: Font.Medium + color: Theme.surfaceText + } + + StyledText { + text: I18n.tr("Sync dark mode with settings portals for system-wide theme hints") + font.pixelSize: Theme.fontSizeSmall + color: Theme.surfaceVariantText + wrapMode: Text.WordWrap + width: parent.width + } + } + + DankToggle { + id: syncToggle + + width: 48 + height: 32 + checked: SettingsData.syncModeWithPortal + anchors.verticalCenter: parent.verticalCenter + onToggled: checked => SettingsData.setSyncModeWithPortal(checked) + } + } + } + // System Configuration Warning Rectangle { width: parent.width diff --git a/Services/PortalService.qml b/Services/PortalService.qml index 9bd16afa..4e40edba 100644 --- a/Services/PortalService.qml +++ b/Services/PortalService.qml @@ -5,6 +5,7 @@ pragma ComponentBehavior: Bound import QtQuick import Quickshell import Quickshell.Io +import qs.Common Singleton { id: root @@ -81,39 +82,34 @@ Singleton { } function getSystemColorScheme() { + if (typeof SettingsData !== "undefined" && SettingsData.syncModeWithPortal === false) { + return + } if (!freedeskAvailable) return DMSService.sendRequest("freedesktop.settings.getColorScheme", null, response => { if (response.result) { systemColorScheme = response.result.value || 0 - - if (typeof Theme !== "undefined") { - const shouldBeLightMode = (systemColorScheme === 2) - if (Theme.isLightMode !== shouldBeLightMode) { - Theme.isLightMode = shouldBeLightMode - if (typeof SessionData !== "undefined") { - SessionData.setLightMode(shouldBeLightMode) - } - } - } } }) } function setLightMode(isLightMode) { + if (typeof SettingsData !== "undefined" && SettingsData.syncModeWithPortal === false) { + return + } if (settingsPortalAvailable) { setSystemColorScheme(isLightMode) } } function setSystemColorScheme(isLightMode) { + if (typeof SettingsData !== "undefined" && SettingsData.syncModeWithPortal === false) { + return + } if (!settingsPortalAvailable || !freedeskAvailable) return - DMSService.sendRequest("freedesktop.settings.setColorScheme", { preferDark: !isLightMode }, response => { - if (!response.error) { - Qt.callLater(() => getSystemColorScheme()) - } - }) + DMSService.sendRequest("freedesktop.settings.setColorScheme", { preferDark: !isLightMode }, response => {}) } function setSystemIconTheme(themeName) { @@ -202,7 +198,7 @@ Singleton { DMSService.sendRequest("freedesktop.getState", null, response => { if (response.result && response.result.settings) { settingsPortalAvailable = response.result.settings.available || false - if (settingsPortalAvailable) { + if (settingsPortalAvailable && SettingsData.syncModeWithPortal) { getSystemColorScheme() } }