import QtQuick import QtQuick.Controls import QtQuick.Layouts import Quickshell import qs.Commons import qs.Modules.Bar.Extras import qs.Services.UI import qs.Widgets NIconButton { id: root property ShellScreen screen // Widget properties passed from Bar.qml for per-instance settings property string widgetId: "" property string section: "" property int sectionWidgetIndex: -1 property int sectionWidgetsCount: 0 property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { if (section && sectionWidgetIndex >= 0) { var widgets = Settings.data.bar.widgets[section]; if (widgets && sectionWidgetIndex < widgets.length) { return widgets[sectionWidgetIndex]; } } return {}; } readonly property string colorName: widgetSettings.colorName !== undefined ? widgetSettings.colorName : widgetMetadata.colorName readonly property color iconColor: { switch (colorName) { case "primary": return Color.mPrimary; case "secondary": return Color.mSecondary; case "tertiary": return Color.mTertiary; case "error": return Color.mError; case "onSurface": default: return Color.mOnSurface; } } baseSize: Style.capsuleHeight applyUiScale: false customRadius: Style.radiusL icon: "power" tooltipText: I18n.tr("tooltips.session-menu") tooltipDirection: BarService.getTooltipDirection() colorBg: Style.capsuleColor colorFg: root.iconColor colorBorder: "transparent" colorBorderHover: "transparent" border.color: Style.capsuleBorderColor border.width: Style.capsuleBorderWidth NPopupContextMenu { id: contextMenu model: [ { "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 === "widget-settings") { BarService.openWidgetSettings(screen, section, sectionWidgetIndex, widgetId, widgetSettings); } } } onClicked: PanelService.getPanel("sessionMenuPanel", screen)?.toggle() onRightClicked: { var popupMenuWindow = PanelService.getPopupMenuWindow(screen); if (popupMenuWindow) { popupMenuWindow.showContextMenu(contextMenu); contextMenu.openAtItem(root, screen); } } }