ColorScheme: possible fix for selecting colorscheme & dark mode toggle
This commit is contained in:
parent
d91a635781
commit
3b50efc7d0
2 changed files with 36 additions and 5 deletions
|
|
@ -187,7 +187,8 @@ ColumnLayout {
|
||||||
color: getSchemeColor(modelData, "mSurface")
|
color: getSchemeColor(modelData, "mSurface")
|
||||||
border.width: Math.max(1, Style.borderL * scaling)
|
border.width: Math.max(1, Style.borderL * scaling)
|
||||||
border.color: (!Settings.data.colorSchemes.useWallpaperColors
|
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
|
scale: root.cardScaleLow
|
||||||
|
|
||||||
// Mouse area for selection
|
// Mouse area for selection
|
||||||
|
|
@ -198,8 +199,8 @@ ColumnLayout {
|
||||||
Settings.data.colorSchemes.useWallpaperColors = false
|
Settings.data.colorSchemes.useWallpaperColors = false
|
||||||
Logger.log("ColorSchemeTab", "Disabled matugen setting")
|
Logger.log("ColorSchemeTab", "Disabled matugen setting")
|
||||||
|
|
||||||
Settings.data.colorSchemes.predefinedScheme = schemePath
|
Settings.data.colorSchemes.predefinedScheme = schemePath.split("/").pop().replace(".json", "")
|
||||||
ColorSchemeService.applyScheme(schemePath)
|
ColorSchemeService.applyScheme(Settings.data.colorSchemes.predefinedScheme)
|
||||||
}
|
}
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
@ -281,7 +282,8 @@ ColumnLayout {
|
||||||
// Selection indicator (Checkmark)
|
// Selection indicator (Checkmark)
|
||||||
Rectangle {
|
Rectangle {
|
||||||
visible: !Settings.data.colorSchemes.useWallpaperColors
|
visible: !Settings.data.colorSchemes.useWallpaperColors
|
||||||
&& (Settings.data.colorSchemes.predefinedScheme === schemePath)
|
&& (Settings.data.colorSchemes.predefinedScheme === schemePath.split("/").pop().replace(".json",
|
||||||
|
""))
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.margins: Style.marginS * scaling
|
anchors.margins: Style.marginS * scaling
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,26 @@ Singleton {
|
||||||
folderModel.folder = "file://" + schemesDirectory
|
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
|
// Force reload by bouncing the path
|
||||||
|
var filePath = resolveSchemePath(nameOrPath)
|
||||||
schemeReader.path = ""
|
schemeReader.path = ""
|
||||||
schemeReader.path = filePath
|
schemeReader.path = filePath
|
||||||
}
|
}
|
||||||
|
|
@ -69,6 +87,17 @@ Singleton {
|
||||||
schemes = files
|
schemes = files
|
||||||
scanning = false
|
scanning = false
|
||||||
Logger.log("ColorScheme", "Listed", schemes.length, "schemes")
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue