mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 14:30:14 +00:00
Set pause when emulator lost focus
This commit is contained in:
parent
3c3a6cb2af
commit
e64114f6a6
@ -9,6 +9,7 @@
|
||||
#endif
|
||||
|
||||
#include "citra_qt/bootmanager.h"
|
||||
#include "citra_qt/ui_settings.h"
|
||||
|
||||
#include "common/key_map.h"
|
||||
#include "common/microprofile.h"
|
||||
@ -285,6 +286,14 @@ void GRenderWindow::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,un
|
||||
setMinimumSize(minimal_size.first, minimal_size.second);
|
||||
}
|
||||
|
||||
void GRenderWindow::focusInEvent(QFocusEvent*) {
|
||||
if (emu_thread && UISettings::values.pause_onfocuslost) emit gotFocus();
|
||||
}
|
||||
|
||||
void GRenderWindow::focusOutEvent(QFocusEvent*) {
|
||||
if (emu_thread && UISettings::values.pause_onfocuslost) emit lostFocus();
|
||||
}
|
||||
|
||||
void GRenderWindow::OnEmulationStarting(EmuThread* emu_thread) {
|
||||
this->emu_thread = emu_thread;
|
||||
child->DisablePainting();
|
||||
|
@ -136,10 +136,26 @@ public slots:
|
||||
signals:
|
||||
/// Emitted when the window is closed
|
||||
void Closed();
|
||||
/// Emitted when the window got focus
|
||||
void gotFocus();
|
||||
/// Emitted when the window lost focus
|
||||
void lostFocus();
|
||||
|
||||
private:
|
||||
void OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) override;
|
||||
|
||||
/**
|
||||
* Capture focus gain to unset pause
|
||||
* @param event
|
||||
*/
|
||||
void focusInEvent(QFocusEvent*) override;
|
||||
|
||||
/**
|
||||
* Capture focus lost to set pause
|
||||
* @param event
|
||||
*/
|
||||
void focusOutEvent(QFocusEvent*) override;
|
||||
|
||||
GGLWidgetInternal* child;
|
||||
|
||||
QByteArray geometry;
|
||||
|
@ -116,6 +116,7 @@ void Config::ReadValues() {
|
||||
|
||||
UISettings::values.single_window_mode = qt_config->value("singleWindowMode", true).toBool();
|
||||
UISettings::values.display_titlebar = qt_config->value("displayTitleBars", true).toBool();
|
||||
UISettings::values.pause_onfocuslost = qt_config->value("pauseOnFocusLost",false).toBool();
|
||||
UISettings::values.confirm_before_closing = qt_config->value("confirmClose",true).toBool();
|
||||
UISettings::values.first_start = qt_config->value("firstStart", true).toBool();
|
||||
|
||||
@ -196,6 +197,7 @@ void Config::SaveValues() {
|
||||
|
||||
qt_config->setValue("singleWindowMode", UISettings::values.single_window_mode);
|
||||
qt_config->setValue("displayTitleBars", UISettings::values.display_titlebar);
|
||||
qt_config->setValue("pauseOnFocusLost", UISettings::values.pause_onfocuslost);
|
||||
qt_config->setValue("confirmClose", UISettings::values.confirm_before_closing);
|
||||
qt_config->setValue("firstStart", UISettings::values.first_start);
|
||||
|
||||
|
@ -21,6 +21,7 @@ ConfigureGeneral::~ConfigureGeneral() {
|
||||
|
||||
void ConfigureGeneral::setConfiguration() {
|
||||
ui->toogle_deepscan->setChecked(UISettings::values.gamedir_deepscan);
|
||||
ui->toogle_pause_onfocuslost->setChecked(UISettings::values.pause_onfocuslost);
|
||||
ui->toogle_check_exit->setChecked(UISettings::values.confirm_before_closing);
|
||||
ui->region_combobox->setCurrentIndex(Settings::values.region_value);
|
||||
ui->toogle_hw_renderer->setChecked(Settings::values.use_hw_renderer);
|
||||
@ -30,6 +31,7 @@ void ConfigureGeneral::setConfiguration() {
|
||||
|
||||
void ConfigureGeneral::applyConfiguration() {
|
||||
UISettings::values.gamedir_deepscan = ui->toogle_deepscan->isChecked();
|
||||
UISettings::values.pause_onfocuslost = ui->toogle_pause_onfocuslost->isChecked();
|
||||
UISettings::values.confirm_before_closing = ui->toogle_check_exit->isChecked();
|
||||
Settings::values.region_value = ui->region_combobox->currentIndex();
|
||||
Settings::values.use_hw_renderer = ui->toogle_hw_renderer->isChecked();
|
||||
|
@ -31,6 +31,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="toogle_pause_onfocuslost">
|
||||
<property name="text">
|
||||
<string>Pause on focus lost</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="toogle_check_exit">
|
||||
<property name="text">
|
||||
|
@ -186,6 +186,8 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr)
|
||||
connect(this, SIGNAL(EmulationStarting(EmuThread*)), graphicsTracingWidget, SLOT(OnEmulationStarting(EmuThread*)));
|
||||
connect(this, SIGNAL(EmulationStopping()), graphicsTracingWidget, SLOT(OnEmulationStopping()));
|
||||
|
||||
connect(render_window, SIGNAL(gotFocus()), this, SLOT(OnStartGame()));
|
||||
connect(render_window, SIGNAL(lostFocus()), this, SLOT(OnPauseGame()));
|
||||
|
||||
// Setup hotkeys
|
||||
RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
|
||||
@ -468,6 +470,8 @@ void GMainWindow::OnStartGame() {
|
||||
|
||||
ui.action_Pause->setEnabled(true);
|
||||
ui.action_Stop->setEnabled(true);
|
||||
|
||||
render_window->setFocus();
|
||||
}
|
||||
|
||||
void GMainWindow::OnPauseGame() {
|
||||
@ -487,7 +491,7 @@ void GMainWindow::ToggleWindowMode() {
|
||||
// Render in the main window...
|
||||
render_window->BackupGeometry();
|
||||
ui.horizontalLayout->addWidget(render_window);
|
||||
render_window->setFocusPolicy(Qt::ClickFocus);
|
||||
render_window->setFocusPolicy(Qt::StrongFocus);
|
||||
if (emulation_running) {
|
||||
render_window->setVisible(true);
|
||||
render_window->setFocus();
|
||||
@ -505,6 +509,7 @@ void GMainWindow::ToggleWindowMode() {
|
||||
game_list->show();
|
||||
}
|
||||
}
|
||||
render_window->setFocus();
|
||||
}
|
||||
|
||||
void GMainWindow::OnConfigure() {
|
||||
|
@ -29,6 +29,7 @@ struct Values {
|
||||
bool single_window_mode;
|
||||
bool display_titlebar;
|
||||
|
||||
bool pause_onfocuslost;
|
||||
bool confirm_before_closing;
|
||||
bool first_start;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user