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

187 lines
5.5 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 {
readonly property bool showLeftButton:
mainUI.mainPane.collapse || mainUI.mainPane.forceCollapse
readonly property bool showRightButton:
chat.roomPane &&
(chat.roomPane.collapse || chat.roomPane.forceCollapse)
readonly property bool center:
showLeftButton || window.settings.alwaysCenterRoomHeader
implicitHeight: theme.baseElementsHeight
color: theme.chat.roomHeader.background
HRowLayout {
id: row
2019-03-26 09:29:46 +11:00
anchors.fill: parent
visible: opacity > 0
// The layout overflows somehow when focusing the room pane and
// is visible behind it (with a transparent theme)
opacity: showRightButton && chat.roomPane.visible ? 0 : 1
Behavior on opacity { HNumberAnimation {} }
2019-03-22 14:28:14 +11:00
HButton {
id: goToMainPaneButton
padded: false
visible: Layout.preferredWidth > 0
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-05-14 16:14:54 +10:00
onClicked: mainUI.mainPane.toggleFocus()
Layout.preferredWidth: showLeftButton ? 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 -
2020-07-15 07:09:09 +10:00
row.spacing -
(showLeftButton ? row.spacing : 0) -
(showRightButton ? row.spacing : 0) -
goToMainPaneButton.width -
avatar.width -
2020-07-15 07:09:09 +10:00
encryptionStatusButton.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
HLabel {
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 -
2020-07-15 07:09:09 +10:00
row.spacing -
(showLeftButton ? row.spacing : 0) -
(showRightButton ? row.spacing : 0) -
goToMainPaneButton.width -
avatar.width -
nameLabel.width -
2020-07-15 07:09:09 +10:00
encryptionStatusButton.width -
goToRoomPaneButton.width
)
Layout.fillWidth: ! center
Layout.fillHeight: true
HoverHandler { id: topicHover }
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
cursorShape:
parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
}
}
HToolTip {
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 : ""
visible: text && (nameHover.hovered || topicHover.hovered)
label.textFormat: Text.StyledText
text: name && topic ? (`${name}<br>${topic}`) : (name || topic)
2019-05-13 03:17:42 +10: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 ?
theme.colors.middleBackground :
theme.colors.positiveBackground
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")
onClicked: toolTip.instantShow()
Layout.preferredWidth: chat.roomInfo.encrypted ? avatar.width : 0
Layout.fillHeight: true
Behavior on Layout.preferredWidth { HNumberAnimation {} }
}
2020-07-15 07:09:09 +10:00
HSpacer {
visible: center
}
HButton {
id: goToRoomPaneButton
padded: false
visible: Layout.preferredWidth > 0
backgroundColor: "transparent"
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: showRightButton ? avatar.width : 0
Layout.fillHeight: true
}
2019-03-22 14:28:14 +11:00
}
}