Somewhat better login logic.

This commit is contained in:
Black Hat 2018-09-13 08:22:41 +08:00
parent 2d2d35fcf5
commit 5890a0e133
6 changed files with 22 additions and 2 deletions

View File

@ -7,7 +7,13 @@ CONFIG += object_parallel_to_source
TARGET = matrique TARGET = matrique
packagesExist(QMatrixClient) {
message("Found libQMatrixClient via pkg-config.")
CONFIG += link_pkgconfig
PKGCONFIG += QMatrixClient
} else {
include(include/libqmatrixclient/libqmatrixclient.pri) include(include/libqmatrixclient/libqmatrixclient.pri)
}
include(include/SortFilterProxyModel/SortFilterProxyModel.pri) include(include/SortFilterProxyModel/SortFilterProxyModel.pri)
# The following define makes your compiler emit warnings if you use # The following define makes your compiler emit warnings if you use

View File

@ -152,6 +152,8 @@ Page {
} }
controller.loginWithCredentials(serverField.text, usernameField.text, passwordField.text) controller.loginWithCredentials(serverField.text, usernameField.text, passwordField.text)
controller.connectionAdded.connect(function() { stackView.pop() })
} }
} }
} }

View File

@ -179,7 +179,7 @@ Page {
flat: true flat: true
highlighted: true highlighted: true
onClicked: Util.pushToStack(stackView, loginPage) onClicked: stackView.push(loginPage)
} }
} }
} }

View File

@ -294,4 +294,10 @@ ApplicationWindow {
property: "connection" property: "connection"
value: currentConnection value: currentConnection
} }
Component.onCompleted: {
matriqueController.initiated.connect(function() {
if (matriqueController.accountCount == 0) stackView.push(loginPage)
})
}
} }

View File

@ -141,6 +141,7 @@ void Controller::invokeLogin() {
c->connectWithToken(account.userId(), accessToken, account.deviceId()); c->connectWithToken(account.userId(), accessToken, account.deviceId());
} }
} }
emit initiated();
} }
QByteArray Controller::loadAccessToken(const AccountSettings& account) { QByteArray Controller::loadAccessToken(const AccountSettings& account) {

View File

@ -17,6 +17,8 @@ class Controller : public QObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool busy READ busy WRITE setBusy NOTIFY busyChanged) Q_PROPERTY(bool busy READ busy WRITE setBusy NOTIFY busyChanged)
Q_PROPERTY(int accountCount READ accountCount NOTIFY connectionAdded NOTIFY
connectionDropped)
public: public:
explicit Controller(QObject* parent = nullptr); 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 QColor color(QString userId);
Q_INVOKABLE void setColor(QString userId, QColor newColor); Q_INVOKABLE void setColor(QString userId, QColor newColor);
@ -66,6 +70,7 @@ class Controller : public QObject {
void toggleWindow(); void toggleWindow();
void connectionAdded(Connection* conn); void connectionAdded(Connection* conn);
void connectionDropped(Connection* conn); void connectionDropped(Connection* conn);
void initiated();
public slots: public slots:
void logout(Connection* conn); void logout(Connection* conn);