From 522b689ce77745bdd746946d829fc46162a73bfb Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 16 Jul 2019 08:36:11 -0400 Subject: [PATCH] Add sidePane settings to theme --- src/qml/SidePane/SidePane.qml | 5 ++++- src/qml/Theme.qml | 8 ++++++++ src/qml/UI.qml | 24 ++++++++++++++---------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/qml/SidePane/SidePane.qml b/src/qml/SidePane/SidePane.qml index d2ba7a61..20c44163 100644 --- a/src/qml/SidePane/SidePane.qml +++ b/src/qml/SidePane/SidePane.qml @@ -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 {} } diff --git a/src/qml/Theme.qml b/src/qml/Theme.qml index 5c227489..6552299b 100644 --- a/src/qml/Theme.qml +++ b/src/qml/Theme.qml @@ -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 { diff --git a/src/qml/UI.qml b/src/qml/UI.qml index 214ed1cb..bef1ef89 100644 --- a/src/qml/UI.qml +++ b/src/qml/UI.qml @@ -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 } } }