Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions quickshell/Common/TrayMenuManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Singleton {

property var activeTrayMenus: ({})

signal openTrayMenuRequested(string itemId)

function requestOpenTrayMenu(itemId) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this function, its useless

openTrayMenuRequested(itemId)
}

function registerMenu(screenName, menu) {
if (!screenName || !menu) return
const newMenus = Object.assign({}, activeTrayMenus)
Expand Down
12 changes: 12 additions & 0 deletions quickshell/DMSShellIPC.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1976,6 +1976,18 @@ Item {
return `SUCCESS: Activated ${itemId}`;
}

function menu(itemId: string): string {
const item = findTrayItem(itemId);
if (!item)
return `ERROR: Tray item not found: ${itemId}`;

if (!item.hasMenu)
return `ERROR: Tray item has no menu: ${itemId}`;

TrayMenuManager.requestOpenTrayMenu(itemId);
return `SUCCESS: Requested menu ${itemId}`;
}

function status(itemId: string): string {
const item = findTrayItem(itemId);
if (!item)
Expand Down
19 changes: 19 additions & 0 deletions quickshell/Modules/DankBar/Widgets/SystemTrayBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ BasePill {
root.showForTrayItem(trayItem, anchorItem, parentScreen, root.isAtBottom, root.isVerticalOrientation, root.axis);
}

Connections {
target: TrayMenuManager

function onOpenTrayMenuRequested(itemId) {
const item = root.allTrayItems.find(trayItem => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move findTrayItem to TrayMenuManager instead of duplicating the logic

const id = trayItem?.id || "";
const tooltipTitle = trayItem?.tooltipTitle || "";
const fullKey = (!tooltipTitle || tooltipTitle === id) ? id : `${id}::${tooltipTitle}`;
return itemId === id || itemId === fullKey;
});

if (!item || !item.hasMenu)
return;

TrayMenuManager.closeAllMenus();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, already handled by showForTrayItem

root.showForTrayItem(item, root, parentScreen, root.isAtBottom, root.isVerticalOrientation, root.axis);
}
}

function openInlineTrayContextMenu(trayItem, areaItem, mouse, anchorItem) {
if (!trayItem) {
return;
Expand Down
Loading