Qt: Simplify Change Disc menu logic
This commit is contained in:
parent
69841d0a09
commit
1998aa96a4
|
@ -129,27 +129,20 @@ void MainWindow::onStartDiscActionTriggered()
|
|||
m_host_interface->bootSystem(std::move(filename), QString());
|
||||
}
|
||||
|
||||
void MainWindow::onChangeDiscActionTriggered()
|
||||
void MainWindow::onChangeDiscFromFileActionTriggered()
|
||||
{
|
||||
QMenu menu(tr("Change Disc..."), this);
|
||||
QAction* from_file = menu.addAction(tr("From File..."));
|
||||
QAction* from_game_list = menu.addAction(tr("From Game List"));
|
||||
QString filename =
|
||||
QFileDialog::getOpenFileName(this, tr("Select Disc Image"), QString(), tr(DISC_IMAGE_FILTER), nullptr);
|
||||
if (filename.isEmpty())
|
||||
return;
|
||||
|
||||
QAction* selected = menu.exec(QCursor::pos());
|
||||
if (selected == from_file)
|
||||
{
|
||||
QString filename =
|
||||
QFileDialog::getOpenFileName(this, tr("Select Disc Image"), QString(), tr(DISC_IMAGE_FILTER), nullptr);
|
||||
if (filename.isEmpty())
|
||||
return;
|
||||
m_host_interface->changeDisc(filename);
|
||||
}
|
||||
|
||||
m_host_interface->changeDisc(filename);
|
||||
}
|
||||
else if (selected == from_game_list)
|
||||
{
|
||||
m_host_interface->pauseSystem(true);
|
||||
switchToGameListView();
|
||||
}
|
||||
void MainWindow::onChangeDiscFromGameListActionTriggered()
|
||||
{
|
||||
m_host_interface->pauseSystem(true);
|
||||
switchToGameListView();
|
||||
}
|
||||
|
||||
void MainWindow::onStartBiosActionTriggered()
|
||||
|
@ -217,6 +210,7 @@ void MainWindow::updateEmulationActions(bool starting, bool running)
|
|||
m_ui.actionReset->setDisabled(starting || !running);
|
||||
m_ui.actionPause->setDisabled(starting || !running);
|
||||
m_ui.actionChangeDisc->setDisabled(starting || !running);
|
||||
m_ui.menuChangeDisc->setDisabled(starting || !running);
|
||||
|
||||
m_ui.actionLoadState->setDisabled(starting);
|
||||
m_ui.actionSaveState->setDisabled(starting);
|
||||
|
@ -263,7 +257,10 @@ void MainWindow::connectSignals()
|
|||
|
||||
connect(m_ui.actionStartDisc, &QAction::triggered, this, &MainWindow::onStartDiscActionTriggered);
|
||||
connect(m_ui.actionStartBios, &QAction::triggered, this, &MainWindow::onStartBiosActionTriggered);
|
||||
connect(m_ui.actionChangeDisc, &QAction::triggered, this, &MainWindow::onChangeDiscActionTriggered);
|
||||
connect(m_ui.actionChangeDisc, &QAction::triggered, [this] { m_ui.menuChangeDisc->exec(QCursor::pos()); });
|
||||
connect(m_ui.actionChangeDiscFromFile, &QAction::triggered, this, &MainWindow::onChangeDiscFromFileActionTriggered);
|
||||
connect(m_ui.actionChangeDiscFromGameList, &QAction::triggered, this,
|
||||
&MainWindow::onChangeDiscFromGameListActionTriggered);
|
||||
connect(m_ui.actionOpenDirectory, &QAction::triggered, this, &MainWindow::onOpenDirectoryActionTriggered);
|
||||
connect(m_ui.actionPowerOff, &QAction::triggered, m_host_interface, &QtHostInterface::powerOffSystem);
|
||||
connect(m_ui.actionReset, &QAction::triggered, m_host_interface, &QtHostInterface::resetSystem);
|
||||
|
|
|
@ -33,6 +33,8 @@ private Q_SLOTS:
|
|||
|
||||
void onStartDiscActionTriggered();
|
||||
void onChangeDiscActionTriggered();
|
||||
void onChangeDiscFromFileActionTriggered();
|
||||
void onChangeDiscFromGameListActionTriggered();
|
||||
void onStartBiosActionTriggered();
|
||||
void onOpenDirectoryActionTriggered();
|
||||
void onExitActionTriggered();
|
||||
|
|
|
@ -37,13 +37,24 @@
|
|||
<property name="title">
|
||||
<string>System</string>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuChangeDisc">
|
||||
<property name="title">
|
||||
<string>Change Disc</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/media-optical.png</normaloff>:/icons/media-optical.png</iconset>
|
||||
</property>
|
||||
<addaction name="actionChangeDiscFromFile"/>
|
||||
<addaction name="actionChangeDiscFromGameList"/>
|
||||
</widget>
|
||||
<addaction name="actionStartDisc"/>
|
||||
<addaction name="actionStartBios"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionPowerOff"/>
|
||||
<addaction name="actionReset"/>
|
||||
<addaction name="actionPause"/>
|
||||
<addaction name="actionChangeDisc"/>
|
||||
<addaction name="menuChangeDisc"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionLoadState"/>
|
||||
<addaction name="actionSaveState"/>
|
||||
|
@ -340,6 +351,16 @@
|
|||
<string>&Settings...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionChangeDiscFromFile">
|
||||
<property name="text">
|
||||
<string>From File...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionChangeDiscFromGameList">
|
||||
<property name="text">
|
||||
<string>From Game List...</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="resources/icons.qrc"/>
|
||||
|
|
Loading…
Reference in New Issue