Skip to content

Commit

Permalink
Merge pull request PrismLauncher#2831 from Trial97/fix_login
Browse files Browse the repository at this point in the history
split the auth loading screen
  • Loading branch information
ZekeZDev authored Oct 20, 2024
2 parents 38e0e0c + b676a67 commit 3ac0808
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 57 deletions.
14 changes: 10 additions & 4 deletions launcher/ui/dialogs/MSALoginDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int MSALoginDialog::exec()
connect(m_authflow_task.get(), &Task::failed, this, &MSALoginDialog::onTaskFailed);
connect(m_authflow_task.get(), &Task::succeeded, this, &QDialog::accept);
connect(m_authflow_task.get(), &Task::aborted, this, &MSALoginDialog::reject);
connect(m_authflow_task.get(), &Task::status, this, &MSALoginDialog::onTaskStatus);
connect(m_authflow_task.get(), &Task::status, this, &MSALoginDialog::onAuthFlowStatus);
connect(m_authflow_task.get(), &AuthFlow::authorizeWithBrowser, this, &MSALoginDialog::authorizeWithBrowser);
connect(m_authflow_task.get(), &AuthFlow::authorizeWithBrowserWithExtra, this, &MSALoginDialog::authorizeWithBrowserWithExtra);
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_authflow_task.get(), &Task::abort);
Expand All @@ -87,7 +87,7 @@ int MSALoginDialog::exec()
connect(m_devicecode_task.get(), &Task::failed, this, &MSALoginDialog::onTaskFailed);
connect(m_devicecode_task.get(), &Task::succeeded, this, &QDialog::accept);
connect(m_devicecode_task.get(), &Task::aborted, this, &MSALoginDialog::reject);
connect(m_devicecode_task.get(), &Task::status, this, &MSALoginDialog::onTaskStatus);
connect(m_devicecode_task.get(), &Task::status, this, &MSALoginDialog::onDeviceFlowStatus);
connect(m_devicecode_task.get(), &AuthFlow::authorizeWithBrowser, this, &MSALoginDialog::authorizeWithBrowser);
connect(m_devicecode_task.get(), &AuthFlow::authorizeWithBrowserWithExtra, this, &MSALoginDialog::authorizeWithBrowserWithExtra);
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_devicecode_task.get(), &Task::abort);
Expand Down Expand Up @@ -132,7 +132,7 @@ void MSALoginDialog::onTaskFailed(QString reason)

void MSALoginDialog::authorizeWithBrowser(const QUrl& url)
{
ui->stackedWidget->setCurrentIndex(1);
ui->stackedWidget2->setCurrentIndex(1);
ui->loginButton->setToolTip(QString("<div style='width: 200px;'>%1</div>").arg(url.toString()));
m_url = url;
}
Expand All @@ -152,12 +152,18 @@ void MSALoginDialog::authorizeWithBrowserWithExtra(QString url, QString code, in
}
}

void MSALoginDialog::onTaskStatus(QString status)
void MSALoginDialog::onDeviceFlowStatus(QString status)
{
ui->stackedWidget->setCurrentIndex(0);
ui->status->setText(status);
}

void MSALoginDialog::onAuthFlowStatus(QString status)
{
ui->stackedWidget2->setCurrentIndex(0);
ui->status2->setText(status);
}

// Public interface
MinecraftAccountPtr MSALoginDialog::newAccount(QWidget* parent)
{
Expand Down
3 changes: 2 additions & 1 deletion launcher/ui/dialogs/MSALoginDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class MSALoginDialog : public QDialog {

protected slots:
void onTaskFailed(QString reason);
void onTaskStatus(QString status);
void onDeviceFlowStatus(QString status);
void onAuthFlowStatus(QString status);
void authorizeWithBrowser(const QUrl& url);
void authorizeWithBrowserWithExtra(QString url, QString code, int expiresIn);

Expand Down
178 changes: 126 additions & 52 deletions launcher/ui/dialogs/MSALoginDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>440</width>
<height>430</height>
<height>447</height>
</rect>
</property>
<property name="minimumSize">
Expand All @@ -21,12 +21,12 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QStackedWidget" name="stackedWidget">
<widget class="QStackedWidget" name="stackedWidget2">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="loadingPage">
<layout class="QVBoxLayout" name="verticalLayout_3">
<widget class="QWidget" name="loadingPage2">
<layout class="QVBoxLayout" name="verticalLayout_31">
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
Expand All @@ -41,7 +41,7 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="loadingLabel">
<widget class="QLabel" name="loadingLabel2">
<property name="font">
<font>
<pointsize>16</pointsize>
Expand All @@ -61,7 +61,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="status">
<widget class="QLabel" name="status2">
<property name="text">
<string>Status</string>
</property>
Expand All @@ -74,7 +74,7 @@
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<spacer name="verticalSpacer_31">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
Expand All @@ -88,8 +88,8 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mpPage">
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,0,0,0">
<widget class="QWidget" name="mpPage1">
<layout class="QVBoxLayout" name="verticalLayout_21" stretch="0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
Expand Down Expand Up @@ -136,51 +136,125 @@
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="Line" name="line_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="orLabel">
<property name="font">
<font>
<pointsize>16</pointsize>
</font>
</property>
<property name="text">
<string>Or</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="loadingPage">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="Line" name="line_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="orLabel">
<property name="font">
<font>
<pointsize>16</pointsize>
</font>
</property>
<property name="text">
<string>Or</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
<spacer name="verticalSpacer_41">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="loadingLabel">
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Please wait...</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="status">
<property name="text">
<string>Status</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="mpPage">
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
Expand Down

0 comments on commit 3ac0808

Please sign in to comment.