Apply Clang Format
This commit is contained in:
189
src/controller.h
189
src/controller.h
@@ -22,109 +22,122 @@
|
||||
|
||||
using namespace Quotient;
|
||||
|
||||
class Controller : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int accountCount READ accountCount NOTIFY connectionAdded NOTIFY
|
||||
connectionDropped)
|
||||
Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE
|
||||
setQuitOnLastWindowClosed NOTIFY quitOnLastWindowClosedChanged)
|
||||
Q_PROPERTY(Connection* connection READ connection WRITE setConnection NOTIFY
|
||||
connectionChanged)
|
||||
Q_PROPERTY(bool isOnline READ isOnline NOTIFY isOnlineChanged)
|
||||
Q_PROPERTY(bool busy READ busy WRITE setBusy NOTIFY busyChanged)
|
||||
class Controller : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int accountCount READ accountCount NOTIFY connectionAdded NOTIFY connectionDropped)
|
||||
Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed NOTIFY quitOnLastWindowClosedChanged)
|
||||
Q_PROPERTY(Connection *connection READ connection WRITE setConnection NOTIFY connectionChanged)
|
||||
Q_PROPERTY(bool isOnline READ isOnline NOTIFY isOnlineChanged)
|
||||
Q_PROPERTY(bool busy READ busy WRITE setBusy NOTIFY busyChanged)
|
||||
|
||||
public:
|
||||
explicit Controller(QObject* parent = nullptr);
|
||||
~Controller();
|
||||
public:
|
||||
explicit Controller(QObject *parent = nullptr);
|
||||
~Controller();
|
||||
|
||||
Q_INVOKABLE void loginWithCredentials(QString, QString, QString, QString);
|
||||
Q_INVOKABLE void loginWithAccessToken(QString, QString, QString, QString);
|
||||
Q_INVOKABLE void loginWithCredentials(QString, QString, QString, QString);
|
||||
Q_INVOKABLE void loginWithAccessToken(QString, QString, QString, QString);
|
||||
|
||||
QVector<Connection*> connections() const { return m_connections; }
|
||||
|
||||
// All the non-Q_INVOKABLE functions.
|
||||
void addConnection(Connection* c);
|
||||
void dropConnection(Connection* c);
|
||||
|
||||
// All the Q_PROPERTYs.
|
||||
int accountCount() { return m_connections.count(); }
|
||||
|
||||
bool quitOnLastWindowClosed() const {
|
||||
return QApplication::quitOnLastWindowClosed();
|
||||
}
|
||||
void setQuitOnLastWindowClosed(bool value) {
|
||||
if (quitOnLastWindowClosed() != value) {
|
||||
QApplication::setQuitOnLastWindowClosed(value);
|
||||
|
||||
emit quitOnLastWindowClosedChanged();
|
||||
QVector<Connection *> connections() const
|
||||
{
|
||||
return m_connections;
|
||||
}
|
||||
}
|
||||
|
||||
bool isOnline() const { return m_ncm.isOnline(); }
|
||||
// All the non-Q_INVOKABLE functions.
|
||||
void addConnection(Connection *c);
|
||||
void dropConnection(Connection *c);
|
||||
|
||||
bool busy() const { return m_busy; }
|
||||
void setBusy(bool busy) {
|
||||
if (m_busy == busy) {
|
||||
return;
|
||||
// All the Q_PROPERTYs.
|
||||
int accountCount()
|
||||
{
|
||||
return m_connections.count();
|
||||
}
|
||||
m_busy = busy;
|
||||
emit busyChanged();
|
||||
}
|
||||
|
||||
Connection* connection() const {
|
||||
if (m_connection.isNull())
|
||||
return nullptr;
|
||||
bool quitOnLastWindowClosed() const
|
||||
{
|
||||
return QApplication::quitOnLastWindowClosed();
|
||||
}
|
||||
void setQuitOnLastWindowClosed(bool value)
|
||||
{
|
||||
if (quitOnLastWindowClosed() != value) {
|
||||
QApplication::setQuitOnLastWindowClosed(value);
|
||||
|
||||
return m_connection;
|
||||
}
|
||||
emit quitOnLastWindowClosedChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void setConnection(Connection* conn) {
|
||||
if (conn == m_connection)
|
||||
return;
|
||||
m_connection = conn;
|
||||
emit connectionChanged();
|
||||
}
|
||||
bool isOnline() const
|
||||
{
|
||||
return m_ncm.isOnline();
|
||||
}
|
||||
|
||||
private:
|
||||
QVector<Connection*> m_connections;
|
||||
QPointer<Connection> m_connection;
|
||||
QNetworkConfigurationManager m_ncm;
|
||||
bool m_busy = false;
|
||||
bool busy() const
|
||||
{
|
||||
return m_busy;
|
||||
}
|
||||
void setBusy(bool busy)
|
||||
{
|
||||
if (m_busy == busy) {
|
||||
return;
|
||||
}
|
||||
m_busy = busy;
|
||||
emit busyChanged();
|
||||
}
|
||||
|
||||
QByteArray loadAccessTokenFromFile(const AccountSettings& account);
|
||||
QByteArray loadAccessTokenFromKeyChain(const AccountSettings& account);
|
||||
Connection *connection() const
|
||||
{
|
||||
if (m_connection.isNull())
|
||||
return nullptr;
|
||||
|
||||
bool saveAccessTokenToFile(const AccountSettings& account,
|
||||
const QByteArray& accessToken);
|
||||
bool saveAccessTokenToKeyChain(const AccountSettings& account,
|
||||
const QByteArray& accessToken);
|
||||
void loadSettings();
|
||||
void saveSettings() const;
|
||||
return m_connection;
|
||||
}
|
||||
|
||||
private slots:
|
||||
void invokeLogin();
|
||||
void setConnection(Connection *conn)
|
||||
{
|
||||
if (conn == m_connection)
|
||||
return;
|
||||
m_connection = conn;
|
||||
emit connectionChanged();
|
||||
}
|
||||
|
||||
signals:
|
||||
void busyChanged();
|
||||
void errorOccured(QString error, QString detail);
|
||||
void syncDone();
|
||||
void connectionAdded(Connection* conn);
|
||||
void connectionDropped(Connection* conn);
|
||||
void initiated();
|
||||
void notificationClicked(const QString roomId, const QString eventId);
|
||||
void quitOnLastWindowClosedChanged();
|
||||
void unreadCountChanged();
|
||||
void connectionChanged();
|
||||
void isOnlineChanged();
|
||||
private:
|
||||
QVector<Connection *> m_connections;
|
||||
QPointer<Connection> m_connection;
|
||||
QNetworkConfigurationManager m_ncm;
|
||||
bool m_busy = false;
|
||||
|
||||
public slots:
|
||||
void logout(Connection* conn);
|
||||
void joinRoom(Connection* c, const QString& alias);
|
||||
void createRoom(Connection* c, const QString& name, const QString& topic);
|
||||
void createDirectChat(Connection* c, const QString& userID);
|
||||
void playAudio(QUrl localFile);
|
||||
void changeAvatar(Connection* conn, QUrl localFile);
|
||||
void markAllMessagesAsRead(Connection* conn);
|
||||
QByteArray loadAccessTokenFromFile(const AccountSettings &account);
|
||||
QByteArray loadAccessTokenFromKeyChain(const AccountSettings &account);
|
||||
|
||||
bool saveAccessTokenToFile(const AccountSettings &account, const QByteArray &accessToken);
|
||||
bool saveAccessTokenToKeyChain(const AccountSettings &account, const QByteArray &accessToken);
|
||||
void loadSettings();
|
||||
void saveSettings() const;
|
||||
|
||||
private slots:
|
||||
void invokeLogin();
|
||||
|
||||
signals:
|
||||
void busyChanged();
|
||||
void errorOccured(QString error, QString detail);
|
||||
void syncDone();
|
||||
void connectionAdded(Connection *conn);
|
||||
void connectionDropped(Connection *conn);
|
||||
void initiated();
|
||||
void notificationClicked(const QString roomId, const QString eventId);
|
||||
void quitOnLastWindowClosedChanged();
|
||||
void unreadCountChanged();
|
||||
void connectionChanged();
|
||||
void isOnlineChanged();
|
||||
|
||||
public slots:
|
||||
void logout(Connection *conn);
|
||||
void joinRoom(Connection *c, const QString &alias);
|
||||
void createRoom(Connection *c, const QString &name, const QString &topic);
|
||||
void createDirectChat(Connection *c, const QString &userID);
|
||||
void playAudio(QUrl localFile);
|
||||
void changeAvatar(Connection *conn, QUrl localFile);
|
||||
void markAllMessagesAsRead(Connection *conn);
|
||||
};
|
||||
|
||||
#endif // CONTROLLER_H
|
||||
#endif // CONTROLLER_H
|
||||
|
||||
Reference in New Issue
Block a user