Add link instance detection

Signed-off-by: Yihe Li <winmikedows@hotmail.com>
This commit is contained in:
Yihe Li
2025-03-27 05:47:47 +08:00
parent 7b511f4c67
commit ea44c2465c
3 changed files with 41 additions and 23 deletions

View File

@ -1379,20 +1379,8 @@ void MainWindow::on_actionDeleteInstance_triggered()
if (response != QMessageBox::Yes)
return;
auto linkedInstances = APPLICATION->instances()->getLinkedInstancesById(id);
if (!linkedInstances.empty()) {
response = CustomMessageBox::selectable(this, tr("There are linked instances"),
tr("The following instance(s) might reference files in this instance:\n\n"
"%1\n\n"
"Deleting it could break the other instance(s), \n\n"
"Do you wish to proceed?",
nullptr, linkedInstances.count())
.arg(linkedInstances.join("\n")),
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
->exec();
if (response != QMessageBox::Yes)
return;
}
if (!checkLinkedInstances(id, this))
return;
if (APPLICATION->instances()->trashInstance(id)) {
ui->actionUndoTrashInstance->setEnabled(APPLICATION->instances()->trashedSomething());
@ -1705,7 +1693,7 @@ void MainWindow::instanceDataChanged(const QModelIndex& topLeft, const QModelInd
QItemSelection test(topLeft, bottomRight);
if (test.contains(current)) {
instanceChanged(current, current);
if (m_selectedInstance && askToUpdateInstanceDirName(APPLICATION->settings(), m_selectedInstance, this)) {
if (m_selectedInstance && askToUpdateInstanceDirName(m_selectedInstance, this)) {
auto newID = m_selectedInstance->name();
refreshInstances();
setSelectedInstanceById(newID);