diff --git a/matrique.pro b/matrique.pro index 6b466e2..0fabc98 100644 --- a/matrique.pro +++ b/matrique.pro @@ -7,7 +7,13 @@ CONFIG += object_parallel_to_source TARGET = matrique -include(include/libqmatrixclient/libqmatrixclient.pri) +packagesExist(QMatrixClient) { + message("Found libQMatrixClient via pkg-config.") + CONFIG += link_pkgconfig + PKGCONFIG += QMatrixClient +} else { + include(include/libqmatrixclient/libqmatrixclient.pri) +} include(include/SortFilterProxyModel/SortFilterProxyModel.pri) # The following define makes your compiler emit warnings if you use diff --git a/qml/Login.qml b/qml/Login.qml index 6ba5c19..1fb0e10 100644 --- a/qml/Login.qml +++ b/qml/Login.qml @@ -152,6 +152,8 @@ Page { } controller.loginWithCredentials(serverField.text, usernameField.text, passwordField.text) + + controller.connectionAdded.connect(function() { stackView.pop() }) } } } diff --git a/qml/Setting.qml b/qml/Setting.qml index 9a76d99..6774ffb 100644 --- a/qml/Setting.qml +++ b/qml/Setting.qml @@ -179,7 +179,7 @@ Page { flat: true highlighted: true - onClicked: Util.pushToStack(stackView, loginPage) + onClicked: stackView.push(loginPage) } } } diff --git a/qml/main.qml b/qml/main.qml index 03a2927..5f3de31 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -294,4 +294,10 @@ ApplicationWindow { property: "connection" value: currentConnection } + + Component.onCompleted: { + matriqueController.initiated.connect(function() { + if (matriqueController.accountCount == 0) stackView.push(loginPage) + }) + } } diff --git a/src/controller.cpp b/src/controller.cpp index 4ade983..52c7f2e 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -141,6 +141,7 @@ void Controller::invokeLogin() { c->connectWithToken(account.userId(), accessToken, account.deviceId()); } } + emit initiated(); } QByteArray Controller::loadAccessToken(const AccountSettings& account) { diff --git a/src/controller.h b/src/controller.h index d6297c1..8f30954 100644 --- a/src/controller.h +++ b/src/controller.h @@ -17,6 +17,8 @@ class Controller : public QObject { Q_OBJECT Q_PROPERTY(bool busy READ busy WRITE setBusy NOTIFY busyChanged) + Q_PROPERTY(int accountCount READ accountCount NOTIFY connectionAdded NOTIFY + connectionDropped) public: explicit Controller(QObject* parent = nullptr); @@ -40,6 +42,8 @@ class Controller : public QObject { } } + int accountCount() { return m_connections.count(); } + Q_INVOKABLE QColor color(QString userId); Q_INVOKABLE void setColor(QString userId, QColor newColor); @@ -66,6 +70,7 @@ class Controller : public QObject { void toggleWindow(); void connectionAdded(Connection* conn); void connectionDropped(Connection* conn); + void initiated(); public slots: void logout(Connection* conn);