summaryrefslogtreecommitdiff
path: root/src/citra_qt/hotkeys.cpp
diff options
context:
space:
mode:
authorGravatar James Rowe2018-01-11 19:21:20 -0700
committerGravatar James Rowe2018-01-12 19:11:03 -0700
commitebf9a784a9f7f4148a669dbb39e7cd50df779a14 (patch)
treed585685a1c0a34b903af1d086d62560bf56bb29f /src/citra_qt/hotkeys.cpp
parentconfig: Default CPU core to Unicorn. (diff)
downloadyuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.gz
yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.xz
yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.zip
Massive removal of unused modules
Diffstat (limited to 'src/citra_qt/hotkeys.cpp')
-rw-r--r--src/citra_qt/hotkeys.cpp90
1 files changed, 0 insertions, 90 deletions
diff --git a/src/citra_qt/hotkeys.cpp b/src/citra_qt/hotkeys.cpp
deleted file mode 100644
index 158ed506f..000000000
--- a/src/citra_qt/hotkeys.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <map>
6#include <QKeySequence>
7#include <QShortcut>
8#include <QtGlobal>
9#include "citra_qt/hotkeys.h"
10#include "citra_qt/ui_settings.h"
11
12struct Hotkey {
13 Hotkey() : shortcut(nullptr), context(Qt::WindowShortcut) {}
14
15 QKeySequence keyseq;
16 QShortcut* shortcut;
17 Qt::ShortcutContext context;
18};
19
20typedef std::map<QString, Hotkey> HotkeyMap;
21typedef std::map<QString, HotkeyMap> HotkeyGroupMap;
22
23HotkeyGroupMap hotkey_groups;
24
25void SaveHotkeys() {
26 UISettings::values.shortcuts.clear();
27 for (auto group : hotkey_groups) {
28 for (auto hotkey : group.second) {
29 UISettings::values.shortcuts.emplace_back(
30 UISettings::Shortcut(group.first + "/" + hotkey.first,
31 UISettings::ContextualShortcut(hotkey.second.keyseq.toString(),
32 hotkey.second.context)));
33 }
34 }
35}
36
37void LoadHotkeys() {
38 // Make sure NOT to use a reference here because it would become invalid once we call
39 // beginGroup()
40 for (auto shortcut : UISettings::values.shortcuts) {
41 QStringList cat = shortcut.first.split("/");
42 Q_ASSERT(cat.size() >= 2);
43
44 // RegisterHotkey assigns default keybindings, so use old values as default parameters
45 Hotkey& hk = hotkey_groups[cat[0]][cat[1]];
46 if (!shortcut.second.first.isEmpty()) {
47 hk.keyseq = QKeySequence::fromString(shortcut.second.first);
48 hk.context = (Qt::ShortcutContext)shortcut.second.second;
49 }
50 if (hk.shortcut)
51 hk.shortcut->setKey(hk.keyseq);
52 }
53}
54
55void RegisterHotkey(const QString& group, const QString& action, const QKeySequence& default_keyseq,
56 Qt::ShortcutContext default_context) {
57 if (hotkey_groups[group].find(action) == hotkey_groups[group].end()) {
58 hotkey_groups[group][action].keyseq = default_keyseq;
59 hotkey_groups[group][action].context = default_context;
60 }
61}
62
63QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widget) {
64 Hotkey& hk = hotkey_groups[group][action];
65
66 if (!hk.shortcut)
67 hk.shortcut = new QShortcut(hk.keyseq, widget, nullptr, nullptr, hk.context);
68
69 return hk.shortcut;
70}
71
72GHotkeysDialog::GHotkeysDialog(QWidget* parent) : QWidget(parent) {
73 ui.setupUi(this);
74
75 for (auto group : hotkey_groups) {
76 QTreeWidgetItem* toplevel_item = new QTreeWidgetItem(QStringList(group.first));
77 for (auto hotkey : group.second) {
78 QStringList columns;
79 columns << hotkey.first << hotkey.second.keyseq.toString();
80 QTreeWidgetItem* item = new QTreeWidgetItem(columns);
81 toplevel_item->addChild(item);
82 }
83 ui.treeWidget->addTopLevelItem(toplevel_item);
84 }
85 // TODO: Make context configurable as well (hiding the column for now)
86 ui.treeWidget->setColumnCount(2);
87
88 ui.treeWidget->resizeColumnToContents(0);
89 ui.treeWidget->resizeColumnToContents(1);
90}