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