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
|
spacing: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
states: [
|
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 {
|
State {
|
||||||
name: "downloaded"
|
name: "downloaded"
|
||||||
when: progressInfo.completed
|
when: progressInfo.completed && !autoOpenFile
|
||||||
|
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: openButton
|
target: openButton
|
||||||
@@ -52,11 +69,8 @@ TimelineContainer {
|
|||||||
|
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: downloadButton
|
target: downloadButton
|
||||||
|
|
||||||
icon.name: "document-open"
|
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")
|
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()
|
onClicked: openSavedFile()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -76,7 +90,6 @@ TimelineContainer {
|
|||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: downloadButton
|
target: downloadButton
|
||||||
icon.name: "media-playback-stop"
|
icon.name: "media-playback-stop"
|
||||||
|
|
||||||
QQC2.ToolTip.text: i18nc("tooltip for a button on a message; stops downloading the message's file", "Stop Download")
|
QQC2.ToolTip.text: i18nc("tooltip for a button on a message; stops downloading the message's file", "Stop Download")
|
||||||
onClicked: currentRoom.cancelFileTransfer(eventId)
|
onClicked: currentRoom.cancelFileTransfer(eventId)
|
||||||
}
|
}
|
||||||
@@ -87,7 +100,6 @@ TimelineContainer {
|
|||||||
|
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: downloadButton
|
target: downloadButton
|
||||||
|
|
||||||
onClicked: fileDelegate.saveFileAs()
|
onClicked: fileDelegate.saveFileAs()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,7 +160,11 @@ TimelineContainer {
|
|||||||
FileDialog {
|
FileDialog {
|
||||||
fileMode: FileDialog.SaveFile
|
fileMode: FileDialog.SaveFile
|
||||||
folder: StandardPaths.writableLocation(StandardPaths.DownloadLocation)
|
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 "urlhelper.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
@@ -22,3 +23,9 @@ void UrlHelper::openUrl(const QUrl &url)
|
|||||||
job->start();
|
job->start();
|
||||||
#endif
|
#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
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Q_INVOKABLE void openUrl(const QUrl &url);
|
Q_INVOKABLE void openUrl(const QUrl &url);
|
||||||
|
Q_INVOKABLE void copyTo(const QUrl &origin, const QUrl &destination);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user