mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-08-14 18:14:21 +00:00
DirectWidgetSettingsPanel
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user