1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

PluginComponent: support for right click not defaulted to poput toggle (#677)

* PluginComponent: support for right click not defaulted to poput toggle

* PluginComponent: right click docs
This commit is contained in:
Massimo Branchini
2025-11-09 18:12:47 +01:00
committed by GitHub
parent caa085a646
commit 5fa117db4c
2 changed files with 35 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ Item {
property real popoutWidth: 400
property real popoutHeight: 0
property var pillClickAction: null
property var pillRightClickAction: null
property Component controlCenterWidget: null
property string ccWidgetIcon: ""
@@ -120,6 +121,18 @@ Item {
pluginPopout.toggle()
}
}
onRightClicked: {
if (pillRightClickAction) {
if (pillRightClickAction.length === 0) {
pillRightClickAction()
} else {
const globalPos = mapToGlobal(0, 0)
const currentScreen = parentScreen || Screen
const pos = SettingsData.getPopupTriggerPosition(globalPos, currentScreen, barThickness, width)
pillRightClickAction(pos.x, pos.y, pos.width, section, currentScreen)
}
}
}
}
BasePill {
@@ -147,6 +160,18 @@ Item {
pluginPopout.toggle()
}
}
onRightClicked: {
if (pillRightClickAction) {
if (pillRightClickAction.length === 0) {
pillRightClickAction()
} else {
const globalPos = mapToGlobal(0, 0)
const currentScreen = parentScreen || Screen
const pos = SettingsData.getPopupTriggerPosition(globalPos, currentScreen, barThickness, width)
pillRightClickAction(pos.x, pos.y, pos.width, section, currentScreen)
}
}
}
}
function closePopout() {

View File

@@ -177,6 +177,7 @@ PluginComponent {
- `popoutWidth`: Popout window width
- `popoutHeight`: Popout window height
- `pillClickAction`: Custom click handler function (overrides popout)
- `pillRightClickAction`: Custom right click handler function
### Control Center Integration
@@ -227,7 +228,7 @@ PluginComponent {
**Custom Click Actions:**
Override default popout with `pillClickAction`:
Override default popout with `pillClickAction` and `pillRightClickAction`:
```qml
pillClickAction: () => {
@@ -238,6 +239,14 @@ pillClickAction: () => {
pillClickAction: (x, y, width, section, screen) => {
popoutService?.toggleControlCenter(x, y, width, section, screen)
}
pillRightClickAction: () => {
Process.exec("bash", ["-c", "notify-send 'Right clicked!'"])
}
pillRightClickAction: (x, y, width, section, screen) => {
popoutService?.toggleControlCenter(x, y, width, section, screen)
}
```
The PluginComponent automatically handles: