Merge pull request #88 from Scrumplex/launch-msa-login
Add open page & copy code button to MSA login dialog
This commit is contained in:
commit
5b5c5afc3a
@ -16,15 +16,19 @@
|
|||||||
#include "MSALoginDialog.h"
|
#include "MSALoginDialog.h"
|
||||||
#include "ui_MSALoginDialog.h"
|
#include "ui_MSALoginDialog.h"
|
||||||
|
|
||||||
|
#include "DesktopServices.h"
|
||||||
#include "minecraft/auth/AccountTask.h"
|
#include "minecraft/auth/AccountTask.h"
|
||||||
|
|
||||||
#include <QtWidgets/QPushButton>
|
#include <QtWidgets/QPushButton>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
|
||||||
MSALoginDialog::MSALoginDialog(QWidget *parent) : QDialog(parent), ui(new Ui::MSALoginDialog)
|
MSALoginDialog::MSALoginDialog(QWidget *parent) : QDialog(parent), ui(new Ui::MSALoginDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->progressBar->setVisible(false);
|
ui->progressBar->setVisible(false);
|
||||||
|
ui->actionButton->setVisible(false);
|
||||||
// ui->buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
|
// ui->buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
|
||||||
|
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
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 urlString = uri.toString();
|
||||||
QString linkString = QString("<a href=\"%1\">%2</a>").arg(urlString, urlString);
|
QString linkString = QString("<a href=\"%1\">%2</a>").arg(urlString, urlString);
|
||||||
ui->label->setText(tr("<p>Please open up %1 in a browser and put in the code <b>%2</b> to proceed with login.</p>").arg(linkString, code));
|
ui->label->setText(tr("<p>Please open up %1 in a browser and put in the code <b>%2</b> to proceed with login.</p>").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() {
|
void MSALoginDialog::hideVerificationUriAndCode() {
|
||||||
m_externalLoginTimer.stop();
|
m_externalLoginTimer.stop();
|
||||||
|
ui->actionButton->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSALoginDialog::setUserInputsEnabled(bool enable)
|
void MSALoginDialog::setUserInputsEnabled(bool enable)
|
||||||
@ -110,6 +121,7 @@ void MSALoginDialog::onTaskFailed(const QString &reason)
|
|||||||
// Re-enable user-interaction
|
// Re-enable user-interaction
|
||||||
setUserInputsEnabled(true);
|
setUserInputsEnabled(true);
|
||||||
ui->progressBar->setVisible(false);
|
ui->progressBar->setVisible(false);
|
||||||
|
ui->actionButton->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSALoginDialog::onTaskSucceeded()
|
void MSALoginDialog::onTaskSucceeded()
|
||||||
|
@ -48,6 +48,15 @@ aaaaa</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="actionButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Open page and copy code</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -59,6 +68,8 @@ aaaaa</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
Loading…
Reference in New Issue
Block a user