| 1 | //\r |
| 2 | // keybindingstab.cpp: Key Bindings tab on the settings dialog\r |
| 3 | //\r |
| 4 | // Part of the Virtual Jaguar Project\r |
| 5 | //\r |
| 6 | // JPM = Jean-Paul Mari <djipi.mari@gmail.com>\r |
| 7 | //\r |
| 8 | // WHO WHEN WHAT\r |
| 9 | // --- ---------- ------------------------------------------------------------\r |
| 10 | // JPM 09/10/2017 Created this file\r |
| 11 | // JPM Sept./2018 Added screenshot key bindings\r |
| 12 | // JPM 10/13/2018 Added breakpoints features\r |
| 13 | //\r |
| 14 | \r |
| 15 | \r |
| 16 | #include "keybindingstab.h"\r |
| 17 | #include "settings.h"\r |
| 18 | \r |
| 19 | \r |
| 20 | //\r |
| 21 | KeyBindings KeyBindingsTable[KB_END] = {\r |
| 22 | { KB_TYPEGENERAL, "KB_Quit", "Quit", "Quit key binding", "Ctrl+Q", NULL, NULL },\r |
| 23 | { KB_TYPEGENERAL, "KB_PickFile", "Pick file", "Pick file key binding", "Ctrl+I", NULL, NULL },\r |
| 24 | { KB_TYPEGENERAL, "KB_Configure", "Configure", "Configure key binding", "Ctrl+C", NULL, NULL },\r |
| 25 | { KB_TYPEGENERAL, "KB_EmuStatus", "Emulator Status", "Emulator status key binding", "Ctrl+S", NULL, NULL },\r |
| 26 | { KB_TYPEGENERAL, "KB_Pause", "Pause", "Pause key binding", "Esc", NULL, NULL },\r |
| 27 | { KB_TYPEGENERAL, "KB_FrameAdvance", "Frame Advance", "Frame advance key binding", "F7", NULL, NULL },\r |
| 28 | { KB_TYPEGENERAL, "KB_FullScreen", "Full Screen", "Full screen key binding", "F9", NULL, NULL },\r |
| 29 | { KB_TYPEGENERAL, "KB_Screenshot", "Screenshot", "Screenshot key binding", "F8", NULL, NULL },\r |
| 30 | { KB_TYPEDEBUGGER, "KB_Restart", "Restart", "Restart key binding", "Ctrl+Shift+F5", NULL, NULL },\r |
| 31 | { KB_TYPEDEBUGGER, "KB_StepInto", "Step Into", "Step into key binding", "F11", NULL, NULL },\r |
| 32 | { KB_TYPEDEBUGGER, "KB_StepOver", "Step Over", "Step over key binding", "F10", NULL, NULL },\r |
| 33 | { KB_TYPEDEBUGGER, "KB_FunctionBreakpoint", "Function Breakpoint", "Function breakpoint binding", "Ctrl+B", NULL, NULL },\r |
| 34 | { KB_TYPEDEBUGGER, "KB_Breakpoints", "Breakpoints", "Breakpoints binding", "Ctrl+Alt+B", NULL, NULL },\r |
| 35 | { KB_TYPEDEBUGGER, "KB_DeleteAllBreakpoints", "Delete All Breakpoints", "Delete all breakpoints binding", "Ctrl+Shift+F9", NULL, NULL }\r |
| 36 | };\r |
| 37 | \r |
| 38 | \r |
| 39 | //\r |
| 40 | #define NBKEYBINDINGS sizeof(KeyBindingsTable)/sizeof(KeyBindings)\r |
| 41 | \r |
| 42 | \r |
| 43 | // \r |
| 44 | KeyBindingsTab::KeyBindingsTab(QWidget * parent/*= 0*/): QWidget(parent)\r |
| 45 | {\r |
| 46 | size_t i;\r |
| 47 | \r |
| 48 | QVBoxLayout *layout1 = new QVBoxLayout;\r |
| 49 | QVBoxLayout *layout2 = new QVBoxLayout;\r |
| 50 | \r |
| 51 | // Initialisation for each layout line\r |
| 52 | for (i = 0; i < NBKEYBINDINGS; i++)\r |
| 53 | {\r |
| 54 | // Prepare the keybinding line\r |
| 55 | layout1->addWidget(KeyBindingsTable[i].KBLabel = new QLabel(KeyBindingsTable[i].KBNameLabel));\r |
| 56 | layout2->addWidget(KeyBindingsTable[i].KBLineEdit = new QLineEdit(""));\r |
| 57 | KeyBindingsTable[i].KBLineEdit->setMaxLength(30);\r |
| 58 | KeyBindingsTable[i].KBLineEdit->setPlaceholderText(KeyBindingsTable[i].KBPlaceholderText);\r |
| 59 | \r |
| 60 | // Check if keybinding can be editable\r |
| 61 | if (KeyBindingsTable[i].KBType != KB_TYPEGENERAL)\r |
| 62 | {\r |
| 63 | if (vjs.hardwareTypeAlpine && (KeyBindingsTable[i].KBType & KB_TYPEALPINE))\r |
| 64 | {\r |
| 65 | }\r |
| 66 | else\r |
| 67 | {\r |
| 68 | if (vjs.softTypeDebugger && (KeyBindingsTable[i].KBType & KB_TYPEDEBUGGER))\r |
| 69 | {\r |
| 70 | }\r |
| 71 | else\r |
| 72 | {\r |
| 73 | KeyBindingsTable[i].KBLabel->hide();\r |
| 74 | KeyBindingsTable[i].KBLineEdit->hide();\r |
| 75 | }\r |
| 76 | }\r |
| 77 | }\r |
| 78 | }\r |
| 79 | \r |
| 80 | // Layouts setup\r |
| 81 | QHBoxLayout *layout3 = new QHBoxLayout;\r |
| 82 | layout3->addLayout(layout1);\r |
| 83 | layout3->addLayout(layout2);\r |
| 84 | QVBoxLayout *layout4 = new QVBoxLayout;\r |
| 85 | layout4->addLayout(layout3);\r |
| 86 | setLayout(layout4);\r |
| 87 | }\r |
| 88 | \r |
| 89 | \r |
| 90 | KeyBindingsTab::~KeyBindingsTab()\r |
| 91 | {\r |
| 92 | }\r |
| 93 | \r |
| 94 | \r |
| 95 | // Load / Update the tabs dialog from the settings\r |
| 96 | void KeyBindingsTab::GetSettings(void)\r |
| 97 | {\r |
| 98 | size_t i;\r |
| 99 | \r |
| 100 | for (i = 0; i < NBKEYBINDINGS; i++)\r |
| 101 | {\r |
| 102 | KeyBindingsTable[i].KBLineEdit->setText(vjs.KBContent[i].KBSettingValue);\r |
| 103 | }\r |
| 104 | }\r |
| 105 | \r |
| 106 | \r |
| 107 | // Save / Update the settings from the tabs dialog\r |
| 108 | void KeyBindingsTab::SetSettings(void)\r |
| 109 | {\r |
| 110 | size_t i;\r |
| 111 | \r |
| 112 | for (i = 0; i < NBKEYBINDINGS; i++)\r |
| 113 | {\r |
| 114 | //strcpy(vjs.KBContent[i].KBSettingName, KeyBindingsTable[i].KBNameSetting);\r |
| 115 | strcpy(vjs.KBContent[i].KBSettingValue, KeyBindingsTable[i].KBLineEdit->text().toUtf8().data());\r |
| 116 | }\r |
| 117 | }\r |
| 118 | \r |