Spectral/matrix/controller.h

71 lines
1.6 KiB
C
Raw Normal View History

2018-02-27 05:10:08 +00:00
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <QObject>
2018-02-27 11:07:50 +00:00
#include "libqmatrixclient/connection.h"
using namespace QMatrixClient;
2018-02-27 05:10:08 +00:00
class Controller : public QObject
{
Q_OBJECT
2018-02-27 11:07:50 +00:00
2018-02-27 11:37:53 +00:00
Q_PROPERTY(bool isLogin READ getIsLogin WRITE setIsLogin NOTIFY isLoginChanged)
2018-02-27 11:07:50 +00:00
Q_PROPERTY(QString userID READ getUserID WRITE setUserID NOTIFY userIDChanged)
Q_PROPERTY(QByteArray token READ getToken WRITE setToken NOTIFY tokenChanged)
2018-02-27 05:10:08 +00:00
public:
explicit Controller(QObject *parent = nullptr);
2018-02-27 11:07:50 +00:00
~Controller();
// All the Q_INVOKABLEs.
Q_INVOKABLE void login(QString, QString, QString);
Q_INVOKABLE void logout();
// All the non-Q_INVOKABLE functions.
// All the Q_PROPERTYs.
2018-02-27 11:37:53 +00:00
bool isLogin = false;
bool getIsLogin() { return isLogin; }
void setIsLogin(bool n) {
if(n != isLogin) {
isLogin = n;
emit isLoginChanged();
}
}
2018-02-27 11:07:50 +00:00
QString userID;
QString getUserID() { return userID; }
void setUserID(QString n) {
if(n != userID) {
userID = n;
emit userIDChanged();
}
}
QByteArray token;
QByteArray getToken() { return token; }
void setToken(QByteArray n) {
if(n != token) {
token = n;
emit tokenChanged();
}
}
private:
QMatrixClient::Connection *connection = new QMatrixClient::Connection();
2018-02-27 11:37:53 +00:00
void connected();
2018-02-27 11:07:50 +00:00
void resync();
void reconnect();
2018-02-27 05:10:08 +00:00
signals:
2018-02-27 11:37:53 +00:00
void isLoginChanged();
2018-02-27 11:07:50 +00:00
void userIDChanged();
void tokenChanged();
void homeServerChanged();
2018-02-27 05:10:08 +00:00
public slots:
};
2018-02-27 11:07:50 +00:00
#endif // CONTROLLER_H