mirror of
https://github.com/overte-org/overte.git
synced 2025-06-20 05:00:00 +02:00
Fixup qt launcher style and add last login
This commit is contained in:
parent
e1a3b24a6d
commit
fba18c2719
4 changed files with 31 additions and 9 deletions
|
@ -9,7 +9,7 @@ Item {
|
||||||
id: root
|
id: root
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
property string titleText: "Sign-in and pick a password"
|
property string titleText: "Sign-in and pick a password"
|
||||||
property string usernamePlaceholder: "User name"
|
property string usernamePlaceholder: "Username"
|
||||||
property string passwordPlaceholder: "Set a password"
|
property string passwordPlaceholder: "Set a password"
|
||||||
property int marginLeft: root.width * 0.15
|
property int marginLeft: root.width * 0.15
|
||||||
|
|
||||||
|
@ -30,8 +30,7 @@ Item {
|
||||||
width: 481
|
width: 481
|
||||||
lineHeight: 35
|
lineHeight: 35
|
||||||
lineHeightMode: Text.FixedHeight
|
lineHeightMode: Text.FixedHeight
|
||||||
text: root.titleText + " " + LauncherState.applicationState
|
text: LauncherState.lastSignupErrorMessage.length == 0 ? root.titleText : "Uh oh."
|
||||||
visible: LauncherState.lastSignupErrorMessage.length == 0 ? root.titleText : "Uh oh."
|
|
||||||
anchors {
|
anchors {
|
||||||
top: root.top
|
top: root.top
|
||||||
topMargin: 29
|
topMargin: 29
|
||||||
|
|
|
@ -78,6 +78,7 @@ Item {
|
||||||
|
|
||||||
enabled: root.enabled
|
enabled: root.enabled
|
||||||
|
|
||||||
|
text: LauncherState.lastUsedUsername
|
||||||
placeholderText: "Username"
|
placeholderText: "Username"
|
||||||
|
|
||||||
seperatorColor: Qt.rgba(1, 1, 1, 0.3)
|
seperatorColor: Qt.rgba(1, 1, 1, 0.3)
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
//#define BREAK_ON_ERROR
|
//#define BREAK_ON_ERROR
|
||||||
|
|
||||||
const QString configHomeLocationKey { "homeLocation" };
|
const QString configHomeLocationKey { "homeLocation" };
|
||||||
|
const QString configLastLoginKey { "lastLogin" };
|
||||||
const QString configLoggedInKey{ "loggedIn" };
|
const QString configLoggedInKey{ "loggedIn" };
|
||||||
const QString configLauncherPathKey{ "launcherPath" };
|
const QString configLauncherPathKey{ "launcherPath" };
|
||||||
|
|
||||||
|
@ -261,10 +262,16 @@ void LauncherState::getCurrentClientVersion() {
|
||||||
_config.launcherPath = getLauncherFilePath();
|
_config.launcherPath = getLauncherFilePath();
|
||||||
_config.loggedIn = false;
|
_config.loggedIn = false;
|
||||||
if (root.contains(configLoggedInKey)) {
|
if (root.contains(configLoggedInKey)) {
|
||||||
_config.loggedIn = root["loggedIn"].toBool();
|
_config.loggedIn = root[configLoggedInKey].toBool();
|
||||||
|
}
|
||||||
|
if (root.contains(configLastLoginKey)) {
|
||||||
|
_config.lastLogin = root[configLastLoginKey].toString();
|
||||||
}
|
}
|
||||||
if (root.contains(configHomeLocationKey)) {
|
if (root.contains(configHomeLocationKey)) {
|
||||||
_config.homeLocation = root["homeLocation"].toString();
|
_config.homeLocation = root[configHomeLocationKey].toString();
|
||||||
|
}
|
||||||
|
if (root.contains(configLauncherPathKey)) {
|
||||||
|
_config.launcherPath = root[configLauncherPathKey].toString();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Failed to open config.json";
|
qDebug() << "Failed to open config.json";
|
||||||
|
@ -274,7 +281,12 @@ void LauncherState::getCurrentClientVersion() {
|
||||||
if (_config.loggedIn) {
|
if (_config.loggedIn) {
|
||||||
downloadClient();
|
downloadClient();
|
||||||
} else {
|
} else {
|
||||||
|
if (_config.lastLogin.isEmpty()) {
|
||||||
setApplicationState(ApplicationState::WaitingForSignup);
|
setApplicationState(ApplicationState::WaitingForSignup);
|
||||||
|
} else {
|
||||||
|
_lastUsedUsername = _config.lastLogin;
|
||||||
|
setApplicationState(ApplicationState::WaitingForLogin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +324,7 @@ void LauncherState::signup(QString email, QString username, QString password, QS
|
||||||
emit lastSignupErrorChanged();
|
emit lastSignupErrorChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject::connect(signupRequest, &SignupRequest::finished, this, [this, signupRequest] {
|
QObject::connect(signupRequest, &SignupRequest::finished, this, [this, signupRequest, username] {
|
||||||
signupRequest->deleteLater();
|
signupRequest->deleteLater();
|
||||||
|
|
||||||
|
|
||||||
|
@ -350,6 +362,9 @@ void LauncherState::signup(QString email, QString username, QString password, QS
|
||||||
// After successfully signing up, attempt to login
|
// After successfully signing up, attempt to login
|
||||||
auto loginRequest = new LoginRequest();
|
auto loginRequest = new LoginRequest();
|
||||||
|
|
||||||
|
_lastUsedUsername = username;
|
||||||
|
_config.lastLogin = username;
|
||||||
|
|
||||||
connect(loginRequest, &LoginRequest::finished, this, [this, loginRequest]() {
|
connect(loginRequest, &LoginRequest::finished, this, [this, loginRequest]() {
|
||||||
ASSERT_STATE(ApplicationState::RequestingLoginAfterSignup);
|
ASSERT_STATE(ApplicationState::RequestingLoginAfterSignup);
|
||||||
|
|
||||||
|
@ -389,7 +404,7 @@ void LauncherState::login(QString username, QString password, QString displayNam
|
||||||
|
|
||||||
auto request = new LoginRequest();
|
auto request = new LoginRequest();
|
||||||
|
|
||||||
connect(request, &LoginRequest::finished, this, [this, request]() {
|
connect(request, &LoginRequest::finished, this, [this, request, username]() {
|
||||||
ASSERT_STATE(ApplicationState::RequestingLogin);
|
ASSERT_STATE(ApplicationState::RequestingLogin);
|
||||||
|
|
||||||
request->deleteLater();
|
request->deleteLater();
|
||||||
|
@ -404,6 +419,8 @@ void LauncherState::login(QString username, QString password, QString displayNam
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_lastUsedUsername = username;
|
||||||
|
_config.lastLogin = username;
|
||||||
_config.loggedIn = true;
|
_config.loggedIn = true;
|
||||||
_loginResponse = request->getToken();
|
_loginResponse = request->getToken();
|
||||||
_loginTokenResponse = request->getRawToken();
|
_loginTokenResponse = request->getRawToken();
|
||||||
|
@ -722,8 +739,9 @@ void LauncherState::launchClient() {
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(configFile.readAll());
|
QJsonDocument doc = QJsonDocument::fromJson(configFile.readAll());
|
||||||
doc.setObject({
|
doc.setObject({
|
||||||
{ configHomeLocationKey, _config.homeLocation },
|
{ configHomeLocationKey, _config.homeLocation },
|
||||||
|
{ configLastLoginKey, _config.lastLogin },
|
||||||
{ configLoggedInKey, _config.loggedIn },
|
{ configLoggedInKey, _config.loggedIn },
|
||||||
{ configLauncherPathKey, _config.launcherPath },
|
{ configLauncherPathKey, getLauncherFilePath() },
|
||||||
});
|
});
|
||||||
configFile.write(doc.toJson());
|
configFile.write(doc.toJson());
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "BuildsRequest.h"
|
#include "BuildsRequest.h"
|
||||||
|
|
||||||
struct LauncherConfig {
|
struct LauncherConfig {
|
||||||
|
QString lastLogin{ "" };
|
||||||
QString launcherPath{ "" };
|
QString launcherPath{ "" };
|
||||||
bool loggedIn{ false };
|
bool loggedIn{ false };
|
||||||
QString homeLocation{ "" };
|
QString homeLocation{ "" };
|
||||||
|
@ -28,6 +29,7 @@ class LauncherState : public QObject {
|
||||||
Q_PROPERTY(QString lastLoginErrorMessage READ getLastLoginErrorMessage NOTIFY lastLoginErrorMessageChanged)
|
Q_PROPERTY(QString lastLoginErrorMessage READ getLastLoginErrorMessage NOTIFY lastLoginErrorMessageChanged)
|
||||||
Q_PROPERTY(QString lastSignupErrorMessage READ getLastSignupErrorMessage NOTIFY lastSignupErrorMessageChanged)
|
Q_PROPERTY(QString lastSignupErrorMessage READ getLastSignupErrorMessage NOTIFY lastSignupErrorMessageChanged)
|
||||||
Q_PROPERTY(QString buildVersion READ getBuildVersion)
|
Q_PROPERTY(QString buildVersion READ getBuildVersion)
|
||||||
|
Q_PROPERTY(QString lastUsedUsername READ getLastUsedUsername)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LauncherState();
|
LauncherState();
|
||||||
|
@ -94,6 +96,7 @@ public:
|
||||||
QString getLastSignupErrorMessage() const { return _lastSignupErrorMessage; }
|
QString getLastSignupErrorMessage() const { return _lastSignupErrorMessage; }
|
||||||
|
|
||||||
QString getBuildVersion() { return QString(LAUNCHER_BUILD_VERSION); }
|
QString getBuildVersion() { return QString(LAUNCHER_BUILD_VERSION); }
|
||||||
|
QString getLastUsedUsername() const { return _lastUsedUsername; }
|
||||||
|
|
||||||
void setApplicationStateError(QString errorMessage);
|
void setApplicationStateError(QString errorMessage);
|
||||||
void setApplicationState(ApplicationState state);
|
void setApplicationState(ApplicationState state);
|
||||||
|
@ -174,6 +177,7 @@ private:
|
||||||
SignupRequest::Error _lastSignupError{ SignupRequest::Error::None };
|
SignupRequest::Error _lastSignupError{ SignupRequest::Error::None };
|
||||||
QString _lastLoginErrorMessage{ "" };
|
QString _lastLoginErrorMessage{ "" };
|
||||||
QString _lastSignupErrorMessage{ "" };
|
QString _lastSignupErrorMessage{ "" };
|
||||||
|
QString _lastUsedUsername;
|
||||||
QString _displayName;
|
QString _displayName;
|
||||||
QString _applicationErrorMessage;
|
QString _applicationErrorMessage;
|
||||||
QString _currentClientVersion;
|
QString _currentClientVersion;
|
||||||
|
|
Loading…
Reference in a new issue