qml: do not unload playlist window if not visible

This commit is contained in:
Fatih Uzunoglu 2024-04-09 16:46:12 +03:00 committed by Steve Lhomme
parent 62aaef36a8
commit 73bad34911
2 changed files with 15 additions and 12 deletions

View File

@ -136,7 +136,7 @@ Item {
Loader {
id: playlistWindowLoader
asynchronous: true
active: !MainCtx.playlistDocked && MainCtx.playlistVisible
active: !MainCtx.playlistDocked
source: "qrc:///playlist/PlaylistDetachedWindow.qml"
}
Connections {

View File

@ -25,10 +25,10 @@ import "qrc:///style/"
Window {
visible: true
visible: MainCtx.playlistVisible
// TODO: Qt >5.13 use transientParent
property QtWindow parentWindow: MainCtx.intfMainWindow
property QtWindow parentWindow
width: 350
minimumWidth: playlistView.minimumWidth
@ -36,16 +36,19 @@ Window {
title: qsTr("Playlist")
color: theme.bg.primary
Component.onCompleted: {
if (!!parentWindow) {
height = parentWindow.height
minimumHeight = parentWindow.minimumHeight
onVisibleChanged: {
if (visible) {
const window = parentWindow ? parentWindow : MainCtx.intfMainWindow
if (window) {
height = window.height
minimumHeight = window.minimumHeight
x = parentWindow.x + parentWindow.width + 10
y = parentWindow.y
} else {
height = 400
minimumHeight = 200
x = window.x + window.width + 10
y = window.y
} else {
height = 400
minimumHeight = 200
}
}
}