mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
desktop-widgets: add overlay IPC and overview option
This commit is contained in:
@@ -12,4 +12,6 @@ This file is more of a quick reference so I know what to account for before next
|
|||||||
- Added desktop widget plugins
|
- Added desktop widget plugins
|
||||||
- dev guidance available
|
- dev guidance available
|
||||||
- builtin clock & dgop widgets
|
- builtin clock & dgop widgets
|
||||||
|
- new IPC targets
|
||||||
- Initial RTL support/i18n
|
- Initial RTL support/i18n
|
||||||
|
- Theme registry
|
||||||
|
|||||||
@@ -893,4 +893,58 @@ Item {
|
|||||||
|
|
||||||
target: "clipboard"
|
target: "clipboard"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IpcHandler {
|
||||||
|
function toggleOverlay(instanceId: string): string {
|
||||||
|
if (!instanceId)
|
||||||
|
return "ERROR: No instance ID specified";
|
||||||
|
|
||||||
|
const instance = SettingsData.getDesktopWidgetInstance(instanceId);
|
||||||
|
if (!instance)
|
||||||
|
return `DESKTOP_WIDGET_NOT_FOUND: ${instanceId}`;
|
||||||
|
|
||||||
|
const currentValue = instance.config?.showOnOverlay ?? false;
|
||||||
|
SettingsData.updateDesktopWidgetInstanceConfig(instanceId, {
|
||||||
|
showOnOverlay: !currentValue
|
||||||
|
});
|
||||||
|
return !currentValue ? `DESKTOP_WIDGET_OVERLAY_ENABLED: ${instanceId}` : `DESKTOP_WIDGET_OVERLAY_DISABLED: ${instanceId}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setOverlay(instanceId: string, enabled: string): string {
|
||||||
|
if (!instanceId)
|
||||||
|
return "ERROR: No instance ID specified";
|
||||||
|
|
||||||
|
const instance = SettingsData.getDesktopWidgetInstance(instanceId);
|
||||||
|
if (!instance)
|
||||||
|
return `DESKTOP_WIDGET_NOT_FOUND: ${instanceId}`;
|
||||||
|
|
||||||
|
const enabledBool = enabled === "true" || enabled === "1";
|
||||||
|
SettingsData.updateDesktopWidgetInstanceConfig(instanceId, {
|
||||||
|
showOnOverlay: enabledBool
|
||||||
|
});
|
||||||
|
return enabledBool ? `DESKTOP_WIDGET_OVERLAY_ENABLED: ${instanceId}` : `DESKTOP_WIDGET_OVERLAY_DISABLED: ${instanceId}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function list(): string {
|
||||||
|
const instances = SettingsData.desktopWidgetInstances || [];
|
||||||
|
if (instances.length === 0)
|
||||||
|
return "No desktop widgets configured";
|
||||||
|
return instances.map(i => `${i.id} [${i.widgetType}] ${i.name || i.widgetType}`).join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
function status(instanceId: string): string {
|
||||||
|
if (!instanceId)
|
||||||
|
return "ERROR: No instance ID specified";
|
||||||
|
|
||||||
|
const instance = SettingsData.getDesktopWidgetInstance(instanceId);
|
||||||
|
if (!instance)
|
||||||
|
return `DESKTOP_WIDGET_NOT_FOUND: ${instanceId}`;
|
||||||
|
|
||||||
|
const overlay = instance.config?.showOnOverlay ?? false;
|
||||||
|
const overview = instance.config?.showOnOverview ?? false;
|
||||||
|
return `overlay: ${overlay}, overview: ${overview}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
target: "desktopWidget"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ Item {
|
|||||||
readonly property bool isBuiltin: pluginId === "desktopClock" || pluginId === "systemMonitor"
|
readonly property bool isBuiltin: pluginId === "desktopClock" || pluginId === "systemMonitor"
|
||||||
readonly property var activeComponent: isBuiltin ? builtinComponent : PluginService.pluginDesktopComponents[pluginId] ?? null
|
readonly property var activeComponent: isBuiltin ? builtinComponent : PluginService.pluginDesktopComponents[pluginId] ?? null
|
||||||
|
|
||||||
|
readonly property bool showOnOverlay: instanceData?.config?.showOnOverlay ?? false
|
||||||
|
readonly property bool showOnOverview: instanceData?.config?.showOnOverview ?? false
|
||||||
|
readonly property bool overviewActive: CompositorService.isNiri && NiriService.inOverview
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: PluginService
|
target: PluginService
|
||||||
enabled: !root.isBuiltin
|
enabled: !root.isBuiltin
|
||||||
@@ -202,7 +206,15 @@ Item {
|
|||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
WlrLayershell.namespace: "quickshell:desktop-widget:" + root.pluginId + (root.instanceId ? ":" + root.instanceId : "")
|
WlrLayershell.namespace: "quickshell:desktop-widget:" + root.pluginId + (root.instanceId ? ":" + root.instanceId : "")
|
||||||
WlrLayershell.layer: root.isInteracting && !CompositorService.useHyprlandFocusGrab ? WlrLayer.Overlay : WlrLayer.Bottom
|
WlrLayershell.layer: {
|
||||||
|
if (root.isInteracting && !CompositorService.useHyprlandFocusGrab)
|
||||||
|
return WlrLayer.Overlay;
|
||||||
|
if (root.showOnOverlay)
|
||||||
|
return WlrLayer.Overlay;
|
||||||
|
if (root.showOnOverview && root.overviewActive)
|
||||||
|
return WlrLayer.Overlay;
|
||||||
|
return WlrLayer.Bottom;
|
||||||
|
}
|
||||||
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
||||||
WlrLayershell.keyboardFocus: {
|
WlrLayershell.keyboardFocus: {
|
||||||
if (!root.isInteracting)
|
if (!root.isInteracting)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
import qs.Common
|
import qs.Common
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import qs.Widgets
|
import qs.Widgets
|
||||||
@@ -68,8 +69,11 @@ SettingsCard {
|
|||||||
DankToggle {
|
DankToggle {
|
||||||
checked: instanceData?.enabled ?? true
|
checked: instanceData?.enabled ?? true
|
||||||
onToggled: isChecked => {
|
onToggled: isChecked => {
|
||||||
if (!root.instanceId) return;
|
if (!root.instanceId)
|
||||||
SettingsData.updateDesktopWidgetInstance(root.instanceId, { enabled: isChecked });
|
return;
|
||||||
|
SettingsData.updateDesktopWidgetInstance(root.instanceId, {
|
||||||
|
enabled: isChecked
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,8 +127,102 @@ SettingsCard {
|
|||||||
width: parent.width - 80 - Theme.spacingM
|
width: parent.width - 80 - Theme.spacingM
|
||||||
text: root.widgetName
|
text: root.widgetName
|
||||||
onEditingFinished: {
|
onEditingFinished: {
|
||||||
if (!root.instanceId) return;
|
if (!root.instanceId)
|
||||||
SettingsData.updateDesktopWidgetInstance(root.instanceId, { name: text });
|
return;
|
||||||
|
SettingsData.updateDesktopWidgetInstance(root.instanceId, {
|
||||||
|
name: text
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsDivider {}
|
||||||
|
|
||||||
|
SettingsToggleRow {
|
||||||
|
text: I18n.tr("Show on Overlay")
|
||||||
|
checked: instanceData?.config?.showOnOverlay ?? false
|
||||||
|
onToggled: isChecked => {
|
||||||
|
if (!root.instanceId)
|
||||||
|
return;
|
||||||
|
SettingsData.updateDesktopWidgetInstanceConfig(root.instanceId, {
|
||||||
|
showOnOverlay: isChecked
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsDivider {
|
||||||
|
visible: CompositorService.isNiri
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsToggleRow {
|
||||||
|
visible: CompositorService.isNiri
|
||||||
|
text: I18n.tr("Show on Overview")
|
||||||
|
checked: instanceData?.config?.showOnOverview ?? false
|
||||||
|
onToggled: isChecked => {
|
||||||
|
if (!root.instanceId)
|
||||||
|
return;
|
||||||
|
SettingsData.updateDesktopWidgetInstanceConfig(root.instanceId, {
|
||||||
|
showOnOverview: isChecked
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsDivider {}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
width: parent.width
|
||||||
|
height: ipcColumn.height + Theme.spacingM * 2
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: ipcColumn
|
||||||
|
x: Theme.spacingM
|
||||||
|
width: parent.width - Theme.spacingM * 2
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
spacing: Theme.spacingXS
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: I18n.tr("Command")
|
||||||
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
|
color: Theme.surfaceText
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: parent.width
|
||||||
|
height: ipcText.height + Theme.spacingS * 2
|
||||||
|
radius: Theme.cornerRadius / 2
|
||||||
|
color: Theme.surfaceHover
|
||||||
|
|
||||||
|
Row {
|
||||||
|
x: Theme.spacingS
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
spacing: Theme.spacingS
|
||||||
|
width: parent.width - Theme.spacingS * 2
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
id: ipcText
|
||||||
|
text: "dms ipc call desktopWidget toggleOverlay " + root.instanceId
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
font.family: Theme.monoFontFamily
|
||||||
|
color: Theme.surfaceVariantText
|
||||||
|
width: parent.width - copyBtn.width - Theme.spacingS
|
||||||
|
elide: Text.ElideMiddle
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
DankButton {
|
||||||
|
id: copyBtn
|
||||||
|
iconName: "content_copy"
|
||||||
|
backgroundColor: "transparent"
|
||||||
|
textColor: Theme.surfaceText
|
||||||
|
buttonHeight: 28
|
||||||
|
horizontalPadding: 4
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
onClicked: {
|
||||||
|
Quickshell.execDetached(["dms", "cl", "copy", "dms ipc call desktopWidget toggleOverlay " + root.instanceId]);
|
||||||
|
ToastService.showInfo(I18n.tr("Copied to clipboard"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,7 +247,8 @@ SettingsCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
if (!item) return;
|
if (!item)
|
||||||
|
return;
|
||||||
item.instanceId = root.instanceId;
|
item.instanceId = root.instanceId;
|
||||||
item.instanceData = Qt.binding(() => root.instanceData);
|
item.instanceData = Qt.binding(() => root.instanceData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -227,12 +227,6 @@ Scope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onAnimatingOutChanged: {
|
|
||||||
if (!animatingOut || scaleAnimation.animation.running)
|
|
||||||
return;
|
|
||||||
Qt.callLater(niriOverviewScope.resetState);
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: Theme.expressiveDurations.expressiveDefaultSpatial
|
duration: Theme.expressiveDurations.expressiveDefaultSpatial
|
||||||
|
|||||||
Reference in New Issue
Block a user