Remember the last selected instance and select it on startup
This commit is contained in:
parent
eff38858ef
commit
8831856172
@ -327,6 +327,7 @@ void MultiMC::initGlobalSettings()
|
|||||||
|
|
||||||
|
|
||||||
m_settings->registerSetting(new Setting("InstSortMode", "Name"));
|
m_settings->registerSetting(new Setting("InstSortMode", "Name"));
|
||||||
|
m_settings->registerSetting(new Setting("SelectedInstance", QString()));
|
||||||
|
|
||||||
// Persistent value for the client ID
|
// Persistent value for the client ID
|
||||||
m_settings->registerSetting(new Setting("YggdrasilClientToken", ""));
|
m_settings->registerSetting(new Setting("YggdrasilClientToken", ""));
|
||||||
|
@ -244,6 +244,28 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
connect(assets_downloader, SIGNAL(finished()), SLOT(assetsFinished()));
|
connect(assets_downloader, SIGNAL(finished()), SLOT(assetsFinished()));
|
||||||
assets_downloader->start();
|
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()
|
MainWindow::~MainWindow()
|
||||||
@ -983,10 +1005,14 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &
|
|||||||
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
|
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
|
||||||
auto ico = MMC->icons()->getIcon(iconKey);
|
auto ico = MMC->icons()->getIcon(iconKey);
|
||||||
ui->actionChangeInstIcon->setIcon(ico);
|
ui->actionChangeInstIcon->setIcon(ico);
|
||||||
|
|
||||||
|
MMC->settings()->set("SelectedInstance", m_selectedInstance->id());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
selectionBad();
|
selectionBad();
|
||||||
|
|
||||||
|
MMC->settings()->set("SelectedInstance", QString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ int InstanceList::add(InstancePtr t)
|
|||||||
return count() - 1;
|
return count() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
InstancePtr InstanceList::getInstanceById(QString instId)
|
InstancePtr InstanceList::getInstanceById(QString instId) const
|
||||||
{
|
{
|
||||||
QListIterator<InstancePtr> iter(m_instances);
|
QListIterator<InstancePtr> iter(m_instances);
|
||||||
InstancePtr inst;
|
InstancePtr inst;
|
||||||
@ -378,7 +378,12 @@ InstancePtr InstanceList::getInstanceById(QString instId)
|
|||||||
return iter.peekPrevious();
|
return iter.peekPrevious();
|
||||||
}
|
}
|
||||||
|
|
||||||
int InstanceList::getInstIndex(BaseInstance *inst)
|
QModelIndex InstanceList::getInstanceIndexById(const QString &id) const
|
||||||
|
{
|
||||||
|
return index(getInstIndex(getInstanceById(id).get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int InstanceList::getInstIndex(BaseInstance *inst) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_instances.count(); i++)
|
for (int i = 0; i < m_instances.count(); i++)
|
||||||
{
|
{
|
||||||
|
@ -91,7 +91,9 @@ public:
|
|||||||
int add(InstancePtr t);
|
int add(InstancePtr t);
|
||||||
|
|
||||||
/// Get an instance by ID
|
/// Get an instance by ID
|
||||||
InstancePtr getInstanceById(QString id);
|
InstancePtr getInstanceById(QString id) const;
|
||||||
|
|
||||||
|
QModelIndex getInstanceIndexById(const QString &id) const;
|
||||||
signals:
|
signals:
|
||||||
void dataIsInvalid();
|
void dataIsInvalid();
|
||||||
|
|
||||||
@ -106,7 +108,7 @@ slots:
|
|||||||
void groupChanged();
|
void groupChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int getInstIndex(BaseInstance *inst);
|
int getInstIndex(BaseInstance *inst) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString m_instDir;
|
QString m_instDir;
|
||||||
|
Loading…
Reference in New Issue
Block a user