1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-01 19:18:28 -04:00

dbar/notifications: fix right click context menu position and add middle

click to DnD
This commit is contained in:
bbedward
2026-07-26 14:51:51 -04:00
parent 564583951c
commit 1f94c3cbd4
2 changed files with 33 additions and 35 deletions
@@ -35,44 +35,42 @@ BasePill {
}
}
onRightClicked: (rx, ry) => {
onRightClicked: {
const screen = root.parentScreen || Screen;
if (!screen)
return;
const globalPos = root.visualContent.mapToItem(null, 0, 0);
const isVertical = root.axis?.isVertical ?? false;
const edge = root.axis?.edge ?? "top";
const gap = Math.max(Theme.spacingXS, root.barSpacing ?? Theme.spacingXS);
const barOffset = root.barThickness + root.barSpacing + gap;
const localPos = root.visualContent.mapToItem(null, root.visualContent.width / 2, root.visualContent.height / 2);
let anchorX;
let anchorY;
let anchorEdge;
if (isVertical) {
anchorY = globalPos.y - (screen.y || 0) + root.visualContent.height / 2;
if (edge === "left") {
anchorX = barOffset;
anchorEdge = "top";
} else {
anchorX = screen.width - barOffset;
anchorEdge = "top";
}
anchorX = edge === "left" ? barOffset : screen.width - barOffset;
anchorY = localPos.y;
} else {
anchorX = globalPos.x - (screen.x || 0) + root.visualContent.width / 2;
if (edge === "bottom") {
anchorY = screen.height - barOffset;
anchorEdge = "bottom";
} else {
anchorY = barOffset;
anchorEdge = "top";
}
anchorX = localPos.x;
anchorY = edge === "bottom" ? screen.height - barOffset : barOffset;
}
dndPopupLoader.active = true;
const popup = dndPopupLoader.item;
if (!popup)
return;
popup.showAt(anchorX, anchorY, screen, anchorEdge);
popup.showAt(anchorX, anchorY, isVertical, edge, screen);
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.MiddleButton
onPressed: mouse => {
root.triggerRipple(this, mouse.x, mouse.y);
SessionData.setDoNotDisturb(!SessionData.doNotDisturb);
}
}
Loader {
@@ -31,14 +31,16 @@ PanelWindow {
}
property point anchorPos: Qt.point(0, 0)
property string anchorEdge: "top"
property bool isVertical: false
property string edge: "top"
visible: false
function showAt(x, y, targetScreen, edge) {
function showAt(x, y, vertical, barEdge, targetScreen) {
if (targetScreen)
root.screen = targetScreen;
anchorPos = Qt.point(x, y);
anchorEdge = edge || "top";
isVertical = vertical ?? false;
edge = barEdge ?? "top";
visible = true;
}
@@ -66,21 +68,19 @@ PanelWindow {
visible: root.visible
x: {
const left = 10;
const right = root.width - width - 10;
const want = root.anchorPos.x - width / 2;
return Math.max(left, Math.min(right, want));
if (root.isVertical) {
if (root.edge === "left")
return Math.min(root.width - width - 10, root.anchorPos.x);
return Math.max(10, root.anchorPos.x - width);
}
return Math.max(10, Math.min(root.width - width - 10, root.anchorPos.x - width / 2));
}
y: {
switch (root.anchorEdge) {
case "bottom":
return Math.max(10, root.anchorPos.y - height);
case "left":
case "right":
if (root.isVertical)
return Math.max(10, Math.min(root.height - height - 10, root.anchorPos.y - height / 2));
default:
return Math.min(root.height - height - 10, root.anchorPos.y);
}
if (root.edge === "bottom")
return Math.max(10, root.anchorPos.y - height);
return Math.min(root.height - height - 10, root.anchorPos.y);
}
onDismissed: root.closeMenu()