Use dialogs from qt labs platform and fix a image downloading bug.
This commit is contained in:
@@ -153,9 +153,9 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: openFileDialog
|
id: openFolderDialog
|
||||||
|
|
||||||
OpenFileDialog {}
|
OpenFolderDialog {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
@@ -169,15 +169,15 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function saveFileAs() {
|
function saveFileAs() {
|
||||||
var fileDialog = openFileDialog.createObject(ApplicationWindow.overlay, {"selectFolder": true})
|
var folderDialog = openFolderDialog.createObject(ApplicationWindow.overlay)
|
||||||
|
|
||||||
fileDialog.chosen.connect(function(path) {
|
folderDialog.chosen.connect(function(path) {
|
||||||
if (!path) return
|
if (!path) return
|
||||||
|
|
||||||
currentRoom.downloadFile(eventId, path + "/" + (content.filename || content.body))
|
currentRoom.downloadFile(eventId, path + "/" + (content.filename || content.body))
|
||||||
})
|
})
|
||||||
|
|
||||||
fileDialog.open()
|
folderDialog.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadAndOpen()
|
function downloadAndOpen()
|
||||||
|
|||||||
@@ -27,8 +27,14 @@ ColumnLayout {
|
|||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
onDownloadedChanged: {
|
onDownloadedChanged: {
|
||||||
if (downloaded && showOnFinished) showSavedFile()
|
if (downloaded && showOnFinished) {
|
||||||
if (downloaded && openOnFinished) openSavedFile()
|
showSavedFile()
|
||||||
|
showOnFinished = false
|
||||||
|
}
|
||||||
|
if (downloaded && openOnFinished) {
|
||||||
|
openSavedFile()
|
||||||
|
openOnFinished = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
@@ -183,9 +189,9 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: openFileDialog
|
id: openFolderDialog
|
||||||
|
|
||||||
OpenFileDialog {}
|
OpenFolderDialog {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
@@ -204,15 +210,15 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function saveFileAs() {
|
function saveFileAs() {
|
||||||
var fileDialog = openFileDialog.createObject(ApplicationWindow.overlay, {"selectFolder": true})
|
var folderDialog = openFolderDialog.createObject(ApplicationWindow.overlay)
|
||||||
|
|
||||||
fileDialog.chosen.connect(function(path) {
|
folderDialog.chosen.connect(function(path) {
|
||||||
if (!path) return
|
if (!path) return
|
||||||
|
|
||||||
currentRoom.downloadFile(eventId, path + "/" + (content.filename || content.body))
|
currentRoom.downloadFile(eventId, path + "/" + (content.filename || content.body))
|
||||||
})
|
})
|
||||||
|
|
||||||
fileDialog.open()
|
folderDialog.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadAndShow()
|
function downloadAndShow()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Dialogs 1.2
|
import Qt.labs.platform 1.1
|
||||||
|
|
||||||
FileDialog {
|
FileDialog {
|
||||||
signal chosen(string path)
|
signal chosen(string path)
|
||||||
@@ -7,7 +7,6 @@ FileDialog {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
title: "Please choose a file"
|
title: "Please choose a file"
|
||||||
selectMultiple: false
|
|
||||||
|
|
||||||
onAccepted: chosen(selectFolder ? folder : fileUrl)
|
onAccepted: chosen(file)
|
||||||
}
|
}
|
||||||
|
|||||||
12
imports/Spectral/Dialog/OpenFolderDialog.qml
Normal file
12
imports/Spectral/Dialog/OpenFolderDialog.qml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import QtQuick 2.12
|
||||||
|
import Qt.labs.platform 1.1
|
||||||
|
|
||||||
|
FolderDialog {
|
||||||
|
signal chosen(string path)
|
||||||
|
|
||||||
|
id: root
|
||||||
|
|
||||||
|
title: "Please choose a folder"
|
||||||
|
|
||||||
|
onAccepted: chosen(folder)
|
||||||
|
}
|
||||||
@@ -10,3 +10,4 @@ AcceptInvitationDialog 2.0 AcceptInvitationDialog.qml
|
|||||||
FontFamilyDialog 2.0 FontFamilyDialog.qml
|
FontFamilyDialog 2.0 FontFamilyDialog.qml
|
||||||
AccountDetailDialog 2.0 AccountDetailDialog.qml
|
AccountDetailDialog 2.0 AccountDetailDialog.qml
|
||||||
OpenFileDialog 2.0 OpenFileDialog.qml
|
OpenFileDialog 2.0 OpenFileDialog.qml
|
||||||
|
OpenFolderDialog 2.0 OpenFolderDialog.qml
|
||||||
|
|||||||
1
res.qrc
1
res.qrc
@@ -56,5 +56,6 @@
|
|||||||
<file>imports/Spectral/Dialog/FontFamilyDialog.qml</file>
|
<file>imports/Spectral/Dialog/FontFamilyDialog.qml</file>
|
||||||
<file>imports/Spectral/Dialog/AccountDetailDialog.qml</file>
|
<file>imports/Spectral/Dialog/AccountDetailDialog.qml</file>
|
||||||
<file>imports/Spectral/Dialog/OpenFileDialog.qml</file>
|
<file>imports/Spectral/Dialog/OpenFileDialog.qml</file>
|
||||||
|
<file>imports/Spectral/Dialog/OpenFolderDialog.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
Reference in New Issue
Block a user