From 02ca6bea8c4261776500862159d61817abf246cc Mon Sep 17 00:00:00 2001 From: Yihe Li Date: Sat, 29 Mar 2025 14:11:09 +0800 Subject: [PATCH] Sync group after updating instance Signed-off-by: Yihe Li --- launcher/ui/MainWindow.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 6c5f86d0a..ddf726373 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -296,8 +296,18 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi view->setAttribute(Qt::WA_MacShowFocusRect, false); connect(delegate, &ListViewDelegate::textChanged, this, [this](QString before, QString after) { if (auto newRoot = askToUpdateInstanceDirName(m_selectedInstance, before, after, this); !newRoot.isEmpty()) { + auto oldID = m_selectedInstance->id(); + auto newID = QFileInfo(newRoot).fileName(); + QString origGroup(APPLICATION->instances()->getInstanceGroup(oldID)); + bool syncGroup = origGroup != GroupId() && oldID != newID; + if (syncGroup) + APPLICATION->instances()->setInstanceGroup(oldID, GroupId()); + refreshInstances(); - setSelectedInstanceById(QFileInfo(newRoot).fileName()); + setSelectedInstanceById(newID); + + if (syncGroup) + APPLICATION->instances()->setInstanceGroup(newID, origGroup); } });