diff --git a/Modules/Bar/Widgets/Volume.qml b/Modules/Bar/Widgets/Volume.qml index 231cca8f..d3b874f5 100644 --- a/Modules/Bar/Widgets/Volume.qml +++ b/Modules/Bar/Widgets/Volume.qml @@ -77,36 +77,35 @@ Item { model: [ { "label": I18n.tr("context-menu.toggle-mute"), - "action": "toggle_mute", + "action": "toggle-mute", "icon": AudioService.muted ? "volume-off" : "volume" }, { "label": I18n.tr("context-menu.open-mixer"), - "action": "open_mixer", + "action": "open-mixer", "icon": "adjustments" - } - // , - // { - // "label": I18n.tr("context-menu.widget-settings"), - // "action": "widget_settings", - // "icon": "settings" - // }, + }, + { + "label": I18n.tr("context-menu.widget-settings"), + "action": "widget-settings", + "icon": "settings" + }, ] onTriggered: action => { - if (action === "toggle_mute") { - AudioService.setOutputMuted(!AudioService.muted); - } else if (action === "open_mixer") { - root.openExternalMixer(); - } else if (action === "widget_settings") - // TODO: Open widget settings - {} - - // Close the popup menu window after handling the action + // Close the popup menu window before handling the action var popupMenuWindow = PanelService.getPopupMenuWindow(screen); if (popupMenuWindow) { popupMenuWindow.close(); } + + if (action === "toggle-mute") { + AudioService.setOutputMuted(!AudioService.muted); + } else if (action === "open-mixer") { + root.openExternalMixer(); + } else if (action === "widget-settings") { + BarService.openWidgetSettings(screen, section, sectionWidgetIndex, widgetId, widgetSettings); + } } } diff --git a/Modules/MainScreen/PopupMenuWindow.qml b/Modules/MainScreen/PopupMenuWindow.qml index b553d0d1..10d58084 100644 --- a/Modules/MainScreen/PopupMenuWindow.qml +++ b/Modules/MainScreen/PopupMenuWindow.qml @@ -87,6 +87,12 @@ PanelWindow { onClicked: root.close() } - // Content will be parented here by the popup - // (e.g., TrayMenu, NPopupContextMenu) + // Container for dialogs that need a full-screen Item parent (e.g., Qt Popup) + Item { + id: dialogContainer + anchors.fill: parent + } + + // Expose the dialog container for external use + readonly property alias dialogParent: dialogContainer } diff --git a/Services/UI/BarService.qml b/Services/UI/BarService.qml index 854d8f02..13781c9a 100644 --- a/Services/UI/BarService.qml +++ b/Services/UI/BarService.qml @@ -294,4 +294,67 @@ Singleton { "y": menuY }; } + + // Open widget settings dialog for a bar widget + // Parameters: + // screen: The screen to show the dialog on + // section: Section id ("left", "center", "right") + // index: Widget index in section + // widgetId: Widget type id (e.g., "Volume") + // widgetData: Current widget settings object + function openWidgetSettings(screen, section, index, widgetId, widgetData) { + // Get the popup menu window to use as parent (avoids clipping issues with bar height) + var popupMenuWindow = PanelService.getPopupMenuWindow(screen); + if (!popupMenuWindow) { + Logger.e("BarService", "No popup menu window found for screen"); + return; + } + + var component = Qt.createComponent(Quickshell.shellDir + "/Modules/Panels/Settings/Bar/BarWidgetSettingsDialog.qml"); + + function instantiateAndOpen() { + // Use dialogParent (Item) instead of window directly for proper Popup anchoring + var dialog = component.createObject(popupMenuWindow.dialogParent, { + "widgetIndex": index, + "widgetData": widgetData, + "widgetId": widgetId, + "sectionId": section + }); + + if (dialog) { + dialog.updateWidgetSettings.connect((sec, idx, settings) => { + var widgets = Settings.data.bar.widgets[sec]; + if (widgets && idx < widgets.length) { + widgets[idx] = Object.assign({}, widgets[idx], settings); + Settings.data.bar.widgets[sec] = widgets; + Settings.saveImmediate(); + } + }); + // Close the popup menu window when dialog closes + dialog.closed.connect(() => { + popupMenuWindow.close(); + dialog.destroy(); + }); + // Show the popup menu window and open the dialog + popupMenuWindow.open(); + dialog.open(); + } else { + Logger.e("BarService", "Failed to create widget settings dialog"); + } + } + + if (component.status === Component.Ready) { + instantiateAndOpen(); + } else if (component.status === Component.Error) { + Logger.e("BarService", "Error loading widget settings dialog:", component.errorString()); + } else { + component.statusChanged.connect(function () { + if (component.status === Component.Ready) { + instantiateAndOpen(); + } else if (component.status === Component.Error) { + Logger.e("BarService", "Error loading widget settings dialog:", component.errorString()); + } + }); + } + } }