2019-12-19 22:46:16 +11:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-07-13 19:39:01 +10:00
|
|
|
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
|
|
|
|
2020-03-18 07:39:29 +11:00
|
|
|
|
|
|
|
readonly property bool showPaneButtons: mainUI.mainPane.collapse
|
|
|
|
|
|
|
|
readonly property bool center:
|
|
|
|
showPaneButtons || window.settings.alwaysCenterRoomHeader
|
|
|
|
|
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HRowLayout {
|
2019-04-21 07:45:51 +10:00
|
|
|
id: row
|
2019-03-26 09:29:46 +11:00
|
|
|
anchors.fill: parent
|
2020-03-18 09:19:26 +11:00
|
|
|
visible: opacity > 0
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2020-03-18 07:39:29 +11:00
|
|
|
HButton {
|
|
|
|
id: goToMainPaneButton
|
|
|
|
padded: false
|
|
|
|
visible: Layout.preferredWidth > 0
|
2020-03-18 09:06:19 +11:00
|
|
|
backgroundColor: "transparent"
|
2020-03-18 09:05:51 +11:00
|
|
|
icon.name: "go-back-to-main-pane"
|
|
|
|
toolTip.text: qsTr("Go back to main pane")
|
2020-03-18 07:39:29 +11:00
|
|
|
|
|
|
|
onClicked: mainUI.mainPane.toggleFocus()
|
|
|
|
|
|
|
|
Layout.preferredWidth: showPaneButtons ? avatar.width : 0
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
Behavior on Layout.preferredWidth { HNumberAnimation {} }
|
|
|
|
}
|
|
|
|
|
|
|
|
HSpacer {
|
|
|
|
visible: center
|
|
|
|
}
|
|
|
|
|
2019-07-07 14:24:23 +10:00
|
|
|
HRoomAvatar {
|
2019-04-21 07:45:51 +10:00
|
|
|
id: avatar
|
2020-03-10 02:46:08 +11:00
|
|
|
roomId: chat.roomId
|
2019-12-09 20:25:31 +11:00
|
|
|
displayName: chat.roomInfo.display_name
|
|
|
|
mxc: chat.roomInfo.avatar_url
|
2020-03-16 06:08:16 +11:00
|
|
|
radius: 0
|
|
|
|
|
2019-04-29 04:20:30 +10:00
|
|
|
Layout.alignment: Qt.AlignTop
|
2019-03-26 09:29:46 +11:00
|
|
|
}
|
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HLabel {
|
2019-12-09 20:25:31 +11:00
|
|
|
id: nameLabel
|
|
|
|
text: chat.roomInfo.display_name || qsTr("Empty room")
|
2019-07-24 16:14:34 +10:00
|
|
|
color: theme.chat.roomHeader.name
|
2019-12-09 20:25:31 +11:00
|
|
|
|
2019-03-26 09:29:46 +11:00
|
|
|
elide: Text.ElideRight
|
2019-07-19 14:10:46 +10:00
|
|
|
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(
|
2020-03-18 07:39:29 +11:00
|
|
|
implicitWidth,
|
|
|
|
row.width -
|
|
|
|
row.spacing * (showPaneButtons ? 3 : 1) -
|
|
|
|
goToMainPaneButton.width -
|
|
|
|
avatar.width -
|
|
|
|
goToRoomPaneButton.width
|
2019-05-13 08:59:29 +10:00
|
|
|
)
|
2019-12-09 20:25:31 +11:00
|
|
|
Layout.fillHeight: true
|
2019-09-08 04:14:04 +10:00
|
|
|
|
|
|
|
HoverHandler { id: nameHover }
|
2019-03-26 09:29:46 +11:00
|
|
|
}
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-09-12 06:01:37 +10:00
|
|
|
HRichLabel {
|
2019-12-09 20:25:31 +11:00
|
|
|
id: topicLabel
|
|
|
|
text: chat.roomInfo.topic
|
2019-09-12 06:01:37 +10:00
|
|
|
textFormat: Text.StyledText
|
2019-07-07 07:50:55 +10:00
|
|
|
font.pixelSize: theme.fontSize.small
|
2019-07-24 16:14:34 +10:00
|
|
|
color: theme.chat.roomHeader.topic
|
2019-12-09 20:25:31 +11:00
|
|
|
|
2019-03-26 09:29:46 +11:00
|
|
|
elide: Text.ElideRight
|
2019-07-19 14:10:46 +10:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
2019-12-09 20:25:31 +11:00
|
|
|
rightPadding: nameLabel.rightPadding
|
2019-05-13 03:17:42 +10:00
|
|
|
|
2020-03-18 07:39:29 +11:00
|
|
|
Layout.preferredWidth: Math.min(
|
|
|
|
implicitWidth,
|
|
|
|
row.width -
|
|
|
|
row.spacing * (showPaneButtons ? 3 : 1) -
|
|
|
|
goToMainPaneButton.width -
|
|
|
|
avatar.width -
|
|
|
|
nameLabel.width -
|
|
|
|
goToRoomPaneButton.width
|
|
|
|
)
|
|
|
|
Layout.fillWidth: ! center
|
2019-07-19 14:10:46 +10:00
|
|
|
Layout.fillHeight: true
|
2019-09-08 04:14:04 +10:00
|
|
|
|
|
|
|
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)
|
2019-09-08 04:14:04 +10:00
|
|
|
|
|
|
|
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
|
|
|
}
|
2020-03-18 07:39:29 +11:00
|
|
|
|
|
|
|
HSpacer {
|
|
|
|
visible: center
|
|
|
|
}
|
|
|
|
|
|
|
|
HButton {
|
|
|
|
id: goToRoomPaneButton
|
|
|
|
padded: false
|
|
|
|
visible: goToMainPaneButton.visible
|
2020-03-18 09:06:19 +11:00
|
|
|
backgroundColor: "transparent"
|
2020-03-18 09:05:51 +11:00
|
|
|
icon.name: "go-to-room-pane"
|
|
|
|
toolTip.text: qsTr("Go to room pane")
|
2020-03-18 07:39:29 +11:00
|
|
|
|
|
|
|
onClicked: chat.roomPane.toggleFocus()
|
|
|
|
|
|
|
|
Layout.preferredWidth: goToMainPaneButton.Layout.preferredWidth
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
2019-03-22 14:28:14 +11:00
|
|
|
}
|
|
|
|
}
|