aboutsummaryrefslogtreecommitdiff
path: root/qml
diff options
context:
space:
mode:
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()
+ }
+
}
}