From 0a2357f04401d76e338c8466f6177823fe6aa400 Mon Sep 17 00:00:00 2001 From: aldelaro5 Date: Sun, 13 May 2018 18:12:31 -0400 Subject: [PATCH] Qt/hotkeys: do not show the debugging tab if the debugger is disabled --- .../Config/Mapping/MappingWindow.cpp | 13 ++++- Source/Core/DolphinQt2/HotkeyScheduler.cpp | 51 ++++++++++--------- Source/Core/DolphinQt2/HotkeyScheduler.h | 1 + 3 files changed, 41 insertions(+), 24 deletions(-) diff --git a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp index e528133980..dadcee805e 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp @@ -289,7 +289,18 @@ void MappingWindow::SetMappingType(MappingWindow::Type type) widget = new HotkeyGeneral(this); AddWidget(tr("General"), widget); AddWidget(tr("TAS Tools"), new HotkeyTAS(this)); - AddWidget(tr("Debugging"), new HotkeyDebugging(this)); + + HotkeyDebugging* debugging_widget = new HotkeyDebugging(this); + QWidget* debugging_widget_wrapper = GetWrappedWidget(debugging_widget, this, 150, 150); + connect(&Settings::Instance(), &Settings::DebugModeToggled, this, [=](bool enabled) { + if (enabled) + m_tab_widget->insertTab(2, debugging_widget_wrapper, tr("Debugging")); + else + m_tab_widget->removeTab(2); + }); + if (Settings::Instance().IsDebugModeEnabled()) + AddWidget(tr("Debugging"), debugging_widget); + AddWidget(tr("Wii and Wii Remote"), new HotkeyWii(this)); AddWidget(tr("Graphics"), new HotkeyGraphics(this)); AddWidget(tr("3D"), new Hotkey3D(this)); diff --git a/Source/Core/DolphinQt2/HotkeyScheduler.cpp b/Source/Core/DolphinQt2/HotkeyScheduler.cpp index 73862102af..39ba49705b 100644 --- a/Source/Core/DolphinQt2/HotkeyScheduler.cpp +++ b/Source/Core/DolphinQt2/HotkeyScheduler.cpp @@ -215,29 +215,7 @@ void HotkeyScheduler::Run() if (SConfig::GetInstance().bEnableDebugging) { - if (IsHotkey(HK_STEP)) - emit Step(); - - if (IsHotkey(HK_STEP_OVER)) - emit StepOver(); - - if (IsHotkey(HK_STEP_OUT)) - emit StepOut(); - - if (IsHotkey(HK_SKIP)) - emit Skip(); - - if (IsHotkey(HK_SHOW_PC)) - emit ShowPC(); - - if (IsHotkey(HK_SET_PC)) - emit Skip(); - - if (IsHotkey(HK_BP_TOGGLE)) - emit ToggleBreakpoint(); - - if (IsHotkey(HK_BP_ADD)) - emit AddBreakpoint(); + CheckDebuggingHotkeys(); } // TODO: HK_MBP_ADD @@ -471,3 +449,30 @@ void HotkeyScheduler::Run() State::UndoSaveState(); } } + +void HotkeyScheduler::CheckDebuggingHotkeys() +{ + if (IsHotkey(HK_STEP)) + emit Step(); + + if (IsHotkey(HK_STEP_OVER)) + emit StepOver(); + + if (IsHotkey(HK_STEP_OUT)) + emit StepOut(); + + if (IsHotkey(HK_SKIP)) + emit Skip(); + + if (IsHotkey(HK_SHOW_PC)) + emit ShowPC(); + + if (IsHotkey(HK_SET_PC)) + emit Skip(); + + if (IsHotkey(HK_BP_TOGGLE)) + emit ToggleBreakpoint(); + + if (IsHotkey(HK_BP_ADD)) + emit AddBreakpoint(); +} diff --git a/Source/Core/DolphinQt2/HotkeyScheduler.h b/Source/Core/DolphinQt2/HotkeyScheduler.h index 3d2a9741a3..6a7fc9e3d5 100644 --- a/Source/Core/DolphinQt2/HotkeyScheduler.h +++ b/Source/Core/DolphinQt2/HotkeyScheduler.h @@ -51,6 +51,7 @@ signals: private: void Run(); + void CheckDebuggingHotkeys(); Common::Flag m_stop_requested; std::thread m_thread;