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 var matugenColors: ({})
|
||||
property bool extractionRequested: false
|
||||
property int colorUpdateTrigger: 0 // Force property re-evaluation
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("Colors.qml → home =", homeDir)
|
||||
// Don't automatically run color extraction - only when requested
|
||||
matugenCheck.running = true // Just check if matugen is available
|
||||
|
||||
// Start monitoring for wallpaper changes
|
||||
wallpaperMonitorTimer.start()
|
||||
// Connect to Theme light mode changes to update colors
|
||||
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 ──────────────── */
|
||||
@@ -113,7 +125,12 @@ Singleton {
|
||||
}
|
||||
|
||||
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(".")) {
|
||||
if (!cur || typeof cur !== "object" || !(part in cur))
|
||||
return fallback
|
||||
|
||||
@@ -211,15 +211,9 @@ Singleton {
|
||||
|
||||
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) {
|
||||
root.lastError = "Failed to parse events JSON: " + error.toString()
|
||||
console.error("CalendarService:", root.lastError)
|
||||
console.error("CalendarService: Raw output was:", eventsProcess.rawOutput)
|
||||
root.eventsByDate = {}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ ScrollView {
|
||||
// Night mode toggle
|
||||
Rectangle {
|
||||
width: (parent.width - Theme.spacingM) / 2
|
||||
height: 50
|
||||
height: 80
|
||||
radius: Theme.cornerRadius
|
||||
color: Prefs.nightModeEnabled ?
|
||||
Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) :
|
||||
@@ -72,19 +72,19 @@ ScrollView {
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingXS
|
||||
spacing: Theme.spacingS
|
||||
|
||||
Text {
|
||||
text: Prefs.nightModeEnabled ? "nightlight" : "dark_mode"
|
||||
font.family: Theme.iconFont
|
||||
font.pixelSize: Theme.iconSize
|
||||
font.pixelSize: Theme.iconSizeLarge
|
||||
color: Prefs.nightModeEnabled ? Theme.primary : Theme.surfaceText
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "Night Mode"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Prefs.nightModeEnabled ? Theme.primary : Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
@@ -114,7 +114,7 @@ ScrollView {
|
||||
// Light/Dark mode toggle
|
||||
Rectangle {
|
||||
width: (parent.width - Theme.spacingM) / 2
|
||||
height: 50
|
||||
height: 80
|
||||
radius: Theme.cornerRadius
|
||||
color: Theme.isLightMode ?
|
||||
Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) :
|
||||
@@ -124,19 +124,19 @@ ScrollView {
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingXS
|
||||
spacing: Theme.spacingS
|
||||
|
||||
Text {
|
||||
text: Theme.isLightMode ? "light_mode" : "palette"
|
||||
font.family: Theme.iconFont
|
||||
font.pixelSize: Theme.iconSize
|
||||
font.pixelSize: Theme.iconSizeLarge
|
||||
color: Theme.isLightMode ? Theme.primary : Theme.surfaceText
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
Text {
|
||||
text: Theme.isLightMode ? "Light Mode" : "Dark Mode"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.isLightMode ? Theme.primary : Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
Reference in New Issue
Block a user