| 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 | // |
| 17 | KeyBindings KeyBindingsTable[KB_END] = { |
| 18 | { KB_TYPEGENERAL, "KB_Quit", "Quit", "Quit keybinding", "Ctrl+Q", NULL, NULL }, |
| 19 | { KB_TYPEGENERAL, "KB_PickFile", "Pick file", "Pick file keybinding", "Ctrl+I", NULL, NULL }, |
| 20 | { KB_TYPEGENERAL, "KB_Configure", "Configure", "Configure keybinding", "Ctrl+C", NULL, NULL }, |
| 21 | { KB_TYPEGENERAL, "KB_EmuStatus", "Emulator Status", "Emulator status keybinding", "Ctrl+S", NULL, NULL }, |
| 22 | { KB_TYPEGENERAL, "KB_Pause", "Pause", "Pause keybinding", "Esc", NULL, NULL }, |
| 23 | { KB_TYPEGENERAL, "KB_FrameAdvance", "Frame Advance", "Frame advance keybinding", "F7", NULL, NULL }, |
| 24 | { KB_TYPEDEBUGGER, "KB_Restart", "Restart", "Restart keybinding", "Ctrl+Shift+F5", NULL, NULL }, |
| 25 | { KB_TYPEDEBUGGER, "KB_StepInto", "Step Into", "Step into keybinding", "F11", NULL, NULL }, |
| 26 | { KB_TYPEDEBUGGER, "KB_StepOver", "Step Over", "Step over kebinding", "F10", NULL, NULL }, |
| 27 | { KB_TYPEGENERAL, "KB_FullScreen", "Full Screen", "Full screen kebinding", "F9", NULL, NULL } |
| 28 | }; |
| 29 | |
| 30 | |
| 31 | // |
| 32 | #define NBKEYBINDINGS sizeof(KeyBindingsTable)/sizeof(KeyBindings) |
| 33 | |
| 34 | |
| 35 | // |
| 36 | KeyBindingsTab::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 | // Prepare the keybinding line |
| 47 | layout1->addWidget(KeyBindingsTable[i].KBLabel = new QLabel(KeyBindingsTable[i].KBNameLabel)); |
| 48 | layout2->addWidget(KeyBindingsTable[i].KBLineEdit = new QLineEdit("")); |
| 49 | KeyBindingsTable[i].KBLineEdit->setMaxLength(30); |
| 50 | KeyBindingsTable[i].KBLineEdit->setPlaceholderText(KeyBindingsTable[i].KBPlaceholderText); |
| 51 | |
| 52 | // Check if keybinding can be editable |
| 53 | if (KeyBindingsTable[i].KBType != KB_TYPEGENERAL) |
| 54 | { |
| 55 | if (vjs.hardwareTypeAlpine && (KeyBindingsTable[i].KBType & KB_TYPEALPINE)) |
| 56 | { |
| 57 | } |
| 58 | else\r |
| 59 | {\r |
| 60 | if (vjs.softTypeDebugger && (KeyBindingsTable[i].KBType & KB_TYPEDEBUGGER))\r |
| 61 | {\r |
| 62 | }\r |
| 63 | else\r |
| 64 | {\r |
| 65 | KeyBindingsTable[i].KBLabel->hide(); |
| 66 | KeyBindingsTable[i].KBLineEdit->hide();\r |
| 67 | }\r |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | // Layouts setup |
| 73 | QHBoxLayout *layout3 = new QHBoxLayout; |
| 74 | layout3->addLayout(layout1); |
| 75 | layout3->addLayout(layout2); |
| 76 | QVBoxLayout *layout4 = new QVBoxLayout; |
| 77 | layout4->addLayout(layout3); |
| 78 | setLayout(layout4); |
| 79 | } |
| 80 | |
| 81 | |
| 82 | KeyBindingsTab::~KeyBindingsTab() |
| 83 | { |
| 84 | } |
| 85 | |
| 86 | |
| 87 | // Load / Update the tabs dialog from the settings |
| 88 | void KeyBindingsTab::GetSettings(void) |
| 89 | { |
| 90 | size_t i; |
| 91 | |
| 92 | for (i = 0; i < NBKEYBINDINGS; i++) |
| 93 | { |
| 94 | KeyBindingsTable[i].KBLineEdit->setText(vjs.KBContent[i].KBSettingValue); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | |
| 99 | // Save / Update the settings from the tabs dialog |
| 100 | void KeyBindingsTab::SetSettings(void) |
| 101 | { |
| 102 | size_t i; |
| 103 | |
| 104 | for (i = 0; i < NBKEYBINDINGS; i++) |
| 105 | { |
| 106 | //strcpy(vjs.KBContent[i].KBSettingName, KeyBindingsTable[i].KBNameSetting); |
| 107 | strcpy(vjs.KBContent[i].KBSettingValue, KeyBindingsTable[i].KBLineEdit->text().toUtf8().data()); |
| 108 | } |
| 109 | } |
| 110 | |