Warning, /network/neochat/src/qml/SpaceListContextMenu.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
0002 // SPDX-FileCopyrightText: 2022 Tobias Fella <tobias.fella@kde.org>
0003 // SPDX-License-Identifier: GPL-3.0-only
0004 
0005 import QtQuick
0006 import QtQuick.Controls as QQC2
0007 import QtQuick.Layouts
0008 
0009 import org.kde.kirigami as Kirigami
0010 import org.kde.kirigamiaddons.components as KirigamiComponents
0011 import org.kde.kirigamiaddons.formcard as FormCard
0012 
0013 import org.kde.neochat
0014 
0015 /**
0016  * Context menu when clicking on a room in the room list
0017  */
0018 Loader {
0019     id: root
0020 
0021     property NeoChatRoom room
0022     required property NeoChatConnection connection
0023 
0024     signal closed
0025 
0026     Component {
0027         id: regularMenu
0028         QQC2.Menu {
0029             QQC2.MenuItem {
0030                 text: i18nc("'Space' is a matrix space", "View Space")
0031                 icon.name: "view-list-details"
0032                 onTriggered: RoomManager.resolveResource(room.id)
0033             }
0034 
0035             QQC2.MenuItem {
0036                 text: i18nc("@action:inmenu", "Copy Address to Clipboard")
0037                 icon.name: "edit-copy"
0038                 onTriggered: if (room.canonicalAlias.length === 0) {
0039                     Clipboard.saveText(room.id);
0040                 } else {
0041                     Clipboard.saveText(room.canonicalAlias);
0042                 }
0043             }
0044 
0045             QQC2.MenuItem {
0046                 text: i18nc("'Space' is a matrix space", "Space Settings")
0047                 icon.name: 'settings-configure'
0048                 onTriggered: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/org/kde/neochat/qml/Categories.qml', {
0049                     room: room,
0050                     connection: connection
0051                 }, {
0052                     title: i18n("Space Settings")
0053                 })
0054             }
0055 
0056             QQC2.MenuSeparator {}
0057 
0058             QQC2.MenuItem {
0059                 text: i18nc("'Space' is a matrix space", "Leave Space")
0060                 icon.name: "go-previous"
0061                 onTriggered: RoomManager.leaveRoom(room)
0062             }
0063 
0064             onClosed: {
0065                 root.closed();
0066                 regularMenu.destroy();
0067             }
0068         }
0069     }
0070 
0071     Component {
0072         id: mobileMenu
0073 
0074         Kirigami.OverlayDrawer {
0075             id: drawer
0076             height: popupContent.implicitHeight
0077             edge: Qt.BottomEdge
0078             padding: 0
0079             leftPadding: 0
0080             rightPadding: 0
0081             bottomPadding: 0
0082             topPadding: 0
0083 
0084             parent: applicationWindow().overlay
0085 
0086             ColumnLayout {
0087                 id: popupContent
0088 
0089                 width: parent.width
0090                 spacing: 0
0091 
0092                 RowLayout {
0093                     id: headerLayout
0094                     Layout.fillWidth: true
0095                     Layout.margins: Kirigami.Units.largeSpacing
0096                     spacing: Kirigami.Units.largeSpacing
0097 
0098                     KirigamiComponents.Avatar {
0099                         id: avatar
0100                         source: room.avatarMediaId ? ("image://mxc/" + room.avatarMediaId) : ""
0101                         Layout.preferredWidth: Kirigami.Units.gridUnit * 3
0102                         Layout.preferredHeight: Kirigami.Units.gridUnit * 3
0103                         Layout.alignment: Qt.AlignTop
0104                     }
0105 
0106                     Kirigami.Heading {
0107                         level: 5
0108                         Layout.fillWidth: true
0109                         text: room.displayName
0110                         wrapMode: Text.WordWrap
0111                     }
0112                 }
0113 
0114                 FormCard.FormButtonDelegate {
0115                     text: i18nc("'Space' is a matrix space", "View Space")
0116                     icon.name: "view-list-details"
0117                     onClicked: RoomManager.resolveResource(root.room.id)
0118                 }
0119 
0120                 FormCard.FormButtonDelegate {
0121                     text: i18nc("@action:inmenu", "Copy Address to Clipboard")
0122                     icon.name: "edit-copy"
0123                     onClicked: if (room.canonicalAlias.length === 0) {
0124                         Clipboard.saveText(room.id);
0125                     } else {
0126                         Clipboard.saveText(room.canonicalAlias);
0127                     }
0128                 }
0129 
0130                 FormCard.FormButtonDelegate {
0131                     text: i18nc("'Space' is a matrix space", "Space Settings")
0132                     icon.name: 'settings-configure'
0133                     onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/org/kde/neochat/qml/Categories.qml', {
0134                         room: room,
0135                         connection: connection
0136                     }, {
0137                         title: i18n("Space Settings")
0138                     })
0139                 }
0140 
0141                 FormCard.FormButtonDelegate {
0142                     text: i18nc("'Space' is a matrix space", "Leave Space")
0143                     onClicked: RoomManager.leaveRoom(room)
0144                 }
0145             }
0146             onClosed: root.closed()
0147         }
0148     }
0149 
0150     asynchronous: true
0151     sourceComponent: Kirigami.Settings.isMobile ? mobileMenu : regularMenu
0152 
0153     function open() {
0154         active = true;
0155     }
0156 
0157     onStatusChanged: if (status == Loader.Ready) {
0158         if (Kirigami.Settings.isMobile) {
0159             item.open();
0160         } else {
0161             item.popup();
0162         }
0163     }
0164 }