diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-04-21 21:39:02 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-04-21 21:39:02 +0200 |
commit | e955b1c6f9390538a7330babc3da2e31d61f5a85 (patch) | |
tree | 08d985ccf172a3999379fe7583b650919ebf0fd8 /gui/dialogs/AccountListDialog.cpp | |
parent | c8f468057ed9c25546f3cd6b968f2c2213304ac1 (diff) | |
parent | 89edc3e15edde37fb9fee2c0e0b98ea13c9b9197 (diff) | |
download | MultiMC-e955b1c6f9390538a7330babc3da2e31d61f5a85.tar MultiMC-e955b1c6f9390538a7330babc3da2e31d61f5a85.tar.gz MultiMC-e955b1c6f9390538a7330babc3da2e31d61f5a85.tar.lz MultiMC-e955b1c6f9390538a7330babc3da2e31d61f5a85.tar.xz MultiMC-e955b1c6f9390538a7330babc3da2e31d61f5a85.zip |
Merge remote-tracking branch 'origin/feature_new_login_dialog2' into develop
Diffstat (limited to 'gui/dialogs/AccountListDialog.cpp')
-rw-r--r-- | gui/dialogs/AccountListDialog.cpp | 71 |
1 files changed, 28 insertions, 43 deletions
diff --git a/gui/dialogs/AccountListDialog.cpp b/gui/dialogs/AccountListDialog.cpp index a38035a6..688cffa8 100644 --- a/gui/dialogs/AccountListDialog.cpp +++ b/gui/dialogs/AccountListDialog.cpp @@ -26,6 +26,7 @@ #include <gui/dialogs/EditAccountDialog.h> #include <gui/dialogs/ProgressDialog.h> #include <gui/dialogs/AccountSelectDialog.h> +#include <gui/dialogs/LoginDialog.h> #include "CustomMessageBox.h" #include <logic/tasks/Task.h> #include <logic/auth/YggdrasilTask.h> @@ -45,10 +46,11 @@ AccountListDialog::AccountListDialog(QWidget *parent) // Expand the account column ui->listView->header()->setSectionResizeMode(1, QHeaderView::Stretch); - QItemSelectionModel* selectionModel = ui->listView->selectionModel(); + QItemSelectionModel *selectionModel = ui->listView->selectionModel(); - connect(selectionModel, &QItemSelectionModel::selectionChanged, - [this] (const QItemSelection& sel, const QItemSelection& dsel) { updateButtonStates(); }); + connect(selectionModel, &QItemSelectionModel::selectionChanged, + [this](const QItemSelection &sel, const QItemSelection &dsel) + { updateButtonStates(); }); connect(m_accounts.get(), SIGNAL(listChanged()), SLOT(listChanged())); connect(m_accounts.get(), SIGNAL(activeAccountChanged()), SLOT(listChanged())); @@ -68,7 +70,8 @@ void AccountListDialog::listChanged() void AccountListDialog::on_addAccountBtn_clicked() { - addAccount(tr("Please enter your Mojang or Minecraft account username and password to add your account.")); + addAccount(tr("Please enter your Mojang or Minecraft account username and password to add " + "your account.")); } void AccountListDialog::on_rmAccountBtn_clicked() @@ -87,7 +90,8 @@ void AccountListDialog::on_setDefaultBtn_clicked() if (selection.size() > 0) { QModelIndex selected = selection.first(); - MojangAccountPtr account = selected.data(MojangAccountList::PointerRole).value<MojangAccountPtr>(); + MojangAccountPtr account = + selected.data(MojangAccountList::PointerRole).value<MojangAccountPtr>(); m_accounts->setActiveAccount(account->username()); } } @@ -113,48 +117,29 @@ void AccountListDialog::updateButtonStates() ui->noDefaultBtn->setDown(m_accounts->activeAccount().get() == nullptr); } -void AccountListDialog::addAccount(const QString& errMsg) +void AccountListDialog::addAccount(const QString &errMsg) { - // TODO: We can use the login dialog for this for now, but we'll have to make something better for it eventually. - EditAccountDialog loginDialog(errMsg, this, EditAccountDialog::UsernameField | EditAccountDialog::PasswordField); - loginDialog.exec(); + // TODO: The login dialog isn't quite done yet + MojangAccountPtr account = LoginDialog::newAccount(this, errMsg); - if (loginDialog.result() == QDialog::Accepted) + if (account != nullptr) { - QString username(loginDialog.username()); - QString password(loginDialog.password()); - - MojangAccountPtr account = MojangAccount::createFromUsername(username); - ProgressDialog progDialog(this); - auto task = account->login(nullptr, password); - progDialog.exec(task.get()); - if(task->successful()) - { - m_accounts->addAccount(account); - if (m_accounts->count() == 1) - m_accounts->setActiveAccount(account->username()); - - // Grab associated player skins - auto job = new NetJob("Player skins: " + account->username()); - - for(AccountProfile profile : account->profiles()) - { - auto meta = MMC->metacache()->resolveEntry("skins", profile.name + ".png"); - auto action = CacheDownload::make( - QUrl("http://" + URLConstants::SKINS_BASE + profile.name + ".png"), - meta); - job->addNetAction(action); - meta->stale = true; - } - - job->start(); - } - else + m_accounts->addAccount(account); + if (m_accounts->count() == 1) + m_accounts->setActiveAccount(account->username()); + + // Grab associated player skins + auto job = new NetJob("Player skins: " + account->username()); + + for (AccountProfile profile : account->profiles()) { - auto reason = task->failReason(); - auto dlg = CustomMessageBox::selectable(this, tr("Login error."), reason, QMessageBox::Critical); - dlg->exec(); - delete dlg; + auto meta = MMC->metacache()->resolveEntry("skins", profile.name + ".png"); + auto action = CacheDownload::make( + QUrl("http://" + URLConstants::SKINS_BASE + profile.name + ".png"), meta); + job->addNetAction(action); + meta->stale = true; } + + job->start(); } } |