summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt2/MainWindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/DolphinQt2/MainWindow.cpp')
-rw-r--r--Source/Core/DolphinQt2/MainWindow.cpp57
1 files changed, 55 insertions, 2 deletions
diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp
index a8049826f2..71e72f6fea 100644
--- a/Source/Core/DolphinQt2/MainWindow.cpp
+++ b/Source/Core/DolphinQt2/MainWindow.cpp
@@ -9,6 +9,7 @@
#include "Common/Common.h"
+#include "Core/Boot/Boot.h"
#include "Core/BootManager.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
@@ -24,9 +25,13 @@
#include "DolphinQt2/AboutDialog.h"
#include "DolphinQt2/Config/ControllersWindow.h"
+
+#include "DolphinQt2/Config/Mapping/MappingWindow.h"
#include "DolphinQt2/Config/SettingsWindow.h"
#include "DolphinQt2/Host.h"
+#include "DolphinQt2/HotkeyScheduler.h"
#include "DolphinQt2/MainWindow.h"
+#include "DolphinQt2/QtUtils/FocusEventFilter.h"
#include "DolphinQt2/Resources.h"
#include "DolphinQt2/Settings.h"
@@ -64,16 +69,32 @@ void MainWindow::InitControllers()
Pad::Initialize();
Keyboard::Initialize();
Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES);
- HotkeyManagerEmu::Initialize();
+ m_hotkey_scheduler = new HotkeyScheduler();
+ m_hotkey_scheduler->Start();
+
+ ConnectHotkeys();
}
void MainWindow::ShutdownControllers()
{
+ m_hotkey_scheduler->Stop();
+
g_controller_interface.Shutdown();
Pad::Shutdown();
Keyboard::Shutdown();
Wiimote::Shutdown();
HotkeyManagerEmu::Shutdown();
+
+ m_hotkey_scheduler->deleteLater();
+}
+
+static void InstallHotkeyFilter(QDialog* dialog)
+{
+ auto* filter = new FocusEventFilter();
+ dialog->installEventFilter(filter);
+
+ filter->connect(filter, &FocusEventFilter::focusOutEvent, [] { HotkeyManagerEmu::Enable(true); });
+ filter->connect(filter, &FocusEventFilter::focusInEvent, [] { HotkeyManagerEmu::Enable(false); });
}
void MainWindow::CreateComponents()
@@ -85,6 +106,11 @@ void MainWindow::CreateComponents()
m_stack = new QStackedWidget(this);
m_controllers_window = new ControllersWindow(this);
m_settings_window = new SettingsWindow(this);
+ m_hotkey_window = new MappingWindow(this, 0);
+
+ InstallHotkeyFilter(m_hotkey_window);
+ InstallHotkeyFilter(m_controllers_window);
+ InstallHotkeyFilter(m_settings_window);
}
void MainWindow::ConnectMenuBar()
@@ -113,6 +139,9 @@ void MainWindow::ConnectMenuBar()
connect(m_menu_bar, &MenuBar::StateSaveOldest, this, &MainWindow::StateSaveOldest);
connect(m_menu_bar, &MenuBar::SetStateSlot, this, &MainWindow::SetStateSlot);
+ // Options
+ connect(m_menu_bar, &MenuBar::ConfigureHotkeys, this, &MainWindow::ShowHotkeyDialog);
+
// View
connect(m_menu_bar, &MenuBar::ShowTable, m_game_list, &GameList::SetTableView);
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView);
@@ -130,6 +159,22 @@ void MainWindow::ConnectMenuBar()
[=]() { m_controllers_window->OnEmulationStateChanged(false); });
}
+void MainWindow::ConnectHotkeys()
+{
+ connect(m_hotkey_scheduler, &HotkeyScheduler::ExitHotkey, this, &MainWindow::close);
+ connect(m_hotkey_scheduler, &HotkeyScheduler::PauseHotkey, this, &MainWindow::Pause);
+ connect(m_hotkey_scheduler, &HotkeyScheduler::StopHotkey, this, &MainWindow::Stop);
+ connect(m_hotkey_scheduler, &HotkeyScheduler::ScreenShotHotkey, this, &MainWindow::ScreenShot);
+ connect(m_hotkey_scheduler, &HotkeyScheduler::FullScreenHotkey, this, &MainWindow::FullScreen);
+
+ connect(m_hotkey_scheduler, &HotkeyScheduler::StateLoadSlotHotkey, this,
+ &MainWindow::StateLoadSlot);
+ connect(m_hotkey_scheduler, &HotkeyScheduler::StateSaveSlotHotkey, this,
+ &MainWindow::StateSaveSlot);
+ connect(m_hotkey_scheduler, &HotkeyScheduler::SetStateSlotHotkey, this,
+ &MainWindow::SetStateSlot);
+}
+
void MainWindow::ConnectToolBar()
{
addToolBar(m_tool_bar);
@@ -287,7 +332,7 @@ void MainWindow::StartGame(const QString& path)
return;
}
// Boot up, show an error if it fails to load the game.
- if (!BootManager::BootCore(path.toStdString(), SConfig::BOOT_DEFAULT))
+ if (!BootManager::BootCore(BootParameters::GenerateFromFile(path.toStdString())))
{
QMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok);
return;
@@ -364,6 +409,14 @@ void MainWindow::ShowAboutDialog()
about->show();
}
+void MainWindow::ShowHotkeyDialog()
+{
+ m_hotkey_window->ChangeMappingType(MappingWindow::Type::MAPPING_HOTKEYS);
+ m_hotkey_window->show();
+ m_hotkey_window->raise();
+ m_hotkey_window->activateWindow();
+}
+
void MainWindow::StateLoad()
{
QString path = QFileDialog::getOpenFileName(this, tr("Select a File"), QDir::currentPath(),