1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 05:25:41 -05:00

theme: make portal prefer-dark sync optional

This commit is contained in:
bbedward
2025-10-16 00:16:34 -04:00
parent b277bd8014
commit cd18fd5aed
5 changed files with 83 additions and 22 deletions

View File

@@ -187,6 +187,7 @@ Singleton {
property bool gtkThemingEnabled: false property bool gtkThemingEnabled: false
property bool qtThemingEnabled: false property bool qtThemingEnabled: false
property bool syncModeWithPortal: true
property bool showDock: false property bool showDock: false
property bool dockAutoHide: false property bool dockAutoHide: false
@@ -428,6 +429,7 @@ Singleton {
soundPluggedIn = settings.soundPluggedIn !== undefined ? settings.soundPluggedIn : true soundPluggedIn = settings.soundPluggedIn !== undefined ? settings.soundPluggedIn : true
gtkThemingEnabled = settings.gtkThemingEnabled !== undefined ? settings.gtkThemingEnabled : false gtkThemingEnabled = settings.gtkThemingEnabled !== undefined ? settings.gtkThemingEnabled : false
qtThemingEnabled = settings.qtThemingEnabled !== undefined ? settings.qtThemingEnabled : false qtThemingEnabled = settings.qtThemingEnabled !== undefined ? settings.qtThemingEnabled : false
syncModeWithPortal = settings.syncModeWithPortal !== undefined ? settings.syncModeWithPortal : true
showDock = settings.showDock !== undefined ? settings.showDock : false showDock = settings.showDock !== undefined ? settings.showDock : false
dockAutoHide = settings.dockAutoHide !== undefined ? settings.dockAutoHide : false dockAutoHide = settings.dockAutoHide !== undefined ? settings.dockAutoHide : false
dockGroupByApp = settings.dockGroupByApp !== undefined ? settings.dockGroupByApp : false dockGroupByApp = settings.dockGroupByApp !== undefined ? settings.dockGroupByApp : false
@@ -600,6 +602,7 @@ Singleton {
"soundPluggedIn": soundPluggedIn, "soundPluggedIn": soundPluggedIn,
"gtkThemingEnabled": gtkThemingEnabled, "gtkThemingEnabled": gtkThemingEnabled,
"qtThemingEnabled": qtThemingEnabled, "qtThemingEnabled": qtThemingEnabled,
"syncModeWithPortal": syncModeWithPortal,
"showDock": showDock, "showDock": showDock,
"dockAutoHide": dockAutoHide, "dockAutoHide": dockAutoHide,
"dockGroupByApp": dockGroupByApp, "dockGroupByApp": dockGroupByApp,
@@ -696,7 +699,7 @@ Singleton {
"notepadFontFamily", "notepadFontSize", "notepadShowLineNumbers", "notepadFontFamily", "notepadFontSize", "notepadShowLineNumbers",
"notepadTransparencyOverride", "notepadLastCustomTransparency", "soundsEnabled", "notepadTransparencyOverride", "notepadLastCustomTransparency", "soundsEnabled",
"useSystemSoundTheme", "soundNewNotification", "soundVolumeChanged", "soundPluggedIn", "gtkThemingEnabled", "useSystemSoundTheme", "soundNewNotification", "soundVolumeChanged", "soundPluggedIn", "gtkThemingEnabled",
"qtThemingEnabled", "showDock", "dockAutoHide", "dockGroupByApp", "qtThemingEnabled", "syncModeWithPortal", "showDock", "dockAutoHide", "dockGroupByApp",
"dockOpenOnOverview", "dockPosition", "dockSpacing", "dockBottomGap", "dockOpenOnOverview", "dockPosition", "dockSpacing", "dockBottomGap",
"cornerRadius", "notificationOverlayEnabled", "dankBarAutoHide", "cornerRadius", "notificationOverlayEnabled", "dankBarAutoHide",
"dankBarOpenOnOverview", "dankBarVisible", "dankBarSpacing", "dankBarBottomGap", "dankBarOpenOnOverview", "dankBarVisible", "dankBarSpacing", "dankBarBottomGap",
@@ -1474,6 +1477,11 @@ Singleton {
} }
} }
function setSyncModeWithPortal(enabled) {
syncModeWithPortal = enabled
saveSettings()
}
function setShowDock(enabled) { function setShowDock(enabled) {
showDock = enabled showDock = enabled
if (enabled && dockPosition === dankBarPosition) { if (enabled && dockPosition === dankBarPosition) {

View File

@@ -381,11 +381,10 @@ Singleton {
} }
const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode) const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode)
isLightMode = light
if (savePrefs && typeof SessionData !== "undefined" && !isGreeterMode) if (savePrefs && typeof SessionData !== "undefined" && !isGreeterMode)
SessionData.setLightMode(isLightMode) SessionData.setLightMode(light)
if (!isGreeterMode) { if (!isGreeterMode) {
PortalService.setLightMode(isLightMode) PortalService.setLightMode(light)
generateSystemThemesFromCurrentTheme() generateSystemThemesFromCurrentTheme()
} }
} }

View File

@@ -620,8 +620,9 @@ Column {
} }
case "darkMode": case "darkMode":
{ {
const newMode = !SessionData.isLightMode
Theme.screenTransition() Theme.screenTransition()
Theme.setLightMode(!SessionData.isLightMode) Theme.setLightMode(newMode)
break break
} }
case "doNotDisturb": case "doNotDisturb":
@@ -700,8 +701,9 @@ Column {
} }
case "darkMode": case "darkMode":
{ {
const newMode = !SessionData.isLightMode
Theme.screenTransition() Theme.screenTransition()
Theme.setLightMode(!SessionData.isLightMode) Theme.setLightMode(newMode)
break break
} }
case "doNotDisturb": case "doNotDisturb":

View File

@@ -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 // System Configuration Warning
Rectangle { Rectangle {
width: parent.width width: parent.width

View File

@@ -5,6 +5,7 @@ pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import Quickshell import Quickshell
import Quickshell.Io import Quickshell.Io
import qs.Common
Singleton { Singleton {
id: root id: root
@@ -81,39 +82,34 @@ Singleton {
} }
function getSystemColorScheme() { function getSystemColorScheme() {
if (typeof SettingsData !== "undefined" && SettingsData.syncModeWithPortal === false) {
return
}
if (!freedeskAvailable) return if (!freedeskAvailable) return
DMSService.sendRequest("freedesktop.settings.getColorScheme", null, response => { DMSService.sendRequest("freedesktop.settings.getColorScheme", null, response => {
if (response.result) { if (response.result) {
systemColorScheme = response.result.value || 0 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) { function setLightMode(isLightMode) {
if (typeof SettingsData !== "undefined" && SettingsData.syncModeWithPortal === false) {
return
}
if (settingsPortalAvailable) { if (settingsPortalAvailable) {
setSystemColorScheme(isLightMode) setSystemColorScheme(isLightMode)
} }
} }
function setSystemColorScheme(isLightMode) { function setSystemColorScheme(isLightMode) {
if (typeof SettingsData !== "undefined" && SettingsData.syncModeWithPortal === false) {
return
}
if (!settingsPortalAvailable || !freedeskAvailable) return if (!settingsPortalAvailable || !freedeskAvailable) return
DMSService.sendRequest("freedesktop.settings.setColorScheme", { preferDark: !isLightMode }, response => { DMSService.sendRequest("freedesktop.settings.setColorScheme", { preferDark: !isLightMode }, response => {})
if (!response.error) {
Qt.callLater(() => getSystemColorScheme())
}
})
} }
function setSystemIconTheme(themeName) { function setSystemIconTheme(themeName) {
@@ -202,7 +198,7 @@ Singleton {
DMSService.sendRequest("freedesktop.getState", null, response => { DMSService.sendRequest("freedesktop.getState", null, response => {
if (response.result && response.result.settings) { if (response.result && response.result.settings) {
settingsPortalAvailable = response.result.settings.available || false settingsPortalAvailable = response.result.settings.available || false
if (settingsPortalAvailable) { if (settingsPortalAvailable && SettingsData.syncModeWithPortal) {
getSystemColorScheme() getSystemColorScheme()
} }
} }