mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-21 20:27:45 +00:00
Add currentProfile property to LauncherCore
This commit is contained in:
parent
c4d870ea0a
commit
e211c95e21
4 changed files with 55 additions and 27 deletions
|
@ -73,6 +73,7 @@ class LauncherCore : public QObject
|
||||||
Q_PROPERTY(QString squareEnixServer READ squareEnixServer WRITE setSquareEnixServer NOTIFY squareEnixServerChanged)
|
Q_PROPERTY(QString squareEnixServer READ squareEnixServer WRITE setSquareEnixServer NOTIFY squareEnixServerChanged)
|
||||||
Q_PROPERTY(QString squareEnixLoginServer READ squareEnixLoginServer WRITE setSquareEnixLoginServer NOTIFY squareEnixLoginServerChanged)
|
Q_PROPERTY(QString squareEnixLoginServer READ squareEnixLoginServer WRITE setSquareEnixLoginServer NOTIFY squareEnixLoginServerChanged)
|
||||||
Q_PROPERTY(Headline *headline READ headline NOTIFY newsChanged)
|
Q_PROPERTY(Headline *headline READ headline NOTIFY newsChanged)
|
||||||
|
Q_PROPERTY(Profile *currentProfile READ currentProfile WRITE setCurrentProfile NOTIFY currentProfileChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LauncherCore();
|
LauncherCore();
|
||||||
|
@ -165,6 +166,9 @@ public:
|
||||||
Q_INVOKABLE void openSystemInfo(Profile *profile);
|
Q_INVOKABLE void openSystemInfo(Profile *profile);
|
||||||
Q_INVOKABLE void openConfigBackup(Profile *profile);
|
Q_INVOKABLE void openConfigBackup(Profile *profile);
|
||||||
|
|
||||||
|
Profile *currentProfile() const;
|
||||||
|
void setCurrentProfile(Profile *profile);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void loadingFinished();
|
void loadingFinished();
|
||||||
void gameInstallationChanged();
|
void gameInstallationChanged();
|
||||||
|
@ -184,6 +188,7 @@ signals:
|
||||||
void stageIndeterminate();
|
void stageIndeterminate();
|
||||||
void stageDeterminate(int min, int max, int value);
|
void stageDeterminate(int min, int max, int value);
|
||||||
void newsChanged();
|
void newsChanged();
|
||||||
|
void currentProfileChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*
|
/*
|
||||||
|
@ -219,4 +224,6 @@ private:
|
||||||
AccountManager *m_accountManager = nullptr;
|
AccountManager *m_accountManager = nullptr;
|
||||||
|
|
||||||
Headline *m_headline = nullptr;
|
Headline *m_headline = nullptr;
|
||||||
|
|
||||||
|
int m_currentProfileIndex = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -714,3 +714,17 @@ void LauncherCore::setIsSteam(bool isSteam)
|
||||||
{
|
{
|
||||||
m_isSteam = isSteam;
|
m_isSteam = isSteam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Profile *LauncherCore::currentProfile() const
|
||||||
|
{
|
||||||
|
return m_profileManager->getProfile(m_currentProfileIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LauncherCore::setCurrentProfile(Profile *profile)
|
||||||
|
{
|
||||||
|
const int newIndex = m_profileManager->getProfileIndex(profile->name());
|
||||||
|
if (newIndex != m_currentProfileIndex) {
|
||||||
|
m_currentProfileIndex = newIndex;
|
||||||
|
Q_EMIT currentProfileChanged();
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,8 +22,6 @@ Kirigami.ApplicationWindow {
|
||||||
visible: true
|
visible: true
|
||||||
title: LauncherCore.isSteam ? "Astra (Steam)" : "Astra"
|
title: LauncherCore.isSteam ? "Astra (Steam)" : "Astra"
|
||||||
|
|
||||||
property var currentSetupProfile: LauncherCore.profileManager.getProfile(0)
|
|
||||||
|
|
||||||
pageStack.initialPage: Kirigami.Page {
|
pageStack.initialPage: Kirigami.Page {
|
||||||
Kirigami.LoadingPlaceholder {
|
Kirigami.LoadingPlaceholder {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
@ -37,15 +35,15 @@ Kirigami.ApplicationWindow {
|
||||||
|
|
||||||
pageStack.layers.clear()
|
pageStack.layers.clear()
|
||||||
|
|
||||||
if (!currentSetupProfile.isGameInstalled) {
|
if (!LauncherCore.currentProfile.isGameInstalled) {
|
||||||
// User must set up the profile
|
// User must set up the profile
|
||||||
pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "SetupPage"), {
|
pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "SetupPage"), {
|
||||||
profile: currentSetupProfile
|
profile: LauncherCore.currentProfile
|
||||||
})
|
})
|
||||||
} else if (!currentSetupProfile.account) {
|
} else if (!LauncherCore.currentProfile.account) {
|
||||||
// User must select an account for the profile
|
// User must select an account for the profile
|
||||||
pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "AccountSetup"), {
|
pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "AccountSetup"), {
|
||||||
profile: currentSetupProfile
|
profile: LauncherCore.currentProfile
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "MainPage"))
|
pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "MainPage"))
|
||||||
|
@ -98,6 +96,10 @@ Kirigami.ApplicationWindow {
|
||||||
// TODO: see if this changed in Qt6
|
// TODO: see if this changed in Qt6
|
||||||
pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "MainPage"))
|
pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "MainPage"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onCurrentProfileChanged() {
|
||||||
|
checkSetup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: checkSetup()
|
Component.onCompleted: checkSetup()
|
||||||
|
|
|
@ -14,9 +14,8 @@ import zone.xiv.astra
|
||||||
QQC2.Control {
|
QQC2.Control {
|
||||||
id: page
|
id: page
|
||||||
|
|
||||||
property var profile: LauncherCore.profileManager.getProfile(0)
|
|
||||||
readonly property bool isLoginValid: {
|
readonly property bool isLoginValid: {
|
||||||
if (!profile.account) {
|
if (!LauncherCore.currentProfile.account) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,11 +23,11 @@ QQC2.Control {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!profile.account.rememberPassword && passwordField.text.length === 0) {
|
if (!LauncherCore.currentProfile.account.rememberPassword && passwordField.text.length === 0) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile.account.useOTP && !profile.account.rememberOTP && otpField.text.length === 0) {
|
if (LauncherCore.currentProfile.account.useOTP && !LauncherCore.currentProfile.account.rememberOTP && otpField.text.length === 0) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,21 +35,27 @@ QQC2.Control {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateFields() {
|
function updateFields() {
|
||||||
usernameField.text = profile.account.name
|
usernameField.text = LauncherCore.currentProfile.account.name
|
||||||
passwordField.text = profile.account.rememberPassword ? profile.account.getPassword() : ""
|
passwordField.text = LauncherCore.currentProfile.account.rememberPassword ? LauncherCore.currentProfile.account.getPassword() : ""
|
||||||
otpField.text = ""
|
otpField.text = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: profile
|
target: LauncherCore
|
||||||
|
|
||||||
|
function onCurrentProfileChanged() {
|
||||||
|
updateFields();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: LauncherCore.currentProfile
|
||||||
|
|
||||||
function onAccountChanged() {
|
function onAccountChanged() {
|
||||||
updateFields()
|
updateFields()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onProfileChanged: updateFields()
|
|
||||||
|
|
||||||
contentItem: ColumnLayout {
|
contentItem: ColumnLayout {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
|
@ -59,7 +64,7 @@ QQC2.Control {
|
||||||
|
|
||||||
FormCard.FormButtonDelegate {
|
FormCard.FormButtonDelegate {
|
||||||
text: i18n("Current Profile")
|
text: i18n("Current Profile")
|
||||||
description: page.profile.name
|
description: LauncherCore.currentProfile.name
|
||||||
|
|
||||||
QQC2.Menu {
|
QQC2.Menu {
|
||||||
id: profileMenu
|
id: profileMenu
|
||||||
|
@ -74,7 +79,7 @@ QQC2.Control {
|
||||||
text: profile.name
|
text: profile.name
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
page.profile = profile
|
LauncherCore.currentProfile = profile
|
||||||
profileMenu.close()
|
profileMenu.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,11 +96,11 @@ QQC2.Control {
|
||||||
|
|
||||||
FormCard.FormButtonDelegate {
|
FormCard.FormButtonDelegate {
|
||||||
text: i18n("Current Account")
|
text: i18n("Current Account")
|
||||||
description: page.profile.account.name
|
description: LauncherCore.currentProfile.account.name
|
||||||
|
|
||||||
leading: Components.Avatar
|
leading: Components.Avatar
|
||||||
{
|
{
|
||||||
source: page.profile.account.avatarUrl
|
source: LauncherCore.currentProfile.account.avatarUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
leadingPadding: Kirigami.Units.largeSpacing * 2
|
leadingPadding: Kirigami.Units.largeSpacing * 2
|
||||||
|
@ -115,7 +120,7 @@ QQC2.Control {
|
||||||
icon.source: account.avatarUrl
|
icon.source: account.avatarUrl
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
page.profile.account = account
|
LauncherCore.currentProfile.account = account
|
||||||
accountMenu.close()
|
accountMenu.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,8 +136,8 @@ QQC2.Control {
|
||||||
|
|
||||||
FormCard.FormTextFieldDelegate {
|
FormCard.FormTextFieldDelegate {
|
||||||
id: usernameField
|
id: usernameField
|
||||||
label: page.profile.account.isSapphire ? i18n("Username") : i18n("Square Enix ID")
|
label: LauncherCore.currentProfile.account.isSapphire ? i18n("Username") : i18n("Square Enix ID")
|
||||||
text: page.profile.account.name
|
text: LauncherCore.currentProfile.account.name
|
||||||
enabled: false
|
enabled: false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +146,7 @@ QQC2.Control {
|
||||||
|
|
||||||
FormCard.FormTextFieldDelegate {
|
FormCard.FormTextFieldDelegate {
|
||||||
id: passwordField
|
id: passwordField
|
||||||
label: page.profile.account.isSapphire ? i18n("Password") : i18n("Square Enix Password")
|
label: LauncherCore.currentProfile.account.isSapphire ? i18n("Password") : i18n("Square Enix Password")
|
||||||
echoMode: TextInput.Password
|
echoMode: TextInput.Password
|
||||||
focus: true
|
focus: true
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
|
@ -151,7 +156,7 @@ QQC2.Control {
|
||||||
loginButton.clicked();
|
loginButton.clicked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
text: page.profile.account.rememberPassword ? "abcdefg" : ""
|
text: LauncherCore.currentProfile.account.rememberPassword ? LauncherCore.currentProfile.account.getPassword() : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
FormCard.FormDelegateSeparator {
|
FormCard.FormDelegateSeparator {
|
||||||
|
@ -160,7 +165,7 @@ QQC2.Control {
|
||||||
FormCard.FormTextFieldDelegate {
|
FormCard.FormTextFieldDelegate {
|
||||||
id: otpField
|
id: otpField
|
||||||
label: i18n("One-time Password")
|
label: i18n("One-time Password")
|
||||||
visible: page.profile.account.useOTP
|
visible: LauncherCore.currentProfile.account.useOTP
|
||||||
onAccepted: loginButton.clicked()
|
onAccepted: loginButton.clicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +178,7 @@ QQC2.Control {
|
||||||
icon.name: "unlock"
|
icon.name: "unlock"
|
||||||
enabled: page.isLoginValid
|
enabled: page.isLoginValid
|
||||||
onClicked: {
|
onClicked: {
|
||||||
LauncherCore.login(page.profile, usernameField.text, passwordField.text, otpField.text)
|
LauncherCore.login(LauncherCore.currentProfile, usernameField.text, passwordField.text, otpField.text)
|
||||||
pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "StatusPage"))
|
pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "StatusPage"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +192,7 @@ QQC2.Control {
|
||||||
|
|
||||||
text: i18n("Forgot ID or Password")
|
text: i18n("Forgot ID or Password")
|
||||||
icon.name: "dialog-password"
|
icon.name: "dialog-password"
|
||||||
visible: !page.profile.account.isSapphire
|
visible: !LauncherCore.currentProfile.account.isSapphire
|
||||||
onClicked: applicationWindow().openUrl('https://secure.square-enix.com/account/app/svc/reminder')
|
onClicked: applicationWindow().openUrl('https://secure.square-enix.com/account/app/svc/reminder')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue