1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-30 08:22:51 -05:00

Add invert on mode change for launcher logo

This commit is contained in:
bbedward
2025-10-06 23:24:39 -04:00
parent 1f8bddaa5e
commit 2757a41102
4 changed files with 131 additions and 47 deletions

View File

@@ -106,6 +106,7 @@ Singleton {
property string launcherLogoMode: "apps" property string launcherLogoMode: "apps"
property string launcherLogoCustomPath: "" property string launcherLogoCustomPath: ""
property string launcherLogoColorOverride: "" property string launcherLogoColorOverride: ""
property bool launcherLogoColorInvertOnMode: false
property real launcherLogoBrightness: 0.5 property real launcherLogoBrightness: 0.5
property real launcherLogoContrast: 1 property real launcherLogoContrast: 1
property int launcherLogoSizeOffset: 0 property int launcherLogoSizeOffset: 0
@@ -333,6 +334,7 @@ Singleton {
launcherLogoMode = settings.launcherLogoMode !== undefined ? settings.launcherLogoMode : "apps" launcherLogoMode = settings.launcherLogoMode !== undefined ? settings.launcherLogoMode : "apps"
launcherLogoCustomPath = settings.launcherLogoCustomPath !== undefined ? settings.launcherLogoCustomPath : "" launcherLogoCustomPath = settings.launcherLogoCustomPath !== undefined ? settings.launcherLogoCustomPath : ""
launcherLogoColorOverride = settings.launcherLogoColorOverride !== undefined ? settings.launcherLogoColorOverride : "" launcherLogoColorOverride = settings.launcherLogoColorOverride !== undefined ? settings.launcherLogoColorOverride : ""
launcherLogoColorInvertOnMode = settings.launcherLogoColorInvertOnMode !== undefined ? settings.launcherLogoColorInvertOnMode : false
launcherLogoBrightness = settings.launcherLogoBrightness !== undefined ? settings.launcherLogoBrightness : 0.5 launcherLogoBrightness = settings.launcherLogoBrightness !== undefined ? settings.launcherLogoBrightness : 0.5
launcherLogoContrast = settings.launcherLogoContrast !== undefined ? settings.launcherLogoContrast : 1 launcherLogoContrast = settings.launcherLogoContrast !== undefined ? settings.launcherLogoContrast : 1
launcherLogoSizeOffset = settings.launcherLogoSizeOffset !== undefined ? settings.launcherLogoSizeOffset : 0 launcherLogoSizeOffset = settings.launcherLogoSizeOffset !== undefined ? settings.launcherLogoSizeOffset : 0
@@ -459,6 +461,7 @@ Singleton {
"launcherLogoMode": launcherLogoMode, "launcherLogoMode": launcherLogoMode,
"launcherLogoCustomPath": launcherLogoCustomPath, "launcherLogoCustomPath": launcherLogoCustomPath,
"launcherLogoColorOverride": launcherLogoColorOverride, "launcherLogoColorOverride": launcherLogoColorOverride,
"launcherLogoColorInvertOnMode": launcherLogoColorInvertOnMode,
"launcherLogoBrightness": launcherLogoBrightness, "launcherLogoBrightness": launcherLogoBrightness,
"launcherLogoContrast": launcherLogoContrast, "launcherLogoContrast": launcherLogoContrast,
"launcherLogoSizeOffset": launcherLogoSizeOffset, "launcherLogoSizeOffset": launcherLogoSizeOffset,
@@ -977,6 +980,11 @@ Singleton {
saveSettings() saveSettings()
} }
function setLauncherLogoColorInvertOnMode(invert) {
launcherLogoColorInvertOnMode = invert
saveSettings()
}
function setLauncherLogoBrightness(brightness) { function setLauncherLogoBrightness(brightness) {
launcherLogoBrightness = brightness launcherLogoBrightness = brightness
saveSettings() saveSettings()

View File

@@ -694,6 +694,59 @@ Singleton {
return Math.round(value * dpr) / dpr return Math.round(value * dpr) / dpr
} }
function invertHex(hex) {
hex = hex.replace('#', '');
if (!/^[0-9A-Fa-f]{6}$/.test(hex)) {
return hex;
}
const r = parseInt(hex.substr(0, 2), 16);
const g = parseInt(hex.substr(2, 2), 16);
const b = parseInt(hex.substr(4, 2), 16);
const invR = (255 - r).toString(16).padStart(2, '0');
const invG = (255 - g).toString(16).padStart(2, '0');
const invB = (255 - b).toString(16).padStart(2, '0');
return `#${invR}${invG}${invB}`;
}
property string baseLogoColor: ""
property string effectiveLogoColor: {
if (typeof SettingsData === "undefined") return ""
const colorOverride = SettingsData.launcherLogoColorOverride
if (!colorOverride || colorOverride === "") return ""
if (!SettingsData.launcherLogoColorInvertOnMode) {
return colorOverride
}
if (baseLogoColor === "") {
baseLogoColor = colorOverride
}
if (typeof SessionData !== "undefined" && SessionData.isLightMode) {
return invertHex(baseLogoColor)
}
return baseLogoColor
}
onIsLightModeChanged: {
if (typeof SettingsData !== "undefined" && SettingsData.launcherLogoColorInvertOnMode && baseLogoColor === "") {
baseLogoColor = SettingsData.launcherLogoColorOverride
}
}
Connections {
target: typeof SettingsData !== "undefined" ? SettingsData : null
function onLauncherLogoColorOverrideChanged() {
baseLogoColor = SettingsData.launcherLogoColorOverride
}
}
Process { Process {
id: matugenCheck id: matugenCheck
command: ["which", "matugen"] command: ["which", "matugen"]

View File

@@ -69,7 +69,7 @@ Item {
anchors.centerIn: parent anchors.centerIn: parent
width: Theme.barIconSize(barThickness, SettingsData.launcherLogoSizeOffset) width: Theme.barIconSize(barThickness, SettingsData.launcherLogoSizeOffset)
height: Theme.barIconSize(barThickness, SettingsData.launcherLogoSizeOffset) height: Theme.barIconSize(barThickness, SettingsData.launcherLogoSizeOffset)
colorOverride: SettingsData.launcherLogoColorOverride colorOverride: Theme.effectiveLogoColor
brightnessOverride: SettingsData.launcherLogoBrightness brightnessOverride: SettingsData.launcherLogoBrightness
contrastOverride: SettingsData.launcherLogoContrast contrastOverride: SettingsData.launcherLogoContrast
} }
@@ -89,10 +89,10 @@ Item {
} }
return "" return ""
} }
layer.enabled: SettingsData.launcherLogoColorOverride !== "" layer.enabled: Theme.effectiveLogoColor !== ""
layer.effect: MultiEffect { layer.effect: MultiEffect {
colorization: 1 colorization: 1
colorizationColor: SettingsData.launcherLogoColorOverride colorizationColor: Theme.effectiveLogoColor
brightness: SettingsData.launcherLogoBrightness brightness: SettingsData.launcherLogoBrightness
contrast: SettingsData.launcherLogoContrast contrast: SettingsData.launcherLogoContrast
} }
@@ -106,10 +106,10 @@ Item {
smooth: true smooth: true
asynchronous: true asynchronous: true
source: SettingsData.launcherLogoCustomPath ? "file://" + SettingsData.launcherLogoCustomPath.replace("file://", "") : "" source: SettingsData.launcherLogoCustomPath ? "file://" + SettingsData.launcherLogoCustomPath.replace("file://", "") : ""
layer.enabled: SettingsData.launcherLogoColorOverride !== "" layer.enabled: Theme.effectiveLogoColor !== ""
layer.effect: MultiEffect { layer.effect: MultiEffect {
colorization: 1 colorization: 1
colorizationColor: SettingsData.launcherLogoColorOverride colorizationColor: Theme.effectiveLogoColor
brightness: SettingsData.launcherLogoBrightness brightness: SettingsData.launcherLogoBrightness
contrast: SettingsData.launcherLogoContrast contrast: SettingsData.launcherLogoContrast
} }

View File

@@ -166,9 +166,9 @@ Item {
} }
} }
Item { Row {
width: parent.width width: parent.width
height: slidersRow.height spacing: Theme.spacingL
visible: SettingsData.launcherLogoMode !== "apps" visible: SettingsData.launcherLogoMode !== "apps"
opacity: visible ? 1 : 0 opacity: visible ? 1 : 0
@@ -179,56 +179,55 @@ Item {
} }
} }
Row { Column {
id: slidersRow width: 120
spacing: Theme.spacingS spacing: Theme.spacingS
anchors.horizontalCenter: parent.horizontalCenter
Column { StyledText {
width: 120 text: qsTr("Color Override")
spacing: Theme.spacingS font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
font.weight: Font.Medium
anchors.horizontalCenter: parent.horizontalCenter
}
StyledText { Rectangle {
text: qsTr("Color Override") width: 32
font.pixelSize: Theme.fontSizeSmall height: 32
color: Theme.surfaceText radius: 16
font.weight: Font.Medium color: SettingsData.launcherLogoColorOverride !== "" ? SettingsData.launcherLogoColorOverride : Qt.rgba(255, 255, 255, 0.9)
anchors.horizontalCenter: parent.horizontalCenter border.color: Theme.outline
border.width: 1
anchors.horizontalCenter: parent.horizontalCenter
DankIcon {
visible: SettingsData.launcherLogoColorOverride === ""
anchors.centerIn: parent
name: "palette"
size: 18
color: "black"
} }
Rectangle { MouseArea {
width: 32 anchors.fill: parent
height: 32 cursorShape: Qt.PointingHandCursor
radius: 16 onClicked: {
color: SettingsData.launcherLogoColorOverride !== "" ? SettingsData.launcherLogoColorOverride : Qt.rgba(255, 255, 255, 0.9) if (PopoutService.colorPickerModal) {
border.color: Theme.outline PopoutService.colorPickerModal.selectedColor = SettingsData.launcherLogoColorOverride !== "" ? SettingsData.launcherLogoColorOverride : Qt.rgba(0, 0, 0, 0)
border.width: 1 PopoutService.colorPickerModal.pickerTitle = qsTr("Choose Launcher Logo Color")
anchors.horizontalCenter: parent.horizontalCenter PopoutService.colorPickerModal.onColorSelectedCallback = function(selectedColor) {
SettingsData.setLauncherLogoColorOverride(selectedColor)
DankIcon {
visible: SettingsData.launcherLogoColorOverride === ""
anchors.centerIn: parent
name: "palette"
size: 18
color: "black"
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
if (PopoutService.colorPickerModal) {
PopoutService.colorPickerModal.selectedColor = SettingsData.launcherLogoColorOverride !== "" ? SettingsData.launcherLogoColorOverride : Qt.rgba(0, 0, 0, 0)
PopoutService.colorPickerModal.pickerTitle = qsTr("Choose Launcher Logo Color")
PopoutService.colorPickerModal.onColorSelectedCallback = function(selectedColor) {
SettingsData.setLauncherLogoColorOverride(selectedColor)
}
PopoutService.colorPickerModal.show()
} }
PopoutService.colorPickerModal.show()
} }
} }
} }
} }
}
Flow {
width: parent.width - 120 - Theme.spacingL
spacing: Theme.spacingS
Column { Column {
width: 120 width: 120
@@ -316,6 +315,30 @@ Item {
} }
} }
} }
Column {
width: 120
spacing: Theme.spacingS
visible: SettingsData.launcherLogoColorOverride !== ""
StyledText {
text: qsTr("Invert on mode change")
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
font.weight: Font.Medium
anchors.horizontalCenter: parent.horizontalCenter
}
DankToggle {
width: 32
height: 18
checked: SettingsData.launcherLogoColorInvertOnMode
anchors.horizontalCenter: parent.horizontalCenter
onToggled: checked => {
SettingsData.setLauncherLogoColorInvertOnMode(checked)
}
}
}
} }
} }
} }