summaryrefslogtreecommitdiffstats
path: root/heimdall-frontend/source/qml/DropFiles.qml
diff options
context:
space:
mode:
Diffstat (limited to 'heimdall-frontend/source/qml/DropFiles.qml')
-rw-r--r--heimdall-frontend/source/qml/DropFiles.qml94
1 files changed, 94 insertions, 0 deletions
diff --git a/heimdall-frontend/source/qml/DropFiles.qml b/heimdall-frontend/source/qml/DropFiles.qml
index ac5c7a7..ddcc90b 100644
--- a/heimdall-frontend/source/qml/DropFiles.qml
+++ b/heimdall-frontend/source/qml/DropFiles.qml
@@ -1,7 +1,101 @@
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
+import QtQuick.Dialogs 1.2
DropFilesForm {
+ id: background
+
+ property var fileUrls: []
+
signal nextPressed(var files)
+
+ ListModel {
+ id: fileModel
+ }
+
+ function setFileGridVisible(visible) {
+ if (fileGridContainer.visible !== visible) {
+ dropFilesContainer.visible = !visible;
+ bottomButtonsContainer.visible = visible;
+ fileGridContainer.visible = visible;
+
+ if (visible) {
+ fileGridView.forceActiveFocus();
+ }
+ }
+ }
+
+ function addFiles(urls) {
+ var count = urls.length;
+ if (count > 0) {
+ for (var i = 0; i < count; i++) {
+ var url = urls[i].toString();
+ var filename = url.slice(url.lastIndexOf('/') + 1, url.length);
+
+ fileModel.append({
+ icon: "drop_zone.svg",
+ text: filename
+ });
+
+ fileUrls.push(urls[i]);
+ }
+
+ setFileGridVisible(true);
+ }
+ }
+
+ function removeFile(index) {
+ if (index >= 0) {
+ fileModel.remove(index);
+ fileUrls.splice(index, 1);
+
+ if (fileUrls.length == 0) {
+ setFileGridVisible(false);
+ }
+ }
+ }
+
+ onKeyPressed: {
+ if (event.key === Qt.Key_Delete || event.key === Qt.Key_Backspace) {
+ event.accepted = true;
+ removeFile(fileGridView.currentIndex);
+ }
+ }
+
+ dropFilesArea {
+ onDropped: {
+ if ((drop.action == Qt.CopyAction || drop.action == Qt.MoveAction) && drop.urls.length > 0) {
+ addFiles(drop.urls);
+ drop.acceptProposedAction();
+ drop.accept(Qt.CopyAction);
+ }
+ }
+ }
+
+ browseButton.onClicked: {
+ browseDialog.open()
+ }
+
+ bottomBrowseButton.onClicked: {
+ browseDialog.open()
+ }
+
+ nextButton {
+ onClicked: nextPressed(fileUrls)
+ }
+
+ fileGridView {
+ model: fileModel
+ }
+
+ FileDialog {
+ id: browseDialog
+ title: "Select firmware file(s)"
+ selectMultiple: true
+ selectFolder: false
+ onAccepted: {
+ addFiles(browseDialog.fileUrls);
+ }
+ }
}