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:
@@ -218,6 +218,9 @@ Singleton {
|
|||||||
|
|
||||||
function setLightMode(lightMode) {
|
function setLightMode(lightMode) {
|
||||||
isLightMode = lightMode;
|
isLightMode = lightMode;
|
||||||
|
if (typeof Theme !== "undefined") {
|
||||||
|
Theme.isLightMode = lightMode;
|
||||||
|
}
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -740,4 +743,27 @@ Singleton {
|
|||||||
return "SUCCESS: Wallpaper cleared"
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,10 @@ qs -c DankMaterialShell ipc call <target> <function>
|
|||||||
| wallpaper | get | none | Get current wallpaper path |
|
| wallpaper | get | none | Get current wallpaper path |
|
||||||
| wallpaper | set | path (string) | Set wallpaper to image path and refresh theme |
|
| wallpaper | set | path (string) | Set wallpaper to image path and refresh theme |
|
||||||
| wallpaper | clear | none | Clear current wallpaper |
|
| 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 |
|
| notifs | clear | none | Clear all notifications |
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import qs.Common
|
|||||||
ListView {
|
ListView {
|
||||||
id: listView
|
id: listView
|
||||||
|
|
||||||
property int currentIndex: 0
|
|
||||||
property int itemHeight: 72
|
property int itemHeight: 72
|
||||||
property int iconSize: 56
|
property int iconSize: 56
|
||||||
property bool showDescription: true
|
property bool showDescription: true
|
||||||
@@ -23,15 +22,15 @@ ListView {
|
|||||||
|
|
||||||
// Ensure the current item is visible
|
// Ensure the current item is visible
|
||||||
function ensureVisible(index) {
|
function ensureVisible(index) {
|
||||||
if (index < 0 || index >= listView.count)
|
if (index < 0 || index >= count)
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
var itemY = index * (itemHeight + itemSpacing);
|
var itemY = index * (itemHeight + itemSpacing);
|
||||||
var itemBottom = itemY + itemHeight;
|
var itemBottom = itemY + itemHeight;
|
||||||
if (itemY < listView.contentY)
|
if (itemY < contentY)
|
||||||
listView.contentY = itemY;
|
contentY = itemY;
|
||||||
else if (itemBottom > listView.contentY + listView.height)
|
else if (itemBottom > contentY + height)
|
||||||
listView.contentY = itemBottom - listView.height;
|
contentY = itemBottom - height;
|
||||||
}
|
}
|
||||||
|
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
@@ -50,12 +49,12 @@ ListView {
|
|||||||
WheelHandler {
|
WheelHandler {
|
||||||
target: null
|
target: null
|
||||||
onWheel: (ev) => {
|
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)
|
if (ev.inverted)
|
||||||
dy = -dy;
|
dy = -dy;
|
||||||
|
|
||||||
const maxY = Math.max(0, listView.contentHeight - listView.height);
|
const maxY = Math.max(0, contentHeight - height);
|
||||||
listView.contentY = Math.max(0, Math.min(maxY, listView.contentY - dy * listView.wheelMultiplier));
|
contentY = Math.max(0, Math.min(maxY, contentY - dy * wheelMultiplier));
|
||||||
ev.accepted = true;
|
ev.accepted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,7 +68,7 @@ ListView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
width: listView.width
|
width: ListView.view.width
|
||||||
height: itemHeight
|
height: itemHeight
|
||||||
radius: Theme.cornerRadiusLarge
|
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)
|
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
|
z: 10
|
||||||
onEntered: {
|
onEntered: {
|
||||||
if (hoverUpdatesSelection && !keyboardNavigationActive)
|
if (hoverUpdatesSelection && !keyboardNavigationActive)
|
||||||
listView.currentIndex = index;
|
currentIndex = index;
|
||||||
|
|
||||||
itemHovered(index);
|
itemHovered(index);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user