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