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:
@@ -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) {
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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":
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user