Somewhat better login logic.
This commit is contained in:
parent
2d2d35fcf5
commit
5890a0e133
|
@ -7,7 +7,13 @@ CONFIG += object_parallel_to_source
|
||||||
|
|
||||||
TARGET = matrique
|
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)
|
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
|
||||||
|
|
|
@ -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() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ Page {
|
||||||
flat: true
|
flat: true
|
||||||
highlighted: true
|
highlighted: true
|
||||||
|
|
||||||
onClicked: Util.pushToStack(stackView, loginPage)
|
onClicked: stackView.push(loginPage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue