summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2013-11-27 15:00:44 +0100
committerPetr Mrázek <peterix@gmail.com>2013-11-30 12:28:20 +0100
commit88318561724cae6d19f892adf778d85e6c736391 (patch)
tree9e0dbcb80c49b7fc88214f82c81d85ffcb529282 /gui
parenteff38858ef32239cd91044295ce7db3def857339 (diff)
downloadMultiMC-88318561724cae6d19f892adf778d85e6c736391.tar
MultiMC-88318561724cae6d19f892adf778d85e6c736391.tar.gz
MultiMC-88318561724cae6d19f892adf778d85e6c736391.tar.lz
MultiMC-88318561724cae6d19f892adf778d85e6c736391.tar.xz
MultiMC-88318561724cae6d19f892adf778d85e6c736391.zip
Remember the last selected instance and select it on startup
Diffstat (limited to 'gui')
-rw-r--r--gui/MainWindow.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp
index cb81958b..a3394a82 100644
--- a/gui/MainWindow.cpp
+++ b/gui/MainWindow.cpp
@@ -244,6 +244,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()
@@ -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());
}
}