From 1075bbb57d574de0588babdc27e4c3b5a93c0496 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Sun, 21 Jun 2026 11:42:56 -0700 Subject: [PATCH] qt: select active CD image slot from mounts After loading or editing CD mounts, switch the CD image controls to the emulated unit they reference. This makes A4091 CD setups show the slot that is actually attached instead of leaving slot 1 shown. --- od-unix/qt/launcher.cpp | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/od-unix/qt/launcher.cpp b/od-unix/qt/launcher.cpp index c6755e9a..b7106847 100644 --- a/od-unix/qt/launcher.cpp +++ b/od-unix/qt/launcher.cpp @@ -12343,6 +12343,45 @@ private: cdSlotUpdating = false; } + void selectCdSlot(int index, bool storeCurrent = true) + { + ensureCdSlots(); + if (index < 0 || index >= cdSlots.size()) { + return; + } + if (storeCurrent) { + storeCurrentCdSlotFromUi(); + } + currentCdSlot = index; + loadCdSlotToUi(currentCdSlot); + } + + void selectPreferredCdSlotAfterLoad() + { + ensureCdSlots(); + int slot = -1; + if (mountedDrives) { + for (int i = 0; i < mountedDrives->topLevelItemCount(); i++) { + const WinUaeQtMountEntry entry = mountEntryFromItem(mountedDrives->topLevelItem(i)); + if (entry.kind == QStringLiteral("cd") + && entry.emuUnit >= 0 + && entry.emuUnit < cdSlots.size()) { + slot = entry.emuUnit; + break; + } + } + } + if (slot < 0) { + for (int i = 0; i < cdSlots.size(); i++) { + if (cdSlots[i].inUse || !cdSlots[i].path.isEmpty()) { + slot = i; + break; + } + } + } + selectCdSlot(slot >= 0 ? slot : 0, false); + } + void ensureCustomRomBoards() { if (customRomBoards.size() == MaxRomBoards) { @@ -13984,6 +14023,7 @@ private: entry.hardfileTail = QStringLiteral(",ide0"); if (showCdDriveMountDialog(&entry, QStringLiteral("Add CD Drive"))) { addMountEntry(entry); + selectCdSlot(entry.emuUnit); } } @@ -14254,6 +14294,9 @@ private: } if (accepted) { updateMountItem(item, entry); + if (entry.kind == QStringLiteral("cd")) { + selectCdSlot(entry.emuUnit); + } } } @@ -16262,6 +16305,7 @@ private: for (const WinUaeQtConfig::Setting &setting : loaded.orderedSettings()) { applySetting(setting.key, setting.value); } + selectPreferredCdSlotAfterLoad(); updateOutputControlState(); updateMountButtons(); refreshInputMappingList(); -- 2.47.3