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.enterSpaceHome(room);
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', {room: room, connection: connection}, { title: i18n("Space Settings") })
0049             }
0050 
0051             QQC2.MenuSeparator {}
0052 
0053             QQC2.MenuItem {
0054                 text: i18nc("'Space' is a matrix space", "Leave Space")
0055                 icon.name: "go-previous"
0056                 onTriggered: RoomManager.leaveRoom(room)
0057             }
0058 
0059             onClosed: {
0060                 root.closed()
0061                 regularMenu.destroy()
0062             }
0063         }
0064     }
0065 
0066     Component {
0067         id: mobileMenu
0068 
0069         Kirigami.OverlayDrawer {
0070             id: drawer
0071             height: popupContent.implicitHeight
0072             edge: Qt.BottomEdge
0073             padding: 0
0074             leftPadding: 0
0075             rightPadding: 0
0076             bottomPadding: 0
0077             topPadding: 0
0078 
0079             parent: applicationWindow().overlay
0080 
0081             ColumnLayout {
0082                 id: popupContent
0083 
0084                 width: parent.width
0085                 spacing: 0
0086 
0087                 RowLayout {
0088                     id: headerLayout
0089                     Layout.fillWidth: true
0090                     Layout.margins: Kirigami.Units.largeSpacing
0091                     spacing: Kirigami.Units.largeSpacing
0092 
0093                     KirigamiComponents.Avatar {
0094                         id: avatar
0095                         source: room.avatarMediaId ? ("image://mxc/" + room.avatarMediaId) : ""
0096                         Layout.preferredWidth: Kirigami.Units.gridUnit * 3
0097                         Layout.preferredHeight: Kirigami.Units.gridUnit * 3
0098                         Layout.alignment: Qt.AlignTop
0099                     }
0100 
0101                     Kirigami.Heading {
0102                         level: 5
0103                         Layout.fillWidth: true
0104                         text: room.displayName
0105                         wrapMode: Text.WordWrap
0106                     }
0107                 }
0108 
0109                 FormCard.FormButtonDelegate {
0110                     text: i18nc("'Space' is a matrix space", "View Space")
0111                     icon.name: "view-list-details"
0112                     onClicked: RoomManager.enterRoom(room);
0113                 }
0114 
0115                 FormCard.FormButtonDelegate {
0116                     text: i18nc("@action:inmenu", "Copy Address to Clipboard")
0117                     icon.name: "edit-copy"
0118                     onClicked: if (room.canonicalAlias.length === 0) {
0119                         Clipboard.saveText(room.id);
0120                     } else {
0121                         Clipboard.saveText(room.canonicalAlias);
0122                     }
0123                 }
0124 
0125                 FormCard.FormButtonDelegate {
0126                     text: i18nc("'Space' is a matrix space", "Space Settings")
0127                     icon.name: 'settings-configure'
0128                     onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/org/kde/neochat/qml/Categories.qml', {room: room, connection: connection}, { title: i18n("Space Settings") })
0129                 }
0130 
0131                 FormCard.FormButtonDelegate {
0132                     text: i18nc("'Space' is a matrix space", "Leave Space")
0133                     onClicked: RoomManager.leaveRoom(room)
0134                 }
0135             }
0136             onClosed: root.closed()
0137         }
0138     }
0139 
0140     asynchronous: true
0141     sourceComponent: Kirigami.Settings.isMobile ? mobileMenu : regularMenu
0142 
0143     function open() {
0144         active = true;
0145     }
0146 
0147     onStatusChanged: if (status == Loader.Ready) {
0148         if (Kirigami.Settings.isMobile) {
0149             item.open();
0150         } else {
0151             item.popup();
0152         }
0153     }
0154 }