1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-08 14:35:39 -05:00

ipc for light/dark mode

This commit is contained in:
bbedward
2025-07-28 15:31:27 -04:00
parent 199c1c3043
commit 99e890cc17
3 changed files with 40 additions and 11 deletions

View File

@@ -218,6 +218,9 @@ Singleton {
function setLightMode(lightMode) {
isLightMode = lightMode;
if (typeof Theme !== "undefined") {
Theme.isLightMode = lightMode;
}
saveSettings();
}
@@ -740,4 +743,27 @@ Singleton {
return "SUCCESS: Wallpaper cleared"
}
}
IpcHandler {
target: "theme"
function toggle(): string {
root.setLightMode(!root.isLightMode)
return root.isLightMode ? "light" : "dark"
}
function light(): string {
root.setLightMode(true)
return "light"
}
function dark(): string {
root.setLightMode(false)
return "dark"
}
function get(): string {
return root.isLightMode ? "light" : "dark"
}
}
}

View File

@@ -125,6 +125,10 @@ qs -c DankMaterialShell ipc call <target> <function>
| wallpaper | get | none | Get current wallpaper path |
| wallpaper | set | path (string) | Set wallpaper to image path and refresh theme |
| wallpaper | clear | none | Clear current wallpaper |
| theme | get | none | Get current theme mode (light/dark) |
| theme | toggle | none | Toggle between light and dark mode |
| theme | light | none | Set theme to light mode |
| theme | dark | none | Set theme to dark mode |
| notifs | clear | none | Clear all notifications |

View File

@@ -7,7 +7,6 @@ import qs.Common
ListView {
id: listView
property int currentIndex: 0
property int itemHeight: 72
property int iconSize: 56
property bool showDescription: true
@@ -23,15 +22,15 @@ ListView {
// Ensure the current item is visible
function ensureVisible(index) {
if (index < 0 || index >= listView.count)
if (index < 0 || index >= count)
return ;
var itemY = index * (itemHeight + itemSpacing);
var itemBottom = itemY + itemHeight;
if (itemY < listView.contentY)
listView.contentY = itemY;
else if (itemBottom > listView.contentY + listView.height)
listView.contentY = itemBottom - listView.height;
if (itemY < contentY)
contentY = itemY;
else if (itemBottom > contentY + height)
contentY = itemBottom - height;
}
onCurrentIndexChanged: {
@@ -50,12 +49,12 @@ ListView {
WheelHandler {
target: null
onWheel: (ev) => {
let dy = ev.pixelDelta.y !== 0 ? ev.pixelDelta.y : (ev.angleDelta.y / 120) * listView.wheelBaseStep;
let dy = ev.pixelDelta.y !== 0 ? ev.pixelDelta.y : (ev.angleDelta.y / 120) * wheelBaseStep;
if (ev.inverted)
dy = -dy;
const maxY = Math.max(0, listView.contentHeight - listView.height);
listView.contentY = Math.max(0, Math.min(maxY, listView.contentY - dy * listView.wheelMultiplier));
const maxY = Math.max(0, contentHeight - height);
contentY = Math.max(0, Math.min(maxY, contentY - dy * wheelMultiplier));
ev.accepted = true;
}
}
@@ -69,7 +68,7 @@ ListView {
}
delegate: Rectangle {
width: listView.width
width: ListView.view.width
height: itemHeight
radius: Theme.cornerRadiusLarge
color: ListView.isCurrentItem ? Theme.primaryPressed : mouseArea.containsMouse ? Theme.primaryHoverLight : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.03)
@@ -152,7 +151,7 @@ ListView {
z: 10
onEntered: {
if (hoverUpdatesSelection && !keyboardNavigationActive)
listView.currentIndex = index;
currentIndex = index;
itemHovered(index);
}