Skip to content

Commit

Permalink
Qt: Implement hotkeys (+ configuration)
Browse files Browse the repository at this point in the history
  • Loading branch information
spycrab committed Jun 5, 2017
1 parent 75d686e commit 946581b
Show file tree
Hide file tree
Showing 26 changed files with 944 additions and 9 deletions.
8 changes: 8 additions & 0 deletions Source/Core/DolphinQt2/CMakeLists.txt
Expand Up @@ -9,6 +9,7 @@ set(CMAKE_AUTOMOC ON)

set(SRCS
AboutDialog.cpp
HotkeyScheduler.cpp
Host.cpp
InDevelopmentWarning.cpp
Main.cpp
Expand All @@ -24,6 +25,12 @@ set(SRCS
Config/Mapping/GCKeyboardEmu.cpp
Config/Mapping/GCPadEmu.cpp
Config/Mapping/GCPadWiiU.cpp
Config/Mapping/Hotkey3D.cpp
Config/Mapping/HotkeyGeneral.cpp
Config/Mapping/HotkeyGraphics.cpp
Config/Mapping/HotkeyStates.cpp
Config/Mapping/HotkeyTAS.cpp
Config/Mapping/HotkeyWii.cpp
Config/Mapping/MappingBool.cpp
Config/Mapping/MappingButton.cpp
Config/Mapping/MappingNumeric.cpp
Expand All @@ -41,6 +48,7 @@ set(SRCS
GameList/GameTracker.cpp
GameList/ListProxyModel.cpp
QtUtils/ElidedButton.cpp
QtUtils/QInputDialog.cpp
Settings/GeneralPane.cpp
Settings/InterfacePane.cpp
)
Expand Down
42 changes: 42 additions & 0 deletions Source/Core/DolphinQt2/Config/Mapping/Hotkey3D.cpp
@@ -0,0 +1,42 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "DolphinQt2/Config/Mapping/Hotkey3D.h"

#include <QGroupBox>
#include <QHBoxLayout>

#include "Core/HotkeyManager.h"

Hotkey3D::Hotkey3D(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}

void Hotkey3D::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();

m_main_layout->addWidget(
CreateGroupBox(tr("3D"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_3D_TOGGLE)));
m_main_layout->addWidget(
CreateGroupBox(tr("3D Depth"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_3D_DEPTH)));

setLayout(m_main_layout);
}

InputConfig* Hotkey3D::GetConfig()
{
return HotkeyManagerEmu::GetConfig();
}

void Hotkey3D::LoadSettings()
{
HotkeyManagerEmu::LoadConfig();
}

void Hotkey3D::SaveSettings()
{
HotkeyManagerEmu::GetConfig()->SaveConfig();
}
25 changes: 25 additions & 0 deletions Source/Core/DolphinQt2/Config/Mapping/Hotkey3D.h
@@ -0,0 +1,25 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include "DolphinQt2/Config/Mapping/MappingWidget.h"

class QHBoxLayout;

class Hotkey3D final : public MappingWidget
{
public:
explicit Hotkey3D(MappingWindow* window);

InputConfig* GetConfig() override;

private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();

// Main
QHBoxLayout* m_main_layout;
};
47 changes: 47 additions & 0 deletions Source/Core/DolphinQt2/Config/Mapping/HotkeyGeneral.cpp
@@ -0,0 +1,47 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "DolphinQt2/Config/Mapping/HotkeyGeneral.h"

#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>

#include "Core/HotkeyManager.h"

HotkeyGeneral::HotkeyGeneral(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}

void HotkeyGeneral::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();

m_main_layout->addWidget(
CreateGroupBox(tr("General"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_GENERAL)));

auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(tr("Volume"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_VOLUME)));
vbox->addWidget(
CreateGroupBox(tr("Emulation Speed"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_SPEED)));
m_main_layout->addItem(vbox);

setLayout(m_main_layout);
}

InputConfig* HotkeyGeneral::GetConfig()
{
return HotkeyManagerEmu::GetConfig();
}

void HotkeyGeneral::LoadSettings()
{
HotkeyManagerEmu::LoadConfig();
}

void HotkeyGeneral::SaveSettings()
{
HotkeyManagerEmu::GetConfig()->SaveConfig();
}
25 changes: 25 additions & 0 deletions Source/Core/DolphinQt2/Config/Mapping/HotkeyGeneral.h
@@ -0,0 +1,25 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include "DolphinQt2/Config/Mapping/MappingWidget.h"

class QHBoxLayout;

class HotkeyGeneral final : public MappingWidget
{
public:
explicit HotkeyGeneral(MappingWindow* window);

InputConfig* GetConfig() override;

private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();

// Main
QHBoxLayout* m_main_layout;
};
48 changes: 48 additions & 0 deletions Source/Core/DolphinQt2/Config/Mapping/HotkeyGraphics.cpp
@@ -0,0 +1,48 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "DolphinQt2/Config/Mapping/HotkeyGraphics.h"

#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>

#include "Core/HotkeyManager.h"

HotkeyGraphics::HotkeyGraphics(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}

void HotkeyGraphics::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();

m_main_layout->addWidget(
CreateGroupBox(tr("Freelook"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_FREELOOK)));

auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(tr("Graphics Toggles"),
HotkeyManagerEmu::GetHotkeyGroup(HKGP_GRAPHICS_TOGGLES)));
vbox->addWidget(
CreateGroupBox(tr("Internal Resolution"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_IR)));
m_main_layout->addItem(vbox);

setLayout(m_main_layout);
}

InputConfig* HotkeyGraphics::GetConfig()
{
return HotkeyManagerEmu::GetConfig();
}

void HotkeyGraphics::LoadSettings()
{
HotkeyManagerEmu::LoadConfig();
}

void HotkeyGraphics::SaveSettings()
{
HotkeyManagerEmu::GetConfig()->SaveConfig();
}
25 changes: 25 additions & 0 deletions Source/Core/DolphinQt2/Config/Mapping/HotkeyGraphics.h
@@ -0,0 +1,25 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include "DolphinQt2/Config/Mapping/MappingWidget.h"

class QHBoxLayout;

class HotkeyGraphics final : public MappingWidget
{
public:
explicit HotkeyGraphics(MappingWindow* window);

InputConfig* GetConfig() override;

private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();

// Main
QHBoxLayout* m_main_layout;
};
42 changes: 42 additions & 0 deletions Source/Core/DolphinQt2/Config/Mapping/HotkeyStates.cpp
@@ -0,0 +1,42 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "DolphinQt2/Config/Mapping/HotkeyStates.h"

#include <QGroupBox>
#include <QHBoxLayout>

#include "Core/HotkeyManager.h"

HotkeyStates::HotkeyStates(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}

void HotkeyStates::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();

m_main_layout->addWidget(
CreateGroupBox(tr("Save"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_SAVE_STATE)));
m_main_layout->addWidget(
CreateGroupBox(tr("Load"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_LOAD_STATE)));

setLayout(m_main_layout);
}

InputConfig* HotkeyStates::GetConfig()
{
return HotkeyManagerEmu::GetConfig();
}

void HotkeyStates::LoadSettings()
{
HotkeyManagerEmu::LoadConfig();
}

void HotkeyStates::SaveSettings()
{
HotkeyManagerEmu::GetConfig()->SaveConfig();
}
25 changes: 25 additions & 0 deletions Source/Core/DolphinQt2/Config/Mapping/HotkeyStates.h
@@ -0,0 +1,25 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include "DolphinQt2/Config/Mapping/MappingWidget.h"

class QHBoxLayout;

class HotkeyStates final : public MappingWidget
{
public:
explicit HotkeyStates(MappingWindow* window);

InputConfig* GetConfig() override;

private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();

// Main
QHBoxLayout* m_main_layout;
};
42 changes: 42 additions & 0 deletions Source/Core/DolphinQt2/Config/Mapping/HotkeyTAS.cpp
@@ -0,0 +1,42 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "DolphinQt2/Config/Mapping/HotkeyTAS.h"

#include <QGroupBox>
#include <QHBoxLayout>

#include "Core/HotkeyManager.h"

HotkeyTAS::HotkeyTAS(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}

void HotkeyTAS::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();

m_main_layout->addWidget(
CreateGroupBox(tr("Frame Advance"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_FRAME_ADVANCE)));
m_main_layout->addWidget(
CreateGroupBox(tr("Movie"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_MOVIE)));

setLayout(m_main_layout);
}

InputConfig* HotkeyTAS::GetConfig()
{
return HotkeyManagerEmu::GetConfig();
}

void HotkeyTAS::LoadSettings()
{
HotkeyManagerEmu::LoadConfig();
}

void HotkeyTAS::SaveSettings()
{
HotkeyManagerEmu::GetConfig()->SaveConfig();
}
25 changes: 25 additions & 0 deletions Source/Core/DolphinQt2/Config/Mapping/HotkeyTAS.h
@@ -0,0 +1,25 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include "DolphinQt2/Config/Mapping/MappingWidget.h"

class QHBoxLayout;

class HotkeyTAS final : public MappingWidget
{
public:
explicit HotkeyTAS(MappingWindow* window);

InputConfig* GetConfig() override;

private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();

// Main
QHBoxLayout* m_main_layout;
};

0 comments on commit 946581b

Please sign in to comment.