nheko/resources/qml/TopBar.qml

131 lines
3.7 KiB
QML
Raw Normal View History

2021-03-05 00:35:15 +01:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
2021-03-05 00:35:15 +01:00
// SPDX-License-Identifier: GPL-3.0-or-later
2021-03-14 22:22:52 +01:00
import Qt.labs.platform 1.1 as Platform
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.2
import im.nheko 1.0
Rectangle {
id: topBar
property var room: TimelineManager.timeline
Layout.fillWidth: true
implicitHeight: topLayout.height + 16
z: 3
2021-05-13 08:23:56 +02:00
color: Nheko.colors.window
2021-03-14 22:22:52 +01:00
TapHandler {
2021-04-11 22:24:39 +02:00
onSingleTapped: {
TimelineManager.timeline.openRoomSettings();
eventPoint.accepted = true;
}
gesturePolicy: TapHandler.ReleaseWithinBounds
}
GridLayout {
//Layout.margins: 8
id: topLayout
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 8
anchors.verticalCenter: parent.verticalCenter
ImageButton {
id: backToRoomsButton
Layout.column: 0
Layout.row: 0
Layout.rowSpan: 2
Layout.alignment: Qt.AlignVCenter
2021-05-13 11:32:20 +02:00
width: Nheko.avatarSize
height: Nheko.avatarSize
visible: TimelineManager.isNarrowView
image: ":/icons/icons/ui/angle-pointing-to-left.png"
ToolTip.visible: hovered
ToolTip.text: qsTr("Back to room list")
onClicked: TimelineManager.backToRooms()
}
Avatar {
Layout.column: 1
Layout.row: 0
Layout.rowSpan: 2
Layout.alignment: Qt.AlignVCenter
2021-05-13 11:32:20 +02:00
width: Nheko.avatarSize
height: Nheko.avatarSize
url: room ? room.roomAvatarUrl.replace("mxc://", "image://MxcImage/") : ""
displayName: room ? room.roomName : qsTr("No room selected")
2021-04-11 22:24:39 +02:00
onClicked: TimelineManager.timeline.openRoomSettings()
}
Label {
Layout.fillWidth: true
Layout.column: 2
Layout.row: 0
2021-05-13 08:23:56 +02:00
color: Nheko.colors.text
font.pointSize: fontMetrics.font.pointSize * 1.1
text: room ? room.roomName : qsTr("No room selected")
2020-12-13 16:05:48 +01:00
maximumLineCount: 1
2021-04-27 11:08:21 +02:00
elide: Text.ElideRight
textFormat: Text.RichText
}
MatrixText {
Layout.fillWidth: true
Layout.column: 2
Layout.row: 1
Layout.maximumHeight: fontMetrics.lineSpacing * 2 // show 2 lines
clip: true
text: room ? room.roomTopic : ""
}
ImageButton {
id: roomOptionsButton
Layout.column: 3
Layout.row: 0
Layout.rowSpan: 2
Layout.alignment: Qt.AlignVCenter
image: ":/icons/icons/ui/vertical-ellipsis.png"
ToolTip.visible: hovered
ToolTip.text: qsTr("Room options")
2021-03-14 22:22:52 +01:00
onClicked: roomOptionsMenu.open(roomOptionsButton)
2021-03-14 22:22:52 +01:00
Platform.Menu {
id: roomOptionsMenu
2021-03-14 22:22:52 +01:00
Platform.MenuItem {
visible: TimelineManager.timeline ? TimelineManager.timeline.permissions.canInvite() : false
text: qsTr("Invite users")
onTriggered: TimelineManager.openInviteUsersDialog()
}
2021-03-14 22:22:52 +01:00
Platform.MenuItem {
text: qsTr("Members")
onTriggered: TimelineManager.openMemberListDialog()
}
2021-03-14 22:22:52 +01:00
Platform.MenuItem {
text: qsTr("Leave room")
onTriggered: TimelineManager.openLeaveRoomDialog()
}
2021-03-14 22:22:52 +01:00
Platform.MenuItem {
text: qsTr("Settings")
onTriggered: TimelineManager.timeline.openRoomSettings()
}
}
}
}
}