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
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.RightButton
|
acceptedButtons: Qt.RightButton
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var settingsPanel = PanelService.getPanel("settingsPanel")
|
var directPanel = PanelService.getPanel("directWidgetSettingsPanel")
|
||||||
settingsPanel.openWidgetSettings(root.section, root.sectionWidgetIndex, root.widgetId, root.widgetSettings)
|
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 requestedTab: SettingsPanel.Tab.General
|
||||||
property int currentTabIndex: 0
|
property int currentTabIndex: 0
|
||||||
property var requestedWidgetSettings: []
|
|
||||||
property var tabsModel: []
|
property var tabsModel: []
|
||||||
property var activeScrollView: null
|
property var activeScrollView: null
|
||||||
|
|
||||||
@@ -240,17 +239,6 @@ NPanel {
|
|||||||
root.currentTabIndex = initialIndex
|
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
|
// Add scroll functions
|
||||||
function scrollDown() {
|
function scrollDown() {
|
||||||
if (activeScrollView && activeScrollView.ScrollBar.vertical) {
|
if (activeScrollView && activeScrollView.ScrollBar.vertical) {
|
||||||
|
|||||||
@@ -412,36 +412,6 @@ ColumnLayout {
|
|||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
updateAvailableWidgetsModel()
|
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 {
|
Connections {
|
||||||
|
|||||||
+3
-1
@@ -17,6 +17,7 @@ Loader {
|
|||||||
property real preferredWidthRatio
|
property real preferredWidthRatio
|
||||||
property real preferredHeightRatio
|
property real preferredHeightRatio
|
||||||
property color panelBackgroundColor: Color.mSurface
|
property color panelBackgroundColor: Color.mSurface
|
||||||
|
property color panelBorderColor: Color.mOutline
|
||||||
property bool draggable: false
|
property bool draggable: false
|
||||||
property var buttonItem: null
|
property var buttonItem: null
|
||||||
property string buttonName: ""
|
property string buttonName: ""
|
||||||
@@ -198,8 +199,9 @@ Loader {
|
|||||||
id: panelBackground
|
id: panelBackground
|
||||||
color: panelBackgroundColor
|
color: panelBackgroundColor
|
||||||
radius: Style.radiusL
|
radius: Style.radiusL
|
||||||
border.color: Color.mOutline
|
border.color: panelBorderColor
|
||||||
border.width: Style.borderS
|
border.width: Style.borderS
|
||||||
|
|
||||||
// Dragging support
|
// Dragging support
|
||||||
property bool draggable: root.draggable
|
property bool draggable: root.draggable
|
||||||
property bool isDragged: false
|
property bool isDragged: false
|
||||||
|
|||||||
@@ -141,6 +141,11 @@ ShellRoot {
|
|||||||
objectName: "settingsPanel"
|
objectName: "settingsPanel"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DirectWidgetSettingsPanel {
|
||||||
|
id: directWidgetSettingsPanel
|
||||||
|
objectName: "directWidgetSettingsPanel"
|
||||||
|
}
|
||||||
|
|
||||||
NotificationHistoryPanel {
|
NotificationHistoryPanel {
|
||||||
id: notificationHistoryPanel
|
id: notificationHistoryPanel
|
||||||
objectName: "notificationHistoryPanel"
|
objectName: "notificationHistoryPanel"
|
||||||
|
|||||||
Reference in New Issue
Block a user