Qt: use Settings::EmulationStateChanged

This commit is contained in:
Michael M
2017-09-04 11:12:13 -07:00
parent 8e805dcbf4
commit 3e1072b24d
22 changed files with 97 additions and 160 deletions

View File

@ -4,6 +4,7 @@
#include <QIcon>
#include "Core/Core.h"
#include "DolphinQt2/QtUtils/ActionHelper.h"
#include "DolphinQt2/Resources.h"
#include "DolphinQt2/Settings.h"
@ -22,40 +23,24 @@ ToolBar::ToolBar(QWidget* parent) : QToolBar(parent)
connect(&Settings::Instance(), &Settings::ThemeChanged, this, &ToolBar::UpdateIcons);
UpdateIcons();
EmulationStopped();
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
[this](Core::State state) { OnEmulationStateChanged(state); });
OnEmulationStateChanged(Core::GetState());
}
void ToolBar::EmulationStarted()
void ToolBar::OnEmulationStateChanged(Core::State state)
{
m_play_action->setEnabled(false);
m_play_action->setVisible(false);
m_pause_action->setEnabled(true);
m_pause_action->setVisible(true);
m_stop_action->setEnabled(true);
m_stop_action->setVisible(true);
m_fullscreen_action->setEnabled(true);
m_screenshot_action->setEnabled(true);
}
bool running = state != Core::State::Uninitialized;
m_stop_action->setEnabled(running);
m_stop_action->setVisible(running);
m_fullscreen_action->setEnabled(running);
m_screenshot_action->setEnabled(running);
void ToolBar::EmulationPaused()
{
m_play_action->setEnabled(true);
m_play_action->setVisible(true);
m_pause_action->setEnabled(false);
m_pause_action->setVisible(false);
m_stop_action->setEnabled(true);
m_stop_action->setVisible(true);
}
void ToolBar::EmulationStopped()
{
m_play_action->setEnabled(true);
m_play_action->setVisible(true);
m_pause_action->setEnabled(false);
m_pause_action->setVisible(false);
m_stop_action->setEnabled(false);
m_fullscreen_action->setEnabled(false);
m_screenshot_action->setEnabled(false);
bool playing = running && state != Core::State::Paused;
m_play_action->setEnabled(!playing);
m_play_action->setVisible(!playing);
m_pause_action->setEnabled(playing);
m_pause_action->setVisible(playing);
}
void ToolBar::MakeActions()