Add close logic for WallpaperSelector
This commit is contained in:
parent
7844cc2975
commit
8a6b842ed0
2 changed files with 27 additions and 3 deletions
|
|
@ -294,7 +294,14 @@ PanelWithOverlay {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: panelMain.dismiss()
|
onClicked: {
|
||||||
|
// If wallpaper selector is open, close it instead of the settings window
|
||||||
|
if (wallpaperSelector.visible) {
|
||||||
|
wallpaperSelector.hide();
|
||||||
|
} else {
|
||||||
|
panelMain.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,23 +8,38 @@ import qs.Settings
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: wallpaperOverlay
|
id: wallpaperOverlay
|
||||||
|
focus: true
|
||||||
|
|
||||||
// Function to show the overlay and load wallpapers
|
// Function to show the overlay and load wallpapers
|
||||||
function show() {
|
function show() {
|
||||||
// Ensure wallpapers are loaded
|
// Ensure wallpapers are loaded
|
||||||
WallpaperManager.loadWallpapers();
|
WallpaperManager.loadWallpapers();
|
||||||
wallpaperOverlay.visible = true;
|
wallpaperOverlay.visible = true;
|
||||||
|
wallpaperOverlay.forceActiveFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to hide the overlay
|
||||||
|
function hide() {
|
||||||
|
wallpaperOverlay.visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
color: Theme.backgroundPrimary
|
color: Theme.backgroundPrimary
|
||||||
visible: false
|
visible: false
|
||||||
z: 1000
|
z: 1000
|
||||||
|
|
||||||
|
// Handle escape key to close
|
||||||
|
Keys.onPressed: function(event) {
|
||||||
|
if (event.key === Qt.Key_Escape) {
|
||||||
|
wallpaperOverlay.hide();
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Click outside to close
|
// Click outside to close
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
wallpaperOverlay.visible = false;
|
wallpaperOverlay.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,6 +56,8 @@ Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Wallpaper Grid
|
// Wallpaper Grid
|
||||||
Item {
|
Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
@ -133,7 +150,7 @@ Rectangle {
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
WallpaperManager.changeWallpaper(modelData);
|
WallpaperManager.changeWallpaper(modelData);
|
||||||
wallpaperOverlay.visible = false;
|
wallpaperOverlay.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue