Testing upload file && minor UI tweaks.

This commit is contained in:
Black Hat
2018-07-15 16:02:26 +08:00
parent 965dbeff83
commit 4ef063ea82
5 changed files with 24 additions and 22 deletions

View File

@@ -1,8 +1,10 @@
#include "controller.h"
#include "connection.h"
#include "events/eventcontent.h"
#include "events/roommessageevent.h"
Controller::Controller(QObject *parent) : QObject(parent) {
Controller::Controller(QObject* parent) : QObject(parent) {
connect(m_connection, &QMatrixClient::Connection::connected, this,
&Controller::connected);
connect(m_connection, &QMatrixClient::Connection::resolveError, this,
@@ -56,10 +58,6 @@ void Controller::logout() {
setIsLogin(false);
}
void Controller::uploadFile(QString filename) {
m_connection->uploadFile(filename);
}
void Controller::connected() {
qDebug() << "Logged in.";
setHomeserver(m_connection->homeserver().toString());
@@ -80,3 +78,9 @@ void Controller::reconnect() {
qDebug() << "Connection lost. Reconnecting...";
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())
}

View File

@@ -13,8 +13,7 @@ class Connection;
class Controller : public QObject {
Q_OBJECT
Q_PROPERTY(QMatrixClient::Connection* connection READ getConnection NOTIFY
connectionChanged)
Q_PROPERTY(QMatrixClient::Connection* connection READ getConnection CONSTANT)
Q_PROPERTY(
bool isLogin READ getIsLogin WRITE setIsLogin NOTIFY isLoginChanged)
Q_PROPERTY(QString homeserver READ getHomeserver WRITE setHomeserver NOTIFY
@@ -32,8 +31,6 @@ class Controller : public QObject {
Q_INVOKABLE void loginWithCredentials(QString, QString, QString);
Q_INVOKABLE void logout();
Q_INVOKABLE void uploadFile(QString);
// All the non-Q_INVOKABLE functions.
// All the Q_PROPERTYs.
@@ -100,6 +97,7 @@ class Controller : public QObject {
void errorOccured();
public slots:
void postFile(QMatrixClient::Room* room, const QUrl& localFilename);
};
#endif // CONTROLLER_H