Add upload status.

This commit is contained in:
Black Hat 2018-07-17 14:14:48 +08:00
parent 731cef3c77
commit cf84320794
2 changed files with 28 additions and 8 deletions

View File

@ -150,17 +150,28 @@ Item {
folder: shortcuts.home
selectMultiple: false
onAccepted: {
console.log("You chose: " + fileDialog.fileUrl)
currentRoom.uploadFile(fileDialog.fileUrl, fileDialog.fileUrl)
currentRoom.fileTransferCompleted.connect(function(id, localFile, mxcUrl) {
console.log("File transferred: " + id + ":" + mxcUrl)
matriqueController.postFile(currentRoom, localFile, mxcUrl)
})
var fileTransferProgressCallback = function(id, sent, total) {
if (id == fileDialog.fileUrl) { inputField.progress = sent / total }
}
var completedCallback = function(id, localFile, mxcUrl) {
if (id == fileDialog.fileUrl) {
matriqueController.postFile(currentRoom, localFile, mxcUrl)
inputField.progress = 0
currentRoom.fileTransferCompleted.disconnect(fileTransferProgressCallback)
currentRoom.fileTransferCompleted.disconnect(completedCallback)
}
}
currentRoom.fileTransferProgress.connect(fileTransferProgressCallback)
currentRoom.fileTransferCompleted.connect(completedCallback)
}
}
}
TextField {
property real progress: 0
id: inputField
Layout.fillWidth: true
Layout.fillHeight: true
@ -170,7 +181,16 @@ Item {
bottomPadding: 0
selectByMouse: true
background: Rectangle { color: Material.theme == Material.Light ? "#eaeaea" : "#242424" }
background: Item {
Rectangle {
width: inputField.width * inputField.progress
height: parent.height
z: 5
color: Material.accent
opacity: 0.4
}
Rectangle { anchors.fill: parent; color: Material.theme == Material.Light ? "#eaeaea" : "#242424" }
}
Keys.onReturnPressed: {
if (inputField.text) {

View File

@ -6,8 +6,8 @@
#include "controller.h"
#include "imageprovider.h"
#include "messageeventmodel.h"
#include "roomlistmodel.h"
#include "room.h"
#include "roomlistmodel.h"
using namespace QMatrixClient;
@ -26,11 +26,11 @@ int main(int argc, char *argv[]) {
// QNetworkProxy::setApplicationProxy(proxy);
qRegisterMetaType<Room *>("Room*");
qRegisterMetaType<User *>("User*");
qmlRegisterType<Controller>("Matrique", 0, 1, "Controller");
qmlRegisterType<RoomListModel>("Matrique", 0, 1, "RoomListModel");
qmlRegisterType<MessageEventModel>("Matrique", 0, 1, "MessageEventModel");
qRegisterMetaType<User *>("User*");
QQmlApplicationEngine engine;