mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 13:32:50 -05:00
Add invert on mode change for launcher logo
This commit is contained in:
@@ -106,6 +106,7 @@ Singleton {
|
||||
property string launcherLogoMode: "apps"
|
||||
property string launcherLogoCustomPath: ""
|
||||
property string launcherLogoColorOverride: ""
|
||||
property bool launcherLogoColorInvertOnMode: false
|
||||
property real launcherLogoBrightness: 0.5
|
||||
property real launcherLogoContrast: 1
|
||||
property int launcherLogoSizeOffset: 0
|
||||
@@ -333,6 +334,7 @@ Singleton {
|
||||
launcherLogoMode = settings.launcherLogoMode !== undefined ? settings.launcherLogoMode : "apps"
|
||||
launcherLogoCustomPath = settings.launcherLogoCustomPath !== undefined ? settings.launcherLogoCustomPath : ""
|
||||
launcherLogoColorOverride = settings.launcherLogoColorOverride !== undefined ? settings.launcherLogoColorOverride : ""
|
||||
launcherLogoColorInvertOnMode = settings.launcherLogoColorInvertOnMode !== undefined ? settings.launcherLogoColorInvertOnMode : false
|
||||
launcherLogoBrightness = settings.launcherLogoBrightness !== undefined ? settings.launcherLogoBrightness : 0.5
|
||||
launcherLogoContrast = settings.launcherLogoContrast !== undefined ? settings.launcherLogoContrast : 1
|
||||
launcherLogoSizeOffset = settings.launcherLogoSizeOffset !== undefined ? settings.launcherLogoSizeOffset : 0
|
||||
@@ -459,6 +461,7 @@ Singleton {
|
||||
"launcherLogoMode": launcherLogoMode,
|
||||
"launcherLogoCustomPath": launcherLogoCustomPath,
|
||||
"launcherLogoColorOverride": launcherLogoColorOverride,
|
||||
"launcherLogoColorInvertOnMode": launcherLogoColorInvertOnMode,
|
||||
"launcherLogoBrightness": launcherLogoBrightness,
|
||||
"launcherLogoContrast": launcherLogoContrast,
|
||||
"launcherLogoSizeOffset": launcherLogoSizeOffset,
|
||||
@@ -977,6 +980,11 @@ Singleton {
|
||||
saveSettings()
|
||||
}
|
||||
|
||||
function setLauncherLogoColorInvertOnMode(invert) {
|
||||
launcherLogoColorInvertOnMode = invert
|
||||
saveSettings()
|
||||
}
|
||||
|
||||
function setLauncherLogoBrightness(brightness) {
|
||||
launcherLogoBrightness = brightness
|
||||
saveSettings()
|
||||
|
||||
@@ -694,6 +694,59 @@ Singleton {
|
||||
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 {
|
||||
id: matugenCheck
|
||||
command: ["which", "matugen"]
|
||||
|
||||
@@ -69,7 +69,7 @@ Item {
|
||||
anchors.centerIn: parent
|
||||
width: Theme.barIconSize(barThickness, SettingsData.launcherLogoSizeOffset)
|
||||
height: Theme.barIconSize(barThickness, SettingsData.launcherLogoSizeOffset)
|
||||
colorOverride: SettingsData.launcherLogoColorOverride
|
||||
colorOverride: Theme.effectiveLogoColor
|
||||
brightnessOverride: SettingsData.launcherLogoBrightness
|
||||
contrastOverride: SettingsData.launcherLogoContrast
|
||||
}
|
||||
@@ -89,10 +89,10 @@ Item {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
layer.enabled: SettingsData.launcherLogoColorOverride !== ""
|
||||
layer.enabled: Theme.effectiveLogoColor !== ""
|
||||
layer.effect: MultiEffect {
|
||||
colorization: 1
|
||||
colorizationColor: SettingsData.launcherLogoColorOverride
|
||||
colorizationColor: Theme.effectiveLogoColor
|
||||
brightness: SettingsData.launcherLogoBrightness
|
||||
contrast: SettingsData.launcherLogoContrast
|
||||
}
|
||||
@@ -106,10 +106,10 @@ Item {
|
||||
smooth: true
|
||||
asynchronous: true
|
||||
source: SettingsData.launcherLogoCustomPath ? "file://" + SettingsData.launcherLogoCustomPath.replace("file://", "") : ""
|
||||
layer.enabled: SettingsData.launcherLogoColorOverride !== ""
|
||||
layer.enabled: Theme.effectiveLogoColor !== ""
|
||||
layer.effect: MultiEffect {
|
||||
colorization: 1
|
||||
colorizationColor: SettingsData.launcherLogoColorOverride
|
||||
colorizationColor: Theme.effectiveLogoColor
|
||||
brightness: SettingsData.launcherLogoBrightness
|
||||
contrast: SettingsData.launcherLogoContrast
|
||||
}
|
||||
|
||||
@@ -166,9 +166,9 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
Row {
|
||||
width: parent.width
|
||||
height: slidersRow.height
|
||||
spacing: Theme.spacingL
|
||||
visible: SettingsData.launcherLogoMode !== "apps"
|
||||
opacity: visible ? 1 : 0
|
||||
|
||||
@@ -179,56 +179,55 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
id: slidersRow
|
||||
Column {
|
||||
width: 120
|
||||
spacing: Theme.spacingS
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
Column {
|
||||
width: 120
|
||||
spacing: Theme.spacingS
|
||||
StyledText {
|
||||
text: qsTr("Color Override")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: qsTr("Color Override")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
Rectangle {
|
||||
width: 32
|
||||
height: 32
|
||||
radius: 16
|
||||
color: SettingsData.launcherLogoColorOverride !== "" ? SettingsData.launcherLogoColorOverride : Qt.rgba(255, 255, 255, 0.9)
|
||||
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 {
|
||||
width: 32
|
||||
height: 32
|
||||
radius: 16
|
||||
color: SettingsData.launcherLogoColorOverride !== "" ? SettingsData.launcherLogoColorOverride : Qt.rgba(255, 255, 255, 0.9)
|
||||
border.color: Theme.outline
|
||||
border.width: 1
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
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()
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Flow {
|
||||
width: parent.width - 120 - Theme.spacingL
|
||||
spacing: Theme.spacingS
|
||||
|
||||
Column {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user