diff options
author | Petr Mrázek <peterix@users.noreply.github.com> | 2019-06-23 19:58:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-23 19:58:21 +0200 |
commit | 384979bf94ce7a1d6645c9a8550e988c4edd38d1 (patch) | |
tree | 198cd12f05743115fe491af4a2e66c29f8cf245a | |
parent | ce12f1a734e08f1653aa482279a4dc6b6f3667eb (diff) | |
parent | b5a16935b75457ed3c34c0f83fe44310ad625cef (diff) | |
download | MultiMC-384979bf94ce7a1d6645c9a8550e988c4edd38d1.tar MultiMC-384979bf94ce7a1d6645c9a8550e988c4edd38d1.tar.gz MultiMC-384979bf94ce7a1d6645c9a8550e988c4edd38d1.tar.lz MultiMC-384979bf94ce7a1d6645c9a8550e988c4edd38d1.tar.xz MultiMC-384979bf94ce7a1d6645c9a8550e988c4edd38d1.zip |
Merge pull request #2704 from Janrupf/feature/autoselect_new_instances
GH-2592 Autoselect newly created instances
-rw-r--r-- | api/logic/InstanceList.cpp | 1 | ||||
-rw-r--r-- | api/logic/InstanceList.h | 1 | ||||
-rw-r--r-- | application/MainWindow.cpp | 8 | ||||
-rw-r--r-- | application/MainWindow.h | 2 |
4 files changed, 12 insertions, 0 deletions
diff --git a/api/logic/InstanceList.cpp b/api/logic/InstanceList.cpp index afbebc25..af4e85cf 100644 --- a/api/logic/InstanceList.cpp +++ b/api/logic/InstanceList.cpp @@ -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; diff --git a/api/logic/InstanceList.h b/api/logic/InstanceList.h index 50b44738..e0abd890 100644 --- a/api/logic/InstanceList.h +++ b/api/logic/InstanceList.h @@ -129,6 +129,7 @@ public: signals: void dataIsInvalid(); void instancesChanged(); + void instanceSelectRequest(QString instanceId); void groupsChanged(QSet<QString> groups); public slots: diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index bec57c0d..a4ef4e51 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -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 ¤t, const QModelIndex & } } +void MainWindow::instanceSelectRequest(QString id) +{ + setSelectedInstanceById(id); +} + void MainWindow::instanceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { auto current = view->selectionModel()->currentIndex(); diff --git a/application/MainWindow.h b/application/MainWindow.h index 7691d50e..69ea7c6b 100644 --- a/application/MainWindow.h +++ b/application/MainWindow.h @@ -152,6 +152,8 @@ private slots: void instanceChanged(const QModelIndex ¤t, const QModelIndex &previous); + void instanceSelectRequest(QString id); + void instanceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); void selectionBad(); |