summaryrefslogtreecommitdiffstats
path: root/gui/MainWindow.cpp
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-12-01 14:28:47 -0600
committerAndrew <forkk@forkk.net>2013-12-01 14:28:47 -0600
commit613699b3626aea750093ab7eaaeccaa28c0e87c6 (patch)
tree7fd542b8f4be10359ba2aaeac9834f1b5c86a750 /gui/MainWindow.cpp
parent2427ad687137bbcfc7303a931d7e0b74d5325e48 (diff)
parent75c4d97b90e39f2bda6e682def0fdda044cbcf6f (diff)
downloadMultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.tar
MultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.tar.gz
MultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.tar.lz
MultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.tar.xz
MultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.zip
Merge branch 'develop' of github.com:MultiMC/MultiMC5 into develop
Diffstat (limited to 'gui/MainWindow.cpp')
-rw-r--r--gui/MainWindow.cpp58
1 files changed, 42 insertions, 16 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp
index cb81958b..854091c6 100644
--- a/gui/MainWindow.cpp
+++ b/gui/MainWindow.cpp
@@ -69,8 +69,9 @@
#include "logic/lists/IconList.h"
#include "logic/lists/JavaVersionList.h"
-#include "logic/auth/AuthenticateTask.h"
-#include "logic/auth/ValidateTask.h"
+#include "logic/auth/flows/AuthenticateTask.h"
+#include "logic/auth/flows/RefreshTask.h"
+#include "logic/auth/flows/ValidateTask.h"
#include "logic/BaseInstance.h"
#include "logic/InstanceFactory.h"
@@ -244,6 +245,28 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
connect(assets_downloader, SIGNAL(finished()), SLOT(assetsFinished()));
assets_downloader->start();
}
+
+ const QString currentInstanceId = MMC->settings()->get("SelectedInstance").toString();
+ if (!currentInstanceId.isNull())
+ {
+ const QModelIndex index = MMC->instances()->getInstanceIndexById(currentInstanceId);
+ if (index.isValid())
+ {
+ const QModelIndex mappedIndex = proxymodel->mapFromSource(index);
+ view->setCurrentIndex(mappedIndex);
+ }
+ else
+ {
+ view->setCurrentIndex(proxymodel->index(0, 0));
+ }
+ }
+ else
+ {
+ view->setCurrentIndex(proxymodel->index(0, 0));
+ }
+
+ // removing this looks stupid
+ view->setFocus();
}
MainWindow::~MainWindow()
@@ -254,7 +277,6 @@ MainWindow::~MainWindow()
delete assets_downloader;
}
-
void MainWindow::repopulateAccountsMenu()
{
accountMenu->clear();
@@ -769,16 +791,16 @@ void MainWindow::doLaunchInst(BaseInstance* instance, MojangAccountPtr account)
{
// We'll need to validate the access token to make sure the account is still logged in.
ProgressDialog progDialog(this);
- ValidateTask validateTask(account, &progDialog);
- progDialog.exec(&validateTask);
-
- if (validateTask.successful())
+ RefreshTask refreshtask(account, &progDialog);
+ progDialog.exec(&refreshtask);
+
+ if (refreshtask.successful())
{
prepareLaunch(m_selectedInstance, account);
}
else
{
- YggdrasilTask::Error* error = validateTask.getError();
+ YggdrasilTask::Error *error = refreshtask.getError();
if (error != nullptr)
{
@@ -790,17 +812,20 @@ void MainWindow::doLaunchInst(BaseInstance* instance, MojangAccountPtr account)
}
else
{
- CustomMessageBox::selectable(this, tr("Access Token Validation Error"),
+ CustomMessageBox::selectable(
+ this, tr("Access Token Validation Error"),
tr("There was an error when trying to validate your access token.\n"
- "Details: %s").arg(error->getDisplayMessage()),
+ "Details: %s").arg(error->getDisplayMessage()),
QMessageBox::Warning, QMessageBox::Ok)->exec();
}
}
else
{
- CustomMessageBox::selectable(this, tr("Access Token Validation Error"),
+ CustomMessageBox::selectable(
+ this, tr("Access Token Validation Error"),
tr("There was an unknown error when trying to validate your access token."
- "The authentication server might be down, or you might not be connected to the Internet."),
+ "The authentication server might be down, or you might not be connected to "
+ "the Internet."),
QMessageBox::Warning, QMessageBox::Ok)->exec();
}
}
@@ -857,10 +882,7 @@ void MainWindow::launchInstance(BaseInstance *instance, MojangAccountPtr account
console = new ConsoleWindow(proc);
connect(console, SIGNAL(isClosing()), this, SLOT(instanceEnded()));
- // I think this will work...
- QString username = account->username();
- QString session_id = account->accessToken();
- proc->setLogin(username, session_id);
+ proc->setLogin(account);
proc->launch();
}
@@ -983,10 +1005,14 @@ void MainWindow::instanceChanged(const QModelIndex &current, const QModelIndex &
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
auto ico = MMC->icons()->getIcon(iconKey);
ui->actionChangeInstIcon->setIcon(ico);
+
+ MMC->settings()->set("SelectedInstance", m_selectedInstance->id());
}
else
{
selectionBad();
+
+ MMC->settings()->set("SelectedInstance", QString());
}
}