Debian Codegraph @

resources/qml/RoomList.qml

raw
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 import "./components"
6 import "./dialogs"
7 import "./ui"
8 import QtQuick
9 import QtQuick.Controls
10 import QtQuick.Layouts
11 import im.nheko
12
13 Page {
14 //leftPadding: Nheko.paddingSmall
15 //rightPadding: Nheko.paddingSmall
16 property int avatarSize: Math.ceil(fontMetrics.lineSpacing * 2.3)
17 property bool collapsed: false
18
19 background: Rectangle {
20 color: Nheko.theme.sidebarBackground
21 }
22 footer: ColumnLayout {
23 spacing: 0
24
25 Rectangle {
26 Layout.fillWidth: true
27 color: Nheko.theme.separator
28 Layout.preferredHeight: 1
29 }
30 Pane {
31 Layout.alignment: Qt.AlignBottom
32 Layout.fillWidth: true
33 Layout.minimumHeight: 40
34 horizontalPadding: Nheko.paddingMedium
35 verticalPadding: 0
36
37 background: Rectangle {
38 color: palette.window
39 }
40 contentItem: RowLayout {
41 id: buttonRow
42
43 ImageButton {
44 id: startChatButton
45
46 Layout.fillWidth: true
47 Layout.margins: Nheko.paddingMedium
48 ToolTip.delay: Nheko.tooltipDelay
49 ToolTip.text: qsTr("Start a new chat")
50 ToolTip.visible: hovered
51 Layout.preferredHeight: 22
52 Layout.preferredWidth: 22
53 hoverEnabled: true
54 image: ":/icons/icons/ui/add-square-button.svg"
55
56 onClicked: roomJoinCreateMenu.popup(startChatButton)
57
58 Menu {
59 id: roomJoinCreateMenu
60
61 MenuItem {
62 text: qsTr("Join a room")
63
64 onTriggered: Nheko.openJoinRoomDialog()
65 }
66 MenuItem {
67 text: qsTr("Create a new room")
68
69 onTriggered: {
70 var createRoom = createRoomComponent.createObject(timelineRoot);
71 createRoom.show();
72 timelineRoot.destroyOnClose(createRoom);
73 }
74 }
75 MenuItem {
76 text: qsTr("Start a direct chat")
77
78 onTriggered: {
79 var createDirect = createDirectComponent.createObject(timelineRoot);
80 createDirect.show();
81 timelineRoot.destroyOnClose(createDirect);
82 }
83 }
84 MenuItem {
85 text: qsTr("Create a new community")
86
87 onTriggered: {
88 var createRoom = createRoomComponent.createObject(timelineRoot, {
89 "space": true
90 });
91 createRoom.show();
92 timelineRoot.destroyOnClose(createRoom);
93 }
94 }
95 }
96 }
97 ImageButton {
98 Layout.fillWidth: true
99 Layout.margins: Nheko.paddingMedium
100 ToolTip.delay: Nheko.tooltipDelay
101 ToolTip.text: qsTr("Room directory")
102 ToolTip.visible: hovered
103 Layout.preferredHeight: 22
104 Layout.preferredWidth: 22
105 hoverEnabled: true
106 image: ":/icons/icons/ui/room-directory.svg"
107 visible: !collapsed
108
109 onClicked: {
110 var win = roomDirectoryComponent.createObject(timelineRoot);
111 win.show();
112 timelineRoot.destroyOnClose(win);
113 }
114 }
115 ImageButton {
116 Layout.fillWidth: true
117 Layout.margins: Nheko.paddingMedium
118 ToolTip.delay: Nheko.tooltipDelay
119 ToolTip.text: qsTr("Search rooms (Ctrl+K)")
120 ToolTip.visible: hovered
121 Layout.preferredHeight: 22
122 Layout.preferredWidth: 22
123 hoverEnabled: true
124 image: ":/icons/icons/ui/search.svg"
125 ripple: false
126 visible: !collapsed
127
128 onClicked: {
129 var component = Qt.createComponent("qrc:/resources/qml/QuickSwitcher.qml");
130 if (component.status == Component.Ready) {
131 var quickSwitch = component.createObject(timelineRoot);
132 quickSwitch.open();
133 destroyOnClosed(quickSwitch);
134 } else {
135 console.error("Failed to create component: " + component.errorString());
136 }
137 }
138 }
139 ImageButton {
140 Layout.fillWidth: true
141 Layout.margins: Nheko.paddingMedium
142 ToolTip.delay: Nheko.tooltipDelay
143 ToolTip.text: qsTr("User settings")
144 ToolTip.visible: hovered
145 Layout.preferredHeight: 22
146 Layout.preferredWidth: 22
147 hoverEnabled: true
148 image: ":/icons/icons/ui/settings.svg"
149 ripple: false
150 visible: !collapsed
151
152 onClicked: mainWindow.push(userSettingsPage)
153 }
154 }
155 }
156 }
157 header: ColumnLayout {
158 spacing: 0
159
160 Pane {
161 id: userInfoPanel
162
163 function openUserProfile() {
164 Nheko.updateUserProfile();
165 var component = Qt.createComponent("qrc:/resources/qml/dialogs/UserProfile.qml");
166 if (component.status == Component.Ready) {
167 var userProfile = component.createObject(timelineRoot, {
168 "profile": Nheko.currentUser
169 });
170 userProfile.show();
171 timelineRoot.destroyOnClose(userProfile);
172 } else {
173 console.error("Failed to create component: " + component.errorString());
174 }
175 }
176
177 Layout.alignment: Qt.AlignBottom
178 Layout.fillWidth: true
179 Layout.minimumHeight: 40
180 //Layout.preferredHeight: userInfoGrid.implicitHeight + 2 * Nheko.paddingMedium
181 padding: Nheko.paddingMedium
182
183 background: Rectangle {
184 color: palette.window
185 }
186 contentItem: RowLayout {
187 id: userInfoGrid
188
189 property var profile: Nheko.currentUser
190
191 spacing: Nheko.paddingMedium
192
193 Avatar {
194 id: headerAvatar
195
196 Layout.alignment: Qt.AlignVCenter
197 Layout.preferredHeight: fontMetrics.lineSpacing * 2
198 Layout.preferredWidth: fontMetrics.lineSpacing * 2
199 displayName: userInfoGrid.profile ? userInfoGrid.profile.displayName : ""
200 enabled: false
201 url: (userInfoGrid.profile ? userInfoGrid.profile.avatarUrl : "").replace("mxc://", "image://MxcImage/")
202 userid: userInfoGrid.profile ? userInfoGrid.profile.userid : ""
203 }
204 ColumnLayout {
205 id: col
206
207 Layout.alignment: Qt.AlignLeft
208 Layout.fillWidth: true
209 Layout.preferredWidth: parent.width - headerAvatar.width - logoutButton.width - Nheko.paddingMedium * 2
210 spacing: 0
211 visible: !collapsed
212
213 ElidedLabel {
214 Layout.alignment: Qt.AlignBottom
215 elideWidth: col.width
216 font.pointSize: fontMetrics.font.pointSize * 1.1
217 font.weight: Font.DemiBold
218 fullText: userInfoGrid.profile ? userInfoGrid.profile.displayName : ""
219 }
220 ElidedLabel {
221 Layout.alignment: Qt.AlignTop
222 color: palette.buttonText
223 elideWidth: col.width
224 font.pointSize: fontMetrics.font.pointSize * 0.9
225 fullText: userInfoGrid.profile ? userInfoGrid.profile.userid : ""
226 }
227 }
228 Item {
229 }
230 ImageButton {
231 id: logoutButton
232
233 Layout.alignment: Qt.AlignVCenter
234 Layout.preferredHeight: fontMetrics.lineSpacing * 2
235 Layout.preferredWidth: fontMetrics.lineSpacing * 2
236 ToolTip.delay: Nheko.tooltipDelay
237 ToolTip.text: qsTr("Logout")
238 ToolTip.visible: hovered
239 image: ":/icons/icons/ui/power-off.svg"
240 visible: !collapsed
241
242 onClicked: Nheko.openLogoutDialog()
243 }
244 }
245
246 InputDialog {
247 id: statusDialog
248
249 prompt: qsTr("Enter your status message:")
250 title: qsTr("Status Message")
251
252 text: userInfoGrid.profile ? Presence.userStatus(userInfoGrid.profile.userid) : ""
253
254 onAccepted: function (text) {
255 Nheko.setStatusMessage(text);
256 }
257 }
258 Menu {
259 id: userInfoMenu
260
261 MenuItem {
262 text: qsTr("Profile settings")
263
264 onTriggered: userInfoPanel.openUserProfile()
265 }
266 MenuItem {
267 text: qsTr("Set status message")
268
269 onTriggered: statusDialog.show()
270 }
271 MenuSeparator {
272 }
273
274 ButtonGroup {
275 id: onlineStateGroup
276 }
277 MenuItem {
278 text: qsTr("Automatic online status")
279 ButtonGroup.group: onlineStateGroup
280 checkable: true
281 checked: Settings.presence == Settings.AutomaticPresence
282 onTriggered: if (checked) Settings.presence = Settings.AutomaticPresence
283 }
284 MenuItem {
285 text: qsTr("Online")
286 ButtonGroup.group: onlineStateGroup
287 checkable: true
288 checked: Settings.presence == Settings.Online
289 onTriggered: if (checked) Settings.presence = Settings.Online
290 }
291 MenuItem {
292 text: qsTr("Unavailable")
293 ButtonGroup.group: onlineStateGroup
294 checkable: true
295 checked: Settings.presence == Settings.Unavailable
296 onTriggered: if (checked) Settings.presence = Settings.Unavailable
297 }
298 MenuItem {
299 text: qsTr("Offline")
300 ButtonGroup.group: onlineStateGroup
301 checkable: true
302 checked: Settings.presence == Settings.Offline
303 onTriggered: if (checked) Settings.presence = Settings.Offline
304 }
305 }
306 TapHandler {
307 acceptedButtons: Qt.LeftButton
308 gesturePolicy: TapHandler.ReleaseWithinBounds
309 margin: -Nheko.paddingSmall
310
311 onLongPressed: userInfoMenu.popup(userInfoPanel)
312 onSingleTapped: userInfoPanel.openUserProfile()
313 }
314 TapHandler {
315 acceptedButtons: Qt.RightButton
316 gesturePolicy: TapHandler.ReleaseWithinBounds
317 margin: -Nheko.paddingSmall
318
319 onSingleTapped: userInfoMenu.popup(userInfoPanel)
320 }
321 }
322 Rectangle {
323 Layout.fillWidth: true
324 color: Nheko.theme.separator
325 Layout.preferredHeight: 2
326 }
327 Rectangle {
328 id: unverifiedStuffBubble
329
330 Layout.fillWidth: true
331 color: Qt.lighter(Nheko.theme.orange, verifyButtonHovered.hovered ? 1.2 : 1)
332 implicitHeight: explanation.height + Nheko.paddingMedium * 2
333 visible: SelfVerificationStatus.status != SelfVerificationStatus.AllVerified
334
335 RowLayout {
336 id: unverifiedStuffBubbleContainer
337
338 height: explanation.height + Nheko.paddingMedium * 2
339 spacing: 0
340 width: parent.width
341
342 Label {
343 id: explanation
344
345 Layout.fillWidth: true
346 Layout.margins: Nheko.paddingMedium
347 Layout.rightMargin: Nheko.paddingSmall
348 color: palette.buttonText
349 text: {
350 switch (SelfVerificationStatus.status) {
351 case SelfVerificationStatus.NoMasterKey:
352 //: Cross-signing setup has not run yet.
353 return qsTr("Encryption not set up");
354 case SelfVerificationStatus.UnverifiedMasterKey:
355 //: The user just signed in with this device and hasn't verified their master key.
356 return qsTr("Unverified login");
357 case SelfVerificationStatus.UnverifiedDevices:
358 //: There are unverified devices signed in to this account.
359 return qsTr("Please verify your other devices");
360 default:
361 return "";
362 }
363 }
364 textFormat: Text.PlainText
365 wrapMode: Text.Wrap
366 }
367 ImageButton {
368 id: closeUnverifiedBubble
369
370 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
371 Layout.rightMargin: Nheko.paddingMedium
372 ToolTip.delay: Nheko.tooltipDelay
373 ToolTip.text: qsTr("Close")
374 ToolTip.visible: closeUnverifiedBubble.hovered
375 Layout.preferredHeight: fontMetrics.font.pixelSize
376 hoverEnabled: true
377 image: ":/icons/icons/ui/dismiss.svg"
378 Layout.preferredWidth: fontMetrics.font.pixelSize
379
380 onClicked: unverifiedStuffBubble.visible = false
381 }
382 }
383 HoverHandler {
384 id: verifyButtonHovered
385
386 acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus | PointerDevice.TouchPad
387 enabled: !closeUnverifiedBubble.hovered
388 }
389 TapHandler {
390 acceptedButtons: Qt.LeftButton
391 enabled: !closeUnverifiedBubble.hovered
392
393 onSingleTapped: {
394 if (SelfVerificationStatus.status == SelfVerificationStatus.UnverifiedDevices)
395 SelfVerificationStatus.verifyUnverifiedDevices();
396 else
397 SelfVerificationStatus.statusChanged();
398 }
399 }
400 }
401 Rectangle {
402 Layout.fillWidth: true
403 color: Nheko.theme.separator
404 Layout.preferredHeight: 1
405 visible: unverifiedStuffBubble.visible
406 }
407 }
408
409 // HACK: https://bugreports.qt.io/browse/QTBUG-83972, qtwayland cannot auto hide menu
410 Connections {
411 function onHideMenu() {
412 userInfoMenu.close();
413 roomContextMenu.close();
414 }
415
416 target: MainWindow
417 }
418 Component {
419 id: roomDirectoryComponent
420
421 RoomDirectory {
422 }
423 }
424 Component {
425 id: createRoomComponent
426
427 CreateRoom {
428 }
429 }
430 Component {
431 id: createDirectComponent
432
433 CreateDirect {
434 }
435 }
436 ListView {
437 id: roomlist
438
439 anchors.left: parent.left
440 anchors.right: parent.right
441 height: parent.height
442 model: Rooms
443 boundsBehavior: Flickable.StopAtBounds
444
445 //reuseItems: true
446 ScrollBar.vertical: ScrollBar {
447 id: scrollbar
448
449 parent: !collapsed && Settings.scrollbarsInRoomlist ? roomlist : null
450 }
451 delegate: ItemDelegate {
452 id: roomItem
453
454 required property string avatarUrl
455 property color backgroundColor: palette.window
456 property color bubbleBackground: palette.highlight
457 property color bubbleText: palette.highlightedText
458 required property string directChatOtherUserId
459 required property bool hasLoudNotification
460 required property bool hasUnreadMessages
461 property color importantText: palette.text
462 required property bool isDirect
463 required property bool isInvite
464 required property bool isSpace
465 required property string lastMessage
466 required property int notificationCount
467 required property string roomId
468 required property string roomName
469 required property var tags
470 required property string time
471 property color unimportantText: palette.buttonText
472
473 ToolTip.delay: Nheko.tooltipDelay
474 ToolTip.text: roomName
475 ToolTip.visible: hovered && collapsed
476 height: avatarSize + 2 * Nheko.paddingMedium
477 state: "normal"
478 width: ListView.view.width - ((scrollbar.interactive && scrollbar.visible && scrollbar.parent) ? scrollbar.width : 0)
479
480 topInset: 0
481 bottomInset: 0
482 leftInset: 0
483 rightInset: 0
484
485 background: Rectangle {
486 color: backgroundColor
487 }
488 states: [
489 State {
490 name: "highlight"
491 when: roomItem.hovered && !((Rooms.currentRoom && roomId == Rooms.currentRoom.roomId) || Rooms.currentRoomPreview.roomid == roomId)
492
493 PropertyChanges {
494 roomItem {
495 backgroundColor: palette.dark
496 bubbleBackground: palette.highlight
497 bubbleText: palette.highlightedText
498 importantText: palette.brightText
499 unimportantText: palette.brightText
500 }
501 }
502 },
503 State {
504 name: "selected"
505 when: (Rooms.currentRoom && roomId == Rooms.currentRoom.roomId) || Rooms.currentRoomPreview.roomid == roomId
506
507 PropertyChanges {
508 roomItem {
509 backgroundColor: palette.highlight
510 bubbleBackground: palette.highlightedText
511 bubbleText: palette.highlight
512 importantText: palette.highlightedText
513 unimportantText: palette.highlightedText
514 }
515 }
516 }
517 ]
518
519 onClicked: {
520 console.log("tapped " + roomId);
521 if (!Rooms.currentRoom || Rooms.currentRoom.roomId !== roomId)
522 Rooms.setCurrentRoom(roomId);
523 else
524 Rooms.resetCurrentRoom();
525 }
526 onPressAndHold: {
527 if (!isInvite)
528 roomContextMenu.show(roomItem, roomId, tags);
529 }
530
531 Ripple {
532 color: Qt.rgba(palette.dark.r, palette.dark.g, palette.dark.b, 0.5)
533 }
534
535 // NOTE(Nico): We want to prevent the touch areas from overlapping. For some reason we need to add 1px of padding for that...
536 Item {
537 anchors.fill: parent
538 anchors.margins: 1
539
540 TapHandler {
541 id: roomItemTh
542
543 acceptedButtons: Qt.RightButton
544 acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus | PointerDevice.TouchPad
545 gesturePolicy: TapHandler.ReleaseWithinBounds
546
547 onSingleTapped: {
548 if (!TimelineManager.isInvite)
549 roomContextMenu.show(roomItemTh.parent, roomId, tags);
550 }
551 }
552 }
553 RowLayout {
554 anchors.fill: parent
555 anchors.margins: Nheko.paddingMedium
556 spacing: Nheko.paddingMedium
557
558 Avatar {
559 id: avatar
560
561 Layout.alignment: Qt.AlignVCenter
562 displayName: roomName
563 enabled: false
564 roomid: roomId
565 url: avatarUrl.replace("mxc://", "image://MxcImage/")
566 userid: isDirect ? directChatOtherUserId : ""
567 Layout.preferredWidth: avatarSize
568 Layout.preferredHeight: avatarSize
569
570 NotificationBubble {
571 id: collapsedNotificationBubble
572
573 anchors.bottom: parent.bottom
574 anchors.margins: -Nheko.paddingSmall
575 anchors.right: parent.right
576 bubbleBackgroundColor: roomItem.bubbleBackground
577 bubbleTextColor: roomItem.bubbleText
578 hasLoudNotification: roomItem.hasLoudNotification
579 mayBeVisible: collapsed && (isSpace ? Settings.spaceNotifications : true)
580 notificationCount: roomItem.notificationCount
581 }
582 }
583 ColumnLayout {
584 id: textContent
585
586 Layout.alignment: Qt.AlignLeft
587 Layout.minimumWidth: 100
588 Layout.preferredWidth: roomItem.width - avatar.width
589 Layout.preferredHeight: avatar.height
590 spacing: Nheko.paddingSmall
591 visible: !collapsed
592
593 Item {
594 id: titleRow
595
596 Layout.alignment: Qt.AlignTop
597 Layout.fillWidth: true
598 Layout.preferredHeight: subtitleText.implicitHeight
599
600 ElidedLabel {
601 id: titleText
602
603 anchors.left: parent.left
604 color: roomItem.importantText
605 elideWidth: parent.width - (timestamp.visible ? timestamp.implicitWidth : 0) - (spaceNotificationBubble.visible ? spaceNotificationBubble.implicitWidth : 0)
606 fullText: TimelineManager.htmlEscape(roomName)
607 textFormat: Text.RichText
608 }
609 Label {
610 id: timestamp
611
612 anchors.baseline: titleText.baseline
613 anchors.right: parent.right
614 color: roomItem.unimportantText
615 font.pixelSize: fontMetrics.font.pixelSize * 0.9
616 text: time
617 visible: !isInvite && !isSpace
618 }
619 NotificationBubble {
620 id: spaceNotificationBubble
621
622 anchors.right: parent.right
623 bubbleBackgroundColor: roomItem.bubbleBackground
624 bubbleTextColor: roomItem.bubbleText
625 hasLoudNotification: roomItem.hasLoudNotification
626 mayBeVisible: !collapsed && (isSpace ? Settings.spaceNotifications : false)
627 notificationCount: roomItem.notificationCount
628 parent: isSpace ? titleRow : subtextRow
629 }
630 }
631 Item {
632 id: subtextRow
633
634 Layout.alignment: Qt.AlignBottom
635 Layout.fillWidth: true
636 Layout.preferredHeight: subtitleText.implicitHeight
637 visible: !isSpace
638
639 ElidedLabel {
640 id: subtitleText
641
642 anchors.left: parent.left
643 color: roomItem.unimportantText
644 elideWidth: subtextRow.width - (subtextNotificationBubble.visible ? subtextNotificationBubble.implicitWidth : 0)
645 font.pixelSize: fontMetrics.font.pixelSize * 0.9
646 fullText: TimelineManager.htmlEscape(lastMessage)
647 textFormat: Text.RichText
648 }
649 NotificationBubble {
650 id: subtextNotificationBubble
651
652 anchors.baseline: subtitleText.baseline
653 anchors.right: parent.right
654 bubbleBackgroundColor: roomItem.bubbleBackground
655 bubbleTextColor: roomItem.bubbleText
656 hasLoudNotification: roomItem.hasLoudNotification
657 mayBeVisible: !collapsed
658 notificationCount: roomItem.notificationCount
659 }
660 }
661 }
662 }
663 Rectangle {
664 anchors.left: parent.left
665 anchors.verticalCenter: parent.verticalCenter
666 color: palette.highlight
667 height: parent.height - Nheko.paddingSmall * 2
668 visible: hasUnreadMessages
669 width: 3
670 }
671 }
672
673 Connections {
674 function onCurrentRoomChanged() {
675 if (Rooms.currentRoom)
676 roomlist.positionViewAtIndex(Rooms.roomidToIndex(Rooms.currentRoom.roomId), ListView.Contain);
677 }
678
679 target: Rooms
680 }
681 Component {
682 id: roomWindowComponent
683
684 ApplicationWindow {
685 id: roomWindowW
686
687 property var room: null
688 property var roomPreview: null
689
690 color: palette.window
691 height: 650
692 minimumHeight: 150
693 minimumWidth: 150
694 title: room.plainRoomName
695 width: 420
696
697 Component.onCompleted: {
698 MainWindow.addPerRoomWindow(room.roomId || roomPreview.roomid, roomWindowW);
699 Nheko.setTransientParent(roomWindowW, null);
700 }
701 Component.onDestruction: MainWindow.removePerRoomWindow(room.roomId || roomPreview.roomid, roomWindowW)
702 onActiveChanged: {
703 room.lastReadIdOnWindowFocus();
704 }
705
706 //flags: Qt.Window | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
707 Shortcut {
708 sequence: StandardKey.Cancel
709
710 onActivated: roomWindowW.close()
711 }
712 TimelineView {
713 id: timeline
714
715 anchors.fill: parent
716 privacyScreen: privacyScreen
717 room: roomWindowW.room
718 roomPreview: roomWindowW.roomPreview.roomid ? roomWindowW.roomPreview : null
719 }
720 PrivacyScreen {
721 id: privacyScreen
722
723 anchors.fill: parent
724 screenTimeout: Settings.privacyScreenTimeout
725 timelineRoot: timeline
726 visible: Settings.privacyScreen
727 windowTarget: roomWindowW
728 }
729 }
730 }
731 Menu {
732 id: roomContextMenu
733
734 property string roomid
735 property var tags
736
737 function show(parent, roomid_, tags_) {
738 roomid = roomid_;
739 tags = tags_;
740 popup(parent);
741 }
742
743 Component.onCompleted: {
744 if (roomContextMenu.popupType != undefined) {
745 roomContextMenu.popupType = 2; // Popup.Native with fallback on older Qt (<6.8.0)
746 }
747 }
748
749 InputDialog {
750 id: newTag
751
752 prompt: qsTr("Enter the tag you want to use:")
753 title: qsTr("New tag")
754
755 onAccepted: function (text) {
756 Rooms.toggleTag(roomContextMenu.roomid, "u." + text, true);
757 }
758 }
759 MenuItem {
760 text: qsTr("Open separately")
761
762 onTriggered: {
763 var roomWindow = roomWindowComponent.createObject(null, {
764 "room": Rooms.getRoomById(roomContextMenu.roomid),
765 "roomPreview": Rooms.getRoomPreviewById(roomContextMenu.roomid)
766 });
767 roomWindow.showNormal();
768 destroyOnClose(roomWindow);
769 }
770 }
771 MenuItem {
772 text: qsTr("Mark as read")
773
774 onTriggered: Rooms.getRoomById(roomContextMenu.roomid).markRoomAsRead()
775 }
776 MenuItem {
777 text: qsTr("Room settings")
778
779 onTriggered: TimelineManager.openRoomSettings(roomContextMenu.roomid)
780 }
781 MenuItem {
782 text: qsTr("Leave room")
783
784 onTriggered: TimelineManager.openLeaveRoomDialog(roomContextMenu.roomid)
785 }
786 MenuItem {
787 text: qsTr("Copy room link")
788
789 onTriggered: Rooms.copyLink(roomContextMenu.roomid)
790 }
791 Menu {
792 id: tagsMenu
793
794 title: qsTr("Tag room as:")
795
796 Instantiator {
797 model: Communities.tagsWithDefault
798
799 delegate: MenuItem {
800 property string t: modelData
801
802 checkable: true
803 checked: roomContextMenu.tags !== undefined && roomContextMenu.tags.includes(t)
804 text: {
805 switch (t) {
806 case "m.favourite":
807 return qsTr("Favourite");
808 case "m.lowpriority":
809 return qsTr("Low priority");
810 case "m.server_notice":
811 return qsTr("Server notice");
812 default:
813 return t.substring(2);
814 }
815 }
816
817 onTriggered: Rooms.toggleTag(roomContextMenu.roomid, t, checked)
818 }
819
820 onObjectAdded: (index, object) => tagsMenu.insertItem(index, object)
821 onObjectRemoved: (index, object) => tagsMenu.removeItem(object)
822 }
823 MenuItem {
824 text: qsTr("Create new tag...")
825
826 onTriggered: newTag.show()
827 }
828 }
829 SpaceMenu {
830 id: rootSpaceMenu
831
832 roomid: roomContextMenu.roomid
833 }
834 }
835 }
836 }