NOISSUE improve account UI
This commit is contained in:
parent
8ed10c5b81
commit
0adb572a07
@ -14,6 +14,7 @@
|
|||||||
#include <tasks/Task.h>
|
#include <tasks/Task.h>
|
||||||
#include <auth/YggdrasilTask.h>
|
#include <auth/YggdrasilTask.h>
|
||||||
#include <launch/steps/TextPrint.h>
|
#include <launch/steps/TextPrint.h>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
LaunchController::LaunchController(QObject *parent) : QObject(parent)
|
LaunchController::LaunchController(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
@ -76,8 +77,9 @@ void LaunchController::login()
|
|||||||
// we loop until the user succeeds in logging in or gives up
|
// we loop until the user succeeds in logging in or gives up
|
||||||
bool tryagain = true;
|
bool tryagain = true;
|
||||||
// the failure. the default failure.
|
// the failure. the default failure.
|
||||||
QString failReason = tr("Your account is currently not logged in. Please enter "
|
const QString needLoginAgain = tr("Your account is currently not logged in. Please enter "
|
||||||
"your password to log in again.");
|
"your password to log in again.");
|
||||||
|
QString failReason = needLoginAgain;
|
||||||
|
|
||||||
while (tryagain)
|
while (tryagain)
|
||||||
{
|
{
|
||||||
@ -94,7 +96,12 @@ void LaunchController::login()
|
|||||||
progDialog.exec(task.get());
|
progDialog.exec(task.get());
|
||||||
if (!task->successful())
|
if (!task->successful())
|
||||||
{
|
{
|
||||||
failReason = task->failReason();
|
auto failReasonNew = task->failReason();
|
||||||
|
if(failReasonNew == "Invalid token.")
|
||||||
|
{
|
||||||
|
failReason = needLoginAgain;
|
||||||
|
}
|
||||||
|
else failReason = failReasonNew;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (m_session->status)
|
switch (m_session->status)
|
||||||
@ -108,6 +115,26 @@ void LaunchController::login()
|
|||||||
case AuthSession::RequiresPassword:
|
case AuthSession::RequiresPassword:
|
||||||
{
|
{
|
||||||
EditAccountDialog passDialog(failReason, m_parentWidget, EditAccountDialog::PasswordField);
|
EditAccountDialog passDialog(failReason, m_parentWidget, EditAccountDialog::PasswordField);
|
||||||
|
auto username = m_session->username;
|
||||||
|
auto chopN = [](QString toChop, int N) -> QString
|
||||||
|
{
|
||||||
|
if(toChop.size() > N)
|
||||||
|
{
|
||||||
|
auto left = toChop.left(N);
|
||||||
|
left += QString("\u25CF").repeated(toChop.size() - N);
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
return toChop;
|
||||||
|
};
|
||||||
|
|
||||||
|
if(username.contains('@'))
|
||||||
|
{
|
||||||
|
auto parts = username.split('@');
|
||||||
|
auto mailbox = chopN(parts[0],3);
|
||||||
|
QString domain = chopN(parts[1], 3);
|
||||||
|
username = mailbox + '@' + domain;
|
||||||
|
}
|
||||||
|
passDialog.setUsername(username);
|
||||||
if (passDialog.exec() == QDialog::Accepted)
|
if (passDialog.exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
password = passDialog.password();
|
password = passDialog.password();
|
||||||
|
@ -519,7 +519,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
repopulateAccountsMenu();
|
repopulateAccountsMenu();
|
||||||
|
|
||||||
accountMenuButton = new QToolButton(this);
|
accountMenuButton = new QToolButton(this);
|
||||||
accountMenuButton->setText(tr("Accounts"));
|
accountMenuButton->setText(tr("Profiles"));
|
||||||
accountMenuButton->setMenu(accountMenu);
|
accountMenuButton->setMenu(accountMenu);
|
||||||
accountMenuButton->setPopupMode(QToolButton::InstantPopup);
|
accountMenuButton->setPopupMode(QToolButton::InstantPopup);
|
||||||
accountMenuButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
accountMenuButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||||
@ -753,8 +753,6 @@ void MainWindow::repopulateAccountsMenu()
|
|||||||
QAction *action = new QAction(tr("No accounts added!"), this);
|
QAction *action = new QAction(tr("No accounts added!"), this);
|
||||||
action->setEnabled(false);
|
action->setEnabled(false);
|
||||||
accountMenu->addAction(action);
|
accountMenu->addAction(action);
|
||||||
|
|
||||||
accountMenu->addSeparator();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -764,9 +762,11 @@ void MainWindow::repopulateAccountsMenu()
|
|||||||
MojangAccountPtr account = accounts->at(i);
|
MojangAccountPtr account = accounts->at(i);
|
||||||
|
|
||||||
// Styling hack
|
// Styling hack
|
||||||
|
/*
|
||||||
QAction *section = new QAction(account->username(), this);
|
QAction *section = new QAction(account->username(), this);
|
||||||
section->setEnabled(false);
|
section->setEnabled(false);
|
||||||
accountMenu->addAction(section);
|
accountMenu->addAction(section);
|
||||||
|
*/
|
||||||
|
|
||||||
for (auto profile : account->profiles())
|
for (auto profile : account->profiles())
|
||||||
{
|
{
|
||||||
@ -782,11 +782,11 @@ void MainWindow::repopulateAccountsMenu()
|
|||||||
accountMenu->addAction(action);
|
accountMenu->addAction(action);
|
||||||
connect(action, SIGNAL(triggered(bool)), SLOT(changeActiveAccount()));
|
connect(action, SIGNAL(triggered(bool)), SLOT(changeActiveAccount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
accountMenu->addSeparator();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
accountMenu->addSeparator();
|
||||||
|
|
||||||
QAction *action = new QAction(tr("No Default Account"), this);
|
QAction *action = new QAction(tr("No Default Account"), this);
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
action->setIcon(MMC->getThemedIcon("noaccount"));
|
action->setIcon(MMC->getThemedIcon("noaccount"));
|
||||||
@ -838,12 +838,14 @@ void MainWindow::activeAccountChanged()
|
|||||||
if (profile != nullptr)
|
if (profile != nullptr)
|
||||||
{
|
{
|
||||||
accountMenuButton->setIcon(SkinUtils::getFaceFromCache(profile->name));
|
accountMenuButton->setIcon(SkinUtils::getFaceFromCache(profile->name));
|
||||||
|
accountMenuButton->setText(profile->name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the icon to the "no account" icon.
|
// Set the icon to the "no account" icon.
|
||||||
accountMenuButton->setIcon(MMC->getThemedIcon("noaccount"));
|
accountMenuButton->setIcon(MMC->getThemedIcon("noaccount"));
|
||||||
|
accountMenuButton->setText(tr("Profiles"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::eventFilter(QObject *obj, QEvent *ev)
|
bool MainWindow::eventFilter(QObject *obj, QEvent *ev)
|
||||||
|
@ -26,8 +26,8 @@ EditAccountDialog::EditAccountDialog(const QString &text, QWidget *parent, int f
|
|||||||
ui->label->setText(text);
|
ui->label->setText(text);
|
||||||
ui->label->setVisible(!text.isEmpty());
|
ui->label->setVisible(!text.isEmpty());
|
||||||
|
|
||||||
ui->userTextBox->setVisible(flags & UsernameField);
|
ui->userTextBox->setEnabled(flags & UsernameField);
|
||||||
ui->passTextBox->setVisible(flags & PasswordField);
|
ui->passTextBox->setEnabled(flags & PasswordField);
|
||||||
}
|
}
|
||||||
|
|
||||||
EditAccountDialog::~EditAccountDialog()
|
EditAccountDialog::~EditAccountDialog()
|
||||||
@ -40,11 +40,21 @@ void EditAccountDialog::on_label_linkActivated(const QString &link)
|
|||||||
QDesktopServices::openUrl(QUrl(link));
|
QDesktopServices::openUrl(QUrl(link));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditAccountDialog::setUsername(const QString & user) const
|
||||||
|
{
|
||||||
|
ui->userTextBox->setText(user);
|
||||||
|
}
|
||||||
|
|
||||||
QString EditAccountDialog::username() const
|
QString EditAccountDialog::username() const
|
||||||
{
|
{
|
||||||
return ui->userTextBox->text();
|
return ui->userTextBox->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditAccountDialog::setPassword(const QString & pass) const
|
||||||
|
{
|
||||||
|
ui->passTextBox->setText(pass);
|
||||||
|
}
|
||||||
|
|
||||||
QString EditAccountDialog::password() const
|
QString EditAccountDialog::password() const
|
||||||
{
|
{
|
||||||
return ui->passTextBox->text();
|
return ui->passTextBox->text();
|
||||||
|
@ -31,14 +31,10 @@ public:
|
|||||||
int flags = UsernameField | PasswordField);
|
int flags = UsernameField | PasswordField);
|
||||||
~EditAccountDialog();
|
~EditAccountDialog();
|
||||||
|
|
||||||
/*!
|
void setUsername(const QString & user) const;
|
||||||
* Gets the text entered in the dialog's username field.
|
void setPassword(const QString & pass) const;
|
||||||
*/
|
|
||||||
QString username() const;
|
|
||||||
|
|
||||||
/*!
|
QString username() const;
|
||||||
* Gets the text entered in the dialog's password field.
|
|
||||||
*/
|
|
||||||
QString password() const;
|
QString password() const;
|
||||||
|
|
||||||
enum Flags
|
enum Flags
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Edit Account</string>
|
<string>Login</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "net/URLConstants.h"
|
#include "net/URLConstants.h"
|
||||||
#include "Env.h"
|
#include "Env.h"
|
||||||
|
|
||||||
#include "dialogs/EditAccountDialog.h"
|
|
||||||
#include "dialogs/ProgressDialog.h"
|
#include "dialogs/ProgressDialog.h"
|
||||||
#include "dialogs/AccountSelectDialog.h"
|
#include "dialogs/AccountSelectDialog.h"
|
||||||
#include "dialogs/LoginDialog.h"
|
#include "dialogs/LoginDialog.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user