all repos — mgba @ ecc6141c67ee8eff2fc74d8a9eaa7fcc4f0b4788

mGBA Game Boy Advance Emulator

Qt: Add option to pause on minimizing window (closes #1379)
Vicki Pfau vi@endrift.com
Tue, 18 Jun 2019 11:14:05 -0700
commit

ecc6141c67ee8eff2fc74d8a9eaa7fcc4f0b4788

parent

a9e96c7d00f7816cebf1edf50575e7d9f59219d8

M CHANGESCHANGES

@@ -55,6 +55,7 @@ - Qt: Make mute menu option also toggle fast-forward mute (fixes mgba.io/i/1424)

- Vita: L2/R2 and L3/R3 can now be mapped on PSTV (fixes mgba.io/i/1292) - mGUI: Remember name and position of last loaded game - Core: Create game-related paths if they don't exist (fixes mgba.io/i/1446) + - Qt: Add option to pause on minimizing window (closes mgba.io/i/1379) 0.7.2: (2019-05-25) Emulation fixes:
M src/platform/qt/SettingsView.cppsrc/platform/qt/SettingsView.cpp

@@ -387,6 +387,7 @@ saveSetting("resampleVideo", m_ui.resampleVideo);

saveSetting("allowOpposingDirections", m_ui.allowOpposingDirections); saveSetting("suspendScreensaver", m_ui.suspendScreensaver); saveSetting("pauseOnFocusLost", m_ui.pauseOnFocusLost); + saveSetting("pauseOnMinimize", m_ui.pauseOnMinimize); saveSetting("savegamePath", m_ui.savegamePath); saveSetting("savestatePath", m_ui.savestatePath); saveSetting("screenshotPath", m_ui.screenshotPath);

@@ -550,6 +551,7 @@ loadSetting("resampleVideo", m_ui.resampleVideo);

loadSetting("allowOpposingDirections", m_ui.allowOpposingDirections); loadSetting("suspendScreensaver", m_ui.suspendScreensaver); loadSetting("pauseOnFocusLost", m_ui.pauseOnFocusLost); + loadSetting("pauseOnMinimize", m_ui.pauseOnMinimize); loadSetting("savegamePath", m_ui.savegamePath); loadSetting("savestatePath", m_ui.savestatePath); loadSetting("screenshotPath", m_ui.screenshotPath);
M src/platform/qt/SettingsView.uisrc/platform/qt/SettingsView.ui

@@ -562,7 +562,7 @@ <string>Pause when inactive</string>

</property> </widget> </item> - <item row="9" column="1"> + <item row="10" column="1"> <widget class="QCheckBox" name="showFps"> <property name="text"> <string>Show FPS in title bar</string>

@@ -572,21 +572,21 @@ <bool>true</bool>

</property> </widget> </item> - <item row="11" column="0" colspan="2"> + <item row="12" column="0" colspan="2"> <widget class="Line" name="line_13"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> </widget> </item> - <item row="14" column="0" colspan="2"> + <item row="15" column="0" colspan="2"> <widget class="Line" name="line_16"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> </widget> </item> - <item row="15" column="1"> + <item row="16" column="1"> <widget class="QCheckBox" name="cheatAutosave"> <property name="text"> <string>Automatically save cheats</string>

@@ -596,7 +596,7 @@ <bool>true</bool>

</property> </widget> </item> - <item row="16" column="1"> + <item row="17" column="1"> <widget class="QCheckBox" name="cheatAutoload"> <property name="text"> <string>Automatically load cheats</string>

@@ -606,7 +606,7 @@ <bool>true</bool>

</property> </widget> </item> - <item row="12" column="1"> + <item row="13" column="1"> <widget class="QCheckBox" name="autosave"> <property name="text"> <string>Automatically save state</string>

@@ -616,7 +616,7 @@ <bool>true</bool>

</property> </widget> </item> - <item row="13" column="1"> + <item row="14" column="1"> <widget class="QCheckBox" name="autoload"> <property name="text"> <string>Automatically load state</string>

@@ -626,10 +626,17 @@ <bool>true</bool>

</property> </widget> </item> - <item row="10" column="1"> + <item row="11" column="1"> <widget class="QCheckBox" name="useDiscordPresence"> <property name="text"> <string>Enable Discord Rich Presence</string> + </property> + </widget> + </item> + <item row="9" column="1"> + <widget class="QCheckBox" name="pauseOnMinimize"> + <property name="text"> + <string>Pause when minimized</string> </property> </widget> </item>
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -602,6 +602,13 @@ }

void Window::showEvent(QShowEvent* event) { if (m_wasOpened) { + if (event->spontaneous() && m_config->getOption("pauseOnMinimize").toInt() && m_controller) { + focusCheck(); + if (m_autoresume) { + m_controller->setPaused(false); + m_autoresume = false; + } + } return; } m_wasOpened = true;

@@ -621,6 +628,19 @@ m_fullscreenOnStart = false;

} reloadDisplayDriver(); setFocus(); +} + +void Window::hideEvent(QHideEvent* event) { + if (!event->spontaneous()) { + return; + } + if (!m_config->getOption("pauseOnMinimize").toInt() || !m_controller) { + return; + } + if (!m_controller->isPaused()) { + m_autoresume = true; + m_controller->setPaused(true); + } } void Window::closeEvent(QCloseEvent* event) {
M src/platform/qt/Window.hsrc/platform/qt/Window.h

@@ -116,6 +116,7 @@ virtual void keyPressEvent(QKeyEvent* event) override;

virtual void keyReleaseEvent(QKeyEvent* event) override; virtual void resizeEvent(QResizeEvent*) override; virtual void showEvent(QShowEvent*) override; + virtual void hideEvent(QHideEvent*) override; virtual void closeEvent(QCloseEvent*) override; virtual void focusInEvent(QFocusEvent*) override; virtual void focusOutEvent(QFocusEvent*) override;