Qt: Option to disable keyboard hotkeys

This commit is contained in:
Pavel 2020-05-02 17:56:09 +03:00 committed by Ivan
parent edde748519
commit 9a4c26dc8c
6 changed files with 39 additions and 9 deletions

View File

@ -43,6 +43,7 @@ gs_frame::gs_frame(const QRect& geometry, const QIcon& appIcon, const std::share
: QWindow(), m_gui_settings(gui_settings)
{
m_disable_mouse = gui_settings->GetValue(gui::gs_disableMouse).toBool();
m_disable_kb_hotkeys = gui_settings->GetValue(gui::gs_disableKbHotkeys).toBool();
m_show_mouse_in_fullscreen = gui_settings->GetValue(gui::gs_showMouseFs).toBool();
m_window_title = qstr(Emu.GetFormattedTitle(0));
@ -127,16 +128,28 @@ void gs_frame::keyPressEvent(QKeyEvent *keyEvent)
if (visibility() == FullScreen) { toggle_fullscreen(); return; }
break;
case Qt::Key_P:
if (keyEvent->modifiers() == Qt::ControlModifier && Emu.IsRunning()) { Emu.Pause(); return; }
if (keyEvent->modifiers() == Qt::ControlModifier && !m_disable_kb_hotkeys && Emu.IsRunning())
{
Emu.Pause();
return;
}
break;
case Qt::Key_S:
if (keyEvent->modifiers() == Qt::ControlModifier && (!Emu.IsStopped())) { Emu.Stop(); return; }
if (keyEvent->modifiers() == Qt::ControlModifier && !m_disable_kb_hotkeys && (!Emu.IsStopped()))
{
Emu.Stop();
return;
}
break;
case Qt::Key_R:
if (keyEvent->modifiers() == Qt::ControlModifier && (!Emu.GetBoot().empty())) { Emu.Restart(); return; }
if (keyEvent->modifiers() == Qt::ControlModifier && !m_disable_kb_hotkeys && (!Emu.GetBoot().empty()))
{
Emu.Restart();
return;
}
break;
case Qt::Key_E:
if (keyEvent->modifiers() == Qt::ControlModifier)
if (keyEvent->modifiers() == Qt::ControlModifier && !m_disable_kb_hotkeys)
{
if (Emu.IsReady()) { Emu.Run(true); return; }
else if (Emu.IsPaused()) { Emu.Resume(); return; }

View File

@ -33,6 +33,7 @@ private:
u64 m_frames = 0;
QString m_window_title;
bool m_disable_mouse = false;
bool m_disable_kb_hotkeys = false;
bool m_show_mouse_in_fullscreen = false;
public:

View File

@ -192,6 +192,7 @@ namespace gui
const gui_save m_check_upd_start = gui_save(meta, "checkUpdateStart", true);
const gui_save gs_disableMouse = gui_save(gs_frame, "disableMouse", false);
const gui_save gs_disableKbHotkeys = gui_save(gs_frame, "disableKbHotkeys", false);
const gui_save gs_showMouseFs = gui_save(gs_frame, "showMouseInFullscreen", false);
const gui_save gs_resize = gui_save(gs_frame, "resize", false);
const gui_save gs_width = gui_save(gs_frame, "width", 1280);

View File

@ -1265,6 +1265,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
{
SubscribeTooltip(ui->gs_resizeOnBoot, tooltips.settings.resize_on_boot);
SubscribeTooltip(ui->gs_disableMouse, tooltips.settings.disable_mouse);
SubscribeTooltip(ui->gs_disableKbHotkeys, tooltips.settings.disable_kb_hotkeys);
SubscribeTooltip(ui->gs_showMouseInFullscreen, tooltips.settings.show_mouse_in_fullscreen);
ui->gs_disableMouse->setChecked(m_gui_settings->GetValue(gui::gs_disableMouse).toBool());
@ -1273,6 +1274,12 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
m_gui_settings->SetValue(gui::gs_disableMouse, val);
});
ui->gs_disableKbHotkeys->setChecked(m_gui_settings->GetValue(gui::gs_disableKbHotkeys).toBool());
connect(ui->gs_disableKbHotkeys, &QCheckBox::clicked, [this](bool val)
{
m_gui_settings->SetValue(gui::gs_disableKbHotkeys, val);
});
ui->gs_showMouseInFullscreen->setChecked(m_gui_settings->GetValue(gui::gs_showMouseFs).toBool());
connect(ui->gs_showMouseInFullscreen, &QCheckBox::clicked, [this](bool val)
{

View File

@ -2338,6 +2338,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="gs_disableKbHotkeys">
<property name="text">
<string>Ignore keyboard hotkeys</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="gs_showMouseInFullscreen">
<property name="text">

View File

@ -103,6 +103,7 @@ public:
const QString resize_on_boot = tr("Automatically resizes the game window on boot.\nThis does not change the internal game resolution.");
const QString show_trophy_popups = tr("Show trophy pop-ups when a trophy is unlocked.");
const QString disable_mouse = tr("Disables the activation of fullscreen mode per double-click while the game screen is active.\nCheck this if you want to play with mouse and keyboard (for example with UCR).");
const QString disable_kb_hotkeys = tr("Disables keyboard hotkeys such as Ctrl-S, Ctrl-E, Ctrl-R, Ctrl-P while the game screen is active.\nCheck this if you want to play with mouse and keyboard.");
const QString max_llvm_threads = tr("Limits the maximum number of threads used for the initial PPU and SPU module compilation.\nLower this in order to increase performance of other open applications.\nThe default uses all available threads.");
const QString show_mouse_in_fullscreen = tr("Shows the mouse cursor when the fullscreen mode is active.\nCurrently this may not work every time.");
const QString show_shader_compilation_hint = tr("Show shader compilation hints using the native overlay.");