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