Uses MatriqueRoom inherited from QMatrixClient::Room and rewrite related
objects.
This commit is contained in:
@@ -2,11 +2,10 @@
|
||||
#define CONTROLLER_H
|
||||
|
||||
#include "connection.h"
|
||||
#include "roomlistmodel.h"
|
||||
#include "user.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMimeDatabase>
|
||||
#include <QMediaPlayer>
|
||||
#include <QObject>
|
||||
|
||||
using namespace QMatrixClient;
|
||||
@@ -14,14 +13,13 @@ using namespace QMatrixClient;
|
||||
class Controller : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(Connection* connection READ getConnection CONSTANT)
|
||||
Q_PROPERTY(
|
||||
bool isLogin READ getIsLogin WRITE setIsLogin NOTIFY isLoginChanged)
|
||||
Q_PROPERTY(QString homeserver READ getHomeserver WRITE setHomeserver NOTIFY
|
||||
Q_PROPERTY(Connection* connection READ connection CONSTANT)
|
||||
Q_PROPERTY(bool isLogin READ isLogin WRITE setIsLogin NOTIFY isLoginChanged)
|
||||
Q_PROPERTY(QString homeserver READ homeserver WRITE setHomeserver NOTIFY
|
||||
homeserverChanged)
|
||||
Q_PROPERTY(QString userID READ getUserID WRITE setUserID NOTIFY userIDChanged)
|
||||
Q_PROPERTY(QByteArray token READ getToken WRITE setToken NOTIFY tokenChanged)
|
||||
Q_PROPERTY(bool busy READ getBusy WRITE setBusy NOTIFY busyChanged)
|
||||
Q_PROPERTY(QString userID READ userID WRITE setUserID NOTIFY userIDChanged)
|
||||
Q_PROPERTY(QByteArray token READ token WRITE setToken NOTIFY tokenChanged)
|
||||
Q_PROPERTY(bool busy READ busy WRITE setBusy NOTIFY busyChanged)
|
||||
|
||||
public:
|
||||
explicit Controller(QObject* parent = nullptr);
|
||||
@@ -36,64 +34,61 @@ class Controller : public QObject {
|
||||
|
||||
// All the Q_PROPERTYs.
|
||||
Connection* m_connection = new Connection();
|
||||
Connection* getConnection() { return m_connection; }
|
||||
Connection* connection() { return m_connection; }
|
||||
|
||||
bool isLogin = false;
|
||||
bool getIsLogin() { return isLogin; }
|
||||
bool isLogin() { return m_isLogin; }
|
||||
void setIsLogin(bool n) {
|
||||
if (n != isLogin) {
|
||||
isLogin = n;
|
||||
if (n != m_isLogin) {
|
||||
m_isLogin = n;
|
||||
emit isLoginChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString userID;
|
||||
QString getUserID() { return userID; }
|
||||
QString userID() { return m_userID; }
|
||||
void setUserID(QString n) {
|
||||
if (n != userID) {
|
||||
userID = n;
|
||||
if (n != m_userID) {
|
||||
m_userID = n;
|
||||
emit userIDChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray token;
|
||||
QByteArray getToken() { return token; }
|
||||
QByteArray token() { return m_token; }
|
||||
void setToken(QByteArray n) {
|
||||
if (n != token) {
|
||||
token = n;
|
||||
if (n != m_token) {
|
||||
m_token = n;
|
||||
emit tokenChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString homeserver;
|
||||
QString getHomeserver() { return homeserver; }
|
||||
QString homeserver() { return m_homeserver; }
|
||||
void setHomeserver(QString n) {
|
||||
if (n != homeserver) {
|
||||
homeserver = n;
|
||||
if (n != m_homeserver) {
|
||||
m_homeserver = n;
|
||||
emit homeserverChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool busy = false;
|
||||
bool getBusy() { return busy; }
|
||||
bool busy() { return m_busy; }
|
||||
void setBusy(bool b) {
|
||||
if (b != busy) {
|
||||
busy = b;
|
||||
if (b != m_busy) {
|
||||
m_busy = b;
|
||||
emit busyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
QClipboard* m_clipboard = QApplication::clipboard();
|
||||
QMimeDatabase m_db;
|
||||
|
||||
bool m_isLogin = false;
|
||||
QString m_userID;
|
||||
QByteArray m_token;
|
||||
QString m_homeserver;
|
||||
bool m_busy = false;
|
||||
|
||||
void connected();
|
||||
void resync();
|
||||
void reconnect();
|
||||
|
||||
QString getMIME(const QUrl& fileUrl) const;
|
||||
void postFile(Room* room, const QUrl& localFile, const QUrl& mxcUrl);
|
||||
|
||||
signals:
|
||||
void connectionChanged();
|
||||
void isLoginChanged();
|
||||
@@ -104,15 +99,11 @@ class Controller : public QObject {
|
||||
void errorOccured();
|
||||
|
||||
public slots:
|
||||
void uploadFile(Room* room);
|
||||
void forgetRoom(const QString& roomID);
|
||||
void joinRoom(const QString& alias);
|
||||
void createRoom(const QString& name, const QString& topic);
|
||||
void createDirectChat(const QString& userID);
|
||||
void copyToClipboard(const QString& text);
|
||||
void saveFileAs(Room* room, QString eventId);
|
||||
void acceptRoom(Room* room);
|
||||
void rejectRoom(Room* room);
|
||||
void playAudio(QUrl localFile);
|
||||
};
|
||||
|
||||
#endif // CONTROLLER_H
|
||||
|
||||
Reference in New Issue
Block a user