Add file-picker dialog which lets you add images to posts

This commit is contained in:
Christian Muehlhaeuser 2020-03-03 05:43:24 +01:00
parent b90ffb4b3d
commit d3dfa08d36
No known key found for this signature in database
GPG key ID: 3CF9FA45CA1EBB7E

View file

@ -2,6 +2,7 @@ import QtQuick 2.4
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.3
Popup {
id: popup
@ -15,6 +16,29 @@ Popup {
anchors.centerIn: mainWindow.overlay
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
FileDialog {
id: imageFileDialog
title: "Please choose an image"
folder: shortcuts.home
nameFilters: [ "Image files (*.jpg *.jpeg *.png *.gif)", "All files (*)" ]
selectExisting: true
selectMultiple: true
onAccepted: {
console.log("chose", imageFileDialog.fileUrls.length)
for (var i = 0; i < imageFileDialog.fileUrls.length; i++) {
console.log(imageFileDialog.fileUrls[i])
busy.running = true
var media = uiBridge.uploadAttachment(imageFileDialog.fileUrls[i])
}
}
onRejected: {
console.log("Canceled")
}
}
Flickable {
id: flickable
anchors.fill: parent
@ -47,9 +71,11 @@ Popup {
busy.running = true
var media = uiBridge.uploadAttachment(drop.urls[i])
/*if (media != '') {
/*
if (media != '') {
attachments.append({"id": media, "url": drop.urls[i]})
}*/
}
*/
}
drop.acceptProposedAction()
}
@ -112,9 +138,12 @@ Popup {
}
}
Label {
TextButton {
text: "Attach files by dragging & dropping them."
font.pointSize: 9
onClicked: function() {
imageFileDialog.open()
}
}
RowLayout {