Only call on interactive uses

Signed-off-by: Yihe Li <winmikedows@hotmail.com>
This commit is contained in:
Yihe Li
2025-03-27 06:53:57 +08:00
parent ea44c2465c
commit 8fea37b8b7
4 changed files with 22 additions and 7 deletions

View File

@ -1428,6 +1428,13 @@ void MainWindow::on_actionExportInstanceFlamePack_triggered()
void MainWindow::on_actionRenameInstance_triggered()
{
if (m_selectedInstance) {
connect(view->itemDelegate(), &QAbstractItemDelegate::closeEditor, this, [this] {
if (askToUpdateInstanceDirName(m_selectedInstance, this)) {
auto newID = m_selectedInstance->name();
refreshInstances();
setSelectedInstanceById(newID);
}
}, Qt::SingleShotConnection);
view->edit(view->currentIndex());
}
}
@ -1693,11 +1700,6 @@ void MainWindow::instanceDataChanged(const QModelIndex& topLeft, const QModelInd
QItemSelection test(topLeft, bottomRight);
if (test.contains(current)) {
instanceChanged(current, current);
if (m_selectedInstance && askToUpdateInstanceDirName(m_selectedInstance, this)) {
auto newID = m_selectedInstance->name();
refreshInstances();
setSelectedInstanceById(newID);
}
}
}