Init file sending.

This commit is contained in:
Black Hat 2018-07-16 22:05:34 +08:00
parent 4ef063ea82
commit 731cef3c77
7 changed files with 34 additions and 7 deletions

@ -1 +1 @@
Subproject commit 496e106083f3740d44716b96ed1b098d61df19eb
Subproject commit 56480bc96b28356c44547cc3d9ea1afbda9f04f9

View File

@ -0,0 +1,19 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtMultimedia 5.8
AvatarContainer {
Button {
id: downloadButton
text: content.body
highlighted: !sentByMe
flat: true
onClicked: downloadable.downloadAndOpen()
Audio {
audioRole: Audio.VoiceCommunicationRole
}
}
}

View File

@ -154,6 +154,7 @@ Item {
currentRoom.uploadFile(fileDialog.fileUrl, fileDialog.fileUrl)
currentRoom.fileTransferCompleted.connect(function(id, localFile, mxcUrl) {
console.log("File transferred: " + id + ":" + mxcUrl)
matriqueController.postFile(currentRoom, localFile, mxcUrl)
})
}
}

View File

@ -24,5 +24,6 @@
<file>qml/component/FileBubble.qml</file>
<file>qml/component/AvatarContainer.qml</file>
<file>qml/form/RoomListForm.qml</file>
<file>qml/component/AudioBubble.qml</file>
</qresource>
</RCC>

View File

@ -79,8 +79,12 @@ void Controller::reconnect() {
m_connection->connectWithToken(userID, token, "");
}
void Controller::postFile(QMatrixClient::Room* room,
const QUrl& localFilename) {
// auto job = m_connection->uploadFile(localFilename.toLocalFile());
// room->fileTransferInfo(localFilename.fileName())
void Controller::postFile(QMatrixClient::Room* room, const QUrl& localFile,
const QUrl& mxcUrl) {
QJsonObject json{{"body", localFile.fileName()},
{"filename", localFile.fileName()},
{"url", mxcUrl.url()}};
room->postMessage(QMatrixClient::RoomMessageEvent{
localFile.fileName(), "m.file",
new QMatrixClient::EventContent::FileContent(json)});
}

View File

@ -97,7 +97,8 @@ class Controller : public QObject {
void errorOccured();
public slots:
void postFile(QMatrixClient::Room* room, const QUrl& localFilename);
void postFile(QMatrixClient::Room* room, const QUrl& localFile,
const QUrl& mxcUrl);
};
#endif // CONTROLLER_H

View File

@ -273,8 +273,9 @@ QVariant MessageEventModel::data(const QModelIndex& index, int role) const {
return "notice";
case MessageEventType::Image:
return "image";
case MessageEventType::File:
case MessageEventType::Audio:
// return "audio";
case MessageEventType::File:
case MessageEventType::Video:
return "file";
default: