Warning, /network/tokodon/src/content/ui/StatusDelegate/ImageMenu.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
0002 // SPDX-License-Identifier: GPL-3.0-or-later
0003
0004 import QtCore
0005 import QtQuick
0006 import QtQuick.Controls 2 as QQC2
0007 import QtQuick.Dialogs
0008 import org.kde.tokodon
0009
0010 import ".."
0011
0012 QQC2.Menu {
0013 id: root
0014
0015 property var attachment
0016
0017 modal: true
0018
0019 Component {
0020 id: saveAsDialog
0021 FileDialog {
0022 property var url
0023 fileMode: FileDialog.SaveFile
0024 currentFolder: StandardPaths.writableLocation(StandardPaths.DownloadLocation)
0025 onAccepted: {
0026 if (!currentFile) {
0027 return;
0028 }
0029 FileHelper.downloadFile(AccountManager.selectedAccount, url, currentFile);
0030 }
0031 }
0032 }
0033
0034 QQC2.MenuItem {
0035 enabled: root.attachment !== null
0036
0037 icon.name: "window"
0038 text: i18n("Save Image As…")
0039
0040 onTriggered: {
0041 const dialog = saveAsDialog.createObject(applicationWindow().overlay, {
0042 url: root.attachment.source,
0043 });
0044 dialog.selectedFile = dialog.currentFolder + "/" + FileHelper.fileName(root.attachment.source);
0045 dialog.open();
0046 }
0047 }
0048
0049 QQC2.MenuItem {
0050 enabled: root.attachment !== null
0051
0052 icon.name: "edit-copy"
0053 text: i18n("Copy Image")
0054 onTriggered: Clipboard.copyImage(root.attachment.source)
0055 }
0056
0057 QQC2.MenuSeparator {}
0058
0059 ShareMenu {
0060 enabled: root.attachment !== null
0061
0062 url: root.attachment !== null && root.attachment !== undefined ? root.attachment.source : ""
0063 }
0064 }