Save/load sidePane manually-set width

This commit is contained in:
miruka 2019-07-21 09:08:22 -04:00
parent c0b51b574c
commit daa2c36af1
2 changed files with 16 additions and 3 deletions

View File

@ -99,6 +99,7 @@ class UIState(JSONConfigFile):
async def default_data(self) -> JsonData: async def default_data(self) -> JsonData:
return { return {
"page": "Pages/Default.qml", "page": "Pages/Default.qml",
"pageProperties": {}, "pageProperties": {},
"sidePaneManualWidth": None,
} }

View File

@ -16,6 +16,18 @@ HRectangle {
property bool manuallyResized: false property bool manuallyResized: false
property int manualWidth: 0 property int manualWidth: 0
Component.onCompleted: {
if (window.uiState.sidePaneManualWidth) {
manualWidth = window.uiState.sidePaneManualWidth
manuallyResized = true
}
}
onManualWidthChanged: {
window.uiState.sidePaneManualWidth = manualWidth
window.uiStateChanged()
}
property int maximumCalculatedWidth: Math.min( property int maximumCalculatedWidth: Math.min(
manuallyResized ? manualWidth : theme.sidePane.maximumAutoWidth, manuallyResized ? manualWidth : theme.sidePane.maximumAutoWidth,
window.width - theme.minimumSupportedWidthPlusSpacing window.width - theme.minimumSupportedWidthPlusSpacing
@ -27,7 +39,7 @@ HRectangle {
property int calculatedWidth: Math.min( property int calculatedWidth: Math.min(
manuallyResized ? manualWidth: parentWidth * autoWidthRatio, manuallyResized ? manualWidth : parentWidth * autoWidthRatio,
maximumCalculatedWidth maximumCalculatedWidth
) )