Fixed return value & menu item name in the QT Debugger's Image menu. (nw)

This commit is contained in:
Andrew Gardner 2013-05-30 16:20:36 +00:00
parent e2956881b9
commit 9ca45de8a6

View File

@ -327,7 +327,7 @@ void MainWindow::mountImage(bool changedTo)
QDir::currentPath(), QDir::currentPath(),
tr("All files (*.*)")); tr("All files (*.*)"));
if (!img->load(filename.toUtf8().data())) if (img->load(filename.toUtf8().data()) != IMAGE_INIT_PASS)
{ {
debug_console_printf(*m_machine, "Image could not be mounted.\n"); debug_console_printf(*m_machine, "Image could not be mounted.\n");
refreshAll(); refreshAll();
@ -336,7 +336,14 @@ void MainWindow::mountImage(bool changedTo)
// Activate the unmount menu option // Activate the unmount menu option
QAction* unmountAct = sender()->parent()->findChild<QAction*>("unmount"); QAction* unmountAct = sender()->parent()->findChild<QAction*>("unmount");
unmountAct->setEnabled(true); unmountAct->setEnabled(true);
// Set the mount name
QMenu* parentMenuItem = menuBar()->findChild<QMenu*>(img->device().name());
QString baseString = parentMenuItem->title();
baseString.truncate(baseString.lastIndexOf(QString(" : ")));
const QString newTitle = baseString + QString(" : ") + QString(img->filename());
parentMenuItem->setTitle(newTitle);
debug_console_printf(*m_machine, "Image %s mounted successfully.\n", filename.toUtf8().data()); debug_console_printf(*m_machine, "Image %s mounted successfully.\n", filename.toUtf8().data());
refreshAll(); refreshAll();
@ -355,6 +362,13 @@ void MainWindow::unmountImage(bool changedTo)
// Deactivate the unmount menu option // Deactivate the unmount menu option
dynamic_cast<QAction*>(sender())->setEnabled(false); dynamic_cast<QAction*>(sender())->setEnabled(false);
// Set the mount name
QMenu* parentMenuItem = menuBar()->findChild<QMenu*>(img->device().name());
QString baseString = parentMenuItem->title();
baseString.truncate(baseString.lastIndexOf(QString(" : ")));
const QString newTitle = baseString + QString(" : ") + QString("[empty slot]");
parentMenuItem->setTitle(newTitle);
debug_console_printf(*m_machine, "Image successfully unmounted.\n"); debug_console_printf(*m_machine, "Image successfully unmounted.\n");
refreshAll(); refreshAll();
} }
@ -398,7 +412,7 @@ void MainWindow::createImagesMenu()
menuName.format("%s : %s", img->device().name(), img->exists() ? img->filename() : "[empty slot]"); menuName.format("%s : %s", img->device().name(), img->exists() ? img->filename() : "[empty slot]");
QMenu* interfaceMenu = imagesMenu->addMenu(menuName.cstr()); QMenu* interfaceMenu = imagesMenu->addMenu(menuName.cstr());
interfaceMenu->setObjectName(img->device().name()); // TODO: FIX interfaceMenu->setObjectName(img->device().name());
QAction* mountAct = new QAction("Mount...", interfaceMenu); QAction* mountAct = new QAction("Mount...", interfaceMenu);
QAction* unmountAct = new QAction("Unmount", interfaceMenu); QAction* unmountAct = new QAction("Unmount", interfaceMenu);