Page MenuHomePhorge

No OneTemporary

Size
7 KB
Referenced Files
None
Subscribers
None
diff --git a/src/contents/ui/ConfirmUploadPopup.qml b/src/contents/ui/ConfirmUploadPopup.qml
index f2cfb5e..e95f641 100644
--- a/src/contents/ui/ConfirmUploadPopup.qml
+++ b/src/contents/ui/ConfirmUploadPopup.qml
@@ -1,86 +1,86 @@
/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2024 tusooa <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import org.kde.kirigami 2.13 as Kirigami
import moe.kazv.mxc.kazv 0.0 as MK
import '.' as Kazv
Kirigami.OverlaySheet {
id: confirmUploadPopup
property var fileUrls: []
property var total: fileUrls.length
property int currentIndex: 0
property var currentFile: fileUrls[currentIndex] || ''
property var currentFileBasename: currentFile.split('/').slice(-1)[0]
title: l10n.get('confirm-upload-popup-title')
signal uploadRequested(var fileUrl)
function call(urls) {
confirmUploadPopup.fileUrls = [...urls];
confirmUploadPopup.currentIndex = 0;
confirmUploadPopup.open();
}
ColumnLayout {
- Layout.preferredWidth: Kirigami.Units.gridUnit * 10
+ Layout.preferredWidth: Kirigami.Units.gridUnit * 40
Label {
text: (
confirmUploadPopup.total === 1
? l10n.get('confirm-upload-popup-prompt-single-file', {
file: confirmUploadPopup.currentFileBasename,
}) : l10n.get('confirm-upload-popup-prompt', {
file: confirmUploadPopup.currentFileBasename,
current: confirmUploadPopup.currentIndex + 1,
total: confirmUploadPopup.total,
})
)
wrapMode: Text.Wrap
Layout.preferredWidth: Kirigami.Units.gridUnit * 10
Layout.fillWidth: true
}
Image {
id: image
objectName: 'imagePreview'
visible: confirmUploadPopup.currentFile && MK.KazvUtil.mimeTypeForUrl(confirmUploadPopup.currentFile).startsWith('image/')
source: confirmUploadPopup.currentFile
Layout.maximumHeight: Kirigami.Units.gridUnit * 5
Layout.preferredWidth: Kirigami.Units.gridUnit * 10
Layout.fillWidth: true
fillMode: Image.PreserveAspectFit
}
RowLayout {
Layout.fillWidth: true
Layout.alignment: Qt.AlignRight
Button {
objectName: 'acceptButton'
text: l10n.get('confirm-upload-popup-accept-button')
onClicked: {
uploadRequested(confirmUploadPopup.currentFile);
if (confirmUploadPopup.currentIndex + 1 < confirmUploadPopup.total) {
++confirmUploadPopup.currentIndex;
} else {
confirmUploadPopup.close();
}
}
}
Button {
objectName: 'cancelButton'
text: l10n.get('confirm-upload-popup-cancel-button')
onClicked: confirmUploadPopup.close();
}
}
}
}
diff --git a/src/tests/quick-tests/tst_ConfirmUploadPopup.qml b/src/tests/quick-tests/tst_ConfirmUploadPopup.qml
index 89b0464..7409ce6 100644
--- a/src/tests/quick-tests/tst_ConfirmUploadPopup.qml
+++ b/src/tests/quick-tests/tst_ConfirmUploadPopup.qml
@@ -1,96 +1,112 @@
/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2024 tusooa <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtTest 1.0
import org.kde.kirigami 2.20 as Kirigami
-
+import moe.kazv.mxc.kazv 0.0 as MK
import '../../contents/ui' as Kazv
import 'test-helpers.js' as Helpers
import 'test-helpers' as TestHelpers
Item {
id: item
- width: 800
+ width: Kirigami.Units.gridUnit * 40
height: 600
property var l10n: Helpers.fluentMock
property var promiseComp: Component {
TestHelpers.MatrixPromiseMock {}
}
Kazv.ConfirmUploadPopup {
id: confirmUploadPopup
property var _uploadRequestedCalled: 0
property var _uploadRequestedLastUrl: undefined
onUploadRequested: (url) => {
++_uploadRequestedCalled;
_uploadRequestedLastUrl = url;
}
}
+ function isSheetOpen(sheet) {
+ if (MK.KazvUtil.kfQtMajorVersion === 5) {
+ return sheet.sheetOpen;
+ } else {
+ return sheet.opened;
+ }
+ }
+
TestCase {
id: confirmUploadPopupTest
name: 'ConfirmUploadPopupTest'
when: windowShown
function cleanup() {
confirmUploadPopup._uploadRequestedCalled = 0;
confirmUploadPopup._uploadRequestedLastUrl = undefined;
}
function test_singleUpload() {
confirmUploadPopup.call(['file:///tmp/image.png']);
- tryVerify(() => confirmUploadPopup.sheetOpen);
- confirmUploadPopup.contentItem.parent = item;
+ tryVerify(() => isSheetOpen(confirmUploadPopup));
+ if (MK.KazvUtil.kfQtMajorVersion === 5) {
+ confirmUploadPopup.contentItem.parent = item;
+ }
tryVerify(() => findChild(confirmUploadPopup, 'imagePreview').visible);
mouseClick(findChild(confirmUploadPopup, 'acceptButton'));
- tryVerify(() => !confirmUploadPopup.sheetOpen);
+ tryVerify(() => !isSheetOpen(confirmUploadPopup));
verify(confirmUploadPopup._uploadRequestedCalled === 1);
verify(confirmUploadPopup._uploadRequestedLastUrl === 'file:///tmp/image.png');
}
function test_singleUploadCancelled() {
confirmUploadPopup.call(['file:///tmp/image.png']);
- tryVerify(() => confirmUploadPopup.sheetOpen);
- confirmUploadPopup.contentItem.parent = item;
+ tryVerify(() => isSheetOpen(confirmUploadPopup));
+ if (MK.KazvUtil.kfQtMajorVersion === 5) {
+ confirmUploadPopup.contentItem.parent = item;
+ }
tryVerify(() => findChild(confirmUploadPopup, 'imagePreview').visible);
mouseClick(findChild(confirmUploadPopup, 'cancelButton'));
- tryVerify(() => !confirmUploadPopup.sheetOpen);
+ tryVerify(() => !isSheetOpen(confirmUploadPopup));
verify(confirmUploadPopup._uploadRequestedCalled === 0);
}
function test_multiUpload() {
confirmUploadPopup.call(['file:///tmp/image.png', 'file:///tmp/a.txt']);
- tryVerify(() => confirmUploadPopup.sheetOpen);
- confirmUploadPopup.contentItem.parent = item;
+ tryVerify(() => isSheetOpen(confirmUploadPopup));
+ if (MK.KazvUtil.kfQtMajorVersion === 5) {
+ confirmUploadPopup.contentItem.parent = item;
+ }
tryVerify(() => findChild(confirmUploadPopup, 'imagePreview').visible);
mouseClick(findChild(confirmUploadPopup, 'acceptButton'));
- verify(confirmUploadPopup.sheetOpen);
+ verify(isSheetOpen(confirmUploadPopup));
tryVerify(() => !findChild(confirmUploadPopup, 'imagePreview').visible);
verify(confirmUploadPopup._uploadRequestedCalled === 1);
verify(confirmUploadPopup._uploadRequestedLastUrl === 'file:///tmp/image.png');
verify(confirmUploadPopup.currentIndex === 1);
mouseClick(findChild(confirmUploadPopup, 'acceptButton'));
- tryVerify(() => !confirmUploadPopup.sheetOpen);
+ tryVerify(() => !isSheetOpen(confirmUploadPopup));
verify(confirmUploadPopup._uploadRequestedCalled === 2);
verify(confirmUploadPopup._uploadRequestedLastUrl === 'file:///tmp/a.txt');
}
function test_multiUploadCancelled() {
confirmUploadPopup.call(['file:///tmp/image.png', 'file:///tmp/a.txt']);
- tryVerify(() => confirmUploadPopup.sheetOpen);
- confirmUploadPopup.contentItem.parent = item;
+ tryVerify(() => isSheetOpen(confirmUploadPopup));
+ if (MK.KazvUtil.kfQtMajorVersion === 5) {
+ confirmUploadPopup.contentItem.parent = item;
+ }
tryVerify(() => findChild(confirmUploadPopup, 'imagePreview').visible);
mouseClick(findChild(confirmUploadPopup, 'cancelButton'));
- tryVerify(() => !confirmUploadPopup.sheetOpen);
+ tryVerify(() => !isSheetOpen(confirmUploadPopup));
verify(confirmUploadPopup._uploadRequestedCalled === 0);
}
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 4:50 PM (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
55333
Default Alt Text
(7 KB)

Event Timeline