SettingsWindow Loading

- reworked the way we load the settings to avoid using
Qt.createComponent which breaks hot reload and more
- introduced a new PanelManager singleton to hold some references to
some panels and later will be used to force having a single panel opened
at all time
This commit is contained in:
quadbyte 2025-08-12 18:58:22 -04:00
parent 0417590221
commit b3002b42b4
5 changed files with 23 additions and 17 deletions

View file

@ -3,9 +3,10 @@ import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import Quickshell import Quickshell
import Quickshell.Wayland import Quickshell.Wayland
import qs.Modules.Settings.Tabs as Tabs
import qs.Services import qs.Services
import qs.Widgets import qs.Widgets
import "Tabs" as Tabs
NLoader { NLoader {
id: root id: root

View file

@ -35,7 +35,7 @@ ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
NText { NText {
text: "Network Settings" text: "Interfaces"
font.pointSize: Style.fontSizeXL * scaling font.pointSize: Style.fontSizeXL * scaling
font.weight: Style.fontWeightBold font.weight: Style.fontWeightBold
color: Colors.textPrimary color: Colors.textPrimary

View file

@ -60,21 +60,7 @@ NBox {
NIconButton { NIconButton {
icon: "settings" icon: "settings"
onClicked: { onClicked: {
if (!root.settingsWindow) { PanelManager.settingsWindow.isLoaded = !PanelManager.settingsWindow.isLoaded
const comp = Qt.createComponent("../../Settings/SettingsWindow.qml")
if (comp.status === Component.Ready) {
root.settingsWindow = comp.createObject(root)
} else {
comp.statusChanged.connect(function () {
if (comp.status === Component.Ready) {
root.settingsWindow = comp.createObject(root)
}
})
}
}
if (root.settingsWindow) {
root.settingsWindow.isLoaded = !root.settingsWindow.isLoaded
}
} }
} }
NIconButton { NIconButton {

10
Services/PanelManager.qml Normal file
View file

@ -0,0 +1,10 @@
pragma Singleton
import Quickshell
import qs.Modules.Settings
Singleton {
id: root
property SettingsWindow settingsWindow: null
}

View file

@ -12,6 +12,7 @@ import qs.Modules.DemoPanel
import qs.Modules.Background import qs.Modules.Background
import qs.Modules.SidePanel import qs.Modules.SidePanel
import qs.Modules.Notification import qs.Modules.Notification
import qs.Modules.Settings
import qs.Services import qs.Services
ShellRoot { ShellRoot {
@ -38,9 +39,17 @@ ShellRoot {
id: calendar id: calendar
} }
SettingsWindow {
id: settingsWindow
}
Component.onCompleted: { Component.onCompleted: {
PanelManager.settingsWindow = settingsWindow
// Ensure our singleton is created as soon as possible // Ensure our singleton is created as soon as possible
// so we start fetching weather asap if necessary // so we start fetching weather asap if necessary
Location.init() Location.init()
} }
} }