Add configurable Plasma panel scroll and click actions
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
.pragma library
|
||||
|
||||
// Task Manager fills unused panel space. Only delegates are task buttons.
|
||||
function hasTaskAt(item, x, y) {
|
||||
if (!item.visible || !item.contains(item.mapFromItem(null, x, y))) return false;
|
||||
if (item.tasksRoot !== undefined && item.isWindow !== undefined && item.index !== undefined) return true;
|
||||
for (const child of item.children) {
|
||||
if (hasTaskAt(child, x, y)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function areaAt(panelLayout, x, y) {
|
||||
if (!panelLayout) return "";
|
||||
for (const child of panelLayout.children) {
|
||||
if (!child.visible || !child.contains(child.mapFromItem(null, x, y))) continue;
|
||||
const applet = child.applet;
|
||||
const name = applet?.plasmoid?.pluginName;
|
||||
if (!name) return "other";
|
||||
if (name === "org.kde.plasma.taskmanager" || name === "org.kde.plasma.icontasks") {
|
||||
return hasTaskAt(applet, x, y) ? "tasks" : "empty";
|
||||
}
|
||||
if (name === "se.ajpanton.panelactions" || name === "org.kde.plasma.panelspacer"
|
||||
|| name === "org.kde.plasma.marginsseparator") return "empty";
|
||||
if (name === "org.kde.plasma.systemtray") return "tray";
|
||||
if (name === "org.kde.plasma.digitalclock" || name === "org.kde.plasma.analogclock") return "clock";
|
||||
if (name === "org.kde.plasma.kickoff" || name === "org.kde.plasma.kicker"
|
||||
|| name === "org.kde.plasma.kickerdash") return "launcher";
|
||||
return "other";
|
||||
}
|
||||
return "empty";
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import org.kde.plasma.core as PlasmaCore
|
||||
import org.kde.plasma.plasmoid
|
||||
import se.ajpanton.panelactions 1.0
|
||||
import "areas.js" as Areas
|
||||
|
||||
PlasmoidItem {
|
||||
id: root
|
||||
readonly property Item panelLayout: {
|
||||
let item = root.parent;
|
||||
while (item) {
|
||||
if (item instanceof GridLayout) return item;
|
||||
item = item.parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
|
||||
Layout.minimumWidth: 0
|
||||
Layout.minimumHeight: 0
|
||||
Layout.preferredWidth: 0
|
||||
Layout.preferredHeight: 0
|
||||
Layout.maximumWidth: 0
|
||||
Layout.maximumHeight: 0
|
||||
preferredRepresentation: fullRepresentation
|
||||
PanelSettings { id: settings }
|
||||
PanelController {
|
||||
active: root.panelLayout !== null && !(Plasmoid.containment.corona?.editMode ?? false)
|
||||
locateArea: (x, y) => Areas.areaAt(root.panelLayout, x, y)
|
||||
scrollActions: ({
|
||||
empty: settings.values.emptyAction,
|
||||
tasks: settings.values.tasksAction,
|
||||
launcher: settings.values.launcherAction,
|
||||
clock: settings.values.clockAction,
|
||||
tray: settings.values.trayAction,
|
||||
other: settings.values.otherAction
|
||||
})
|
||||
clickActions: settings.values
|
||||
onActionRequested: (action, direction) => invoke(action, direction)
|
||||
onClickRequested: slot => {
|
||||
const action = settings.values[slot];
|
||||
if (action === "command" || action === "application") settings.launchClick(slot);
|
||||
else invoke(action, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user