Move side pane props and stuff to SidePane.qml

This commit is contained in:
miruka 2019-07-16 08:52:26 -04:00
parent 522b689ce7
commit 4be4834883
2 changed files with 38 additions and 31 deletions

View File

@ -7,18 +7,50 @@ import "../Base"
HRectangle { HRectangle {
id: sidePane id: sidePane
clip: true // Avoid artifacts when collapsed
visible: mainUI.accountsPresent
// Avoid artifacts when collapsed
clip: true // Properties that may be set externally
property int parentWidth: parent.width
onParentWidthChanged: if (canAutoSize) { width = getWidth() }
property bool canAutoSize: true
// Pane state properties - should not be modified
readonly property bool reduced: width < 1 readonly property bool reduced: width < 1
readonly property bool collapsed: readonly property bool collapsed:
width < theme.sidePane.collapsedWidth + theme.spacing width < theme.sidePane.collapsedWidth + theme.spacing
property int currentSpacing: collapsed ? 0 : theme.spacing property int currentSpacing: collapsed ? 0 : theme.spacing
Behavior on currentSpacing { HNumberAnimation {} } Behavior on currentSpacing { 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

View File

@ -38,36 +38,11 @@ Item {
SidePane { SidePane {
id: sidePane id: sidePane
visible: accountsPresent canAutoSize: uiSplitView.canAutoSize
property QtObject ts: theme.sidePane width: getWidth() // Initial width
Layout.minimumWidth: theme.sidePane.collapsedWidth
function set_width() {
width =
parent.width * ts.autoWidthRatio <
ts.autoCollapseBelowWidth ?
Layout.minimumWidth :
Math.min(parent.width * ts.autoWidthRatio,
ts.maximumAutoWidth)
}
property int parentWidth: parent.width
onParentWidthChanged: if (uiSplitView.canAutoSize) { set_width() }
width: set_width() // Initial width
Layout.minimumWidth: ts.collapsedWidth
Layout.maximumWidth: parent.width Layout.maximumWidth: parent.width
Behavior on width {
HNumberAnimation {
// Don't slow down the user manually resizing
duration: (
uiSplitView.canAutoSize &&
parent.width * 0.3 <
theme.sidePane.autoReduceBelowWidth * 1.2
) ? theme.animationDuration : 0
}
}
} }
StackView { StackView {