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
+40 -1
View File
@@ -1,9 +1,11 @@
import QtQuick
import QtQuick.Controls
import Quickshell
import qs.Commons
import qs.Modules.Bar.Extras
import qs.Services.Networking
import qs.Services.UI
import qs.Widgets
Item {
id: root
@@ -33,6 +35,36 @@ Item {
implicitWidth: pill.width
implicitHeight: pill.height
NPopupContextMenu {
id: contextMenu
model: [
{
"label": BluetoothService.enabled ? I18n.tr("context-menu.disable-bluetooth") : I18n.tr("context-menu.enable-bluetooth"),
"action": "toggle-bluetooth",
"icon": BluetoothService.enabled ? "bluetooth-off" : "bluetooth"
},
{
"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-bluetooth") {
BluetoothService.setBluetoothEnabled(!BluetoothService.enabled);
} else if (action === "widget-settings") {
BarService.openWidgetSettings(screen, section, sectionWidgetIndex, widgetId, widgetSettings);
}
}
}
BarPill {
id: pill
@@ -57,7 +89,14 @@ Item {
forceOpen: !isBarVertical && root.displayMode === "alwaysShow"
forceClose: isBarVertical || root.displayMode === "alwaysHide" || BluetoothService.connectedDevices.length === 0
onClicked: PanelService.getPanel("bluetoothPanel", screen)?.toggle(this)
onRightClicked: BluetoothService.setBluetoothEnabled(!BluetoothService.enabled)
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
const pos = BarService.getContextMenuPosition(pill, contextMenu.implicitWidth, contextMenu.implicitHeight);
contextMenu.openAtItem(pill, pos.x, pos.y);
popupMenuWindow.showContextMenu(contextMenu);
}
}
tooltipText: {
if (pill.text !== "") {
return pill.text;