Files
Huỳnh Thiện Lộc 8ff7ce2cea feat(island): add system tray slot and overflow menu to compact home (#3780)
* feat(island): add system tray slot and overflow menu to compact home

- Add system tray slot and overflow expander menu in Dynamic Island
- Share tray icon path resolution and DBus context menu fallback in TrayMenuManager
- Support edge-anchored context menu positioning across top, bottom, left, and right
- Lock bottom and edge anchoring in DContextMenu to prevent animation jitter

* fix(island): only instantiate tray menus when tray slot is enabled

* feat(island): expand tray item and caret click area to slot height

* fix(island): use Theme.surfaceTextHover and restore DContextMenu height behavior

* refactor(tray): extract shared TrayMenuContent and TrayOverflowGrid, support tray order and IPC in island

* Revert "refactor(tray): extract shared TrayMenuContent and TrayOverflowGrid, support tray order and IPC in island"

This reverts commit 29888f89cd.

* refactor(tray): use shared TrayMenuManager helpers and TrayItemIcon, support tray order and IPC in island

* refactor(tray): extract shared TrayMenuContent and TrayOverflowGrid

* feat(island): support tray item drag and drop reordering

* fix(island): prevent re-entrant tray drag reordering on model destruction

* fix(tray): remove native submenu anchor hydration to prevent popup stutter

* fix(tray): decouple submenu hydrator from anchor window to avoid stutter

* fix(tray): restore anchor window on submenu hydrator and disable on island

* tray: fix bar overflow surface & reuse max visible items on the island
2026-10-14 16:55:26 -04:00

98 lines
3.0 KiB
QML

pragma ComponentBehavior: Bound
import QtQuick
import qs.Common
import qs.Widgets
DContextMenu {
id: root
property var hiddenItems: []
property var contextMenu: null
property var parentScreen: null
signal itemActivated(var item)
layerNamespace: "dms:tray-overflow-menu"
minMenuWidth: 0
readonly property real iconSize: Theme.iconSizeSmall
readonly property real itemSize: iconSize + Theme.spacingS
readonly property real iconSpacing: Theme.spacingXXS
readonly property int cols: Math.min(5, Math.max(1, hiddenItems.length))
// DContextMenu has flickable margins Theme.spacingS on both sides
customContentWidth: cols * itemSize + (cols - 1) * iconSpacing + Theme.spacingS * 2
function openAt(targetX, targetY, screen, edge) {
root.menuEdge = edge || "top";
parentScreen = screen;
let menuX = targetX;
let menuY = targetY;
switch (edge) {
case "bottom":
menuX = targetX - effectiveMenuWidth / 2;
menuY = targetY - Theme.spacingXS;
break;
case "left":
menuX = targetX + Theme.spacingXS;
menuY = targetY;
break;
case "right":
menuX = targetX - Theme.spacingXS;
menuY = targetY;
break;
case "top":
default:
menuX = targetX - effectiveMenuWidth / 2;
menuY = targetY + Theme.spacingXS;
break;
}
root.open(screen, menuX, menuY, false);
root.originX = targetX;
root.originY = targetY;
}
customContent: Component {
TrayOverflowGrid {
items: root.hiddenItems
customColumns: root.cols
customIconSize: root.iconSize
customItemSize: root.itemSize
customSpacing: root.iconSpacing
onItemClicked: (item, mouse, itemArea) => {
if (!item)
return;
const screen = root.parentScreen;
if (mouse.button === Qt.RightButton) {
if (item.hasMenu && root.contextMenu) {
root.itemActivated(item);
root.hide();
root.contextMenu.openFor(item, root.originX, root.originY, screen, root.menuEdge);
return;
}
const gp = itemArea.mapToGlobal(mouse.x, mouse.y);
TrayMenuManager.callContextMenuFallback(item.id, gp.x, gp.y);
root.hide();
return;
}
if (!item.onlyMenu) {
item.activate();
root.hide();
return;
}
if (item.hasMenu && root.contextMenu) {
root.itemActivated(item);
root.hide();
root.contextMenu.openFor(item, root.originX, root.originY, screen, root.menuEdge);
}
}
}
}
}