diff --git a/qml/form/RoomForm.qml b/qml/form/RoomForm.qml index bcf718d..e93c79b 100644 --- a/qml/form/RoomForm.qml +++ b/qml/form/RoomForm.qml @@ -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) { diff --git a/src/main.cpp b/src/main.cpp index 62ee158..2dfa117 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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*"); + qRegisterMetaType("User*"); qmlRegisterType("Matrique", 0, 1, "Controller"); qmlRegisterType("Matrique", 0, 1, "RoomListModel"); qmlRegisterType("Matrique", 0, 1, "MessageEventModel"); - qRegisterMetaType("User*"); QQmlApplicationEngine engine;