Big code cleanup for SidePane.qml
This commit is contained in:
parent
4be4834883
commit
797d63b988
|
@ -11,46 +11,40 @@ HRectangle {
|
||||||
visible: mainUI.accountsPresent
|
visible: mainUI.accountsPresent
|
||||||
|
|
||||||
|
|
||||||
// Properties that may be set externally
|
|
||||||
|
|
||||||
property int parentWidth: parent.width
|
|
||||||
onParentWidthChanged: if (canAutoSize) { width = getWidth() }
|
|
||||||
|
|
||||||
property bool canAutoSize: true
|
property bool canAutoSize: true
|
||||||
|
property int parentWidth: parent.width
|
||||||
|
|
||||||
|
// Needed for SplitView because it breaks the binding on collapse
|
||||||
|
onParentWidthChanged: if (canAutoSize) {
|
||||||
|
width = Qt.binding(() => implicitWidth)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Pane state properties - should not be modified
|
property int autoWidth:
|
||||||
|
Math.min(
|
||||||
|
parentWidth * theme.sidePane.autoWidthRatio,
|
||||||
|
theme.sidePane.maximumAutoWidth
|
||||||
|
)
|
||||||
|
|
||||||
readonly property bool reduced: width < 1
|
property bool collapse:
|
||||||
readonly property bool collapsed:
|
canAutoSize ?
|
||||||
width < theme.sidePane.collapsedWidth + theme.spacing
|
autoWidth < theme.sidePane.autoCollapseBelowWidth :
|
||||||
|
width < theme.sidePane.autoCollapseBelowWidth
|
||||||
|
|
||||||
|
property bool reduce:
|
||||||
|
window.width < theme.sidePane.autoReduceBelowWindowWidth
|
||||||
|
|
||||||
|
property int implicitWidth:
|
||||||
|
reduce ? 0 :
|
||||||
|
collapse ? theme.sidePane.collapsedWidth :
|
||||||
|
autoWidth
|
||||||
|
|
||||||
|
property int currentSpacing: collapse ? 0 : theme.spacing
|
||||||
|
|
||||||
property int currentSpacing: collapsed ? 0 : theme.spacing
|
|
||||||
Behavior on currentSpacing { HNumberAnimation {} }
|
Behavior on currentSpacing { HNumberAnimation {} }
|
||||||
|
Behavior on implicitWidth { HNumberAnimation {} }
|
||||||
|
|
||||||
|
|
||||||
// Width functions and animations
|
|
||||||
|
|
||||||
function getWidth() {
|
|
||||||
var ts = theme.sidePane
|
|
||||||
return parentWidth * ts.autoWidthRatio < ts.autoCollapseBelowWidth ?
|
|
||||||
ts.collapsedWidth :
|
|
||||||
Math.min(parentWidth * ts.autoWidthRatio, ts.maximumAutoWidth)
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on width {
|
|
||||||
HNumberAnimation {
|
|
||||||
// Don't slow down the user manually resizing
|
|
||||||
duration: (
|
|
||||||
canAutoSize &&
|
|
||||||
parentWidth * 0.3 < theme.sidePane.autoReduceBelowWidth * 1.2
|
|
||||||
) ? theme.animationDuration : 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Pane content
|
|
||||||
|
|
||||||
HColumnLayout {
|
HColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,8 @@ QtObject {
|
||||||
|
|
||||||
property int autoCollapseBelowWidth: 120
|
property int autoCollapseBelowWidth: 120
|
||||||
property int collapsedWidth: avatar.size
|
property int collapsedWidth: avatar.size
|
||||||
property int autoReduceBelowWidth:
|
|
||||||
|
property int autoReduceBelowWindowWidth:
|
||||||
minimumSupportedWidth + collapsedWidth
|
minimumSupportedWidth + collapsedWidth
|
||||||
|
|
||||||
property color background: colors.background2
|
property color background: colors.background2
|
||||||
|
|
|
@ -40,7 +40,7 @@ Item {
|
||||||
id: sidePane
|
id: sidePane
|
||||||
canAutoSize: uiSplitView.canAutoSize
|
canAutoSize: uiSplitView.canAutoSize
|
||||||
|
|
||||||
width: getWidth() // Initial width
|
width: implicitWidth // Initial width
|
||||||
Layout.minimumWidth: theme.sidePane.collapsedWidth
|
Layout.minimumWidth: theme.sidePane.collapsedWidth
|
||||||
Layout.maximumWidth: parent.width
|
Layout.maximumWidth: parent.width
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user