Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F84313867
D304.1780759599.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D304.1780759599.diff
View Options
diff --git a/src/contents/ui/EventView.qml b/src/contents/ui/EventView.qml
--- a/src/contents/ui/EventView.qml
+++ b/src/contents/ui/EventView.qml
@@ -40,6 +40,8 @@
Layout.minimumHeight: calculatedHeight
Layout.preferredHeight: calculatedHeight
+ signal startDownload
+
Component {
id: textEV
Types.Text {
diff --git a/src/contents/ui/MediaFileMenu.qml b/src/contents/ui/MediaFileMenu.qml
--- a/src/contents/ui/MediaFileMenu.qml
+++ b/src/contents/ui/MediaFileMenu.qml
@@ -16,6 +16,7 @@
id: mediaFileMenu
required property var eventContent
+ required property var eventId
property var jobManager: kazvIOManager
property var mtxSdk: matrixSdk
@@ -40,29 +41,21 @@
property var saveAction: Kirigami.Action {
text: l10n.get('media-file-menu-option-save-as')
onTriggered: {
- fileDialog.open()
+ fileDialog.saveAs(mediaFileMenu.eventContent, mediaFileMenu.eventId);
}
}
property var optionMenu: [viewAction, saveAction]
- property var fileDialog: Kazv.FileDialogAdapter {
- id: fileDialog
- folder: Platform.StandardPaths.writableLocation(Platform.StandardPaths.DownloadLocation)
- onAccepted: {
- mediaFileMenu.fileHandler.downloadFile(fileUrl)
- }
-
- Component.onCompleted: {
- if (MK.KazvUtil.kfQtMajorVersion === 5) {
- fileDialog.selectExisting = false;
- } else {
- fileDialog.fileMode = Kazv.FileDialogAdapter.SaveFile;
- }
- }
- }
-
Component.onCompleted: {
mediaFileMenu.fileHandler.startDownload.connect(mediaFileMenu.startDownload)
+ eventView.startDownload.connect(() => {
+ const file = mediaFileMenu.fileHandler.getFile();
+ if (file) {
+ const mediaId = mediaFileMenu.fileHandler.getMediaId(file.mxcUri);
+ mediaFileMenu.fileHandler.updateKazvIOJob(mediaId, false);
+ }
+ mediaFileMenu.startDownload();
+ });
}
}
diff --git a/src/contents/ui/RoomPage.qml b/src/contents/ui/RoomPage.qml
--- a/src/contents/ui/RoomPage.qml
+++ b/src/contents/ui/RoomPage.qml
@@ -8,6 +8,7 @@
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import QtQuick.Window 2.15
+import Qt.labs.platform as Platform
import org.kde.kirigami 2.13 as Kirigami
import moe.kazv.mxc.kazv 0.0 as MK
@@ -28,6 +29,46 @@
property var paginationRequests: ({})
property var refreshRoomStateRequest: null
+ property var fileDialog: Kazv.FileDialogAdapter {
+ id: fileDialog
+
+ property var eventContent
+ property var eventId
+ property var jobManager: kazvIOManager
+ property var mtxSdk: matrixSdk
+ property var fileHandler: Kazv.FileHandler {
+ id: fileHandler
+ autoCache: false
+ eventContent: fileDialog.eventContent
+ kazvIOManager: fileDialog.jobManager
+ matrixSdk: fileDialog.mtxSdk
+ }
+
+ function saveAs(eventContent, eventId) {
+ fileDialog.eventContent = eventContent;
+ fileDialog.eventId = eventId;
+ fileDialog.open();
+ }
+
+ folder: Platform.StandardPaths.writableLocation(Platform.StandardPaths.DownloadLocation)
+
+ onAccepted: {
+ fileDialog.fileHandler.downloadFile(fileUrl);
+ const event = roomTimelineView.getEventById(fileDialog.eventId);
+ if (event) {
+ event.startDownload();
+ }
+ }
+
+ Component.onCompleted: {
+ if (MK.KazvUtil.kfQtMajorVersion === 5) {
+ fileDialog.selectExisting = false;
+ } else {
+ fileDialog.fileMode = Kazv.FileDialogAdapter.SaveFile;
+ }
+ }
+ }
+
signal mentionUserRequested(string userId)
signal replaceDraftRequested(string newDraft)
signal paginateBackRequested(string eventId)
diff --git a/src/contents/ui/RoomTimelineView.qml b/src/contents/ui/RoomTimelineView.qml
--- a/src/contents/ui/RoomTimelineView.qml
+++ b/src/contents/ui/RoomTimelineView.qml
@@ -4,11 +4,11 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-import QtQuick 2.2
-import QtQuick.Layouts 1.15
-import QtQuick.Controls 2.15
+import QtQuick
+import QtQuick.Layouts
+import QtQuick.Controls
-import org.kde.kirigami 2.13 as Kirigami
+import org.kde.kirigami as Kirigami
import '.' as Kazv
ListView {
@@ -180,4 +180,12 @@
const index = timeline.indexOfEvent(eventId);
positionViewAtIndex(index, ListView.Center);
}
+
+ function getEventById(eventId) {
+ const index = timeline.indexOfEvent(eventId);
+ if (index < 0) {
+ return null;
+ }
+ return itemAtIndex(index);
+ }
}
diff --git a/src/contents/ui/event-types/Audio.qml b/src/contents/ui/event-types/Audio.qml
--- a/src/contents/ui/event-types/Audio.qml
+++ b/src/contents/ui/event-types/Audio.qml
@@ -28,6 +28,7 @@
id: bubble
eventContent: event.content
+ eventId: event.eventId
ColumnLayout {
property var msgLabel: Kazv.SelectableText {
diff --git a/src/contents/ui/event-types/File.qml b/src/contents/ui/event-types/File.qml
--- a/src/contents/ui/event-types/File.qml
+++ b/src/contents/ui/event-types/File.qml
@@ -28,6 +28,7 @@
id: bubble
eventContent: event.content
+ eventId: event.eventId
ColumnLayout {
Layout.fillWidth: true
diff --git a/src/contents/ui/event-types/Image.qml b/src/contents/ui/event-types/Image.qml
--- a/src/contents/ui/event-types/Image.qml
+++ b/src/contents/ui/event-types/Image.qml
@@ -59,6 +59,7 @@
id: bubble
eventContent: event.content
+ eventId: event.eventId
property var label: Kazv.SelectableText {
objectName: 'bodyLabel'
diff --git a/src/contents/ui/event-types/MediaBubble.qml b/src/contents/ui/event-types/MediaBubble.qml
--- a/src/contents/ui/event-types/MediaBubble.qml
+++ b/src/contents/ui/event-types/MediaBubble.qml
@@ -16,9 +16,11 @@
id: bubble
required property var eventContent
+ required property var eventId
property var mediaFileMenu: Kazv.MediaFileMenu {
eventContent: bubble.eventContent
+ eventId: bubble.eventId
}
menuContent: mediaFileMenu.optionMenu.concat(additionalMenuContent)
diff --git a/src/contents/ui/event-types/Video.qml b/src/contents/ui/event-types/Video.qml
--- a/src/contents/ui/event-types/Video.qml
+++ b/src/contents/ui/event-types/Video.qml
@@ -57,6 +57,7 @@
Layout.fillWidth: true
eventContent: event.content
+ eventId: event.eventId
ColumnLayout {
id: layout
diff --git a/src/tests/quick-tests/test-helpers/KazvIOManagerMock.qml b/src/tests/quick-tests/test-helpers/KazvIOManagerMock.qml
--- a/src/tests/quick-tests/test-helpers/KazvIOManagerMock.qml
+++ b/src/tests/quick-tests/test-helpers/KazvIOManagerMock.qml
@@ -6,6 +6,8 @@
import QtQuick 2.15
+import moe.kazv.mxc.kazv 0.0 as MK
+
QtObject {
id: managerMock
property var startNewUploadJob: mockHelper.noop([
@@ -28,4 +30,18 @@
const component = Qt.createComponent("KazvIOJobMock.qml");
return component.createObject(managerMock, { jobId: jobId });
}
+
+ function jobResultL10nMsg(ec: MK.KazvIOBaseJob.ErrorCode, isUpload: bool): string {
+ const resultL10nId = isUpload ? 'kazv-io-upload-failure-prompt' : 'kazv-io-download-failure-prompt'
+ const detailL10nId = new Map([
+ [MK.KazvIOBaseJob.UserCancel, 'kazv-io-failure-detail-user-cancel'],
+ [MK.KazvIOBaseJob.OpenFileError, 'kazv-io-failure-detail-open-file-error'],
+ [MK.KazvIOBaseJob.WriteFileError, 'kazv-io-failure-detail-write-file-error'],
+ [MK.KazvIOBaseJob.KIOError, 'kazv-io-failure-detail-network-error'],
+ [MK.KazvIOBaseJob.HashError, 'kazv-io-failure-detail-hash-error'],
+ [MK.KazvIOBaseJob.ResponseError, 'kazv-io-failure-detail-response-error'],
+ [MK.KazvIOBaseJob.KazvError, 'kazv-io-failure-detail-kazv-error']
+ ]);
+ return l10n.get(resultL10nId, {detail: l10n.get(detailL10nId.get(ec))});
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jun 6, 8:26 AM (21 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1551663
Default Alt Text
D304.1780759599.diff (7 KB)
Attached To
Mode
D304: Lift the save as dialog to the RoomPage to prevent ListView updates from destroying it
Attached
Detach File
Event Timeline
Log In to Comment