Use KConfig.WindowStateSaver to handle window geometry

BUG: 491091
This commit is contained in:
Eamonn Rea 2025-01-03 12:49:47 +00:00 committed by Bart De Vries
parent f95ec063aa
commit 68fee587c2
No known key found for this signature in database
GPG Key ID: 7285665DA6E2D42B
2 changed files with 9 additions and 34 deletions

View File

@ -18,7 +18,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(KF_MIN_VERSION "6.0.0")
set(KF_MIN_VERSION "6.5.0")
set(QT_MIN_VERSION "6.4.0")
find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE)

View File

@ -12,6 +12,7 @@ import QtQuick.Effects
import QtCore
import org.kde.kirigami as Kirigami
import org.kde.config as KConfig
import org.kde.kasts
import org.kde.kasts.settings
@ -25,8 +26,9 @@ Kirigami.ApplicationWindow {
title: i18n("Kasts")
property bool isMobile: Kirigami.Settings.isMobile
width: isMobile ? 360 : 800
height: isMobile ? 660 : 600
width: isMobile ? Kirigami.Units.gridUnit * 20 : Kirigami.Units.gridUnit * 45
height: isMobile ? Kirigami.Units.gridUnit * 37 : Kirigami.Units.gridUnit * 34
pageStack.clip: true
pageStack.popHiddenPages: true
@ -81,47 +83,20 @@ Kirigami.ApplicationWindow {
}
}
KConfig.WindowStateSaver {
configGroupName: "MainWindow"
}
Settings {
id: settings
property alias x: kastsMainWindow.x
property alias y: kastsMainWindow.y
property var mobileWidth
property var mobileHeight
property var desktopWidth
property var desktopHeight
property int headerSize: Kirigami.Units.gridUnit * 5
property alias lastOpenedPage: kastsMainWindow.currentPage
property alias feedSorting: kastsMainWindow.feedSorting
property int episodeListFilterType: AbstractEpisodeProxyModel.NoFilter
}
function saveWindowLayout() {
if (isMobile) {
settings.mobileWidth = kastsMainWindow.width;
settings.mobileHeight = kastsMainWindow.height;
} else {
settings.desktopWidth = kastsMainWindow.width;
settings.desktopHeight = kastsMainWindow.height;
}
}
function restoreWindowLayout() {
if (isMobile) {
if (settings.mobileWidth) kastsMainWindow.width = settings.mobileWidth;
if (settings.mobileHeight) kastsMainWindow.height = settings.mobileHeight;
} else {
if (settings.desktopWidth) kastsMainWindow.width = settings.desktopWidth;
if (settings.desktopHeight) kastsMainWindow.height = settings.desktopHeight;
}
}
Component.onDestruction: {
saveWindowLayout();
}
Component.onCompleted: {
restoreWindowLayout();
pageStack.initialPage = getPage(currentPage);
// Delete played enclosures if set in settings