From 306b98edacab8d1ad819d1b66fa54789b3e0bdea Mon Sep 17 00:00:00 2001 From: janrupf Date: Mon, 17 Jun 2019 16:13:52 +0200 Subject: [PATCH 1/2] GH-2592 Autoselect newly created instances --- api/logic/InstanceList.cpp | 1 + api/logic/InstanceList.h | 1 + application/MainWindow.cpp | 8 ++++++++ application/MainWindow.h | 2 ++ 4 files changed, 12 insertions(+) diff --git a/api/logic/InstanceList.cpp b/api/logic/InstanceList.cpp index afbebc25..dc367e30 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 instanceAdded(instID); } saveGroupList(); return true; diff --git a/api/logic/InstanceList.h b/api/logic/InstanceList.h index 50b44738..5f92a924 100644 --- a/api/logic/InstanceList.h +++ b/api/logic/InstanceList.h @@ -129,6 +129,7 @@ public: signals: void dataIsInvalid(); void instancesChanged(); + void instanceAdded(QString instanceId); void groupsChanged(QSet groups); public slots: diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index bec57c0d..ca98130e 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::instanceAdded, this, &MainWindow::instanceAdded); + // 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::instanceAdded(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..ea5b9847 100644 --- a/application/MainWindow.h +++ b/application/MainWindow.h @@ -152,6 +152,8 @@ private slots: void instanceChanged(const QModelIndex ¤t, const QModelIndex &previous); + void instanceAdded(QString id); + void instanceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); void selectionBad(); From b5a16935b75457ed3c34c0f83fe44310ad625cef Mon Sep 17 00:00:00 2001 From: janrupf Date: Sun, 23 Jun 2019 14:54:17 +0200 Subject: [PATCH 2/2] NOISSUE Renaming for better understanding --- api/logic/InstanceList.cpp | 2 +- api/logic/InstanceList.h | 2 +- application/MainWindow.cpp | 4 ++-- application/MainWindow.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/logic/InstanceList.cpp b/api/logic/InstanceList.cpp index dc367e30..af4e85cf 100644 --- a/api/logic/InstanceList.cpp +++ b/api/logic/InstanceList.cpp @@ -819,7 +819,7 @@ bool InstanceList::commitStagedInstance(const QString& path, const QString& inst instanceSet.insert(instID); m_groups.insert(groupName); emit instancesChanged(); - emit instanceAdded(instID); + emit instanceSelectRequest(instID); } saveGroupList(); return true; diff --git a/api/logic/InstanceList.h b/api/logic/InstanceList.h index 5f92a924..e0abd890 100644 --- a/api/logic/InstanceList.h +++ b/api/logic/InstanceList.h @@ -129,7 +129,7 @@ public: signals: void dataIsInvalid(); void instancesChanged(); - void instanceAdded(QString instanceId); + void instanceSelectRequest(QString instanceId); void groupsChanged(QSet groups); public slots: diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index ca98130e..a4ef4e51 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -703,7 +703,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow connect(MMC->instances().get(), &InstanceList::dataIsInvalid, this, &MainWindow::selectionBad); // handle newly added instances - connect(MMC->instances().get(), &InstanceList::instanceAdded, this, &MainWindow::instanceAdded); + 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); @@ -1839,7 +1839,7 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex & } } -void MainWindow::instanceAdded(QString id) +void MainWindow::instanceSelectRequest(QString id) { setSelectedInstanceById(id); } diff --git a/application/MainWindow.h b/application/MainWindow.h index ea5b9847..69ea7c6b 100644 --- a/application/MainWindow.h +++ b/application/MainWindow.h @@ -152,7 +152,7 @@ private slots: void instanceChanged(const QModelIndex ¤t, const QModelIndex &previous); - void instanceAdded(QString id); + void instanceSelectRequest(QString id); void instanceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);