Save and restore window size

This commit is contained in:
Carl Schwan
2020-12-30 13:19:16 +00:00
parent 4463e3e3f2
commit 8224d3ae9f
4 changed files with 44 additions and 2 deletions

View File

@@ -6,6 +6,7 @@
*/
import QtQuick 2.14
import QtQuick.Controls 2.14 as QQC2
import QtQuick.Window 2.2
import QtQuick.Layouts 1.14
import org.kde.kirigami 2.12 as Kirigami
@@ -34,6 +35,23 @@ Kirigami.ApplicationWindow {
}
}
onClosing: Controller.saveWindowGeometry(root)
// This timer allows to batch update the window size change to reduce
// the io load and also work around the fact that x/y/width/height are
// changed when loading the page and overwrite the saved geometry from
// the previous session.
Timer {
id: saveWindowGeometryTimer
interval: 1000
onTriggered: Controller.saveWindowGeometry(root)
}
onWidthChanged: saveWindowGeometryTimer.restart()
onHeightChanged: saveWindowGeometryTimer.restart()
onXChanged: saveWindowGeometryTimer.restart()
onYChanged: saveWindowGeometryTimer.restart()
/**
* Manage opening and close rooms
*/