mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2025-03-14 13:20:59 +00:00
NOISSUE Add a 'copy link' button to the login screen.
This commit is contained in:
parent
5e71eb1788
commit
460be33642
@ -24,6 +24,7 @@
|
||||
|
||||
#include <qrcode/QrCodeGenerator.h>
|
||||
#include <QMessageBox>
|
||||
#include <QClipboard>
|
||||
|
||||
constexpr auto selectionFlags = QItemSelectionModel::Clear | QItemSelectionModel::Select | QItemSelectionModel::Rows | QItemSelectionModel::Current;
|
||||
|
||||
@ -113,6 +114,7 @@ AccountsDialog::AccountsDialog(QWidget *parent, const QString& internalId) : QDi
|
||||
connect(m_accounts.get(), &AccountList::accountChanged, this, &AccountsDialog::onAccountChanged);
|
||||
|
||||
connect(ui->linkButton, &QToolButton::clicked, this, &AccountsDialog::onQrButtonClicked);
|
||||
connect(ui->copyLinkButton, &QToolButton::clicked, this, &AccountsDialog::onCopyLinkButtonClicked);
|
||||
connect(&m_externalLoginTimer, &QTimer::timeout, this, &AccountsDialog::externalLoginTick);
|
||||
|
||||
ui->createProfileErrorLabel->setVisible(false);
|
||||
@ -481,12 +483,14 @@ void AccountsDialog::stopLogin()
|
||||
m_loginAccount = nullptr;
|
||||
ui->getFreshCodeButton->setEnabled(true);
|
||||
ui->linkButton->setVisible(false);
|
||||
ui->copyLinkButton->setVisible(false);
|
||||
}
|
||||
|
||||
void AccountsDialog::startLogin()
|
||||
{
|
||||
ui->getFreshCodeButton->setEnabled(false);
|
||||
ui->linkButton->setVisible(false);
|
||||
ui->copyLinkButton->setVisible(false);
|
||||
m_loginAccount = MinecraftAccount::createBlankMSA();
|
||||
m_loginTask = m_loginAccount->loginMSA();
|
||||
connect(m_loginTask.get(), &Task::failed, this, &AccountsDialog::onLoginTaskFailed);
|
||||
@ -509,6 +513,11 @@ void AccountsDialog::onQrButtonClicked(bool)
|
||||
DesktopServices::openUrl(m_codeUrl);
|
||||
}
|
||||
|
||||
void AccountsDialog::onCopyLinkButtonClicked(bool)
|
||||
{
|
||||
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||
clipboard->setText(m_codeUrl.toString());
|
||||
}
|
||||
|
||||
void AccountsDialog::externalLoginTick() {
|
||||
m_externalLoginElapsed++;
|
||||
@ -567,6 +576,7 @@ void AccountsDialog::showVerificationUriAndCode(const QUrl& uri, const QString&
|
||||
ui->linkButton->setIcon(QPixmap::fromImage(qrcode));
|
||||
ui->linkButton->setText(codeUrlString);
|
||||
ui->linkButton->setVisible(true);
|
||||
ui->copyLinkButton->setVisible(true);
|
||||
|
||||
ui->label->setText(tr("You can scan the QR code and complete the login process on a separate device, or you can open the link and login on this machine."));
|
||||
m_code = code;
|
||||
@ -574,6 +584,7 @@ void AccountsDialog::showVerificationUriAndCode(const QUrl& uri, const QString&
|
||||
|
||||
void AccountsDialog::hideVerificationUriAndCode() {
|
||||
ui->linkButton->setVisible(false);
|
||||
ui->copyLinkButton->setVisible(false);
|
||||
ui->progressBar->setVisible(false);
|
||||
m_externalLoginTimer.stop();
|
||||
}
|
||||
|
@ -115,6 +115,7 @@ private:
|
||||
private slots:
|
||||
void onGetFreshCodeButtonClicked(bool);
|
||||
void onQrButtonClicked(bool);
|
||||
void onCopyLinkButtonClicked(bool);
|
||||
void onLoginTaskFailed(const QString &reason);
|
||||
void onLoginTaskSucceeded();
|
||||
void onLoginTaskStatus(const QString &status);
|
||||
|
@ -63,7 +63,7 @@
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="fullAccountPage">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@ -391,19 +391,6 @@
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="WrapLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QToolButton" name="linkButton">
|
||||
<property name="sizePolicy">
|
||||
@ -429,7 +416,30 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="WrapLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QProgressBar" name="progressBar">
|
||||
<property name="textVisible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QToolButton" name="getFreshCodeButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
@ -445,13 +455,28 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QProgressBar" name="progressBar">
|
||||
<property name="textVisible">
|
||||
<bool>false</bool>
|
||||
<item row="2" column="1">
|
||||
<widget class="QToolButton" name="copyLinkButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>true</bool>
|
||||
<property name="text">
|
||||
<string notr="true">Copy Link</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="edit"/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user