moment/src/gui/Pages/Chat/RoomHeader.qml

131 lines
3.6 KiB
QML
Raw Normal View History

2019-12-19 22:46:16 +11:00
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Layouts 1.12
2019-12-18 19:53:08 +11:00
import "../../Base"
2019-03-22 14:28:14 +11:00
2019-08-28 12:46:31 +10:00
Rectangle {
2019-07-17 07:08:06 +10:00
implicitHeight: theme.baseElementsHeight
2019-12-09 20:25:31 +11:00
color: theme.chat.roomHeader.background
2019-03-22 14:28:14 +11:00
readonly property bool showPaneButtons: mainUI.mainPane.collapse
readonly property bool center:
showPaneButtons || window.settings.alwaysCenterRoomHeader
HRowLayout {
id: row
2019-03-26 09:29:46 +11:00
anchors.fill: parent
2019-03-22 14:28:14 +11:00
HButton {
id: goToMainPaneButton
padded: false
visible: Layout.preferredWidth > 0
2020-03-18 09:05:51 +11:00
icon.name: "go-back-to-main-pane"
toolTip.text: qsTr("Go back to main pane")
onClicked: mainUI.mainPane.toggleFocus()
Layout.preferredWidth: showPaneButtons ? avatar.width : 0
Layout.fillHeight: true
Behavior on Layout.preferredWidth { HNumberAnimation {} }
}
HSpacer {
visible: center
}
HRoomAvatar {
id: avatar
roomId: chat.roomId
2019-12-09 20:25:31 +11:00
displayName: chat.roomInfo.display_name
mxc: chat.roomInfo.avatar_url
radius: 0
Layout.alignment: Qt.AlignTop
2019-03-26 09:29:46 +11:00
}
HLabel {
2019-12-09 20:25:31 +11:00
id: nameLabel
text: chat.roomInfo.display_name || qsTr("Empty room")
color: theme.chat.roomHeader.name
2019-12-09 20:25:31 +11:00
2019-03-26 09:29:46 +11:00
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
2019-12-09 20:25:31 +11:00
leftPadding: theme.spacing
rightPadding: leftPadding
2019-05-13 03:17:42 +10:00
2019-12-09 20:25:31 +11:00
Layout.preferredWidth: Math.min(
implicitWidth,
row.width -
row.spacing * (showPaneButtons ? 3 : 1) -
goToMainPaneButton.width -
avatar.width -
goToRoomPaneButton.width
)
2019-12-09 20:25:31 +11:00
Layout.fillHeight: true
HoverHandler { id: nameHover }
2019-03-26 09:29:46 +11:00
}
2019-03-22 14:28:14 +11:00
HRichLabel {
2019-12-09 20:25:31 +11:00
id: topicLabel
text: chat.roomInfo.topic
textFormat: Text.StyledText
font.pixelSize: theme.fontSize.small
color: theme.chat.roomHeader.topic
2019-12-09 20:25:31 +11:00
2019-03-26 09:29:46 +11:00
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
2019-12-09 20:25:31 +11:00
rightPadding: nameLabel.rightPadding
2019-05-13 03:17:42 +10:00
Layout.preferredWidth: Math.min(
implicitWidth,
row.width -
row.spacing * (showPaneButtons ? 3 : 1) -
goToMainPaneButton.width -
avatar.width -
nameLabel.width -
goToRoomPaneButton.width
)
Layout.fillWidth: ! center
Layout.fillHeight: true
HoverHandler { id: topicHover }
}
HToolTip {
visible: text && (nameHover.hovered || topicHover.hovered)
2019-12-09 20:25:31 +11:00
label.textFormat: Text.StyledText
text: name && topic ? (`${name}<br>${topic}`) : (name || topic)
readonly property string name:
2019-12-09 20:25:31 +11:00
nameLabel.truncated ?
(`<b>${chat.roomInfo.display_name}</b>`) : ""
2019-05-13 03:17:42 +10:00
2019-12-09 20:25:31 +11:00
readonly property string topic:
topicLabel.truncated ? chat.roomInfo.topic : ""
2019-05-13 03:17:42 +10:00
}
HSpacer {
visible: center
}
HButton {
id: goToRoomPaneButton
padded: false
visible: goToMainPaneButton.visible
2020-03-18 09:05:51 +11:00
icon.name: "go-to-room-pane"
toolTip.text: qsTr("Go to room pane")
onClicked: chat.roomPane.toggleFocus()
Layout.preferredWidth: goToMainPaneButton.Layout.preferredWidth
Layout.fillHeight: true
}
2019-03-22 14:28:14 +11:00
}
}