mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-12-14 04:32:14 +00:00
NOISSUE Add button to copy MSA code
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright 2013-2021 MultiMC Contributors
|
/* Copyright 2013-2022 MultiMC Contributors
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QtWidgets/QPushButton>
|
#include <QtWidgets/QPushButton>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QClipboard>
|
||||||
|
|
||||||
MSALoginDialog::MSALoginDialog(QWidget *parent) : QDialog(parent), ui(new Ui::MSALoginDialog)
|
MSALoginDialog::MSALoginDialog(QWidget *parent) : QDialog(parent), ui(new Ui::MSALoginDialog)
|
||||||
{
|
{
|
||||||
@@ -34,6 +35,7 @@ MSALoginDialog::MSALoginDialog(QWidget *parent) : QDialog(parent), ui(new Ui::MS
|
|||||||
int MSALoginDialog::exec() {
|
int MSALoginDialog::exec() {
|
||||||
setUserInputsEnabled(false);
|
setUserInputsEnabled(false);
|
||||||
ui->progressBar->setVisible(true);
|
ui->progressBar->setVisible(true);
|
||||||
|
ui->copyCodeButton->setVisible(false);
|
||||||
|
|
||||||
// Setup the login task and start it
|
// Setup the login task and start it
|
||||||
m_account = MinecraftAccount::createBlankMSA();
|
m_account = MinecraftAccount::createBlankMSA();
|
||||||
@@ -68,6 +70,8 @@ void MSALoginDialog::externalLoginTick() {
|
|||||||
|
|
||||||
|
|
||||||
void MSALoginDialog::showVerificationUriAndCode(const QUrl& uri, const QString& code, int expiresIn) {
|
void MSALoginDialog::showVerificationUriAndCode(const QUrl& uri, const QString& code, int expiresIn) {
|
||||||
|
ui->copyCodeButton->setVisible(true);
|
||||||
|
|
||||||
m_externalLoginElapsed = 0;
|
m_externalLoginElapsed = 0;
|
||||||
m_externalLoginTimeout = expiresIn;
|
m_externalLoginTimeout = expiresIn;
|
||||||
|
|
||||||
@@ -81,9 +85,12 @@ 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));
|
||||||
|
|
||||||
|
m_code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSALoginDialog::hideVerificationUriAndCode() {
|
void MSALoginDialog::hideVerificationUriAndCode() {
|
||||||
|
ui->copyCodeButton->setVisible(false);
|
||||||
m_externalLoginTimer.stop();
|
m_externalLoginTimer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,3 +146,8 @@ MinecraftAccountPtr MSALoginDialog::newAccount(QWidget *parent, QString msg)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MSALoginDialog::on_copyCodeButton_clicked()
|
||||||
|
{
|
||||||
|
QApplication::clipboard()->setText(m_code);
|
||||||
|
}
|
||||||
@@ -49,6 +49,7 @@ slots:
|
|||||||
void onTaskProgress(qint64 current, qint64 total);
|
void onTaskProgress(qint64 current, qint64 total);
|
||||||
void showVerificationUriAndCode(const QUrl &uri, const QString &code, int expiresIn);
|
void showVerificationUriAndCode(const QUrl &uri, const QString &code, int expiresIn);
|
||||||
void hideVerificationUriAndCode();
|
void hideVerificationUriAndCode();
|
||||||
|
void on_copyCodeButton_clicked();
|
||||||
|
|
||||||
void externalLoginTick();
|
void externalLoginTick();
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ private:
|
|||||||
MinecraftAccountPtr m_account;
|
MinecraftAccountPtr m_account;
|
||||||
shared_qobject_ptr<AccountTask> m_loginTask;
|
shared_qobject_ptr<AccountTask> m_loginTask;
|
||||||
QTimer m_externalLoginTimer;
|
QTimer m_externalLoginTimer;
|
||||||
|
QString m_code;
|
||||||
int m_externalLoginElapsed = 0;
|
int m_externalLoginElapsed = 0;
|
||||||
int m_externalLoginTimeout = 0;
|
int m_externalLoginTimeout = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,14 +49,25 @@ aaaaa</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="orientation">
|
<item>
|
||||||
<enum>Qt::Horizontal</enum>
|
<widget class="QPushButton" name="copyCodeButton">
|
||||||
</property>
|
<property name="text">
|
||||||
<property name="standardButtons">
|
<string>Copy Code</string>
|
||||||
<set>QDialogButtonBox::Cancel</set>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</widget>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
Reference in New Issue
Block a user