BarWidgets: All the right click contextual menus. Fix #541

This commit is contained in:
ItsLemmy
2025-11-17 22:47:17 -05:00
parent f3207b526f
commit c407edb4e9
27 changed files with 951 additions and 68 deletions
+46 -1
View File
@@ -4,6 +4,7 @@ import QtQuick.Layouts
import Quickshell
import Quickshell.Wayland
import qs.Commons
import qs.Modules.Bar.Extras
import qs.Services.System
import qs.Services.UI
import qs.Widgets
@@ -56,12 +57,56 @@ NIconButton {
colorBorder: Color.transparent
colorBorderHover: Color.transparent
NPopupContextMenu {
id: contextMenu
model: [
{
"label": NotificationService.doNotDisturb ? I18n.tr("context-menu.disable-dnd") : I18n.tr("context-menu.enable-dnd"),
"action": "toggle-dnd",
"icon": NotificationService.doNotDisturb ? "bell" : "bell-off"
},
{
"label": I18n.tr("context-menu.clear-history"),
"action": "clear-history",
"icon": "trash"
},
{
"label": I18n.tr("context-menu.widget-settings"),
"action": "widget-settings",
"icon": "settings"
},
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
if (action === "toggle-dnd") {
NotificationService.doNotDisturb = !NotificationService.doNotDisturb;
} else if (action === "clear-history") {
NotificationService.clearHistory();
} else if (action === "widget-settings") {
BarService.openWidgetSettings(screen, section, sectionWidgetIndex, widgetId, widgetSettings);
}
}
}
onClicked: {
var panel = PanelService.getPanel("notificationHistoryPanel", screen);
panel?.toggle(this);
}
onRightClicked: NotificationService.doNotDisturb = !NotificationService.doNotDisturb
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
const pos = BarService.getContextMenuPosition(root, contextMenu.implicitWidth, contextMenu.implicitHeight);
contextMenu.openAtItem(root, pos.x, pos.y);
popupMenuWindow.showContextMenu(contextMenu);
}
}
Loader {
anchors.right: parent.right