Make it possible to "save as" attachment after opening them
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
committed by
Tobias Fella
parent
236c6a2d04
commit
edaf1005d4
@@ -41,9 +41,26 @@ TimelineContainer {
|
||||
spacing: Kirigami.Units.largeSpacing
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "downloadedInstant"
|
||||
when: progressInfo.completed && autoOpenFile
|
||||
|
||||
PropertyChanges {
|
||||
target: openButton
|
||||
icon.name: "document-open"
|
||||
onClicked: openSavedFile()
|
||||
}
|
||||
|
||||
PropertyChanges {
|
||||
target: downloadButton
|
||||
icon.name: "download"
|
||||
QQC2.ToolTip.text: i18nc("tooltip for a button on a message; offers ability to download its file", "Download")
|
||||
onClicked: saveFileAs()
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "downloaded"
|
||||
when: progressInfo.completed
|
||||
when: progressInfo.completed && !autoOpenFile
|
||||
|
||||
PropertyChanges {
|
||||
target: openButton
|
||||
@@ -52,11 +69,8 @@ TimelineContainer {
|
||||
|
||||
PropertyChanges {
|
||||
target: downloadButton
|
||||
|
||||
icon.name: "document-open"
|
||||
|
||||
QQC2.ToolTip.text: i18nc("tooltip for a button on a message; offers ability to open its downloaded file with an appropriate application", "Open File")
|
||||
|
||||
onClicked: openSavedFile()
|
||||
}
|
||||
},
|
||||
@@ -76,7 +90,6 @@ TimelineContainer {
|
||||
PropertyChanges {
|
||||
target: downloadButton
|
||||
icon.name: "media-playback-stop"
|
||||
|
||||
QQC2.ToolTip.text: i18nc("tooltip for a button on a message; stops downloading the message's file", "Stop Download")
|
||||
onClicked: currentRoom.cancelFileTransfer(eventId)
|
||||
}
|
||||
@@ -87,7 +100,6 @@ TimelineContainer {
|
||||
|
||||
PropertyChanges {
|
||||
target: downloadButton
|
||||
|
||||
onClicked: fileDelegate.saveFileAs()
|
||||
}
|
||||
}
|
||||
@@ -148,7 +160,11 @@ TimelineContainer {
|
||||
FileDialog {
|
||||
fileMode: FileDialog.SaveFile
|
||||
folder: StandardPaths.writableLocation(StandardPaths.DownloadLocation)
|
||||
onAccepted: currentRoom.downloadFile(eventId, file)
|
||||
onAccepted: if (openSavedFile) {
|
||||
UrlHelper.copyTo(progressInfo.localPath, file)
|
||||
} else {
|
||||
currentRoom.downloadFile(eventId, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "urlhelper.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QtGlobal>
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
@@ -22,3 +23,9 @@ void UrlHelper::openUrl(const QUrl &url)
|
||||
job->start();
|
||||
#endif
|
||||
}
|
||||
|
||||
void UrlHelper::copyTo(const QUrl &origin, const QUrl &destination)
|
||||
{
|
||||
QFile originFile(origin.toLocalFile());
|
||||
originFile.copy(destination.toLocalFile());
|
||||
}
|
||||
|
||||
@@ -10,4 +10,5 @@ class UrlHelper : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
Q_INVOKABLE void openUrl(const QUrl &url);
|
||||
Q_INVOKABLE void copyTo(const QUrl &origin, const QUrl &destination);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user