* Added a Keybindings dialog tabs.
[clinton/Virtual-Jaguar-Rx.git] / src / gui / keybindingstab.cpp
CommitLineData
024bfc46
JPM
1//
2// keybindingstab.cpp: Key Bindings tab on the settings dialog
3//
4// Part of the Virtual Jaguar Project
5//
6// JPM = Jean-Paul Mari <djipi.mari@gmail.com>
7//
8// WHO WHEN WHAT
9// --- ---------- ------------------------------------------------------------
10// JPM 09/10/2017 Created this file
11
12#include "keybindingstab.h"
13#include "settings.h"
14
15
16//
17KeyBindings KeyBindingsTable[KB_END] = {
18 { "KB_Quit", "Quit", "Quit keybinding", "Ctrl+Q", NULL, NULL },
19 { "KB_PickFile", "Pick file", "Pick file keybinding", "Ctrl+I", NULL, NULL },
20 { "KB_Configure", "Configure", "Configure keybinding", "Ctrl+C", NULL, NULL },
21 { "KB_EmuStatus", "Emulator Status", "Emulator status keybinding", "Ctrl+S", NULL, NULL },
22 { "KB_Pause", "Pause", "Pause keybinding", "Esc", NULL, NULL },
23 { "KB_FrameAdvance", "Frame Advance", "Frame advance keybinding", "F7", NULL, NULL },
24 { "KB_Restart", "Restart", "Restart keybinding", "Ctrl+Shift+F5", NULL, NULL },
25 { "KB_StepInto", "Step Into", "Step into keybinding", "F11", NULL, NULL },
26 { "KB_StepOver", "Step Over", "Step over kebinding", "F10", NULL, NULL },
27 { "KB_FullScreen", "Full Screen", "Full screen kebinding", "F9", NULL, NULL }
28 };
29
30
31//
32#define NBKEYBINDINGS sizeof(KeyBindingsTable)/sizeof(KeyBindings)
33
34
35//
36KeyBindingsTab::KeyBindingsTab(QWidget * parent/*= 0*/): QWidget(parent)
37{
38 size_t i;
39
40 QVBoxLayout *layout1 = new QVBoxLayout;
41 QVBoxLayout *layout2 = new QVBoxLayout;
42
43 // Initialisation for each layout line
44 for (i = 0; i < NBKEYBINDINGS; i++)
45 {
46 layout1->addWidget(KeyBindingsTable[i].KBLabel = new QLabel(KeyBindingsTable[i].KBNameLabel));
47 layout2->addWidget(KeyBindingsTable[i].KBLineEdit = new QLineEdit(""));
48 KeyBindingsTable[i].KBLineEdit->setMaxLength(30);
49 KeyBindingsTable[i].KBLineEdit->setPlaceholderText(KeyBindingsTable[i].KBPlaceholderText);
50 }
51
52 // Layouts setup
53 QHBoxLayout *layout3 = new QHBoxLayout;
54 layout3->addLayout(layout1);
55 layout3->addLayout(layout2);
56 QVBoxLayout *layout4 = new QVBoxLayout;
57 layout4->addLayout(layout3);
58 setLayout(layout4);
59}
60
61
62KeyBindingsTab::~KeyBindingsTab()
63{
64}
65
66
67// Load / Update the tabs dialog from the settings
68void KeyBindingsTab::GetSettings(void)
69{
70 size_t i;
71
72 for (i = 0; i < NBKEYBINDINGS; i++)
73 {
74 KeyBindingsTable[i].KBLineEdit->setText(vjs.KBContent[i].KBSettingValue);
75 }
76}
77
78
79// Save / Update the settings from the tabs dialog
80void KeyBindingsTab::SetSettings(void)
81{
82 size_t i;
83
84 for (i = 0; i < NBKEYBINDINGS; i++)
85 {
86 //strcpy(vjs.KBContent[i].KBSettingName, KeyBindingsTable[i].KBNameSetting);
87 strcpy(vjs.KBContent[i].KBSettingValue, KeyBindingsTable[i].KBLineEdit->text().toUtf8().data());
88 }
89}
90