From b0bbc6572a9d1fa4b0e4088c49ad5161036f0a6c Mon Sep 17 00:00:00 2001 From: Black Hat Date: Tue, 2 Jul 2019 10:33:08 +0800 Subject: [PATCH] Add busy property to controller. --- src/controller.cpp | 5 ++++- src/controller.h | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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);