RoomHeader buttons and RoomSidePane size/collapse

RoomSidePane's size and collapsing is not bound anymore to the
RoomHeader buttons.
This commit is contained in:
miruka 2019-05-12 18:59:29 -04:00
parent b9b6d2fcb3
commit b35e635be4
4 changed files with 31 additions and 16 deletions

View File

@ -80,15 +80,28 @@ HColumnLayout {
RoomSidePane { RoomSidePane {
id: roomSidePane id: roomSidePane
function set_width() { width = referenceWidth } collapsed: width < Layout.minimumWidth + 8
property int referenceWidth: roomHeader.buttonsWidth property int parentWidth: parent.width
onReferenceWidthChanged: property int collapseBelow: 120
function set_width() {
width = parent.width * 0.3 < collapseBelow ?
Layout.minimumWidth : Math.min(parent.width * 0.3, 300)
}
onParentWidthChanged:
if (chatSplitView.canAutoSize) { set_width() } if (chatSplitView.canAutoSize) { set_width() }
width: set_width() // Initial width width: set_width() // Initial width
Layout.minimumWidth: HStyle.avatar.size Layout.minimumWidth: HStyle.avatar.size
Layout.maximumWidth: parent.width Layout.maximumWidth: parent.width
Behavior on width {
NumberAnimation {
duration: chatSplitView.canAutoSize ? 120 : 0
}
}
} }
} }
} }

View File

@ -6,14 +6,14 @@ HRectangle {
property string displayName: "" property string displayName: ""
property string topic: "" property string topic: ""
property bool collapseButtons: width < 480 property bool collapseButtons: width < 400
property alias buttonsWidth: viewButtons.width
id: roomHeader id: roomHeader
color: HStyle.chat.roomHeader.background color: HStyle.chat.roomHeader.background
HRowLayout { HRowLayout {
id: row id: row
spacing: 8
anchors.fill: parent anchors.fill: parent
HAvatar { HAvatar {
@ -30,11 +30,12 @@ HRectangle {
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: 1 maximumLineCount: 1
Layout.maximumWidth: Layout.maximumWidth: Math.max(
0,
row.width - Layout.leftMargin * 2 - avatar.width - row.width - Layout.leftMargin * 2 - avatar.width -
viewButtons.width - viewButtons.width -
(expandButton.visible ? expandButton.width : 0) (expandButton.visible ? expandButton.width : 0)
Layout.leftMargin: 8 )
} }
HLabel { HLabel {
@ -44,18 +45,19 @@ HRectangle {
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: 1 maximumLineCount: 1
Layout.maximumWidth: Layout.maximumWidth: Math.max(
row.width - Layout.leftMargin * 2 - avatar.width - 0,
row.width - row.totalSpacing - avatar.width -
roomName.width - viewButtons.width - roomName.width - viewButtons.width -
(expandButton.visible ? expandButton.width : 0) (expandButton.visible ? expandButton.width : 0)
Layout.leftMargin: 8 )
} }
HSpacer {} HSpacer {}
Row { Row {
id: viewButtons id: viewButtons
Layout.maximumWidth: collapseButtons ? 0 : implicitWidth Layout.preferredWidth: collapseButtons ? 0 : implicitWidth
HButton { HButton {
iconName: "room_view_members" iconName: "room_view_members"
@ -77,7 +79,7 @@ HRectangle {
iconName: "room_view_settings" iconName: "room_view_settings"
} }
Behavior on Layout.maximumWidth { Behavior on Layout.preferredWidth {
NumberAnimation { id: buttonsAnimation; duration: 120 } NumberAnimation { id: buttonsAnimation; duration: 120 }
} }
} }

View File

@ -4,10 +4,8 @@ import "../../Base"
Column { Column {
property int normalSpacing: 8 property int normalSpacing: 8
property bool collapsed:
width < roomSidePane.Layout.minimumWidth + normalSpacing
leftPadding: collapsed ? 0 : normalSpacing leftPadding: roomSidePane.collapsed ? 0 : normalSpacing
rightPadding: leftPadding rightPadding: leftPadding
ListView { ListView {
@ -16,7 +14,7 @@ Column {
id: memberList id: memberList
spacing: collapsed ? 0 : normalSpacing spacing: parent.leftPadding
topMargin: spacing topMargin: spacing
bottomMargin: topMargin bottomMargin: topMargin

View File

@ -5,6 +5,8 @@ import "../../Base"
HRectangle { HRectangle {
id: roomSidePane id: roomSidePane
property bool collapsed: false
HColumnLayout { HColumnLayout {
anchors.fill: parent anchors.fill: parent