mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-07 14:05:38 -05:00
Fix light mode toggle for matugen themes
This commit is contained in:
@@ -21,14 +21,26 @@ Singleton {
|
|||||||
property string matugenJson: ""
|
property string matugenJson: ""
|
||||||
property var matugenColors: ({})
|
property var matugenColors: ({})
|
||||||
property bool extractionRequested: false
|
property bool extractionRequested: false
|
||||||
|
property int colorUpdateTrigger: 0 // Force property re-evaluation
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
console.log("Colors.qml → home =", homeDir)
|
console.log("Colors.qml → home =", homeDir)
|
||||||
// Don't automatically run color extraction - only when requested
|
// Don't automatically run color extraction - only when requested
|
||||||
matugenCheck.running = true // Just check if matugen is available
|
matugenCheck.running = true // Just check if matugen is available
|
||||||
|
|
||||||
// Start monitoring for wallpaper changes
|
// Connect to Theme light mode changes to update colors
|
||||||
wallpaperMonitorTimer.start()
|
if (typeof Theme !== "undefined") {
|
||||||
|
Theme.isLightModeChanged.connect(root.onLightModeChanged)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onLightModeChanged() {
|
||||||
|
// Force color properties to update when light mode changes
|
||||||
|
if (matugenColors && Object.keys(matugenColors).length > 0) {
|
||||||
|
console.log("Light mode changed - updating dynamic colors")
|
||||||
|
colorUpdateTrigger++ // This will trigger re-evaluation of all color properties
|
||||||
|
colorsUpdated()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ──────────────── availability checks ──────────────── */
|
/* ──────────────── availability checks ──────────────── */
|
||||||
@@ -113,7 +125,12 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getMatugenColor(path, fallback) {
|
function getMatugenColor(path, fallback) {
|
||||||
let cur = matugenColors?.colors?.dark
|
// Include colorUpdateTrigger in the function to make properties reactive to changes
|
||||||
|
colorUpdateTrigger // This dependency forces re-evaluation when colorUpdateTrigger changes
|
||||||
|
|
||||||
|
// Use light or dark colors based on Theme.isLightMode
|
||||||
|
const colorMode = (typeof Theme !== "undefined" && Theme.isLightMode) ? "light" : "dark"
|
||||||
|
let cur = matugenColors?.colors?.[colorMode]
|
||||||
for (const part of path.split(".")) {
|
for (const part of path.split(".")) {
|
||||||
if (!cur || typeof cur !== "object" || !(part in cur))
|
if (!cur || typeof cur !== "object" || !(part in cur))
|
||||||
return fallback
|
return fallback
|
||||||
|
|||||||
@@ -211,15 +211,9 @@ Singleton {
|
|||||||
|
|
||||||
console.log("CalendarService: Loaded events for", Object.keys(newEventsByDate).length, "days")
|
console.log("CalendarService: Loaded events for", Object.keys(newEventsByDate).length, "days")
|
||||||
|
|
||||||
// Debug: log parsed events
|
|
||||||
for (let dateKey in newEventsByDate) {
|
|
||||||
console.log(" " + dateKey + ":", newEventsByDate[dateKey].map(e => e.title).join(", "))
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
root.lastError = "Failed to parse events JSON: " + error.toString()
|
root.lastError = "Failed to parse events JSON: " + error.toString()
|
||||||
console.error("CalendarService:", root.lastError)
|
console.error("CalendarService:", root.lastError)
|
||||||
console.error("CalendarService: Raw output was:", eventsProcess.rawOutput)
|
|
||||||
root.eventsByDate = {}
|
root.eventsByDate = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ ScrollView {
|
|||||||
// Night mode toggle
|
// Night mode toggle
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: (parent.width - Theme.spacingM) / 2
|
width: (parent.width - Theme.spacingM) / 2
|
||||||
height: 50
|
height: 80
|
||||||
radius: Theme.cornerRadius
|
radius: Theme.cornerRadius
|
||||||
color: Prefs.nightModeEnabled ?
|
color: Prefs.nightModeEnabled ?
|
||||||
Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) :
|
Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) :
|
||||||
@@ -72,19 +72,19 @@ ScrollView {
|
|||||||
|
|
||||||
Column {
|
Column {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
spacing: Theme.spacingXS
|
spacing: Theme.spacingS
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: Prefs.nightModeEnabled ? "nightlight" : "dark_mode"
|
text: Prefs.nightModeEnabled ? "nightlight" : "dark_mode"
|
||||||
font.family: Theme.iconFont
|
font.family: Theme.iconFont
|
||||||
font.pixelSize: Theme.iconSize
|
font.pixelSize: Theme.iconSizeLarge
|
||||||
color: Prefs.nightModeEnabled ? Theme.primary : Theme.surfaceText
|
color: Prefs.nightModeEnabled ? Theme.primary : Theme.surfaceText
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: "Night Mode"
|
text: "Night Mode"
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
color: Prefs.nightModeEnabled ? Theme.primary : Theme.surfaceText
|
color: Prefs.nightModeEnabled ? Theme.primary : Theme.surfaceText
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
@@ -114,7 +114,7 @@ ScrollView {
|
|||||||
// Light/Dark mode toggle
|
// Light/Dark mode toggle
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: (parent.width - Theme.spacingM) / 2
|
width: (parent.width - Theme.spacingM) / 2
|
||||||
height: 50
|
height: 80
|
||||||
radius: Theme.cornerRadius
|
radius: Theme.cornerRadius
|
||||||
color: Theme.isLightMode ?
|
color: Theme.isLightMode ?
|
||||||
Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) :
|
Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) :
|
||||||
@@ -124,19 +124,19 @@ ScrollView {
|
|||||||
|
|
||||||
Column {
|
Column {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
spacing: Theme.spacingXS
|
spacing: Theme.spacingS
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: Theme.isLightMode ? "light_mode" : "palette"
|
text: Theme.isLightMode ? "light_mode" : "palette"
|
||||||
font.family: Theme.iconFont
|
font.family: Theme.iconFont
|
||||||
font.pixelSize: Theme.iconSize
|
font.pixelSize: Theme.iconSizeLarge
|
||||||
color: Theme.isLightMode ? Theme.primary : Theme.surfaceText
|
color: Theme.isLightMode ? Theme.primary : Theme.surfaceText
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: Theme.isLightMode ? "Light Mode" : "Dark Mode"
|
text: Theme.isLightMode ? "Light Mode" : "Dark Mode"
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
color: Theme.isLightMode ? Theme.primary : Theme.surfaceText
|
color: Theme.isLightMode ? Theme.primary : Theme.surfaceText
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|||||||
Reference in New Issue
Block a user