From 9003c6066722f282f7df412216d06800a0cb1c00 Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Wed, 22 Oct 2025 09:39:24 -0400 Subject: [PATCH] DirectWidgetSettingsPanel --- Modules/Bar/Widgets/SystemMonitor.qml | 4 +- .../Settings/DirectWidgetSettingsPanel.qml | 64 +++++++++++++++++++ Modules/Settings/SettingsPanel.qml | 12 ---- Modules/Settings/Tabs/BarTab.qml | 30 --------- Widgets/NPanel.qml | 4 +- shell.qml | 5 ++ 6 files changed, 74 insertions(+), 45 deletions(-) create mode 100644 Modules/Settings/DirectWidgetSettingsPanel.qml diff --git a/Modules/Bar/Widgets/SystemMonitor.qml b/Modules/Bar/Widgets/SystemMonitor.qml index 691d08c1a..f28b50678 100644 --- a/Modules/Bar/Widgets/SystemMonitor.qml +++ b/Modules/Bar/Widgets/SystemMonitor.qml @@ -351,8 +351,8 @@ Rectangle { anchors.fill: parent acceptedButtons: Qt.RightButton onClicked: { - var settingsPanel = PanelService.getPanel("settingsPanel") - settingsPanel.openWidgetSettings(root.section, root.sectionWidgetIndex, root.widgetId, root.widgetSettings) + var directPanel = PanelService.getPanel("directWidgetSettingsPanel") + directPanel.openWidgetSettings(root.section, root.sectionWidgetIndex, root.widgetId, root.widgetSettings) } } } diff --git a/Modules/Settings/DirectWidgetSettingsPanel.qml b/Modules/Settings/DirectWidgetSettingsPanel.qml new file mode 100644 index 000000000..e0d822506 --- /dev/null +++ b/Modules/Settings/DirectWidgetSettingsPanel.qml @@ -0,0 +1,64 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import Quickshell +import Quickshell.Wayland +import qs.Modules.Settings.Tabs +import qs.Commons +import qs.Services +import qs.Widgets + +NPanel { + id: root + + panelBackgroundColor: Color.transparent + panelBorderColor: Color.transparent + + property var requestedWidgetSettings: [] + + panelContent: Item { + + Component.onCompleted: { + Qt.callLater(() => { + var component = Qt.createComponent(Qt.resolvedUrl(Quickshell.shellDir + "/Modules/Settings/Bar/BarWidgetSettingsDialog.qml")) + + function instantiateAndOpen() { + var dialog = component.createObject(Overlay.overlay, { + "widgetIndex": requestedWidgetSettings.widgetIndex, + "widgetData": requestedWidgetSettings.widgetData, + "widgetId": requestedWidgetSettings.widgetId, + "sectionId": requestedWidgetSettings.sectionId + }) + if (dialog) { + dialog.updateWidgetSettings.connect(updateWidgetSettingsInSection) + dialog.open() + } + } + + if (component.status === Component.Ready) { + instantiateAndOpen() + } else { + component.statusChanged.connect(instantiateAndOpen) + } + + // Clear the request after handling + requestedWidgetSettings = [] + }) + } + } + + function openWidgetSettings(section, widgetIndex, widgetId, widgetData) { + requestedWidgetSettings = { + "sectionId": section, + "widgetIndex": widgetIndex, + "widgetId": widgetId, + "widgetData": widgetData + } + open() + } + + function updateWidgetSettingsInSection(section, index, settings) { + Settings.data.bar.widgets[section][index] = settings + close() + } +} diff --git a/Modules/Settings/SettingsPanel.qml b/Modules/Settings/SettingsPanel.qml index 3a0962c74..c23c9f883 100644 --- a/Modules/Settings/SettingsPanel.qml +++ b/Modules/Settings/SettingsPanel.qml @@ -44,7 +44,6 @@ NPanel { property int requestedTab: SettingsPanel.Tab.General property int currentTabIndex: 0 - property var requestedWidgetSettings: [] property var tabsModel: [] property var activeScrollView: null @@ -240,17 +239,6 @@ NPanel { root.currentTabIndex = initialIndex } - function openWidgetSettings(section, widgetIndex, widgetId, widgetData) { - settingsPanel.requestedWidgetSettings = { - "sectionId": section, - "widgetIndex": widgetIndex, - "widgetId": widgetId, - "widgetData": widgetData - } - settingsPanel.requestedTab = SettingsPanel.Tab.Bar - settingsPanel.open() - } - // Add scroll functions function scrollDown() { if (activeScrollView && activeScrollView.ScrollBar.vertical) { diff --git a/Modules/Settings/Tabs/BarTab.qml b/Modules/Settings/Tabs/BarTab.qml index 56851fd01..a9552659b 100644 --- a/Modules/Settings/Tabs/BarTab.qml +++ b/Modules/Settings/Tabs/BarTab.qml @@ -412,36 +412,6 @@ ColumnLayout { Component.onCompleted: { updateAvailableWidgetsModel() - - // This code is only used when we open settings directly from the widget - // Check if there's a widget settings request - if (settingsPanel.requestedWidgetSettings && Object.keys(settingsPanel.requestedWidgetSettings).length > 0) { - Qt.callLater(() => { - var component = Qt.createComponent(Qt.resolvedUrl(Quickshell.shellDir + "/Modules/Settings/Bar/BarWidgetSettingsDialog.qml")) - - function instantiateAndOpen() { - var dialog = component.createObject(Overlay.overlay, { - "widgetIndex": settingsPanel.requestedWidgetSettings.widgetIndex, - "widgetData": settingsPanel.requestedWidgetSettings.widgetData, - "widgetId": settingsPanel.requestedWidgetSettings.widgetId, - "sectionId": settingsPanel.requestedWidgetSettings.sectionId - }) - if (dialog) { - dialog.updateWidgetSettings.connect(_updateWidgetSettingsInSection) - dialog.open() - } - } - - if (component.status === Component.Ready) { - instantiateAndOpen() - } else { - component.statusChanged.connect(instantiateAndOpen) - } - - // Clear the request after handling - settingsPanel.requestedWidgetSettings = [] - }) - } } Connections { diff --git a/Widgets/NPanel.qml b/Widgets/NPanel.qml index ab1e143a2..00327550c 100644 --- a/Widgets/NPanel.qml +++ b/Widgets/NPanel.qml @@ -17,6 +17,7 @@ Loader { property real preferredWidthRatio property real preferredHeightRatio property color panelBackgroundColor: Color.mSurface + property color panelBorderColor: Color.mOutline property bool draggable: false property var buttonItem: null property string buttonName: "" @@ -198,8 +199,9 @@ Loader { id: panelBackground color: panelBackgroundColor radius: Style.radiusL - border.color: Color.mOutline + border.color: panelBorderColor border.width: Style.borderS + // Dragging support property bool draggable: root.draggable property bool isDragged: false diff --git a/shell.qml b/shell.qml index 16227fd14..ffa34b54c 100644 --- a/shell.qml +++ b/shell.qml @@ -141,6 +141,11 @@ ShellRoot { objectName: "settingsPanel" } + DirectWidgetSettingsPanel { + id: directWidgetSettingsPanel + objectName: "directWidgetSettingsPanel" + } + NotificationHistoryPanel { id: notificationHistoryPanel objectName: "notificationHistoryPanel"