diff --git a/src/controller.cpp b/src/controller.cpp index 4f4fd8232..256f74a15 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -122,6 +122,7 @@ void Controller::addConnection(Connection* c) { c->setLazyLoading(true); connect(c, &Connection::syncDone, this, [=] { + setBusy(false); emit syncDone(); c->sync(30000); c->saveState(); @@ -130,7 +131,9 @@ void Controller::addConnection(Connection* c) { using namespace QMatrixClient; - c->sync(30000); + setBusy(true); + + c->sync(); emit connectionAdded(c); } diff --git a/src/controller.h b/src/controller.h index 310f38973..600ac140d 100644 --- a/src/controller.h +++ b/src/controller.h @@ -23,6 +23,7 @@ class Controller : public QObject { setQuitOnLastWindowClosed NOTIFY quitOnLastWindowClosedChanged) Q_PROPERTY(Connection* connection READ connection WRITE setConnection NOTIFY connectionChanged) + Q_PROPERTY(bool busy READ busy WRITE setBusy NOTIFY busyChanged) public: explicit Controller(QObject* parent = nullptr); @@ -53,6 +54,12 @@ class Controller : public QObject { } } + bool busy() { return m_busy; } + void setBusy(bool busy) { + m_busy = busy; + emit busyChanged(); + } + Connection* connection() { if (m_connection.isNull()) return nullptr; @@ -69,6 +76,7 @@ class Controller : public QObject { private: QVector m_connections; QPointer m_connection; + bool m_busy = false; QByteArray loadAccessTokenFromFile(const AccountSettings& account); QByteArray loadAccessTokenFromKeyChain(const AccountSettings& account);