Qt: Only enable view->game properties for game list entry

This commit is contained in:
Connor McLaughlin 2021-03-11 02:15:25 +10:00
parent ebfbae8dd1
commit d150a2ccc3
2 changed files with 20 additions and 13 deletions

View file

@ -421,6 +421,15 @@ void MainWindow::onRunningGameChanged(const QString& filename, const QString& ga
if (m_display_widget) if (m_display_widget)
m_display_widget->setWindowTitle(windowTitle()); m_display_widget->setWindowTitle(windowTitle());
bool has_game_list_entry = false;
if (!filename.isEmpty())
{
const GameListEntry* entry = m_host_interface->getGameList()->GetEntryForPath(filename.toStdString().c_str());
has_game_list_entry = (entry != nullptr);
}
m_ui.actionViewGameProperties->setEnabled(has_game_list_entry);
} }
void MainWindow::onApplicationStateChanged(Qt::ApplicationState state) void MainWindow::onApplicationStateChanged(Qt::ApplicationState state)
@ -550,21 +559,14 @@ void MainWindow::onViewSystemDisplayTriggered()
void MainWindow::onViewGamePropertiesActionTriggered() void MainWindow::onViewGamePropertiesActionTriggered()
{ {
const GameListEntry* entry; if (!m_emulation_running)
return;
if (m_emulation_running) const std::string& path = System::GetRunningPath();
{ if (path.empty())
const std::string& path = System::GetRunningPath(); return;
if (path.empty())
return;
entry = m_host_interface->getGameList()->GetEntryForPath(path.c_str());
}
else
{
entry = m_game_list_widget->getSelectedEntry();
}
const GameListEntry* entry = m_host_interface->getGameList()->GetEntryForPath(path.c_str());
if (!entry) if (!entry)
return; return;
@ -908,6 +910,8 @@ void MainWindow::updateEmulationActions(bool starting, bool running, bool cheevo
m_ui.toolBar->insertAction(m_ui.actionPowerOff, m_ui.actionResumeLastState); m_ui.toolBar->insertAction(m_ui.actionPowerOff, m_ui.actionResumeLastState);
m_ui.toolBar->removeAction(m_ui.actionPowerOff); m_ui.toolBar->removeAction(m_ui.actionPowerOff);
} }
m_ui.actionViewGameProperties->setEnabled(false);
} }
if (m_open_debugger_on_start && running) if (m_open_debugger_on_start && running)

View file

@ -779,6 +779,9 @@
</property> </property>
</action> </action>
<action name="actionViewGameProperties"> <action name="actionViewGameProperties">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Game &amp;Properties</string> <string>Game &amp;Properties</string>
</property> </property>