Builtin ability to remember size for HDrawer
This commit is contained in:
parent
8c8ba221d3
commit
f65425957b
|
@ -166,11 +166,10 @@ class UIState(JSONConfigFile):
|
||||||
|
|
||||||
async def default_data(self) -> JsonData:
|
async def default_data(self) -> JsonData:
|
||||||
return {
|
return {
|
||||||
"collapseAccounts": {},
|
"collapseAccounts": {},
|
||||||
"page": "Pages/Default.qml",
|
"page": "Pages/Default.qml",
|
||||||
"pageProperties": {},
|
"pageProperties": {},
|
||||||
"sidePaneFilter": "",
|
"sidePaneFilter": "",
|
||||||
"sidePaneManualWidth": None,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,20 +24,25 @@ Drawer {
|
||||||
background: Rectangle { id: bg; color: theme.colors.strongBackground }
|
background: Rectangle { id: bg; color: theme.colors.strongBackground }
|
||||||
|
|
||||||
|
|
||||||
signal userResized(int newWidth)
|
|
||||||
|
|
||||||
property alias color: bg.color
|
property alias color: bg.color
|
||||||
|
|
||||||
property Item referenceSizeParent: parent
|
property int defaultSize: 300
|
||||||
|
|
||||||
property int preferredSize:
|
property int preferredSize:
|
||||||
horizontal ? referenceSizeParent.width : referenceSizeParent.height
|
window.uiState[objectName] ?
|
||||||
|
(window.uiState[objectName].size || defaultSize) :
|
||||||
|
defaultSize
|
||||||
|
|
||||||
property int minimumSize: resizeAreaSize
|
property int minimumSize: resizeAreaSize
|
||||||
property int maximumSize:
|
property int maximumSize:
|
||||||
horizontal ?
|
horizontal ?
|
||||||
referenceSizeParent.width - theme.minimumSupportedWidth :
|
referenceSizeParent.width - theme.minimumSupportedWidth :
|
||||||
referenceSizeParent.height - theme.minimumSupportedHeight
|
referenceSizeParent.height - theme.minimumSupportedHeight
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
property Item referenceSizeParent: parent
|
||||||
|
|
||||||
property bool collapse:
|
property bool collapse:
|
||||||
(horizontal ? window.width : window.height) < 400
|
(horizontal ? window.width : window.height) < 400
|
||||||
property int peekSizeWhileCollapsed:
|
property int peekSizeWhileCollapsed:
|
||||||
|
@ -50,6 +55,8 @@ Drawer {
|
||||||
peekSizeWhileCollapsed :
|
peekSizeWhileCollapsed :
|
||||||
Math.max(minimumSize, Math.min(preferredSize, maximumSize))
|
Math.max(minimumSize, Math.min(preferredSize, maximumSize))
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
readonly property int visibleSize: visible ? width * position : 0
|
readonly property int visibleSize: visible ? width * position : 0
|
||||||
|
|
||||||
readonly property bool horizontal:
|
readonly property bool horizontal:
|
||||||
|
@ -101,7 +108,17 @@ Drawer {
|
||||||
(drawer.edge === Qt.BottomEdge ? -mouseY : mouseY)
|
(drawer.edge === Qt.BottomEdge ? -mouseY : mouseY)
|
||||||
}
|
}
|
||||||
|
|
||||||
onReleased: userResized(drawer.preferredSize)
|
onReleased: {
|
||||||
|
if (! drawer.objectName) {
|
||||||
|
console.warn("Can't save pane size, no objectName set")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
window.uiState[drawer.objectName] = {
|
||||||
|
size: drawer.preferredSize,
|
||||||
|
}
|
||||||
|
window.uiStateChanged()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,9 @@ import "../../Base"
|
||||||
|
|
||||||
HDrawer {
|
HDrawer {
|
||||||
id: roomSidePane
|
id: roomSidePane
|
||||||
|
objectName: "roomPane"
|
||||||
edge: Qt.RightEdge
|
edge: Qt.RightEdge
|
||||||
preferredSize: buttonRepeater.childrenImplicitWidth
|
defaultSize: buttonRepeater.childrenImplicitWidth
|
||||||
minimumSize:
|
minimumSize:
|
||||||
buttonRepeater.count > 0 ? buttonRepeater.itemAt(0).implicitWidth : 0
|
buttonRepeater.count > 0 ? buttonRepeater.itemAt(0).implicitWidth : 0
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,13 @@ import "utils.js" as U
|
||||||
|
|
||||||
HDrawer {
|
HDrawer {
|
||||||
id: debugConsole
|
id: debugConsole
|
||||||
|
objectName: "debugConsole"
|
||||||
edge: Qt.TopEdge
|
edge: Qt.TopEdge
|
||||||
x: horizontal ? 0 : referenceSizeParent.width / 2 - width / 2
|
x: horizontal ? 0 : referenceSizeParent.width / 2 - width / 2
|
||||||
y: vertical ? 0 : referenceSizeParent.height / 2 - height / 2
|
y: vertical ? 0 : referenceSizeParent.height / 2 - height / 2
|
||||||
width: horizontal ? calculatedSize : Math.min(window.width, 720)
|
width: horizontal ? calculatedSize : Math.min(window.width, 720)
|
||||||
height: vertical ? calculatedSize : Math.min(window.height, 720)
|
height: vertical ? calculatedSize : Math.min(window.height, 720)
|
||||||
preferredSize: 400
|
defaultSize: 400
|
||||||
z: 9999
|
z: 9999
|
||||||
position: 0
|
position: 0
|
||||||
|
|
||||||
|
|
|
@ -5,15 +5,10 @@ import "../utils.js" as Utils
|
||||||
|
|
||||||
HDrawer {
|
HDrawer {
|
||||||
id: sidePane
|
id: sidePane
|
||||||
|
objectName: "mainPane"
|
||||||
color: theme.sidePane.background
|
color: theme.sidePane.background
|
||||||
preferredSize: window.uiState.sidePaneManualWidth || 300
|
|
||||||
minimumSize: theme.controls.avatar.size + theme.spacing * 2
|
minimumSize: theme.controls.avatar.size + theme.spacing * 2
|
||||||
|
|
||||||
onUserResized: {
|
|
||||||
window.uiState.sidePaneManualWidth = newWidth
|
|
||||||
window.uiStateChanged()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
property bool hasFocus: toolBar.filterField.activeFocus
|
property bool hasFocus: toolBar.filterField.activeFocus
|
||||||
property alias sidePaneList: sidePaneList
|
property alias sidePaneList: sidePaneList
|
||||||
|
|
Loading…
Reference in New Issue
Block a user