Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F84676699
D304.1781507524.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D304.1781507524.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 downloadStart
+
Component {
id: textEV
Types.Text {
diff --git a/src/contents/ui/FileHandler.qml b/src/contents/ui/FileHandler.qml
--- a/src/contents/ui/FileHandler.qml
+++ b/src/contents/ui/FileHandler.qml
@@ -45,7 +45,7 @@
* Emit when start download, not emit when start cache.
* Can be used to indicate progress bar visible
*/
- signal startDownload
+ signal downloadStart
function getMediaId(mxcUri) {
const temp = mxcUri.toString().split('/')
@@ -63,7 +63,7 @@
kazvIOManager.startNewDownloadJob(mxcToHttp(file.mxcUri), saveFileUrl, mediaId,
file.sha256, token, file.key, file.iv);
fileHandler.updateKazvIOJob(mediaId, false);
- fileHandler.startDownload();
+ fileHandler.downloadStart();
}
function cacheFile() {
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,11 +16,12 @@
id: mediaFileMenu
required property var eventContent
+ required property var eventId
property var jobManager: kazvIOManager
property var mtxSdk: matrixSdk
- signal startDownload
+ signal downloadStart
property var fileHandler: FileHandler {
id: fileHandler
@@ -40,29 +41,22 @@
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;
- }
- }
- }
+ property var optionMenu: [viewAction, saveAction]
Component.onCompleted: {
- mediaFileMenu.fileHandler.startDownload.connect(mediaFileMenu.startDownload)
+ mediaFileMenu.fileHandler.downloadStart.connect(mediaFileMenu.downloadStart)
+ eventView.downloadStart.connect(() => {
+ const file = mediaFileMenu.fileHandler.getFile();
+ if (file) {
+ const mediaId = mediaFileMenu.fileHandler.getMediaId(file.mxcUri);
+ mediaFileMenu.fileHandler.updateKazvIOJob(mediaId, false);
+ }
+ mediaFileMenu.downloadStart();
+ });
}
}
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,49 @@
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);
+ // A newly created eventView will automatically look for its KazvIOJob.
+ // Here we just need to find those eventViews that have been created and notify them that the download has started.
+ for (const eventView of roomTimelineView.contentItem.children) {
+ if (eventView.event.eventId === fileDialog.eventId) {
+ eventView.downloadStart();
+ }
+ }
+ }
+
+ 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 {
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
Mon, Jun 15, 12:12 AM (20 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1589762
Default Alt Text
D304.1781507524.diff (8 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