matrixion/resources/qml/RoomList.qml

833 lines
31 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: Nheko Contributors
2021-05-15 00:35:34 +03:00
//
// SPDX-License-Identifier: GPL-3.0-or-later
2022-04-22 01:26:25 +03:00
import "./components"
2021-05-28 18:25:46 +03:00
import "./dialogs"
import "./ui"
2021-05-22 16:19:44 +03:00
import Qt.labs.platform 1.1 as Platform
import QtQml
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import im.nheko
2021-05-15 00:35:34 +03:00
Page {
2021-06-06 00:36:08 +03:00
//leftPadding: Nheko.paddingSmall
//rightPadding: Nheko.paddingSmall
2021-06-08 23:18:51 +03:00
property int avatarSize: Math.ceil(fontMetrics.lineSpacing * 2.3)
property bool collapsed: false
2021-06-06 00:36:08 +03:00
2023-06-02 02:45:24 +03:00
background: Rectangle {
color: Nheko.theme.sidebarBackground
}
footer: ColumnLayout {
spacing: 0
Rectangle {
Layout.fillWidth: true
color: Nheko.theme.separator
2023-10-26 17:43:09 +03:00
Layout.preferredHeight: 1
2023-06-02 02:45:24 +03:00
}
Pane {
Layout.alignment: Qt.AlignBottom
Layout.fillWidth: true
Layout.minimumHeight: 40
horizontalPadding: Nheko.paddingMedium
verticalPadding: 0
background: Rectangle {
color: palette.window
}
contentItem: RowLayout {
id: buttonRow
ImageButton {
Layout.fillWidth: true
Layout.margins: Nheko.paddingMedium
ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: qsTr("Start a new chat")
ToolTip.visible: hovered
2023-10-26 17:43:09 +03:00
Layout.preferredHeight: 22
Layout.preferredWidth: 22
2023-06-02 02:45:24 +03:00
hoverEnabled: true
image: ":/icons/icons/ui/add-square-button.svg"
onClicked: roomJoinCreateMenu.open(parent)
Platform.Menu {
id: roomJoinCreateMenu
Platform.MenuItem {
text: qsTr("Join a room")
onTriggered: Nheko.openJoinRoomDialog()
}
Platform.MenuItem {
text: qsTr("Create a new room")
onTriggered: {
var createRoom = createRoomComponent.createObject(timelineRoot);
createRoom.show();
timelineRoot.destroyOnClose(createRoom);
}
}
Platform.MenuItem {
text: qsTr("Start a direct chat")
onTriggered: {
var createDirect = createDirectComponent.createObject(timelineRoot);
createDirect.show();
timelineRoot.destroyOnClose(createDirect);
}
}
Platform.MenuItem {
text: qsTr("Create a new community")
onTriggered: {
var createRoom = createRoomComponent.createObject(timelineRoot, {
"space": true
});
createRoom.show();
timelineRoot.destroyOnClose(createRoom);
}
}
}
}
ImageButton {
Layout.fillWidth: true
Layout.margins: Nheko.paddingMedium
ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: qsTr("Room directory")
ToolTip.visible: hovered
2023-10-26 17:43:09 +03:00
Layout.preferredHeight: 22
Layout.preferredWidth: 22
2023-06-02 02:45:24 +03:00
hoverEnabled: true
image: ":/icons/icons/ui/room-directory.svg"
visible: !collapsed
onClicked: {
var win = roomDirectoryComponent.createObject(timelineRoot);
win.show();
timelineRoot.destroyOnClose(win);
}
}
ImageButton {
Layout.fillWidth: true
Layout.margins: Nheko.paddingMedium
ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: qsTr("Search rooms (Ctrl+K)")
ToolTip.visible: hovered
2023-10-26 17:43:09 +03:00
Layout.preferredHeight: 22
Layout.preferredWidth: 22
2023-06-02 02:45:24 +03:00
hoverEnabled: true
image: ":/icons/icons/ui/search.svg"
ripple: false
visible: !collapsed
onClicked: {
2023-06-19 02:54:32 +03:00
var component = Qt.createComponent("qrc:/resources/qml/QuickSwitcher.qml");
2023-06-02 02:45:24 +03:00
if (component.status == Component.Ready) {
var quickSwitch = component.createObject(timelineRoot);
quickSwitch.open();
destroyOnClosed(quickSwitch);
} else {
console.error("Failed to create component: " + component.errorString());
}
}
}
ImageButton {
Layout.fillWidth: true
Layout.margins: Nheko.paddingMedium
ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: qsTr("User settings")
ToolTip.visible: hovered
2023-10-26 17:43:09 +03:00
Layout.preferredHeight: 22
Layout.preferredWidth: 22
2023-06-02 02:45:24 +03:00
hoverEnabled: true
image: ":/icons/icons/ui/settings.svg"
ripple: false
visible: !collapsed
onClicked: mainWindow.push(userSettingsPage)
}
}
}
}
header: ColumnLayout {
spacing: 0
Pane {
id: userInfoPanel
function openUserProfile() {
Nheko.updateUserProfile();
2023-06-19 02:54:32 +03:00
var component = Qt.createComponent("qrc:/resources/qml/dialogs/UserProfile.qml");
2023-06-02 02:45:24 +03:00
if (component.status == Component.Ready) {
var userProfile = component.createObject(timelineRoot, {
"profile": Nheko.currentUser
});
userProfile.show();
timelineRoot.destroyOnClose(userProfile);
} else {
console.error("Failed to create component: " + component.errorString());
}
}
Layout.alignment: Qt.AlignBottom
Layout.fillWidth: true
Layout.minimumHeight: 40
//Layout.preferredHeight: userInfoGrid.implicitHeight + 2 * Nheko.paddingMedium
padding: Nheko.paddingMedium
background: Rectangle {
color: palette.window
}
contentItem: RowLayout {
id: userInfoGrid
property var profile: Nheko.currentUser
spacing: Nheko.paddingMedium
Avatar {
2023-10-26 17:43:09 +03:00
id: headerAvatar
2023-06-02 02:45:24 +03:00
Layout.alignment: Qt.AlignVCenter
Layout.preferredHeight: fontMetrics.lineSpacing * 2
Layout.preferredWidth: fontMetrics.lineSpacing * 2
displayName: userInfoGrid.profile ? userInfoGrid.profile.displayName : ""
enabled: false
url: (userInfoGrid.profile ? userInfoGrid.profile.avatarUrl : "").replace("mxc://", "image://MxcImage/")
userid: userInfoGrid.profile ? userInfoGrid.profile.userid : ""
}
ColumnLayout {
id: col
Layout.alignment: Qt.AlignLeft
Layout.fillWidth: true
2023-10-26 17:43:09 +03:00
Layout.preferredWidth: parent.width - headerAvatar.width - logoutButton.width - Nheko.paddingMedium * 2
2023-06-02 02:45:24 +03:00
spacing: 0
visible: !collapsed
ElidedLabel {
Layout.alignment: Qt.AlignBottom
elideWidth: col.width
font.pointSize: fontMetrics.font.pointSize * 1.1
font.weight: Font.DemiBold
fullText: userInfoGrid.profile ? userInfoGrid.profile.displayName : ""
}
ElidedLabel {
Layout.alignment: Qt.AlignTop
color: palette.buttonText
elideWidth: col.width
font.pointSize: fontMetrics.font.pointSize * 0.9
fullText: userInfoGrid.profile ? userInfoGrid.profile.userid : ""
}
}
Item {
}
ImageButton {
id: logoutButton
Layout.alignment: Qt.AlignVCenter
Layout.preferredHeight: fontMetrics.lineSpacing * 2
Layout.preferredWidth: fontMetrics.lineSpacing * 2
ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: qsTr("Logout")
ToolTip.visible: hovered
image: ":/icons/icons/ui/power-off.svg"
visible: !collapsed
onClicked: Nheko.openLogoutDialog()
}
}
InputDialog {
id: statusDialog
prompt: qsTr("Enter your status message:")
title: qsTr("Status Message")
onAccepted: function (text) {
Nheko.setStatusMessage(text);
}
}
Platform.Menu {
id: userInfoMenu
Platform.MenuItem {
text: qsTr("Profile settings")
onTriggered: userInfoPanel.openUserProfile()
}
Platform.MenuItem {
text: qsTr("Set status message")
onTriggered: statusDialog.show()
}
2023-10-26 00:22:39 +03:00
Platform.MenuSeparator {
}
Platform.MenuItemGroup {
id: onlineStateGroup
}
Platform.MenuItem {
text: qsTr("Automatic online status")
group: onlineStateGroup
checkable: true
checked: Settings.presence == Settings.AutomaticPresence
onTriggered: if (checked) Settings.presence = Settings.AutomaticPresence
}
Platform.MenuItem {
text: qsTr("Online")
group: onlineStateGroup
checkable: true
checked: Settings.presence == Settings.Online
onTriggered: if (checked) Settings.presence = Settings.Online
}
Platform.MenuItem {
text: qsTr("Unavailable")
group: onlineStateGroup
checkable: true
checked: Settings.presence == Settings.Unavailable
onTriggered: if (checked) Settings.presence = Settings.Unavailable
}
Platform.MenuItem {
text: qsTr("Offline")
group: onlineStateGroup
checkable: true
checked: Settings.presence == Settings.Offline
onTriggered: if (checked) Settings.presence = Settings.Offline
}
2023-06-02 02:45:24 +03:00
}
TapHandler {
acceptedButtons: Qt.LeftButton
gesturePolicy: TapHandler.ReleaseWithinBounds
margin: -Nheko.paddingSmall
onLongPressed: userInfoMenu.open()
onSingleTapped: userInfoPanel.openUserProfile()
}
TapHandler {
acceptedButtons: Qt.RightButton
gesturePolicy: TapHandler.ReleaseWithinBounds
margin: -Nheko.paddingSmall
onSingleTapped: userInfoMenu.open()
}
}
Rectangle {
Layout.fillWidth: true
color: Nheko.theme.separator
2023-10-26 17:43:09 +03:00
Layout.preferredHeight: 2
2023-06-02 02:45:24 +03:00
}
Rectangle {
id: unverifiedStuffBubble
Layout.fillWidth: true
color: Qt.lighter(Nheko.theme.orange, verifyButtonHovered.hovered ? 1.2 : 1)
implicitHeight: explanation.height + Nheko.paddingMedium * 2
visible: SelfVerificationStatus.status != SelfVerificationStatus.AllVerified
RowLayout {
id: unverifiedStuffBubbleContainer
height: explanation.height + Nheko.paddingMedium * 2
spacing: 0
width: parent.width
Label {
id: explanation
Layout.fillWidth: true
Layout.margins: Nheko.paddingMedium
Layout.rightMargin: Nheko.paddingSmall
color: palette.buttonText
text: {
switch (SelfVerificationStatus.status) {
case SelfVerificationStatus.NoMasterKey:
//: Cross-signing setup has not run yet.
return qsTr("Encryption not set up");
case SelfVerificationStatus.UnverifiedMasterKey:
//: The user just signed in with this device and hasn't verified their master key.
return qsTr("Unverified login");
case SelfVerificationStatus.UnverifiedDevices:
//: There are unverified devices signed in to this account.
return qsTr("Please verify your other devices");
default:
return "";
}
}
textFormat: Text.PlainText
wrapMode: Text.Wrap
}
ImageButton {
id: closeUnverifiedBubble
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.rightMargin: Nheko.paddingMedium
ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: qsTr("Close")
ToolTip.visible: closeUnverifiedBubble.hovered
2023-10-26 17:43:09 +03:00
Layout.preferredHeight: fontMetrics.font.pixelSize
2023-06-02 02:45:24 +03:00
hoverEnabled: true
image: ":/icons/icons/ui/dismiss.svg"
2023-10-26 17:43:09 +03:00
Layout.preferredWidth: fontMetrics.font.pixelSize
2023-06-02 02:45:24 +03:00
onClicked: unverifiedStuffBubble.visible = false
}
}
HoverHandler {
id: verifyButtonHovered
acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus | PointerDevice.TouchPad
enabled: !closeUnverifiedBubble.hovered
}
TapHandler {
acceptedButtons: Qt.LeftButton
enabled: !closeUnverifiedBubble.hovered
onSingleTapped: {
if (SelfVerificationStatus.status == SelfVerificationStatus.UnverifiedDevices)
SelfVerificationStatus.verifyUnverifiedDevices();
else
SelfVerificationStatus.statusChanged();
}
}
}
Rectangle {
Layout.fillWidth: true
color: Nheko.theme.separator
2023-10-26 17:43:09 +03:00
Layout.preferredHeight: 1
2023-06-02 02:45:24 +03:00
visible: unverifiedStuffBubble.visible
}
}
// HACK: https://bugreports.qt.io/browse/QTBUG-83972, qtwayland cannot auto hide menu
Connections {
function onHideMenu() {
2023-06-02 02:45:24 +03:00
userInfoMenu.close();
roomContextMenu.close();
}
2023-06-02 02:45:24 +03:00
target: MainWindow
}
Component {
id: roomDirectoryComponent
RoomDirectory {
}
}
2022-03-26 00:30:19 +03:00
Component {
id: createRoomComponent
CreateRoom {
}
}
2022-03-26 19:28:44 +03:00
Component {
id: createDirectComponent
CreateDirect {
}
}
2021-05-19 20:34:10 +03:00
ListView {
2021-05-21 22:19:03 +03:00
id: roomlist
2021-05-19 20:34:10 +03:00
anchors.left: parent.left
anchors.right: parent.right
height: parent.height
model: Rooms
boundsBehavior: Flickable.StopAtBounds
2021-05-19 20:34:10 +03:00
2023-06-02 02:45:24 +03:00
//reuseItems: true
ScrollBar.vertical: ScrollBar {
id: scrollbar
2022-08-10 01:20:44 +03:00
2023-06-02 02:45:24 +03:00
parent: !collapsed && Settings.scrollbarsInRoomlist ? roomlist : null
2021-05-28 18:25:46 +03:00
}
delegate: ItemDelegate {
2021-05-21 22:19:03 +03:00
id: roomItem
2023-06-02 02:45:24 +03:00
required property string avatarUrl
property color backgroundColor: palette.window
property color bubbleBackground: palette.highlight
property color bubbleText: palette.highlightedText
2023-06-02 02:45:24 +03:00
required property string directChatOtherUserId
required property bool hasLoudNotification
required property bool hasUnreadMessages
2023-06-02 02:45:24 +03:00
property color importantText: palette.text
2021-08-31 03:08:47 +03:00
required property bool isDirect
2023-06-02 02:45:24 +03:00
required property bool isInvite
required property bool isSpace
required property string lastMessage
required property int notificationCount
required property string roomId
required property string roomName
required property var tags
required property string time
property color unimportantText: palette.buttonText
ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: roomName
2023-06-02 02:45:24 +03:00
ToolTip.visible: hovered && collapsed
height: avatarSize + 2 * Nheko.paddingMedium
state: "normal"
width: ListView.view.width - ((scrollbar.interactive && scrollbar.visible && scrollbar.parent) ? scrollbar.width : 0)
2023-06-02 02:45:24 +03:00
background: Rectangle {
color: backgroundColor
}
2021-05-21 22:19:03 +03:00
states: [
State {
name: "highlight"
when: roomItem.hovered && !((Rooms.currentRoom && roomId == Rooms.currentRoom.roomId) || Rooms.currentRoomPreview.roomid == roomId)
2021-05-21 22:19:03 +03:00
PropertyChanges {
2023-10-26 17:43:09 +03:00
roomItem {
backgroundColor: palette.dark
bubbleBackground: palette.highlight
bubbleText: palette.highlightedText
importantText: palette.brightText
unimportantText: palette.brightText
}
2021-05-21 22:19:03 +03:00
}
},
State {
name: "selected"
2021-07-17 23:16:02 +03:00
when: (Rooms.currentRoom && roomId == Rooms.currentRoom.roomId) || Rooms.currentRoomPreview.roomid == roomId
2021-05-21 22:19:03 +03:00
PropertyChanges {
2023-10-26 17:43:09 +03:00
roomItem {
backgroundColor: palette.highlight
bubbleBackground: palette.highlightedText
bubbleText: palette.highlight
importantText: palette.highlightedText
unimportantText: palette.highlightedText
}
2021-05-21 22:19:03 +03:00
}
}
]
2021-05-19 20:34:10 +03:00
2023-06-02 02:45:24 +03:00
onClicked: {
console.log("tapped " + roomId);
if (!Rooms.currentRoom || Rooms.currentRoom.roomId !== roomId)
Rooms.setCurrentRoom(roomId);
else
Rooms.resetCurrentRoom();
}
onPressAndHold: {
if (!isInvite)
roomContextMenu.show(roomId, tags);
}
Ripple {
color: Qt.rgba(palette.dark.r, palette.dark.g, palette.dark.b, 0.5)
}
// NOTE(Nico): We want to prevent the touch areas from overlapping. For some reason we need to add 1px of padding for that...
Item {
anchors.fill: parent
anchors.margins: 1
TapHandler {
acceptedButtons: Qt.RightButton
2023-06-02 02:45:24 +03:00
acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus | PointerDevice.TouchPad
gesturePolicy: TapHandler.ReleaseWithinBounds
onSingleTapped: {
if (!TimelineManager.isInvite)
roomContextMenu.show(roomId, tags);
}
}
2021-05-21 22:19:03 +03:00
}
RowLayout {
2021-05-19 20:34:10 +03:00
anchors.fill: parent
anchors.margins: Nheko.paddingMedium
2023-06-02 02:45:24 +03:00
spacing: Nheko.paddingMedium
2021-05-19 20:34:10 +03:00
Avatar {
id: avatar
Layout.alignment: Qt.AlignVCenter
2023-06-02 02:45:24 +03:00
displayName: roomName
enabled: false
roomid: roomId
url: avatarUrl.replace("mxc://", "image://MxcImage/")
2021-09-05 03:53:33 +03:00
userid: isDirect ? directChatOtherUserId : ""
2023-10-26 17:43:09 +03:00
Layout.preferredWidth: avatarSize
Layout.preferredHeight: avatarSize
2021-06-08 23:18:51 +03:00
2022-04-22 01:26:25 +03:00
NotificationBubble {
2021-06-08 23:18:51 +03:00
id: collapsedNotificationBubble
anchors.bottom: parent.bottom
anchors.margins: -Nheko.paddingSmall
2023-06-02 02:45:24 +03:00
anchors.right: parent.right
bubbleBackgroundColor: roomItem.bubbleBackground
bubbleTextColor: roomItem.bubbleText
hasLoudNotification: roomItem.hasLoudNotification
2022-06-06 19:07:25 +03:00
mayBeVisible: collapsed && (isSpace ? Settings.spaceNotifications : true)
2023-06-02 02:45:24 +03:00
notificationCount: roomItem.notificationCount
2021-06-08 23:18:51 +03:00
}
2021-05-19 20:34:10 +03:00
}
ColumnLayout {
id: textContent
Layout.alignment: Qt.AlignLeft
Layout.minimumWidth: 100
2023-10-26 17:43:09 +03:00
Layout.preferredWidth: roomItem.width - avatar.width
Layout.preferredHeight: avatar.height
2022-02-26 18:06:20 +03:00
spacing: Nheko.paddingSmall
2023-06-02 02:45:24 +03:00
visible: !collapsed
2021-05-19 20:34:10 +03:00
2023-06-09 21:14:41 +03:00
Item {
2022-04-20 06:18:11 +03:00
id: titleRow
2022-02-26 18:06:20 +03:00
Layout.alignment: Qt.AlignTop
2023-06-09 21:14:41 +03:00
Layout.fillWidth: true
Layout.preferredHeight: subtitleText.implicitHeight
ElidedLabel {
id: titleText
anchors.left: parent.left
color: roomItem.importantText
elideWidth: parent.width - (timestamp.visible ? timestamp.implicitWidth : 0) - (spaceNotificationBubble.visible ? spaceNotificationBubble.implicitWidth : 0)
fullText: TimelineManager.htmlEscape(roomName)
textFormat: Text.RichText
2021-05-19 20:34:10 +03:00
}
Label {
id: timestamp
2021-06-18 17:22:06 +03:00
2023-06-09 21:14:41 +03:00
anchors.baseline: titleText.baseline
anchors.right: parent.right
2021-05-21 22:19:03 +03:00
color: roomItem.unimportantText
2023-06-02 02:45:24 +03:00
font.pixelSize: fontMetrics.font.pixelSize * 0.9
text: time
2023-06-02 02:45:24 +03:00
visible: !isInvite && !isSpace
2021-05-19 20:34:10 +03:00
}
2023-06-09 21:14:41 +03:00
NotificationBubble {
id: spaceNotificationBubble
anchors.right: parent.right
bubbleBackgroundColor: roomItem.bubbleBackground
bubbleTextColor: roomItem.bubbleText
hasLoudNotification: roomItem.hasLoudNotification
mayBeVisible: !collapsed && (isSpace ? Settings.spaceNotifications : false)
notificationCount: roomItem.notificationCount
parent: isSpace ? titleRow : subtextRow
}
2021-05-19 20:34:10 +03:00
}
2023-06-09 21:14:41 +03:00
Item {
2022-04-20 06:18:11 +03:00
id: subtextRow
2023-06-02 02:45:24 +03:00
Layout.alignment: Qt.AlignBottom
2021-05-19 20:34:10 +03:00
Layout.fillWidth: true
2023-06-09 21:14:41 +03:00
Layout.preferredHeight: subtitleText.implicitHeight
visible: !isSpace
2021-05-19 20:34:10 +03:00
ElidedLabel {
2023-06-09 21:14:41 +03:00
id: subtitleText
anchors.left: parent.left
2021-05-21 22:19:03 +03:00
color: roomItem.unimportantText
2023-06-09 21:14:41 +03:00
elideWidth: subtextRow.width - (subtextNotificationBubble.visible ? subtextNotificationBubble.implicitWidth : 0)
2023-06-02 02:45:24 +03:00
font.pixelSize: fontMetrics.font.pixelSize * 0.9
2023-01-18 21:20:32 +03:00
fullText: TimelineManager.htmlEscape(lastMessage)
2021-05-22 11:16:42 +03:00
textFormat: Text.RichText
2021-05-19 20:34:10 +03:00
}
2023-06-09 21:14:41 +03:00
NotificationBubble {
id: subtextNotificationBubble
anchors.baseline: subtitleText.baseline
anchors.right: parent.right
bubbleBackgroundColor: roomItem.bubbleBackground
bubbleTextColor: roomItem.bubbleText
hasLoudNotification: roomItem.hasLoudNotification
mayBeVisible: !collapsed
notificationCount: roomItem.notificationCount
}
2021-05-19 20:34:10 +03:00
}
}
}
Rectangle {
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
color: palette.highlight
2023-06-02 02:45:24 +03:00
height: parent.height - Nheko.paddingSmall * 2
visible: hasUnreadMessages
2023-06-02 02:45:24 +03:00
width: 3
2021-05-19 20:34:10 +03:00
}
2021-05-15 00:35:34 +03:00
}
2023-06-02 02:45:24 +03:00
Connections {
function onCurrentRoomChanged() {
if (Rooms.currentRoom)
roomlist.positionViewAtIndex(Rooms.roomidToIndex(Rooms.currentRoom.roomId), ListView.Contain);
}
2023-06-02 02:45:24 +03:00
target: Rooms
}
Component {
id: roomWindowComponent
2023-06-02 02:45:24 +03:00
ApplicationWindow {
id: roomWindowW
property var room: null
property var roomPreview: null
color: palette.window
height: 650
minimumHeight: 150
minimumWidth: 150
title: room.plainRoomName
width: 420
Component.onCompleted: {
MainWindow.addPerRoomWindow(room.roomId || roomPreview.roomid, roomWindowW);
Nheko.setTransientParent(roomWindowW, null);
}
Component.onDestruction: MainWindow.removePerRoomWindow(room.roomId || roomPreview.roomid, roomWindowW)
onActiveChanged: {
room.lastReadIdOnWindowFocus();
}
2023-06-02 02:45:24 +03:00
//flags: Qt.Window | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
Shortcut {
sequence: StandardKey.Cancel
2023-06-02 02:45:24 +03:00
onActivated: roomWindowW.close()
}
TimelineView {
id: timeline
2023-06-02 02:45:24 +03:00
anchors.fill: parent
privacyScreen: privacyScreen
room: roomWindowW.room
roomPreview: roomWindowW.roomPreview.roomid ? roomWindowW.roomPreview : null
}
PrivacyScreen {
id: privacyScreen
2023-06-02 02:45:24 +03:00
anchors.fill: parent
screenTimeout: Settings.privacyScreenTimeout
timelineRoot: timeline
visible: Settings.privacyScreen
windowTarget: roomWindowW
}
}
}
2023-06-02 02:45:24 +03:00
Component {
id: nestedSpaceMenuLevel
2023-06-02 02:45:24 +03:00
SpaceMenuLevel {
childMenu: rootSpaceMenu.childMenu
roomid: roomContextMenu.roomid
}
}
2023-06-02 02:45:24 +03:00
Platform.Menu {
id: roomContextMenu
2023-06-02 02:45:24 +03:00
property string roomid
property var tags
2021-05-15 00:35:34 +03:00
2023-06-02 02:45:24 +03:00
function show(roomid_, tags_) {
roomid = roomid_;
tags = tags_;
open();
}
2021-05-15 00:35:34 +03:00
2023-06-02 02:45:24 +03:00
InputDialog {
id: newTag
2021-05-15 00:35:34 +03:00
2023-06-02 02:45:24 +03:00
prompt: qsTr("Enter the tag you want to use:")
title: qsTr("New tag")
2021-05-15 00:35:34 +03:00
2023-06-02 02:45:24 +03:00
onAccepted: function (text) {
Rooms.toggleTag(roomContextMenu.roomid, "u." + text, true);
}
}
Platform.MenuItem {
text: qsTr("Open separately")
2021-05-15 00:35:34 +03:00
2023-06-02 02:45:24 +03:00
onTriggered: {
var roomWindow = roomWindowComponent.createObject(null, {
"room": Rooms.getRoomById(roomContextMenu.roomid),
"roomPreview": Rooms.getRoomPreviewById(roomContextMenu.roomid)
});
roomWindow.showNormal();
destroyOnClose(roomWindow);
}
}
Platform.MenuItem {
text: qsTr("Mark as read")
onTriggered: Rooms.getRoomById(roomContextMenu.roomid).markRoomAsRead()
}
2023-06-02 02:45:24 +03:00
Platform.MenuItem {
text: qsTr("Room settings")
2021-05-15 00:35:34 +03:00
2023-06-02 02:45:24 +03:00
onTriggered: TimelineManager.openRoomSettings(roomContextMenu.roomid)
}
Platform.MenuItem {
text: qsTr("Leave room")
2021-05-30 13:41:44 +03:00
2023-06-02 02:45:24 +03:00
onTriggered: TimelineManager.openLeaveRoomDialog(roomContextMenu.roomid)
}
Platform.MenuItem {
text: qsTr("Copy room link")
2021-05-30 13:41:44 +03:00
2023-06-02 02:45:24 +03:00
onTriggered: Rooms.copyLink(roomContextMenu.roomid)
}
Platform.Menu {
id: tagsMenu
2021-05-30 13:41:44 +03:00
2023-06-02 02:45:24 +03:00
title: qsTr("Tag room as:")
2021-05-30 13:41:44 +03:00
2023-06-02 02:45:24 +03:00
Instantiator {
model: Communities.tagsWithDefault
2022-03-26 19:28:44 +03:00
2023-06-02 02:45:24 +03:00
delegate: Platform.MenuItem {
property string t: modelData
checkable: true
checked: roomContextMenu.tags !== undefined && roomContextMenu.tags.includes(t)
text: {
switch (t) {
case "m.favourite":
return qsTr("Favourite");
case "m.lowpriority":
return qsTr("Low priority");
case "m.server_notice":
return qsTr("Server notice");
default:
return t.substring(2);
2022-09-05 03:00:20 +03:00
}
}
2023-06-02 02:45:24 +03:00
onTriggered: Rooms.toggleTag(roomContextMenu.roomid, t, checked)
2021-05-30 13:41:44 +03:00
}
2023-06-02 02:45:24 +03:00
onObjectAdded: (index, object) => tagsMenu.insertItem(index, object)
onObjectRemoved: (index, object) => tagsMenu.removeItem(object)
2021-05-15 00:35:34 +03:00
}
2023-06-02 02:45:24 +03:00
Platform.MenuItem {
text: qsTr("Create new tag...")
2021-05-15 00:35:34 +03:00
2023-06-02 02:45:24 +03:00
onTriggered: newTag.show()
2021-05-15 00:35:34 +03:00
}
}
2023-06-02 02:45:24 +03:00
SpaceMenuLevel {
id: rootSpaceMenu
2021-05-15 00:35:34 +03:00
2023-06-02 02:45:24 +03:00
childMenu: nestedSpaceMenuLevel
position: -1
roomid: roomContextMenu.roomid
title: qsTr("Add or remove from community...")
}
2021-05-15 00:35:34 +03:00
}
}
}