Warning, /network/neochat/src/qml/FileDelegateContextMenu.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org> 0002 // SPDX-License-Identifier: GPL-3.0-only 0003 0004 import QtQuick 0005 import QtQuick.Controls as QQC2 0006 import Qt.labs.platform 0007 0008 import org.kde.kirigami as Kirigami 0009 0010 import org.kde.neochat 0011 import org.kde.neochat.config 0012 0013 /** 0014 * @brief The menu for media messages. 0015 * 0016 * This component just overloads the actions and nested actions of the base menu 0017 * to what is required for a media item. 0018 * 0019 * @sa MessageDelegateContextMenu 0020 */ 0021 MessageDelegateContextMenu { 0022 id: root 0023 0024 /** 0025 * @brief The MIME type of the media. 0026 */ 0027 property string mimeType 0028 0029 /** 0030 * @brief Progress info when downloading files. 0031 * 0032 * @sa Quotient::FileTransferInfo 0033 */ 0034 required property var progressInfo 0035 0036 /** 0037 * @brief The main list of menu item actions. 0038 * 0039 * Each action will be instantiated as a single line in the menu. 0040 */ 0041 property list<Kirigami.Action> actions: [ 0042 Kirigami.Action { 0043 text: i18n("Open Externally") 0044 icon.name: "document-open" 0045 onTriggered: { 0046 currentRoom.openEventMediaExternally(root.eventId) 0047 } 0048 }, 0049 Kirigami.Action { 0050 text: i18n("Save As") 0051 icon.name: "document-save" 0052 onTriggered: { 0053 var dialog = saveAsDialog.createObject(QQC2.ApplicationWindow.overlay) 0054 dialog.open() 0055 dialog.currentFile = dialog.folder + "/" + currentRoom.fileNameToDownload(eventId) 0056 } 0057 }, 0058 Kirigami.Action { 0059 text: i18n("Reply") 0060 icon.name: "mail-replied-symbolic" 0061 onTriggered: { 0062 currentRoom.mainCache.replyId = eventId; 0063 currentRoom.editCache.editId = ""; 0064 RoomManager.requestFullScreenClose() 0065 } 0066 }, 0067 Kirigami.Action { 0068 text: i18n("Copy") 0069 icon.name: "edit-copy" 0070 onTriggered: { 0071 currentRoom.copyEventMedia(root.eventId) 0072 } 0073 }, 0074 Kirigami.Action { 0075 visible: author.id === currentRoom.localUser.id || currentRoom.canSendState("redact") 0076 text: i18n("Remove") 0077 icon.name: "edit-delete-remove" 0078 icon.color: "red" 0079 onTriggered: applicationWindow().pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/RemoveSheet.qml", {room: currentRoom, eventId: eventId}, { 0080 title: i18nc("@title", "Remove Message"), 0081 width: Kirigami.Units.gridUnit * 25 0082 }) 0083 }, 0084 Kirigami.Action { 0085 text: i18nc("@action:button 'Report' as in 'Report this event to the administrators'", "Report") 0086 icon.name: "dialog-warning-symbolic" 0087 visible: author.id !== currentRoom.localUser.id 0088 onTriggered: applicationWindow().pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/ReportSheet.qml", {room: currentRoom, eventId: eventId}, { 0089 title: i18nc("@title", "Report Message"), 0090 width: Kirigami.Units.gridUnit * 25 0091 }) 0092 }, 0093 Kirigami.Action { 0094 text: i18n("View Source") 0095 icon.name: "code-context" 0096 onTriggered: RoomManager.viewEventSource(root.eventId) 0097 } 0098 ] 0099 0100 /** 0101 * @brief The list of menu item actions that have sub-actions. 0102 * 0103 * Each action will be instantiated as a single line that opens a sub menu. 0104 */ 0105 property list<Kirigami.Action> nestedActions: [ 0106 ShareAction { 0107 id: shareAction 0108 inputData: { 0109 'urls': [], 0110 'mimeType': [root.mimeType] 0111 } 0112 property string filename: StandardPaths.writableLocation(StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_").replace("/", "_").replace("+", "_") + currentRoom.fileNameToDownload(eventId); 0113 0114 doBeforeSharing: () => { 0115 currentRoom.downloadFile(eventId, filename) 0116 } 0117 Component.onCompleted: { 0118 shareAction.inputData = { 0119 urls: [filename], 0120 mimeType: [root.mimeType] 0121 }; 0122 } 0123 } 0124 ] 0125 0126 Component { 0127 id: saveAsDialog 0128 FileDialog { 0129 fileMode: FileDialog.SaveFile 0130 folder: Config.lastSaveDirectory.length > 0 ? Config.lastSaveDirectory : StandardPaths.writableLocation(StandardPaths.DownloadLocation) 0131 onAccepted: { 0132 if (!currentFile) { 0133 return; 0134 } 0135 Config.lastSaveDirectory = folder 0136 Config.save() 0137 currentRoom.downloadFile(eventId, currentFile) 0138 } 0139 } 0140 } 0141 }