mirror of https://github.com/mgba-emu/mgba.git
Qt: Add options to mute on minimize or focus lost
This commit is contained in:
parent
fee40bc74d
commit
14419282f4
|
@ -421,6 +421,8 @@ void SettingsView::updateConfig() {
|
||||||
saveSetting("suspendScreensaver", m_ui.suspendScreensaver);
|
saveSetting("suspendScreensaver", m_ui.suspendScreensaver);
|
||||||
saveSetting("pauseOnFocusLost", m_ui.pauseOnFocusLost);
|
saveSetting("pauseOnFocusLost", m_ui.pauseOnFocusLost);
|
||||||
saveSetting("pauseOnMinimize", m_ui.pauseOnMinimize);
|
saveSetting("pauseOnMinimize", m_ui.pauseOnMinimize);
|
||||||
|
saveSetting("muteOnFocusLost", m_ui.muteOnFocusLost);
|
||||||
|
saveSetting("muteOnMinimize", m_ui.muteOnMinimize);
|
||||||
saveSetting("savegamePath", m_ui.savegamePath);
|
saveSetting("savegamePath", m_ui.savegamePath);
|
||||||
saveSetting("savestatePath", m_ui.savestatePath);
|
saveSetting("savestatePath", m_ui.savestatePath);
|
||||||
saveSetting("screenshotPath", m_ui.screenshotPath);
|
saveSetting("screenshotPath", m_ui.screenshotPath);
|
||||||
|
|
|
@ -556,18 +556,22 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="1">
|
<item row="8" column="1">
|
||||||
<widget class="QCheckBox" name="pauseOnFocusLost">
|
<layout class="QHBoxLayout" name="horizontalLayout_21">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Pause when inactive</string>
|
<widget class="QCheckBox" name="pauseOnFocusLost">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Pause</string>
|
||||||
</item>
|
</property>
|
||||||
<item row="9" column="1">
|
</widget>
|
||||||
<widget class="QCheckBox" name="pauseOnMinimize">
|
</item>
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Pause when minimized</string>
|
<widget class="QCheckBox" name="muteOnFocusLost">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Mute</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="0" colspan="2">
|
<item row="10" column="0" colspan="2">
|
||||||
<widget class="Line" name="line_17">
|
<widget class="Line" name="line_17">
|
||||||
|
@ -684,6 +688,38 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="9" column="1">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_24">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="pauseOnMinimize">
|
||||||
|
<property name="text">
|
||||||
|
<string>Pause</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="muteOnMinimize">
|
||||||
|
<property name="text">
|
||||||
|
<string>Mute</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0">
|
||||||
|
<widget class="QLabel" name="label_41">
|
||||||
|
<property name="text">
|
||||||
|
<string>When inactive:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="0">
|
||||||
|
<widget class="QLabel" name="label_42">
|
||||||
|
<property name="text">
|
||||||
|
<string>When minimized:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="emulation">
|
<widget class="QWidget" name="emulation">
|
||||||
|
|
|
@ -656,12 +656,21 @@ void Window::resizeEvent(QResizeEvent*) {
|
||||||
|
|
||||||
void Window::showEvent(QShowEvent* event) {
|
void Window::showEvent(QShowEvent* event) {
|
||||||
if (m_wasOpened) {
|
if (m_wasOpened) {
|
||||||
if (event->spontaneous() && m_config->getOption("pauseOnMinimize").toInt() && m_controller) {
|
if (event->spontaneous() && m_controller) {
|
||||||
focusCheck();
|
focusCheck();
|
||||||
if (m_autoresume) {
|
if (m_config->getOption("pauseOnMinimize").toInt() && m_autoresume) {
|
||||||
m_controller->setPaused(false);
|
m_controller->setPaused(false);
|
||||||
m_autoresume = false;
|
m_autoresume = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_config->getOption("muteOnMinimize").toInt()) {
|
||||||
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
|
mCore* core = m_controller->thread()->core;
|
||||||
|
int fakeBool = 0;
|
||||||
|
mCoreConfigGetIntValue(&core->config, "mute", &fakeBool);
|
||||||
|
core->opts.mute = fakeBool;
|
||||||
|
core->reloadConfigOption(core, NULL, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -692,13 +701,20 @@ void Window::hideEvent(QHideEvent* event) {
|
||||||
if (!event->spontaneous()) {
|
if (!event->spontaneous()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!m_config->getOption("pauseOnMinimize").toInt() || !m_controller) {
|
if (!m_controller) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!m_controller->isPaused()) {
|
|
||||||
|
if (m_config->getOption("pauseOnMinimize").toInt() && !m_controller->isPaused()) {
|
||||||
m_autoresume = true;
|
m_autoresume = true;
|
||||||
m_controller->setPaused(true);
|
m_controller->setPaused(true);
|
||||||
}
|
}
|
||||||
|
if (m_config->getOption("muteOnMinimize").toInt()) {
|
||||||
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
|
mCore* core = m_controller->thread()->core;
|
||||||
|
core->opts.mute = true;
|
||||||
|
core->reloadConfigOption(core, NULL, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::closeEvent(QCloseEvent* event) {
|
void Window::closeEvent(QCloseEvent* event) {
|
||||||
|
@ -1832,15 +1848,29 @@ Action* Window::addGameAction(const QString& visibleName, const QString& name, A
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::focusCheck() {
|
void Window::focusCheck() {
|
||||||
if (!m_config->getOption("pauseOnFocusLost").toInt() || !m_controller) {
|
if (!m_controller) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (QGuiApplication::focusWindow() && m_autoresume) {
|
if (m_config->getOption("pauseOnFocusLost").toInt()) {
|
||||||
m_controller->setPaused(false);
|
if (QGuiApplication::focusWindow() && m_autoresume) {
|
||||||
m_autoresume = false;
|
m_controller->setPaused(false);
|
||||||
} else if (!QGuiApplication::focusWindow() && !m_controller->isPaused()) {
|
m_autoresume = false;
|
||||||
m_autoresume = true;
|
} else if (!QGuiApplication::focusWindow() && !m_controller->isPaused()) {
|
||||||
m_controller->setPaused(true);
|
m_autoresume = true;
|
||||||
|
m_controller->setPaused(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_config->getOption("muteOnFocusLost").toInt()) {
|
||||||
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
|
mCore* core = m_controller->thread()->core;
|
||||||
|
if (QGuiApplication::focusWindow()) {
|
||||||
|
int fakeBool = 0;
|
||||||
|
mCoreConfigGetIntValue(&core->config, "mute", &fakeBool);
|
||||||
|
core->opts.mute = fakeBool;
|
||||||
|
} else {
|
||||||
|
core->opts.mute = true;
|
||||||
|
}
|
||||||
|
core->reloadConfigOption(core, NULL, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue