2020-09-23 19:57:54 -04:00
|
|
|
// Copyright Mirage authors & contributors <https://github.com/mirukana/mirage>
|
2019-12-19 07:46:16 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-07-13 05:39:01 -04:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2019-12-18 04:53:08 -04:00
|
|
|
import "../../Base"
|
2019-03-21 23:28:14 -04:00
|
|
|
|
2019-08-27 22:46:31 -04:00
|
|
|
Rectangle {
|
2020-07-14 16:47:04 -04:00
|
|
|
readonly property bool showLeftButton:
|
|
|
|
mainUI.mainPane.collapse || mainUI.mainPane.forceCollapse
|
|
|
|
|
|
|
|
readonly property bool showRightButton:
|
|
|
|
chat.roomPane &&
|
|
|
|
(chat.roomPane.collapse || chat.roomPane.forceCollapse)
|
2020-03-17 16:39:29 -04:00
|
|
|
|
|
|
|
readonly property bool center:
|
2020-07-14 16:47:04 -04:00
|
|
|
showLeftButton || window.settings.alwaysCenterRoomHeader
|
2020-03-17 16:39:29 -04:00
|
|
|
|
|
|
|
|
2020-07-12 00:25:57 -04:00
|
|
|
implicitHeight: theme.baseElementsHeight
|
|
|
|
color: theme.chat.roomHeader.background
|
|
|
|
|
2019-04-28 15:18:36 -04:00
|
|
|
HRowLayout {
|
2019-04-20 17:45:51 -04:00
|
|
|
id: row
|
2019-03-25 18:29:46 -04:00
|
|
|
anchors.fill: parent
|
2020-03-17 18:19:26 -04:00
|
|
|
visible: opacity > 0
|
|
|
|
|
|
|
|
// The layout overflows somehow when focusing the room pane and
|
|
|
|
// is visible behind it (with a transparent theme)
|
2020-07-14 16:47:04 -04:00
|
|
|
opacity: showRightButton && chat.roomPane.visible ? 0 : 1
|
2020-03-17 18:19:26 -04:00
|
|
|
|
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
2019-03-21 23:28:14 -04:00
|
|
|
|
2020-03-17 16:39:29 -04:00
|
|
|
HButton {
|
|
|
|
id: goToMainPaneButton
|
|
|
|
padded: false
|
|
|
|
visible: Layout.preferredWidth > 0
|
2020-03-17 18:06:19 -04:00
|
|
|
backgroundColor: "transparent"
|
2020-03-17 18:05:51 -04:00
|
|
|
icon.name: "go-back-to-main-pane"
|
|
|
|
toolTip.text: qsTr("Go back to main pane")
|
2020-03-17 16:39:29 -04:00
|
|
|
|
2020-05-14 02:14:54 -04:00
|
|
|
onClicked: mainUI.mainPane.toggleFocus()
|
2020-03-17 16:39:29 -04:00
|
|
|
|
2020-07-14 16:47:04 -04:00
|
|
|
Layout.preferredWidth: showLeftButton ? avatar.width : 0
|
2020-03-17 16:39:29 -04:00
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
Behavior on Layout.preferredWidth { HNumberAnimation {} }
|
|
|
|
}
|
|
|
|
|
|
|
|
HSpacer {
|
|
|
|
visible: center
|
|
|
|
}
|
|
|
|
|
2019-07-07 00:24:23 -04:00
|
|
|
HRoomAvatar {
|
2019-04-20 17:45:51 -04:00
|
|
|
id: avatar
|
2020-08-23 16:57:53 -04:00
|
|
|
clientUserId: chat.userId
|
2020-03-09 11:46:08 -04:00
|
|
|
roomId: chat.roomId
|
2019-12-09 05:25:31 -04:00
|
|
|
displayName: chat.roomInfo.display_name
|
|
|
|
mxc: chat.roomInfo.avatar_url
|
2020-03-15 15:08:16 -04:00
|
|
|
radius: 0
|
|
|
|
|
2019-04-28 14:20:30 -04:00
|
|
|
Layout.alignment: Qt.AlignTop
|
2019-03-25 18:29:46 -04:00
|
|
|
}
|
|
|
|
|
2019-04-28 15:18:36 -04:00
|
|
|
HLabel {
|
2019-12-09 05:25:31 -04:00
|
|
|
id: nameLabel
|
|
|
|
text: chat.roomInfo.display_name || qsTr("Empty room")
|
2019-07-24 02:14:34 -04:00
|
|
|
color: theme.chat.roomHeader.name
|
2019-12-09 05:25:31 -04:00
|
|
|
|
2019-03-25 18:29:46 -04:00
|
|
|
elide: Text.ElideRight
|
2019-07-19 00:10:46 -04:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
2019-12-09 05:25:31 -04:00
|
|
|
leftPadding: theme.spacing
|
|
|
|
rightPadding: leftPadding
|
2019-05-12 13:17:42 -04:00
|
|
|
|
2019-12-09 05:25:31 -04:00
|
|
|
Layout.preferredWidth: Math.min(
|
2020-03-17 16:39:29 -04:00
|
|
|
implicitWidth,
|
|
|
|
row.width -
|
2020-07-14 17:09:09 -04:00
|
|
|
row.spacing -
|
|
|
|
(showLeftButton ? row.spacing : 0) -
|
|
|
|
(showRightButton ? row.spacing : 0) -
|
2020-03-17 16:39:29 -04:00
|
|
|
goToMainPaneButton.width -
|
|
|
|
avatar.width -
|
2020-07-14 17:09:09 -04:00
|
|
|
encryptionStatusButton.width -
|
2020-03-17 16:39:29 -04:00
|
|
|
goToRoomPaneButton.width
|
2019-05-12 18:59:29 -04:00
|
|
|
)
|
2019-12-09 05:25:31 -04:00
|
|
|
Layout.fillHeight: true
|
2019-09-07 14:14:04 -04:00
|
|
|
|
|
|
|
HoverHandler { id: nameHover }
|
2019-03-25 18:29:46 -04:00
|
|
|
}
|
2019-03-21 23:28:14 -04:00
|
|
|
|
2020-07-11 23:42:49 -04:00
|
|
|
HLabel {
|
2019-12-09 05:25:31 -04:00
|
|
|
id: topicLabel
|
|
|
|
text: chat.roomInfo.topic
|
2019-09-11 16:01:37 -04:00
|
|
|
textFormat: Text.StyledText
|
2019-07-06 17:50:55 -04:00
|
|
|
font.pixelSize: theme.fontSize.small
|
2019-07-24 02:14:34 -04:00
|
|
|
color: theme.chat.roomHeader.topic
|
2019-12-09 05:25:31 -04:00
|
|
|
|
2019-03-25 18:29:46 -04:00
|
|
|
elide: Text.ElideRight
|
2019-07-19 00:10:46 -04:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
2019-12-09 05:25:31 -04:00
|
|
|
rightPadding: nameLabel.rightPadding
|
2019-05-12 13:17:42 -04:00
|
|
|
|
2020-03-17 16:39:29 -04:00
|
|
|
Layout.preferredWidth: Math.min(
|
|
|
|
implicitWidth,
|
|
|
|
row.width -
|
2020-07-14 17:09:09 -04:00
|
|
|
row.spacing -
|
|
|
|
(showLeftButton ? row.spacing : 0) -
|
|
|
|
(showRightButton ? row.spacing : 0) -
|
2020-03-17 16:39:29 -04:00
|
|
|
goToMainPaneButton.width -
|
|
|
|
avatar.width -
|
|
|
|
nameLabel.width -
|
2020-07-14 17:09:09 -04:00
|
|
|
encryptionStatusButton.width -
|
2020-03-17 16:39:29 -04:00
|
|
|
goToRoomPaneButton.width
|
|
|
|
)
|
|
|
|
Layout.fillWidth: ! center
|
2019-07-19 00:10:46 -04:00
|
|
|
Layout.fillHeight: true
|
2019-09-07 14:14:04 -04:00
|
|
|
|
|
|
|
HoverHandler { id: topicHover }
|
2020-07-11 23:42:49 -04:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
acceptedButtons: Qt.NoButton
|
|
|
|
cursorShape:
|
|
|
|
parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
|
|
|
|
}
|
2019-09-07 14:14:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HToolTip {
|
|
|
|
readonly property string name:
|
2019-12-09 05:25:31 -04:00
|
|
|
nameLabel.truncated ?
|
|
|
|
(`<b>${chat.roomInfo.display_name}</b>`) : ""
|
2019-05-12 13:17:42 -04:00
|
|
|
|
2019-12-09 05:25:31 -04:00
|
|
|
readonly property string topic:
|
|
|
|
topicLabel.truncated ? chat.roomInfo.topic : ""
|
2020-07-12 00:25:57 -04:00
|
|
|
|
|
|
|
visible: text && (nameHover.hovered || topicHover.hovered)
|
|
|
|
label.textFormat: Text.StyledText
|
|
|
|
text: name && topic ? (`${name}<br>${topic}`) : (name || topic)
|
2019-05-12 13:17:42 -04:00
|
|
|
}
|
2020-03-17 16:39:29 -04:00
|
|
|
|
2020-06-27 11:11:14 -04:00
|
|
|
HButton {
|
|
|
|
id: encryptionStatusButton
|
|
|
|
padded: false
|
|
|
|
visible: Layout.preferredWidth > 0
|
|
|
|
backgroundColor: "transparent"
|
|
|
|
|
|
|
|
icon.name:
|
|
|
|
chat.roomInfo.unverified_devices ?
|
|
|
|
"device-unset" :
|
|
|
|
"device-verified"
|
|
|
|
|
|
|
|
icon.color:
|
|
|
|
chat.roomInfo.unverified_devices ?
|
2020-07-10 13:27:35 -04:00
|
|
|
theme.colors.middleBackground :
|
|
|
|
theme.colors.positiveBackground
|
2020-06-27 11:11:14 -04:00
|
|
|
|
|
|
|
toolTip.text:
|
|
|
|
chat.roomInfo.unverified_devices ?
|
|
|
|
qsTr("Some members in this encrypted room have " +
|
|
|
|
"unverified devices") :
|
|
|
|
qsTr("All members in this encrypted room are verified")
|
|
|
|
|
2020-11-05 22:03:59 -04:00
|
|
|
onClicked: toolTip.instantToggle()
|
2020-06-27 11:11:14 -04:00
|
|
|
|
|
|
|
Layout.preferredWidth: chat.roomInfo.encrypted ? avatar.width : 0
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
Behavior on Layout.preferredWidth { HNumberAnimation {} }
|
|
|
|
}
|
|
|
|
|
2020-07-14 17:09:09 -04:00
|
|
|
HSpacer {
|
|
|
|
visible: center
|
|
|
|
}
|
|
|
|
|
2020-03-17 16:39:29 -04:00
|
|
|
HButton {
|
|
|
|
id: goToRoomPaneButton
|
|
|
|
padded: false
|
2020-07-14 16:47:04 -04:00
|
|
|
visible: Layout.preferredWidth > 0
|
2020-03-17 18:06:19 -04:00
|
|
|
backgroundColor: "transparent"
|
2020-03-17 18:05:51 -04:00
|
|
|
icon.name: "go-to-room-pane"
|
|
|
|
toolTip.text: qsTr("Go to room pane")
|
2020-03-17 16:39:29 -04:00
|
|
|
|
|
|
|
onClicked: chat.roomPane.toggleFocus()
|
|
|
|
|
2020-07-14 16:47:04 -04:00
|
|
|
Layout.preferredWidth: showRightButton ? avatar.width : 0
|
2020-03-17 16:39:29 -04:00
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
2019-03-21 23:28:14 -04:00
|
|
|
}
|
|
|
|
}
|