From acd2d8b801d033c34a762b064dbf3e4c3cd31525 Mon Sep 17 00:00:00 2001 From: cold-brewed Date: Tue, 2 Aug 2022 17:08:12 -0400 Subject: [PATCH] qt: Update cdrom media menu to make it more consistent with floppy. Add current image name to cdrom and floppy media menu. Don't display reload option unless previous image is set. --- src/qt/qt_mediamenu.cpp | 19 ++++++++++++------- src/qt/qt_mediamenu.hpp | 1 - 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/qt/qt_mediamenu.cpp b/src/qt/qt_mediamenu.cpp index 96fba3808..a4fcb5113 100644 --- a/src/qt/qt_mediamenu.cpp +++ b/src/qt/qt_mediamenu.cpp @@ -115,13 +115,12 @@ void MediaMenu::refresh(QMenu *parentMenu) { cdromMutePos = menu->children().count(); menu->addAction(tr("&Mute"), [this, i]() { cdromMute(i); })->setCheckable(true); menu->addSeparator(); - cdromEmptyPos = menu->children().count(); - menu->addAction(tr("E&mpty"), [this, i]() { cdromEject(i); })->setCheckable(true); + menu->addAction(tr("&Image..."), [this, i]() { cdromMount(i); })->setCheckable(false); cdromReloadPos = menu->children().count(); menu->addAction(tr("&Reload previous image"), [this, i]() { cdromReload(i); }); menu->addSeparator(); cdromImagePos = menu->children().count(); - menu->addAction(tr("&Image"), [this, i]() { cdromMount(i); })->setCheckable(true); + menu->addAction(tr("E&ject"), [this, i]() { cdromEject(i); })->setCheckable(false); cdromMenus[i] = menu; cdromUpdateMenu(i); }); @@ -344,6 +343,7 @@ void MediaMenu::floppyExportTo86f(int i) { void MediaMenu::floppyUpdateMenu(int i) { QString name = floppyfns[i]; + QFileInfo fi(floppyfns[i]); if (!floppyMenus.contains(i)) return; @@ -354,6 +354,7 @@ void MediaMenu::floppyUpdateMenu(int i) { auto* ejectMenu = dynamic_cast(childs[floppyEjectPos]); auto* exportMenu = dynamic_cast(childs[floppyExportPos]); ejectMenu->setEnabled(!name.isEmpty()); + ejectMenu->setText(QString::asprintf(tr("Eject %s").toUtf8().constData(), name.isEmpty() ? QString().toUtf8().constData() : fi.fileName().toUtf8().constData())); exportMenu->setEnabled(!name.isEmpty()); int type = fdd_get_type(i); @@ -428,6 +429,10 @@ void MediaMenu::cdromReload(int i) { void MediaMenu::cdromUpdateMenu(int i) { QString name = cdrom[i].image_path; + QString prev_name = cdrom[i].prev_image_path; + QFileInfo fi(cdrom[i].image_path); + QFileInfo fi_prev(cdrom[i].prev_image_path); + if (!cdromMenus.contains(i)) return; auto* menu = cdromMenus[i]; @@ -437,12 +442,12 @@ void MediaMenu::cdromUpdateMenu(int i) { muteMenu->setChecked(cdrom[i].sound_on == 0); auto* imageMenu = dynamic_cast(childs[cdromImagePos]); - auto* emptyMenu = dynamic_cast(childs[cdromEmptyPos]); - imageMenu->setChecked(cdrom[i].host_drive == 200); - emptyMenu->setChecked(cdrom[i].host_drive != 200); + imageMenu->setEnabled(!name.isEmpty()); + imageMenu->setText(QString::asprintf(tr("Eject %s").toUtf8().constData(), name.isEmpty() ? QString().toUtf8().constData() : fi.fileName().toUtf8().constData())); auto* prevMenu = dynamic_cast(childs[cdromReloadPos]); - prevMenu->setEnabled(cdrom[i].prev_host_drive != 0); + prevMenu->setText(QString::asprintf(tr("Reload %s").toUtf8().constData(), prev_name.isEmpty() ? tr("previous image").toUtf8().constData() : fi_prev.fileName().toUtf8().constData())); + prevMenu->setVisible(name.isEmpty() && cdrom[i].prev_host_drive != 0); QString busName = tr("Unknown Bus"); switch (cdrom[i].bus_type) { diff --git a/src/qt/qt_mediamenu.hpp b/src/qt/qt_mediamenu.hpp index 94f547d3f..9b08d3ee3 100644 --- a/src/qt/qt_mediamenu.hpp +++ b/src/qt/qt_mediamenu.hpp @@ -80,7 +80,6 @@ private: int floppyEjectPos; int cdromMutePos; - int cdromEmptyPos; int cdromReloadPos; int cdromImagePos;