Skip to content

Commit 723cfe1

Browse files
authored
feat(login): add offline and ely.by accounts in setup wizard (#72)
Signed-off-by: so5iso4ka <so5iso4ka@icloud.com>
1 parent d1665ab commit 723cfe1

3 files changed

Lines changed: 62 additions & 11 deletions

File tree

launcher/ui/setupwizard/LoginWizardPage.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "LoginWizardPage.h"
22
#include "minecraft/auth/AccountList.h"
3+
#include "ui/dialogs/ElybyLoginDialog.h"
34
#include "ui/dialogs/MSALoginDialog.h"
5+
#include "ui/dialogs/OfflineLoginDialog.h"
46
#include "ui_LoginWizardPage.h"
57

68
#include "Application.h"
@@ -27,7 +29,7 @@ void LoginWizardPage::retranslate()
2729
ui->retranslateUi(this);
2830
}
2931

30-
void LoginWizardPage::on_pushButton_clicked()
32+
void LoginWizardPage::on_addMicrosoftButton_clicked()
3133
{
3234
wizard()->hide();
3335
auto account = MSALoginDialog::newAccount(nullptr);
@@ -42,3 +44,35 @@ void LoginWizardPage::on_pushButton_clicked()
4244
}
4345
}
4446
}
47+
48+
void LoginWizardPage::on_addElybyButton_clicked()
49+
{
50+
wizard()->hide();
51+
auto account = ElybyLoginDialog::newAccount(nullptr, "Please enter your username and password of Elyby account.");
52+
wizard()->show();
53+
if (account) {
54+
APPLICATION->accounts()->addAccount(account);
55+
APPLICATION->accounts()->setDefaultAccount(account);
56+
if (wizard()->currentId() == wizard()->pageIds().last()) {
57+
wizard()->accept();
58+
} else {
59+
wizard()->next();
60+
}
61+
}
62+
}
63+
64+
void LoginWizardPage::on_addOfflineButton_clicked()
65+
{
66+
wizard()->hide();
67+
auto account = OfflineLoginDialog::newAccount(nullptr, "Please enter your desired username to add your offline account.");
68+
wizard()->show();
69+
if (account) {
70+
APPLICATION->accounts()->addAccount(account);
71+
APPLICATION->accounts()->setDefaultAccount(account);
72+
if (wizard()->currentId() == wizard()->pageIds().last()) {
73+
wizard()->accept();
74+
} else {
75+
wizard()->next();
76+
}
77+
}
78+
}

launcher/ui/setupwizard/LoginWizardPage.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ class LoginWizardPage : public BaseWizardPage {
1616
void initializePage() override;
1717
bool validatePage() override;
1818
void retranslate() override;
19+
1920
private slots:
20-
void on_pushButton_clicked();
21+
void on_addMicrosoftButton_clicked();
22+
void on_addElybyButton_clicked();
23+
void on_addOfflineButton_clicked();
2124

2225
private:
2326
Ui::LoginWizardPage* ui;

launcher/ui/setupwizard/LoginWizardPage.ui

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
<item>
1818
<widget class="QLabel" name="label">
1919
<property name="text">
20-
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:14pt; font-weight:600;&quot;&gt;Add Microsoft account&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
20+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:14pt; font-weight:600;&quot;&gt;Add
21+
account&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;
22+
</string>
2123
</property>
2224
<property name="textFormat">
23-
<enum>Qt::RichText</enum>
25+
<enum>Qt::TextFormat::RichText</enum>
2426
</property>
2527
<property name="wordWrap">
2628
<bool>true</bool>
@@ -30,7 +32,8 @@
3032
<item>
3133
<widget class="QLabel" name="label_2">
3234
<property name="text">
33-
<string>In order to play Minecraft, you must have at least one Microsoft account logged in. Do you want to log in now?</string>
35+
<string>In order to play Minecraft, you must have at least one account logged in. Do you want to log in now?
36+
</string>
3437
</property>
3538
<property name="wordWrap">
3639
<bool>true</bool>
@@ -40,21 +43,35 @@
4043
<item>
4144
<widget class="Line" name="line">
4245
<property name="orientation">
43-
<enum>Qt::Horizontal</enum>
46+
<enum>Qt::Orientation::Horizontal</enum>
4447
</property>
4548
</widget>
4649
</item>
4750
<item>
48-
<widget class="QPushButton" name="pushButton">
51+
<widget class="QPushButton" name="addMicrosoftButton">
4952
<property name="text">
5053
<string>Add Microsoft account</string>
5154
</property>
5255
</widget>
5356
</item>
57+
<item>
58+
<widget class="QPushButton" name="addElybyButton">
59+
<property name="text">
60+
<string>Add Ely.by account</string>
61+
</property>
62+
</widget>
63+
</item>
64+
<item>
65+
<widget class="QPushButton" name="addOfflineButton">
66+
<property name="text">
67+
<string>Add Offline account</string>
68+
</property>
69+
</widget>
70+
</item>
5471
<item>
5572
<spacer name="verticalSpacer">
5673
<property name="orientation">
57-
<enum>Qt::Vertical</enum>
74+
<enum>Qt::Orientation::Vertical</enum>
5875
</property>
5976
<property name="sizeHint" stdset="0">
6077
<size>
@@ -68,7 +85,4 @@
6885
</widget>
6986
<resources/>
7087
<connections/>
71-
<buttongroups>
72-
<buttongroup name="buttonGroup"/>
73-
</buttongroups>
7488
</ui>

0 commit comments

Comments
 (0)