Add expand/search button to room pane when narrow

This commit is contained in:
miruka 2020-07-14 04:54:23 -04:00
parent fea1a8df4c
commit e5f147e977
2 changed files with 54 additions and 31 deletions

View File

@ -65,11 +65,12 @@ HColumnLayout {
color: theme.chat.roomPane.bottomBar.background color: theme.chat.roomPane.bottomBar.background
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumHeight: theme.baseElementsHeight Layout.preferredHeight: childrenRect.height
Layout.maximumHeight: Layout.minimumHeight
HRowLayout { HRowLayout {
anchors.fill: parent width: parent.width
layoutDirection:
expandButton.visible ? Qt.RightToLeft : Qt.LeftToRight
HTextField { HTextField {
id: filterField id: filterField
@ -82,7 +83,6 @@ HColumnLayout {
opacity: width >= 16 * theme.uiScale ? 1 : 0 opacity: width >= 16 * theme.uiScale ? 1 : 0
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true
// FIXME: fails to display sometimes for some reason if // FIXME: fails to display sometimes for some reason if
// declared normally // declared normally
@ -124,37 +124,57 @@ HColumnLayout {
Behavior on opacity { HNumberAnimation {} } Behavior on opacity { HNumberAnimation {} }
} }
HButton { HColumnLayout {
id: inviteButton HButton {
icon.name: "room-send-invite" id: inviteButton
backgroundColor: icon.name: "room-send-invite"
theme.chat.roomPane.bottomBar.inviteButton.background backgroundColor:
enabled: theme.chat.roomPane.bottomBar.inviteButton.background
chat.userInfo.presence !== "offline" && enabled:
chat.roomInfo.can_invite chat.userInfo.presence !== "offline" &&
chat.roomInfo.can_invite
toolTip.text: toolTip.text:
enabled ? enabled ?
qsTr("Invite members to this room") : qsTr("Invite members to this room") :
qsTr("No permission to invite members to this room") qsTr("No permission to invite members to this room")
onClicked: utils.makePopup( onClicked: utils.makePopup(
"Popups/InviteToRoomPopup.qml", "Popups/InviteToRoomPopup.qml",
{ {
userId: chat.userId, userId: chat.userId,
roomId: chat.roomId, roomId: chat.roomId,
roomName: chat.roomInfo.display_name, roomName: chat.roomInfo.display_name,
invitingAllowed: invitingAllowed:
Qt.binding(() => inviteButton.enabled), Qt.binding(() => inviteButton.enabled),
}, },
) )
Layout.fillHeight: true Layout.preferredHeight: filterField.implicitHeight
HShortcut { HShortcut {
sequences: window.settings.keys.inviteToRoom sequences: window.settings.keys.inviteToRoom
onActivated: onActivated:
if (inviteButton.enabled) inviteButton.clicked() if (inviteButton.enabled) inviteButton.clicked()
}
}
HButton {
id: expandButton
icon.name: "room-pane-expand-search"
backgroundColor: inviteButton.backgroundColor
toolTip.text: qsTr("Expand search")
visible: Layout.preferredHeight > 0
// Will trigger roomPane.requireDefaultSize
onClicked: filterField.forceActiveFocus()
Layout.preferredHeight:
filterField.width < 32 * theme.uiScale ?
filterField.implicitHeight :
0
Behavior on Layout.preferredHeight { HNumberAnimation {} }
} }
} }
} }

View File

@ -0,0 +1,3 @@
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
<path d="m23.809 21.646-6.205-6.205c1.167-1.605 1.857-3.579 1.857-5.711 0-5.365-4.365-9.73-9.731-9.73-5.365 0-9.73 4.365-9.73 9.73 0 5.366 4.365 9.73 9.73 9.73 2.034 0 3.923-.627 5.487-1.698l6.238 6.238zm-20.955-11.916c0-3.792 3.085-6.877 6.877-6.877s6.877 3.085 6.877 6.877-3.085 6.877-6.877 6.877c-3.793 0-6.877-3.085-6.877-6.877z"/>
</svg>

After

Width:  |  Height:  |  Size: 431 B