mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
DirectWidgetSettingsPanel
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+3
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user