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", {
0080 room: currentRoom,
0081 eventId: eventId
0082 }, {
0083 title: i18nc("@title", "Remove Message"),
0084 width: Kirigami.Units.gridUnit * 25
0085 })
0086 },
0087 Kirigami.Action {
0088 text: i18nc("@action:button 'Report' as in 'Report this event to the administrators'", "Report")
0089 icon.name: "dialog-warning-symbolic"
0090 visible: author.id !== currentRoom.localUser.id
0091 onTriggered: applicationWindow().pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/ReportSheet.qml", {
0092 room: currentRoom,
0093 eventId: eventId
0094 }, {
0095 title: i18nc("@title", "Report Message"),
0096 width: Kirigami.Units.gridUnit * 25
0097 })
0098 },
0099 Kirigami.Action {
0100 text: i18n("View Source")
0101 icon.name: "code-context"
0102 onTriggered: RoomManager.viewEventSource(root.eventId)
0103 }
0104 ]
0105
0106 /**
0107 * @brief The list of menu item actions that have sub-actions.
0108 *
0109 * Each action will be instantiated as a single line that opens a sub menu.
0110 */
0111 property list<Kirigami.Action> nestedActions: [
0112 ShareAction {
0113 id: shareAction
0114 inputData: {
0115 'urls': [],
0116 'mimeType': [root.mimeType]
0117 }
0118 property string filename: StandardPaths.writableLocation(StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_").replace("/", "_").replace("+", "_") + currentRoom.fileNameToDownload(eventId)
0119
0120 doBeforeSharing: () => {
0121 currentRoom.downloadFile(eventId, filename);
0122 }
0123 Component.onCompleted: {
0124 shareAction.inputData = {
0125 urls: [filename],
0126 mimeType: [root.mimeType]
0127 };
0128 }
0129 }
0130 ]
0131
0132 Component {
0133 id: saveAsDialog
0134 FileDialog {
0135 fileMode: FileDialog.SaveFile
0136 folder: Config.lastSaveDirectory.length > 0 ? Config.lastSaveDirectory : StandardPaths.writableLocation(StandardPaths.DownloadLocation)
0137 onAccepted: {
0138 if (!currentFile) {
0139 return;
0140 }
0141 Config.lastSaveDirectory = folder;
0142 Config.save();
0143 currentRoom.downloadFile(eventId, currentFile);
0144 }
0145 }
0146 }
0147 }