mirror of https://github.com/mgba-emu/mgba.git
Qt: Added a setting for pausing when the emulator is not in focus
This commit is contained in:
parent
2b5da04d9c
commit
9c5852a896
1
CHANGES
1
CHANGES
|
@ -16,6 +16,7 @@ Features:
|
|||
- Libretro: Customizable idle loop removal
|
||||
- Implemented cycle counting for sprite rendering
|
||||
- Cleaner, unified settings window
|
||||
- Added a setting for pausing when the emulator is not in focus
|
||||
Bugfixes:
|
||||
- Util: Fix PowerPC PNG read/write pixel order
|
||||
- VFS: Fix VFileReadline and remove _vfdReadline
|
||||
|
|
|
@ -39,6 +39,7 @@ SettingsView::SettingsView(ConfigController* controller, InputController* inputC
|
|||
loadSetting("resampleVideo", m_ui.resampleVideo);
|
||||
loadSetting("allowOpposingDirections", m_ui.allowOpposingDirections);
|
||||
loadSetting("suspendScreensaver", m_ui.suspendScreensaver);
|
||||
loadSetting("pauseOnFocusLost", m_ui.pauseOnFocusLost);
|
||||
|
||||
double fastForwardRatio = loadSetting("fastForwardRatio").toDouble();
|
||||
if (fastForwardRatio <= 0) {
|
||||
|
@ -142,6 +143,7 @@ void SettingsView::updateConfig() {
|
|||
saveSetting("resampleVideo", m_ui.resampleVideo);
|
||||
saveSetting("allowOpposingDirections", m_ui.allowOpposingDirections);
|
||||
saveSetting("suspendScreensaver", m_ui.suspendScreensaver);
|
||||
saveSetting("pauseOnFocusLost", m_ui.pauseOnFocusLost);
|
||||
|
||||
if (m_ui.fastForwardUnbounded->isChecked()) {
|
||||
saveSetting("fastForwardRatio", "-1");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>417</width>
|
||||
<height>457</height>
|
||||
<height>478</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -493,14 +493,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<item row="14" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Idle loops</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<item row="14" column="1">
|
||||
<widget class="QComboBox" name="idleOptimization">
|
||||
<item>
|
||||
<property name="text">
|
||||
|
@ -547,6 +547,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<widget class="QCheckBox" name="pauseOnFocusLost">
|
||||
<property name="text">
|
||||
<string>Pause when inactive</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
|
|
@ -72,6 +72,7 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent)
|
|||
, m_shortcutController(new ShortcutController(this))
|
||||
, m_playerId(playerId)
|
||||
, m_fullscreenOnStart(false)
|
||||
, m_autoresume(false)
|
||||
{
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setAcceptDrops(true);
|
||||
|
@ -140,6 +141,7 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent)
|
|||
connect(this, SIGNAL(sampleRateChanged(unsigned)), m_controller, SLOT(setAudioSampleRate(unsigned)));
|
||||
connect(this, SIGNAL(fpsTargetChanged(float)), m_controller, SLOT(setFPSTarget(float)));
|
||||
connect(&m_fpsTimer, SIGNAL(timeout()), this, SLOT(showFPS()));
|
||||
connect(&m_focusCheck, SIGNAL(timeout()), this, SLOT(focusCheck()));
|
||||
connect(m_display, &Display::hideCursor, [this]() {
|
||||
if (static_cast<QStackedLayout*>(m_screenWidget->layout())->currentWidget() == m_display) {
|
||||
m_screenWidget->setCursor(Qt::BlankCursor);
|
||||
|
@ -152,6 +154,7 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent)
|
|||
|
||||
m_log.setLevels(GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL | GBA_LOG_STATUS);
|
||||
m_fpsTimer.setInterval(FPS_TIMER_INTERVAL);
|
||||
m_focusCheck.setInterval(200);
|
||||
|
||||
m_shortcutController->setConfigController(m_config);
|
||||
setupMenu(menuBar());
|
||||
|
@ -604,6 +607,7 @@ void Window::gameStarted(GBAThread* context) {
|
|||
|
||||
m_hitUnimplementedBiosCall = false;
|
||||
m_fpsTimer.start();
|
||||
m_focusCheck.start();
|
||||
}
|
||||
|
||||
void Window::gameStopped() {
|
||||
|
@ -618,6 +622,7 @@ void Window::gameStopped() {
|
|||
m_screenWidget->unsetCursor();
|
||||
|
||||
m_fpsTimer.stop();
|
||||
m_focusCheck.stop();
|
||||
}
|
||||
|
||||
void Window::gameCrashed(const QString& errorMessage) {
|
||||
|
@ -1354,6 +1359,18 @@ QAction* Window::addHiddenAction(QMenu* menu, QAction* action, const QString& na
|
|||
return action;
|
||||
}
|
||||
|
||||
void Window::focusCheck() {
|
||||
if (!m_config->getOption("pauseOnFocusLost").toInt()) {
|
||||
return;
|
||||
}
|
||||
if (QGuiApplication::focusWindow() && m_autoresume) {
|
||||
m_controller->setPaused(false);
|
||||
} else if (!QGuiApplication::focusWindow() && !m_controller->isPaused()) {
|
||||
m_autoresume = true;
|
||||
m_controller->setPaused(true);
|
||||
}
|
||||
}
|
||||
|
||||
WindowBackground::WindowBackground(QWidget* parent)
|
||||
: QLabel(parent)
|
||||
{
|
||||
|
|
|
@ -123,6 +123,7 @@ private slots:
|
|||
|
||||
void recordFrame();
|
||||
void showFPS();
|
||||
void focusCheck();
|
||||
|
||||
private:
|
||||
static const int FPS_TIMER_INTERVAL = 2000;
|
||||
|
@ -164,6 +165,8 @@ private:
|
|||
ShaderSelector* m_shaderView;
|
||||
int m_playerId;
|
||||
bool m_fullscreenOnStart;
|
||||
QTimer m_focusCheck;
|
||||
bool m_autoresume;
|
||||
|
||||
bool m_hitUnimplementedBiosCall;
|
||||
|
||||
|
|
Loading…
Reference in New Issue