2019-07-13 19:39:01 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2019-04-29 05:18:36 +10:00
|
|
|
import "../Base"
|
2019-08-18 10:29:56 +10:00
|
|
|
import "../utils.js" as Utils
|
2019-03-26 18:19:55 +11:00
|
|
|
|
2019-08-28 12:46:31 +10:00
|
|
|
Rectangle {
|
2019-03-26 18:19:55 +11:00
|
|
|
id: sidePane
|
2019-08-18 17:27:00 +10:00
|
|
|
clip: true
|
2019-07-18 03:34:02 +10:00
|
|
|
opacity: mainUI.accountsPresent && ! reduce ? 1 : 0
|
|
|
|
visible: opacity > 0
|
2019-04-29 01:01:38 +10:00
|
|
|
|
2019-07-24 16:14:34 +10:00
|
|
|
color: theme.sidePane.background
|
|
|
|
|
2019-08-31 03:48:24 +10:00
|
|
|
property bool hasFocus: toolBar.filterField.activeFocus
|
2019-08-31 01:05:11 +10:00
|
|
|
property alias sidePaneList: sidePaneList
|
2019-08-31 03:48:24 +10:00
|
|
|
property alias toolBar: toolBar
|
2019-08-18 05:58:32 +10:00
|
|
|
|
2019-07-17 02:37:11 +10:00
|
|
|
property real autoWidthRatio: theme.sidePane.autoWidthRatio
|
2019-07-18 03:34:02 +10:00
|
|
|
property bool manuallyResizing: false
|
|
|
|
property bool manuallyResized: false
|
|
|
|
property int manualWidth: 0
|
2019-08-18 03:35:43 +10:00
|
|
|
property bool animateWidth: true
|
2019-07-16 22:52:26 +10:00
|
|
|
|
2019-07-21 23:08:22 +10:00
|
|
|
Component.onCompleted: {
|
|
|
|
if (window.uiState.sidePaneManualWidth) {
|
|
|
|
manualWidth = window.uiState.sidePaneManualWidth
|
|
|
|
manuallyResized = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-31 03:48:24 +10:00
|
|
|
onFocusChanged: if (focus) toolBar.filterField.forceActiveFocus()
|
2019-08-20 03:55:21 +10:00
|
|
|
|
2019-07-21 23:08:22 +10:00
|
|
|
onManualWidthChanged: {
|
|
|
|
window.uiState.sidePaneManualWidth = manualWidth
|
|
|
|
window.uiStateChanged()
|
|
|
|
}
|
|
|
|
|
2019-07-18 03:34:02 +10:00
|
|
|
property int maximumCalculatedWidth: Math.min(
|
|
|
|
manuallyResized ? manualWidth : theme.sidePane.maximumAutoWidth,
|
|
|
|
window.width - theme.minimumSupportedWidthPlusSpacing
|
|
|
|
)
|
|
|
|
|
|
|
|
property int parentWidth: parent.width
|
|
|
|
// Needed for SplitView since it breaks the binding when user manual sizes
|
|
|
|
onParentWidthChanged: width = Qt.binding(() => implicitWidth)
|
2019-07-16 22:52:26 +10:00
|
|
|
|
|
|
|
|
2019-07-18 03:34:02 +10:00
|
|
|
property int calculatedWidth: Math.min(
|
2019-07-21 23:08:22 +10:00
|
|
|
manuallyResized ? manualWidth : parentWidth * autoWidthRatio,
|
2019-07-18 03:34:02 +10:00
|
|
|
maximumCalculatedWidth
|
|
|
|
)
|
2019-07-12 12:25:50 +10:00
|
|
|
|
2019-07-16 23:21:45 +10:00
|
|
|
property bool collapse:
|
2019-07-18 03:34:02 +10:00
|
|
|
(manuallyResizing ? width : calculatedWidth) <
|
|
|
|
(manuallyResized ?
|
|
|
|
(theme.sidePane.collapsedWidth + theme.spacing * 2) :
|
|
|
|
theme.sidePane.autoCollapseBelowWidth)
|
2019-07-16 22:36:11 +10:00
|
|
|
|
2019-07-16 23:21:45 +10:00
|
|
|
property bool reduce:
|
|
|
|
window.width < theme.sidePane.autoReduceBelowWindowWidth
|
2019-05-13 05:57:18 +10:00
|
|
|
|
2019-07-16 23:21:45 +10:00
|
|
|
property int implicitWidth:
|
|
|
|
reduce ? 0 :
|
|
|
|
collapse ? theme.sidePane.collapsedWidth :
|
2019-07-18 03:34:02 +10:00
|
|
|
calculatedWidth
|
2019-07-16 22:52:26 +10:00
|
|
|
|
2019-07-17 07:08:06 +10:00
|
|
|
property int currentSpacing:
|
2019-07-18 03:34:02 +10:00
|
|
|
width <= theme.sidePane.collapsedWidth + theme.spacing * 2 ?
|
|
|
|
0 : theme.spacing
|
2019-07-16 22:52:26 +10:00
|
|
|
|
2019-07-16 23:21:45 +10:00
|
|
|
Behavior on currentSpacing { HNumberAnimation {} }
|
2019-08-18 03:35:43 +10:00
|
|
|
Behavior on implicitWidth {
|
|
|
|
HNumberAnimation { factor: animateWidth ? 1 : 0 }
|
|
|
|
}
|
2019-07-16 22:52:26 +10:00
|
|
|
|
|
|
|
|
2019-08-21 03:27:13 +10:00
|
|
|
function setFocus() {
|
|
|
|
forceActiveFocus()
|
|
|
|
if (reduce) {
|
|
|
|
pageLoader.item.currentIndex = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-21 03:41:55 +10:00
|
|
|
Keys.enabled: sidePane.hasFocus
|
2019-08-31 01:05:11 +10:00
|
|
|
Keys.onUpPressed: sidePaneList.previous(false) // do not activate
|
|
|
|
Keys.onDownPressed: sidePaneList.next(false)
|
2019-08-21 03:41:55 +10:00
|
|
|
Keys.onEnterPressed: Keys.onReturnPressed(event)
|
|
|
|
Keys.onReturnPressed: if (event.modifiers & Qt.ShiftModifier) {
|
2019-08-31 01:05:11 +10:00
|
|
|
sidePaneList.toggleCollapseAccount()
|
2019-08-21 03:41:55 +10:00
|
|
|
} else {
|
2019-09-08 06:39:14 +10:00
|
|
|
if (window.settings.clearRoomFilterOnEnter) {
|
|
|
|
mainUI.sidePane.toolBar.roomFilter = ""
|
|
|
|
}
|
|
|
|
|
2019-08-31 01:05:11 +10:00
|
|
|
sidePaneList.activate()
|
2019-08-21 03:41:55 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HColumnLayout {
|
2019-03-26 18:19:55 +11:00
|
|
|
anchors.fill: parent
|
|
|
|
|
2019-08-31 01:05:11 +10:00
|
|
|
SidePaneList {
|
|
|
|
id: sidePaneList
|
2019-08-18 17:27:00 +10:00
|
|
|
clip: true
|
|
|
|
|
2019-03-26 18:19:55 +11:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
|
2019-08-31 01:05:11 +10:00
|
|
|
SidePaneToolBar {
|
2019-08-31 03:48:24 +10:00
|
|
|
id: toolBar
|
2019-07-03 03:59:52 +10:00
|
|
|
}
|
2019-03-26 18:19:55 +11:00
|
|
|
}
|
|
|
|
}
|