Add sidePane settings to theme

This commit is contained in:
miruka 2019-07-16 08:36:11 -04:00
parent 5cc701113e
commit 522b689ce7
3 changed files with 26 additions and 11 deletions

View File

@ -11,7 +11,10 @@ HRectangle {
// Avoid artifacts when collapsed
clip: true
property bool collapsed: false
readonly property bool reduced: width < 1
readonly property bool collapsed:
width < theme.sidePane.collapsedWidth + theme.spacing
property int currentSpacing: collapsed ? 0 : theme.spacing
Behavior on currentSpacing { HNumberAnimation {} }

View File

@ -66,6 +66,14 @@ QtObject {
}
property QtObject sidePane: QtObject {
property real autoWidthRatio: 0.3
property int maximumAutoWidth: 300
property int autoCollapseBelowWidth: 120
property int collapsedWidth: avatar.size
property int autoReduceBelowWidth:
minimumSupportedWidth + collapsedWidth
property color background: colors.background2
property QtObject account: QtObject {

View File

@ -39,29 +39,33 @@ Item {
SidePane {
id: sidePane
visible: accountsPresent
collapsed: width < Layout.minimumWidth + theme.spacing
property int parentWidth: parent.width
property int collapseBelow: 120
property QtObject ts: theme.sidePane
function set_width() {
width = parent.width * 0.3 < collapseBelow ?
Layout.minimumWidth : Math.min(parent.width * 0.3, 300)
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: theme.avatar.size
Layout.minimumWidth: ts.collapsedWidth
Layout.maximumWidth: parent.width
Behavior on width {
HNumberAnimation {
// Don't slow down the user manually resizing
duration:
(uiSplitView.canAutoSize &&
parent.width * 0.3 < sidePane.collapseBelow * 1.2) ?
theme.animationDuration : 0
duration: (
uiSplitView.canAutoSize &&
parent.width * 0.3 <
theme.sidePane.autoReduceBelowWidth * 1.2
) ? theme.animationDuration : 0
}
}
}