Add sidePane settings to theme
This commit is contained in:
parent
5cc701113e
commit
522b689ce7
|
@ -11,7 +11,10 @@ HRectangle {
|
||||||
// Avoid artifacts when collapsed
|
// Avoid artifacts when collapsed
|
||||||
clip: true
|
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
|
property int currentSpacing: collapsed ? 0 : theme.spacing
|
||||||
|
|
||||||
Behavior on currentSpacing { HNumberAnimation {} }
|
Behavior on currentSpacing { HNumberAnimation {} }
|
||||||
|
|
|
@ -66,6 +66,14 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
property QtObject sidePane: 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 color background: colors.background2
|
||||||
|
|
||||||
property QtObject account: QtObject {
|
property QtObject account: QtObject {
|
||||||
|
|
|
@ -39,29 +39,33 @@ Item {
|
||||||
SidePane {
|
SidePane {
|
||||||
id: sidePane
|
id: sidePane
|
||||||
visible: accountsPresent
|
visible: accountsPresent
|
||||||
collapsed: width < Layout.minimumWidth + theme.spacing
|
|
||||||
|
|
||||||
property int parentWidth: parent.width
|
property QtObject ts: theme.sidePane
|
||||||
property int collapseBelow: 120
|
|
||||||
|
|
||||||
function set_width() {
|
function set_width() {
|
||||||
width = parent.width * 0.3 < collapseBelow ?
|
width =
|
||||||
Layout.minimumWidth : Math.min(parent.width * 0.3, 300)
|
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() }
|
onParentWidthChanged: if (uiSplitView.canAutoSize) { set_width() }
|
||||||
|
|
||||||
width: set_width() // Initial width
|
width: set_width() // Initial width
|
||||||
Layout.minimumWidth: theme.avatar.size
|
Layout.minimumWidth: ts.collapsedWidth
|
||||||
Layout.maximumWidth: parent.width
|
Layout.maximumWidth: parent.width
|
||||||
|
|
||||||
Behavior on width {
|
Behavior on width {
|
||||||
HNumberAnimation {
|
HNumberAnimation {
|
||||||
// Don't slow down the user manually resizing
|
// Don't slow down the user manually resizing
|
||||||
duration:
|
duration: (
|
||||||
(uiSplitView.canAutoSize &&
|
uiSplitView.canAutoSize &&
|
||||||
parent.width * 0.3 < sidePane.collapseBelow * 1.2) ?
|
parent.width * 0.3 <
|
||||||
theme.animationDuration : 0
|
theme.sidePane.autoReduceBelowWidth * 1.2
|
||||||
|
) ? theme.animationDuration : 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user