diff --git a/src/gui/Base/HDrawer.qml b/src/gui/Base/HDrawer.qml index b93bc6eb..c8a942cd 100644 --- a/src/gui/Base/HDrawer.qml +++ b/src/gui/Base/HDrawer.qml @@ -8,7 +8,7 @@ Drawer { property string saveName: "" property var saveId: "ALL" - property var saveProperties: ["preferredSize"] + property var saveProperties: ["preferredSize", "forceCollapse"] // @@ -27,6 +27,9 @@ Drawer { property int snapAt: defaultSize property int snapZone: theme.spacing * 2 + property bool forceCollapse: + window.getState(this, "forceCollapse", false) + // property Item referenceSizeParent: parent @@ -36,7 +39,8 @@ Drawer { window.settings.collapseSidePanesUnderWindowWidth * theme.uiScale property int peekSizeWhileCollapsed: - horizontal ? referenceSizeParent.width : referenceSizeParent.height + (horizontal ? referenceSizeParent.width : referenceSizeParent.height) * + (forceCollapse && ! collapse ? 0.5 : 1) property int resizeAreaSize: theme.spacing / 2 @@ -44,12 +48,12 @@ Drawer { requireDefaultSize ? defaultSize : minimumSize readonly property int calculatedSizeNoRequiredMinimum: - collapse ? + collapse || forceCollapse ? peekSizeWhileCollapsed : Math.max(minimumSize, Math.min(preferredSize, maximumSize)) readonly property int calculatedSize: - collapse ? + collapse || forceCollapse ? peekSizeWhileCollapsed : Math.max(calculatedMinimumSize, Math.min(preferredSize, maximumSize)) @@ -78,14 +82,16 @@ Drawer { // FIXME: https://bugreports.qt.io/browse/QTBUG-59141 // dragMargin: parent.width / 2 - interactive: collapse + interactive: collapse || forceCollapse position: 1 - visible: ! collapse + visible: ! collapse && ! forceCollapse modal: false closePolicy: Popup.NoAutoClose background: Rectangle { id: bg; color: theme.colors.strongBackground } + onForceCollapseChanged: window.saveState(this) + Behavior on width { enabled: horizontal && ! resizeMouseHandler.drag.active NumberAnimation { duration: 100 } diff --git a/src/gui/Pages/Chat/RoomHeader.qml b/src/gui/Pages/Chat/RoomHeader.qml index e6f76c34..b1c513a7 100644 --- a/src/gui/Pages/Chat/RoomHeader.qml +++ b/src/gui/Pages/Chat/RoomHeader.qml @@ -5,10 +5,15 @@ import QtQuick.Layouts 1.12 import "../../Base" Rectangle { - readonly property bool showPaneButtons: mainUI.mainPane.collapse + readonly property bool showLeftButton: + mainUI.mainPane.collapse || mainUI.mainPane.forceCollapse + + readonly property bool showRightButton: + chat.roomPane && + (chat.roomPane.collapse || chat.roomPane.forceCollapse) readonly property bool center: - showPaneButtons || window.settings.alwaysCenterRoomHeader + showLeftButton || window.settings.alwaysCenterRoomHeader implicitHeight: theme.baseElementsHeight @@ -21,7 +26,7 @@ Rectangle { // The layout overflows somehow when focusing the room pane and // is visible behind it (with a transparent theme) - opacity: showPaneButtons && chat.roomPane.visible ? 0 : 1 + opacity: showRightButton && chat.roomPane.visible ? 0 : 1 Behavior on opacity { HNumberAnimation {} } @@ -35,7 +40,7 @@ Rectangle { onClicked: mainUI.mainPane.toggleFocus() - Layout.preferredWidth: showPaneButtons ? avatar.width : 0 + Layout.preferredWidth: showLeftButton ? avatar.width : 0 Layout.fillHeight: true Behavior on Layout.preferredWidth { HNumberAnimation {} } @@ -68,7 +73,9 @@ Rectangle { Layout.preferredWidth: Math.min( implicitWidth, row.width - - row.spacing * (showPaneButtons ? 3 : 1) - + row.spacing + + (showLeftButton ? row.spacing : 0) + + (showRightButton ? row.spacing : 0) + goToMainPaneButton.width - avatar.width - goToRoomPaneButton.width @@ -92,7 +99,9 @@ Rectangle { Layout.preferredWidth: Math.min( implicitWidth, row.width - - row.spacing * (showPaneButtons ? 3 : 1) - + row.spacing + + (showLeftButton ? row.spacing : 0) + + (showRightButton ? row.spacing : 0) + goToMainPaneButton.width - avatar.width - nameLabel.width - @@ -161,14 +170,14 @@ Rectangle { HButton { id: goToRoomPaneButton padded: false - visible: goToMainPaneButton.visible + visible: Layout.preferredWidth > 0 backgroundColor: "transparent" icon.name: "go-to-room-pane" toolTip.text: qsTr("Go to room pane") onClicked: chat.roomPane.toggleFocus() - Layout.preferredWidth: goToMainPaneButton.Layout.preferredWidth + Layout.preferredWidth: showRightButton ? avatar.width : 0 Layout.fillHeight: true } } diff --git a/src/gui/Pages/Chat/RoomPane/RoomPane.qml b/src/gui/Pages/Chat/RoomPane/RoomPane.qml index b382fbcd..09450333 100644 --- a/src/gui/Pages/Chat/RoomPane/RoomPane.qml +++ b/src/gui/Pages/Chat/RoomPane/RoomPane.qml @@ -18,6 +18,7 @@ MultiviewPane { return } + roomPane.forceCollapse = false roomPane.open() swipeView.currentItem.keybindFocusItem.forceActiveFocus() } @@ -67,8 +68,16 @@ MultiviewPane { enabled: ["back", "members", "settings"].includes(modelData) onClicked: - modelData === "back" ? roomPane.toggleFocus() : - modelData === "members" ? swipeView.currentIndex = 0 : + modelData === "back" ? + roomPane.toggleFocus() : + + (modelData === "members" && swipeView.currentIndex === 0) || + (modelData === "settings" && swipeView.currentIndex === 1) ? + roomPane.forceCollapse = true : + + modelData === "members" ? + swipeView.currentIndex = 0 : + swipeView.currentIndex = 1 Behavior on width {