diff --git a/Modules/SettingsPanel/Tabs/ColorSchemeTab.qml b/Modules/SettingsPanel/Tabs/ColorSchemeTab.qml index de5ba2c..5708d01 100644 --- a/Modules/SettingsPanel/Tabs/ColorSchemeTab.qml +++ b/Modules/SettingsPanel/Tabs/ColorSchemeTab.qml @@ -187,7 +187,8 @@ ColumnLayout { color: getSchemeColor(modelData, "mSurface") border.width: Math.max(1, Style.borderL * scaling) border.color: (!Settings.data.colorSchemes.useWallpaperColors - && (Settings.data.colorSchemes.predefinedScheme === modelData)) ? Color.mPrimary : Color.mOutline + && (Settings.data.colorSchemes.predefinedScheme === modelData.split("/").pop().replace( + ".json", ""))) ? Color.mPrimary : Color.mOutline scale: root.cardScaleLow // Mouse area for selection @@ -198,8 +199,8 @@ ColumnLayout { Settings.data.colorSchemes.useWallpaperColors = false Logger.log("ColorSchemeTab", "Disabled matugen setting") - Settings.data.colorSchemes.predefinedScheme = schemePath - ColorSchemeService.applyScheme(schemePath) + Settings.data.colorSchemes.predefinedScheme = schemePath.split("/").pop().replace(".json", "") + ColorSchemeService.applyScheme(Settings.data.colorSchemes.predefinedScheme) } hoverEnabled: true cursorShape: Qt.PointingHandCursor @@ -281,7 +282,8 @@ ColumnLayout { // Selection indicator (Checkmark) Rectangle { visible: !Settings.data.colorSchemes.useWallpaperColors - && (Settings.data.colorSchemes.predefinedScheme === schemePath) + && (Settings.data.colorSchemes.predefinedScheme === schemePath.split("/").pop().replace(".json", + "")) anchors.right: parent.right anchors.top: parent.top anchors.margins: Style.marginS * scaling diff --git a/Services/ColorSchemeService.qml b/Services/ColorSchemeService.qml index ade585f..aed0228 100644 --- a/Services/ColorSchemeService.qml +++ b/Services/ColorSchemeService.qml @@ -48,8 +48,26 @@ Singleton { folderModel.folder = "file://" + schemesDirectory } - function applyScheme(filePath) { + function getBasename(path) { + if (!path) + return "" + var chunks = path.split("/") + var last = chunks[chunks.length - 1] + return last.endsWith(".json") ? last.slice(0, -5) : last + } + + function resolveSchemePath(nameOrPath) { + if (!nameOrPath) + return "" + if (nameOrPath.indexOf("/") !== -1) { + return nameOrPath + } + return schemesDirectory + "/" + nameOrPath.replace(".json", "") + ".json" + } + + function applyScheme(nameOrPath) { // Force reload by bouncing the path + var filePath = resolveSchemePath(nameOrPath) schemeReader.path = "" schemeReader.path = filePath } @@ -69,6 +87,17 @@ Singleton { schemes = files scanning = false Logger.log("ColorScheme", "Listed", schemes.length, "schemes") + // Normalize stored scheme to basename and re-apply if necessary + var stored = Settings.data.colorSchemes.predefinedScheme + if (stored) { + var basename = getBasename(stored) + if (basename !== stored) { + Settings.data.colorSchemes.predefinedScheme = basename + } + if (!Settings.data.colorSchemes.useWallpaperColors) { + applyScheme(basename) + } + } } } }