Skip to content
Permalink
Browse files

Merge pull request #2704 from Janrupf/feature/autoselect_new_instances

GH-2592 Autoselect newly created instances
  • Loading branch information...
peterix committed Jun 23, 2019
2 parents ce12f1a + b5a1693 commit 384979bf94ce7a1d6645c9a8550e988c4edd38d1
Showing with 12 additions and 0 deletions.
  1. +1 −0 api/logic/InstanceList.cpp
  2. +1 −0 api/logic/InstanceList.h
  3. +8 −0 application/MainWindow.cpp
  4. +2 −0 application/MainWindow.h
@@ -819,6 +819,7 @@ bool InstanceList::commitStagedInstance(const QString& path, const QString& inst
instanceSet.insert(instID);
m_groups.insert(groupName);
emit instancesChanged();
emit instanceSelectRequest(instID);
}
saveGroupList();
return true;
@@ -129,6 +129,7 @@ class MULTIMC_LOGIC_EXPORT InstanceList : public QAbstractListModel
signals:
void dataIsInvalid();
void instancesChanged();
void instanceSelectRequest(QString instanceId);
void groupsChanged(QSet<QString> groups);

public slots:
@@ -702,6 +702,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
// model reset -> selection is invalid. All the instance pointers are wrong.
connect(MMC->instances().get(), &InstanceList::dataIsInvalid, this, &MainWindow::selectionBad);

// handle newly added instances
connect(MMC->instances().get(), &InstanceList::instanceSelectRequest, this, &MainWindow::instanceSelectRequest);

// When the global settings page closes, we want to know about it and update our state
connect(MMC, &MultiMC::globalSettingsClosed, this, &MainWindow::globalSettingsClosed);

@@ -1836,6 +1839,11 @@ void MainWindow::instanceChanged(const QModelIndex &current, const QModelIndex &
}
}

void MainWindow::instanceSelectRequest(QString id)
{
setSelectedInstanceById(id);
}

void MainWindow::instanceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
auto current = view->selectionModel()->currentIndex();
@@ -152,6 +152,8 @@ private slots:

void instanceChanged(const QModelIndex &current, const QModelIndex &previous);

void instanceSelectRequest(QString id);

void instanceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);

void selectionBad();

0 comments on commit 384979b

Please sign in to comment.
You can’t perform that action at this time.