mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-28 07:22:50 -05:00
Per light-mode/dark-mode wallpaper option
This commit is contained in:
@@ -18,6 +18,11 @@ Singleton {
|
|||||||
property string profileLastPath: ""
|
property string profileLastPath: ""
|
||||||
property bool perMonitorWallpaper: false
|
property bool perMonitorWallpaper: false
|
||||||
property var monitorWallpapers: ({})
|
property var monitorWallpapers: ({})
|
||||||
|
property bool perModeWallpaper: false
|
||||||
|
property string wallpaperPathLight: ""
|
||||||
|
property string wallpaperPathDark: ""
|
||||||
|
property var monitorWallpapersLight: ({})
|
||||||
|
property var monitorWallpapersDark: ({})
|
||||||
property bool doNotDisturb: false
|
property bool doNotDisturb: false
|
||||||
property bool nightModeEnabled: false
|
property bool nightModeEnabled: false
|
||||||
property int nightModeTemperature: 4500
|
property int nightModeTemperature: 4500
|
||||||
@@ -83,6 +88,11 @@ Singleton {
|
|||||||
profileLastPath = settings.profileLastPath !== undefined ? settings.profileLastPath : ""
|
profileLastPath = settings.profileLastPath !== undefined ? settings.profileLastPath : ""
|
||||||
perMonitorWallpaper = settings.perMonitorWallpaper !== undefined ? settings.perMonitorWallpaper : false
|
perMonitorWallpaper = settings.perMonitorWallpaper !== undefined ? settings.perMonitorWallpaper : false
|
||||||
monitorWallpapers = settings.monitorWallpapers !== undefined ? settings.monitorWallpapers : {}
|
monitorWallpapers = settings.monitorWallpapers !== undefined ? settings.monitorWallpapers : {}
|
||||||
|
perModeWallpaper = settings.perModeWallpaper !== undefined ? settings.perModeWallpaper : false
|
||||||
|
wallpaperPathLight = settings.wallpaperPathLight !== undefined ? settings.wallpaperPathLight : ""
|
||||||
|
wallpaperPathDark = settings.wallpaperPathDark !== undefined ? settings.wallpaperPathDark : ""
|
||||||
|
monitorWallpapersLight = settings.monitorWallpapersLight !== undefined ? settings.monitorWallpapersLight : {}
|
||||||
|
monitorWallpapersDark = settings.monitorWallpapersDark !== undefined ? settings.monitorWallpapersDark : {}
|
||||||
doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false
|
doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false
|
||||||
nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false
|
nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false
|
||||||
nightModeTemperature = settings.nightModeTemperature !== undefined ? settings.nightModeTemperature : 4500
|
nightModeTemperature = settings.nightModeTemperature !== undefined ? settings.nightModeTemperature : 4500
|
||||||
@@ -151,6 +161,11 @@ Singleton {
|
|||||||
"profileLastPath": profileLastPath,
|
"profileLastPath": profileLastPath,
|
||||||
"perMonitorWallpaper": perMonitorWallpaper,
|
"perMonitorWallpaper": perMonitorWallpaper,
|
||||||
"monitorWallpapers": monitorWallpapers,
|
"monitorWallpapers": monitorWallpapers,
|
||||||
|
"perModeWallpaper": perModeWallpaper,
|
||||||
|
"wallpaperPathLight": wallpaperPathLight,
|
||||||
|
"wallpaperPathDark": wallpaperPathDark,
|
||||||
|
"monitorWallpapersLight": monitorWallpapersLight,
|
||||||
|
"monitorWallpapersDark": monitorWallpapersDark,
|
||||||
"doNotDisturb": doNotDisturb,
|
"doNotDisturb": doNotDisturb,
|
||||||
"nightModeEnabled": nightModeEnabled,
|
"nightModeEnabled": nightModeEnabled,
|
||||||
"nightModeTemperature": nightModeTemperature,
|
"nightModeTemperature": nightModeTemperature,
|
||||||
@@ -191,9 +206,21 @@ Singleton {
|
|||||||
|
|
||||||
function setLightMode(lightMode) {
|
function setLightMode(lightMode) {
|
||||||
isLightMode = lightMode
|
isLightMode = lightMode
|
||||||
|
syncWallpaperForCurrentMode()
|
||||||
saveSettings()
|
saveSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function syncWallpaperForCurrentMode() {
|
||||||
|
if (!perModeWallpaper) return
|
||||||
|
|
||||||
|
if (perMonitorWallpaper) {
|
||||||
|
monitorWallpapers = isLightMode ? Object.assign({}, monitorWallpapersLight) : Object.assign({}, monitorWallpapersDark)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
wallpaperPath = isLightMode ? wallpaperPathLight : wallpaperPathDark
|
||||||
|
}
|
||||||
|
|
||||||
function setDoNotDisturb(enabled) {
|
function setDoNotDisturb(enabled) {
|
||||||
doNotDisturb = enabled
|
doNotDisturb = enabled
|
||||||
saveSettings()
|
saveSettings()
|
||||||
@@ -264,6 +291,13 @@ Singleton {
|
|||||||
|
|
||||||
function setWallpaper(imagePath) {
|
function setWallpaper(imagePath) {
|
||||||
wallpaperPath = imagePath
|
wallpaperPath = imagePath
|
||||||
|
if (perModeWallpaper) {
|
||||||
|
if (isLightMode) {
|
||||||
|
wallpaperPathLight = imagePath
|
||||||
|
} else {
|
||||||
|
wallpaperPathDark = imagePath
|
||||||
|
}
|
||||||
|
}
|
||||||
saveSettings()
|
saveSettings()
|
||||||
|
|
||||||
if (typeof Theme !== "undefined") {
|
if (typeof Theme !== "undefined") {
|
||||||
@@ -273,6 +307,13 @@ Singleton {
|
|||||||
|
|
||||||
function setWallpaperColor(color) {
|
function setWallpaperColor(color) {
|
||||||
wallpaperPath = color
|
wallpaperPath = color
|
||||||
|
if (perModeWallpaper) {
|
||||||
|
if (isLightMode) {
|
||||||
|
wallpaperPathLight = color
|
||||||
|
} else {
|
||||||
|
wallpaperPathDark = color
|
||||||
|
}
|
||||||
|
}
|
||||||
saveSettings()
|
saveSettings()
|
||||||
|
|
||||||
if (typeof Theme !== "undefined") {
|
if (typeof Theme !== "undefined") {
|
||||||
@@ -420,9 +461,51 @@ Singleton {
|
|||||||
|
|
||||||
function setPerMonitorWallpaper(enabled) {
|
function setPerMonitorWallpaper(enabled) {
|
||||||
perMonitorWallpaper = enabled
|
perMonitorWallpaper = enabled
|
||||||
|
if (enabled && perModeWallpaper) {
|
||||||
|
syncWallpaperForCurrentMode()
|
||||||
|
}
|
||||||
|
saveSettings()
|
||||||
|
|
||||||
|
if (typeof Theme !== "undefined") {
|
||||||
|
Theme.generateSystemThemesFromCurrentTheme()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPerModeWallpaper(enabled) {
|
||||||
|
if (enabled && wallpaperCyclingEnabled) {
|
||||||
|
setWallpaperCyclingEnabled(false)
|
||||||
|
}
|
||||||
|
if (enabled && perMonitorWallpaper) {
|
||||||
|
var monitorCyclingAny = false
|
||||||
|
for (var key in monitorCyclingSettings) {
|
||||||
|
if (monitorCyclingSettings[key].enabled) {
|
||||||
|
monitorCyclingAny = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (monitorCyclingAny) {
|
||||||
|
var newSettings = Object.assign({}, monitorCyclingSettings)
|
||||||
|
for (var screenName in newSettings) {
|
||||||
|
newSettings[screenName].enabled = false
|
||||||
|
}
|
||||||
|
monitorCyclingSettings = newSettings
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
perModeWallpaper = enabled
|
||||||
|
if (enabled) {
|
||||||
|
if (perMonitorWallpaper) {
|
||||||
|
monitorWallpapersLight = Object.assign({}, monitorWallpapers)
|
||||||
|
monitorWallpapersDark = Object.assign({}, monitorWallpapers)
|
||||||
|
} else {
|
||||||
|
wallpaperPathLight = wallpaperPath
|
||||||
|
wallpaperPathDark = wallpaperPath
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
syncWallpaperForCurrentMode()
|
||||||
|
}
|
||||||
saveSettings()
|
saveSettings()
|
||||||
|
|
||||||
// Refresh dynamic theming when per-monitor mode changes
|
|
||||||
if (typeof Theme !== "undefined") {
|
if (typeof Theme !== "undefined") {
|
||||||
Theme.generateSystemThemesFromCurrentTheme()
|
Theme.generateSystemThemesFromCurrentTheme()
|
||||||
}
|
}
|
||||||
@@ -436,9 +519,29 @@ Singleton {
|
|||||||
delete newMonitorWallpapers[screenName]
|
delete newMonitorWallpapers[screenName]
|
||||||
}
|
}
|
||||||
monitorWallpapers = newMonitorWallpapers
|
monitorWallpapers = newMonitorWallpapers
|
||||||
|
|
||||||
|
if (perModeWallpaper) {
|
||||||
|
if (isLightMode) {
|
||||||
|
var newLight = Object.assign({}, monitorWallpapersLight)
|
||||||
|
if (path && path !== "") {
|
||||||
|
newLight[screenName] = path
|
||||||
|
} else {
|
||||||
|
delete newLight[screenName]
|
||||||
|
}
|
||||||
|
monitorWallpapersLight = newLight
|
||||||
|
} else {
|
||||||
|
var newDark = Object.assign({}, monitorWallpapersDark)
|
||||||
|
if (path && path !== "") {
|
||||||
|
newDark[screenName] = path
|
||||||
|
} else {
|
||||||
|
delete newDark[screenName]
|
||||||
|
}
|
||||||
|
monitorWallpapersDark = newDark
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
saveSettings()
|
saveSettings()
|
||||||
|
|
||||||
// Trigger dynamic theming if this is the first monitor and dynamic theming is enabled
|
|
||||||
if (typeof Theme !== "undefined" && typeof Quickshell !== "undefined") {
|
if (typeof Theme !== "undefined" && typeof Quickshell !== "undefined") {
|
||||||
var screens = Quickshell.screens
|
var screens = Quickshell.screens
|
||||||
if (screens.length > 0 && screenName === screens[0].name) {
|
if (screens.length > 0 && screenName === screens[0].name) {
|
||||||
|
|||||||
@@ -391,6 +391,63 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Per-Mode Wallpaper Section - Full Width
|
||||||
|
Rectangle {
|
||||||
|
width: parent.width
|
||||||
|
height: 1
|
||||||
|
color: Theme.outline
|
||||||
|
opacity: 0.2
|
||||||
|
visible: SessionData.wallpaperPath !== ""
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
width: parent.width
|
||||||
|
spacing: Theme.spacingM
|
||||||
|
visible: SessionData.wallpaperPath !== ""
|
||||||
|
|
||||||
|
Row {
|
||||||
|
width: parent.width
|
||||||
|
spacing: Theme.spacingM
|
||||||
|
|
||||||
|
DankIcon {
|
||||||
|
name: "brightness_6"
|
||||||
|
size: Theme.iconSize
|
||||||
|
color: SessionData.perModeWallpaper ? Theme.primary : Theme.surfaceVariantText
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
width: parent.width - Theme.iconSize - Theme.spacingM - perModeToggle.width - Theme.spacingM
|
||||||
|
spacing: Theme.spacingXS
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: "Per-Mode Wallpapers"
|
||||||
|
font.pixelSize: Theme.fontSizeLarge
|
||||||
|
font.weight: Font.Medium
|
||||||
|
color: Theme.surfaceText
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: "Set different wallpapers for light and dark mode"
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
color: Theme.surfaceVariantText
|
||||||
|
width: parent.width
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DankToggle {
|
||||||
|
id: perModeToggle
|
||||||
|
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
checked: SessionData.perModeWallpaper
|
||||||
|
onToggled: toggled => {
|
||||||
|
return SessionData.setPerModeWallpaper(toggled)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Per-Monitor Wallpaper Section - Full Width
|
// Per-Monitor Wallpaper Section - Full Width
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@@ -482,19 +539,18 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wallpaper Cycling Section - Full Width
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 1
|
height: 1
|
||||||
color: Theme.outline
|
color: Theme.outline
|
||||||
opacity: 0.2
|
opacity: 0.2
|
||||||
visible: SessionData.wallpaperPath !== "" || SessionData.perMonitorWallpaper
|
visible: (SessionData.wallpaperPath !== "" || SessionData.perMonitorWallpaper) && !SessionData.perModeWallpaper
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: Theme.spacingM
|
spacing: Theme.spacingM
|
||||||
visible: SessionData.wallpaperPath !== "" || SessionData.perMonitorWallpaper
|
visible: (SessionData.wallpaperPath !== "" || SessionData.perMonitorWallpaper) && !SessionData.perModeWallpaper
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@@ -551,7 +607,6 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cycling mode and settings
|
|
||||||
Column {
|
Column {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: Theme.spacingS
|
spacing: Theme.spacingS
|
||||||
|
|||||||
@@ -38,6 +38,18 @@ LazyLoader {
|
|||||||
property bool isColorSource: source.startsWith("#")
|
property bool isColorSource: source.startsWith("#")
|
||||||
property string transitionType: SessionData.wallpaperTransition
|
property string transitionType: SessionData.wallpaperTransition
|
||||||
property string actualTransitionType: transitionType
|
property string actualTransitionType: transitionType
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: SessionData
|
||||||
|
function onIsLightModeChanged() {
|
||||||
|
if (SessionData.perModeWallpaper) {
|
||||||
|
var newSource = SessionData.getMonitorWallpaper(modelData.name) || ""
|
||||||
|
if (newSource !== root.source) {
|
||||||
|
root.source = newSource
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
onTransitionTypeChanged: {
|
onTransitionTypeChanged: {
|
||||||
if (transitionType === "random") {
|
if (transitionType === "random") {
|
||||||
if (SessionData.includedTransitions.length === 0) {
|
if (SessionData.includedTransitions.length === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user