diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp index f46aa3b9..174ad46c 100644 --- a/launcher/ui/dialogs/MSALoginDialog.cpp +++ b/launcher/ui/dialogs/MSALoginDialog.cpp @@ -16,15 +16,19 @@ #include "MSALoginDialog.h" #include "ui_MSALoginDialog.h" +#include "DesktopServices.h" #include "minecraft/auth/AccountTask.h" #include #include +#include +#include MSALoginDialog::MSALoginDialog(QWidget *parent) : QDialog(parent), ui(new Ui::MSALoginDialog) { ui->setupUi(this); ui->progressBar->setVisible(false); + ui->actionButton->setVisible(false); // ui->buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); @@ -81,10 +85,17 @@ void MSALoginDialog::showVerificationUriAndCode(const QUrl& uri, const QString& QString urlString = uri.toString(); QString linkString = QString("%2").arg(urlString, urlString); ui->label->setText(tr("

Please open up %1 in a browser and put in the code %2 to proceed with login.

").arg(linkString, code)); + ui->actionButton->setVisible(true); + connect(ui->actionButton, &QPushButton::clicked, [=]() { + DesktopServices::openUrl(uri); + QClipboard* cb = QApplication::clipboard(); + cb->setText(code); + }); } void MSALoginDialog::hideVerificationUriAndCode() { m_externalLoginTimer.stop(); + ui->actionButton->setVisible(false); } void MSALoginDialog::setUserInputsEnabled(bool enable) @@ -110,6 +121,7 @@ void MSALoginDialog::onTaskFailed(const QString &reason) // Re-enable user-interaction setUserInputsEnabled(true); ui->progressBar->setVisible(false); + ui->actionButton->setVisible(false); } void MSALoginDialog::onTaskSucceeded() diff --git a/launcher/ui/dialogs/MSALoginDialog.ui b/launcher/ui/dialogs/MSALoginDialog.ui index 78cbfb26..c18d01a1 100644 --- a/launcher/ui/dialogs/MSALoginDialog.ui +++ b/launcher/ui/dialogs/MSALoginDialog.ui @@ -49,14 +49,25 @@ aaaaa - - - Qt::Horizontal - - - QDialogButtonBox::Cancel - - + + + + + Open page and copy code + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel + + + +