diff options
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 267a2971..05417f51 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2479,24 +2479,56 @@ static HRESULT CreateShortcut(LPCWSTR targetFileName, LPCWSTR arguments, bool MainWindow::modifyExecutablesDialog() { bool result = false; + try { - EditExecutablesDialog dialog(*m_OrganizerCore.executablesList(), + const auto oldExecutables = *m_OrganizerCore.executablesList(); + auto* profile = m_OrganizerCore.currentProfile(); + + EditExecutablesDialog dialog(oldExecutables, *m_OrganizerCore.modList(), - m_OrganizerCore.currentProfile(), + profile, m_OrganizerCore.managedGame(), this); QSettings &settings = m_OrganizerCore.settings().directInterface(); QString key = QString("geometry/%1").arg(dialog.objectName()); + if (settings.contains(key)) { dialog.restoreGeometry(settings.value(key).toByteArray()); } + if (dialog.exec() == QDialog::Accepted) { - m_OrganizerCore.setExecutablesList(dialog.getExecutablesList()); + const auto newExecutables = dialog.getExecutablesList(); + + // remove all the custom overwrites and forced libraries + for (const auto& e : oldExecutables) { + profile->removeSetting("custom_overwrites", e.title()); + profile->removeForcedLibraries(e.title()); + } + + // set the new custom overwrites and forced libraries + for (const auto& e : newExecutables) { + if (auto modName=dialog.getCustomOverwrites().find(e.title())) { + profile->storeSetting("custom_overwrites", e.title(), *modName); + } + + if (auto list=dialog.getForcedLibraries().find(e.title())) { + if (!list->empty()) { + profile->setForcedLibrariesEnabled(e.title(), true); + profile->storeForcedLibraries(e.title(), *list); + } + } + } + + // set the new executables list + m_OrganizerCore.setExecutablesList(newExecutables); + result = true; } + settings.setValue(key, dialog.saveGeometry()); refreshExecutablesList(); + updatePinnedExecutables(); } catch (const std::exception &e) { reportError(e.what()); } |
