aboutsummaryrefslogtreecommitdiff
path: root/qml
diff options
context:
space:
mode:
authorMiquel Lionel <lionel@les-miquelots.net>2021-10-20 12:48:09 +0100
committerlink2xt <link2xt@testrun.org>2021-10-27 09:16:28 +0300
commit1a8b1d4dfb1af936ec68b30af475dcfbeff6453c (patch)
tree88035de2469c17329bd652b4c35d06bc6cee9e79 /qml
parent9b329f6eaaa178b74c32b64977f5344d14de3a3e (diff)
downloadkdeltachat-1a8b1d4dfb1af936ec68b30af475dcfbeff6453c.tar.gz
kdeltachat-1a8b1d4dfb1af936ec68b30af475dcfbeff6453c.zip
Implement saving attachment to filesystem
Diffstat (limited to 'qml')
-rw-r--r--qml/Message.qml60
1 files changed, 59 insertions, 1 deletions
diff --git a/qml/Message.qml b/qml/Message.qml
index 9d8f377..fc69e8f 100644
--- a/qml/Message.qml
+++ b/qml/Message.qml
@@ -12,6 +12,8 @@ RowLayout {
property DcMessage message
property DcContext context
+ property var saveAsUrl: ""
+ property var saveSuccess: false
readonly property DcContact from: context.getContact(message.fromId)
readonly property DcMessage quoteMessage: message.quotedMessage
readonly property DcContact quoteFrom: quoteMessage ? context.getContact(quoteMessage.fromId) : null
@@ -33,6 +35,49 @@ RowLayout {
}
}
+ Popup {
+ id: saveAsPopup
+
+ modal: true
+ focus: true
+ anchors.centerIn: parent
+ width: 400
+ height: 100
+ padding: 10
+ onClosed: saveAsUrl = ""
+ contentChildren: [
+ Text {
+ text: saveSuccess == true ? "Success !" : "Failure !"
+ bottomPadding: 10
+ font.bold: true
+ font.pixelSize: 14
+ },
+ Text {
+ text: saveSuccess == true ? "The file has been saved locally at <br><b>" + saveAsUrl + "</b>" : "An error was detected. Maybe you<br>dont have enough permissions to copy the file to <br><b>" + saveAsUrl + "</b>"
+ topPadding: 20
+ leftPadding: 10
+ bottomPadding: 20
+ }
+ ]
+ }
+
+ FileDialog {
+ id: saveAsDialog
+
+ title: "Save attachment `" + root.message.filename + "` as ..."
+ folder: shortcuts.home
+ selectFolder: false
+ selectExisting: false
+ onAccepted: {
+ var url = saveAsDialog.fileUrl.toString();
+ if (url.startsWith("file://")) {
+ saveAsUrl = url.substring(7);
+ saveSuccess = root.message.saveAttach(saveAsUrl);
+ saveAsPopup.open();
+ }
+ }
+ }
+
Rectangle {
Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.preferredWidth: messageContents.width
@@ -174,7 +219,7 @@ RowLayout {
padding: 5
icon.name: "document-save-as"
text: "Save attachment"
- onClicked: console.log("dummy")
+ onClicked: saveAsDialog.open()
}
}
@@ -220,11 +265,24 @@ RowLayout {
Menu {
id: contextMenu
+ Component.onCompleted: {
+ if (!root.message.filename.length > 0)
+ contextMenu.removeAction(saveAsContext);
+
+ }
+
Action {
text: "Info"
onTriggered: messageDialog.open()
}
+ Action {
+ id: saveAsContext
+
+ text: "Save attachment as ..."
+ onTriggered: saveAsDialog.open()
+ }
+
}
}