Edit SettingsWindow

This commit is contained in:
Ly-sec 2025-08-07 00:34:33 +02:00
parent 0bfef118dc
commit 6ef29ae745
17 changed files with 283 additions and 130 deletions

View file

@ -70,9 +70,7 @@ PanelWithOverlay {
if (shell && shell.settingsWindow && shell.settingsWindow.visible) {
shell.settingsWindow.visible = false;
}
if (wallpaperPanelLoader.active && wallpaperPanelLoader.item && wallpaperPanelLoader.item.visible) {
wallpaperPanelLoader.item.visible = false;
}
if (wifiPanelLoader.active && wifiPanelLoader.item && wifiPanelLoader.item.visible) {
wifiPanelLoader.item.visible = false;
}
@ -151,19 +149,7 @@ PanelWithOverlay {
component: BluetoothPanel {}
}
// LazyLoader for WallpaperPanel
LazyLoader {
id: wallpaperPanelLoader
loading: false
component: WallpaperPanel {
Component.onCompleted: {
if (parent) {
anchors.top = parent.top;
anchors.right = parent.right;
}
}
}
}
// SettingsIcon component
SettingsIcon {
@ -175,6 +161,8 @@ PanelWithOverlay {
}
}
Item {
anchors.fill: mainRectangle
x: sidebarPopupRect.slideOffset
@ -363,12 +351,11 @@ PanelWithOverlay {
settingsModal.openSettings();
}
}
onWallpaperRequested: {
if (!wallpaperPanelLoader.active) {
wallpaperPanelLoader.loading = true;
}
if (wallpaperPanelLoader.item) {
wallpaperPanelLoader.item.visible = true;
onWallpaperSelectorRequested: {
// Use the SettingsModal's openSettings function with wallpaper tab (index 6)
if (typeof settingsModal !== 'undefined' && settingsModal && settingsModal.openSettings) {
settingsModal.openSettings(6); // 6 is the wallpaper tab index
}
}
}

View file

@ -20,6 +20,7 @@ Rectangle {
signal recordingStateMismatch(bool actualState)
signal settingsRequested()
signal wallpaperRequested()
signal wallpaperSelectorRequested()
Rectangle {
id: card
@ -161,7 +162,7 @@ Rectangle {
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked: {
wallpaperRequested()
wallpaperSelectorRequested()
}
}
}

View file

@ -27,12 +27,25 @@ PanelWindow {
property var settingsWindow: null
// Function to open the modal and initialize temp values
function openSettings() {
function openSettings(initialTabIndex) {
if (!settingsWindow) {
// Create new window
settingsWindow = settingsComponent.createObject(null); // No parent to avoid dependency issues
if (settingsWindow) {
// Set the initial tab if provided
if (typeof initialTabIndex === 'number' && initialTabIndex >= 0 && initialTabIndex <= 8) {
settingsWindow.activeTabIndex = initialTabIndex;
}
settingsWindow.visible = true;
// Show wallpaper selector if opening wallpaper tab (after window is visible)
if (typeof initialTabIndex === 'number' && initialTabIndex === 6) {
Qt.callLater(function() {
if (settingsWindow && settingsWindow.showWallpaperSelector) {
settingsWindow.showWallpaperSelector();
}
}, 100); // Small delay to ensure window is fully loaded
}
// Handle window closure
settingsWindow.visibleChanged.connect(function() {
if (settingsWindow && !settingsWindow.visible) {

View file

@ -0,0 +1,81 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Quickshell
import Quickshell.Wayland
import qs.Settings
import qs.Services
import qs.Widgets.SettingsWindow
import qs.Components
PanelWindow {
id: settingsModal
implicitWidth: 480
implicitHeight: 780
visible: false
color: "transparent"
anchors.top: true
anchors.right: true
margins.right: 0
margins.top: 0
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
// Property to track the settings window instance
property var settingsWindow: null
// Function to open the modal and initialize temp values
function openSettings() {
if (!settingsWindow) {
// Create new window
settingsWindow = settingsComponent.createObject(null); // No parent to avoid dependency issues
if (settingsWindow) {
settingsWindow.visible = true;
// Handle window closure
settingsWindow.visibleChanged.connect(function() {
if (settingsWindow && !settingsWindow.visible) {
var windowToDestroy = settingsWindow;
settingsWindow = null;
windowToDestroy.destroy();
}
});
}
} else if (settingsWindow.visible) {
// Close and destroy window
var windowToDestroy = settingsWindow;
settingsWindow = null;
windowToDestroy.visible = false;
windowToDestroy.destroy();
}
}
// Function to close the modal and release focus
function closeSettings() {
if (settingsWindow) {
var windowToDestroy = settingsWindow;
settingsWindow = null;
windowToDestroy.visible = false;
windowToDestroy.destroy();
}
}
Component {
id: settingsComponent
SettingsWindow {}
}
// Clean up on destruction
Component.onDestruction: {
if (settingsWindow) {
var windowToDestroy = settingsWindow;
settingsWindow = null;
windowToDestroy.destroy();
}
}
// Refresh weather data when hidden
onVisibleChanged: {
if (!visible && typeof weather !== 'undefined' && weather !== null && weather.fetchCityWeather) {
weather.fetchCityWeather();
}
}
}