2 // keybindingstab.cpp: Key Bindings tab on the settings dialog
4 // Part of the Virtual Jaguar Project
6 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
9 // --- ---------- ------------------------------------------------------------
10 // JPM 09/10/2017 Created this file
11 // JPM Sept./2018 Added screenshot key bindings
12 // JPM 10/13/2018 Added breakpoints features
16 #include "keybindingstab.h"
21 KeyBindings KeyBindingsTable
[KB_END
] = {
22 { KB_TYPEGENERAL
, "KB_Quit", "Quit", "Quit key binding", "Ctrl+Q", NULL
, NULL
},
23 { KB_TYPEGENERAL
, "KB_PickFile", "Pick file", "Pick file key binding", "Ctrl+I", NULL
, NULL
},
24 { KB_TYPEGENERAL
, "KB_Configure", "Configure", "Configure key binding", "Ctrl+C", NULL
, NULL
},
25 { KB_TYPEGENERAL
, "KB_EmuStatus", "Emulator Status", "Emulator status key binding", "Ctrl+S", NULL
, NULL
},
26 { KB_TYPEGENERAL
, "KB_Pause", "Pause", "Pause key binding", "Esc", NULL
, NULL
},
27 { KB_TYPEGENERAL
, "KB_FrameAdvance", "Frame Advance", "Frame advance key binding", "F7", NULL
, NULL
},
28 { KB_TYPEGENERAL
, "KB_FullScreen", "Full Screen", "Full screen key binding", "F9", NULL
, NULL
},
29 { KB_TYPEGENERAL
, "KB_Screenshot", "Screenshot", "Screenshot key binding", "F8", NULL
, NULL
},
30 { KB_TYPEDEBUGGER
, "KB_Restart", "Restart", "Restart key binding", "Ctrl+Shift+F5", NULL
, NULL
},
31 { KB_TYPEDEBUGGER
, "KB_StepInto", "Step Into", "Step into key binding", "F11", NULL
, NULL
},
32 { KB_TYPEDEBUGGER
, "KB_StepOver", "Step Over", "Step over key binding", "F10", NULL
, NULL
},
33 { KB_TYPEDEBUGGER
, "KB_FunctionBreakpoint", "Function Breakpoint", "Function breakpoint binding", "Ctrl+B", NULL
, NULL
},
34 { KB_TYPEDEBUGGER
, "KB_Breakpoints", "Breakpoints", "Breakpoints binding", "Ctrl+Alt+B", NULL
, NULL
},
35 { KB_TYPEDEBUGGER
, "KB_DeleteAllBreakpoints", "Delete All Breakpoints", "Delete all breakpoints binding", "Ctrl+Shift+F9", NULL
, NULL
}
40 #define NBKEYBINDINGS sizeof(KeyBindingsTable)/sizeof(KeyBindings)
44 KeyBindingsTab::KeyBindingsTab(QWidget
* parent
/*= 0*/): QWidget(parent
)
48 QVBoxLayout
*layout1
= new QVBoxLayout
;
49 QVBoxLayout
*layout2
= new QVBoxLayout
;
51 // Initialisation for each layout line
52 for (i
= 0; i
< NBKEYBINDINGS
; i
++)
54 // Prepare the keybinding line
55 layout1
->addWidget(KeyBindingsTable
[i
].KBLabel
= new QLabel(KeyBindingsTable
[i
].KBNameLabel
));
56 layout2
->addWidget(KeyBindingsTable
[i
].KBLineEdit
= new QLineEdit(""));
57 KeyBindingsTable
[i
].KBLineEdit
->setMaxLength(30);
58 KeyBindingsTable
[i
].KBLineEdit
->setPlaceholderText(KeyBindingsTable
[i
].KBPlaceholderText
);
60 // Check if keybinding can be editable
61 if (KeyBindingsTable
[i
].KBType
!= KB_TYPEGENERAL
)
63 if (vjs
.hardwareTypeAlpine
&& (KeyBindingsTable
[i
].KBType
& KB_TYPEALPINE
))
68 if (vjs
.softTypeDebugger
&& (KeyBindingsTable
[i
].KBType
& KB_TYPEDEBUGGER
))
73 KeyBindingsTable
[i
].KBLabel
->hide();
74 KeyBindingsTable
[i
].KBLineEdit
->hide();
81 QHBoxLayout
*layout3
= new QHBoxLayout
;
82 layout3
->addLayout(layout1
);
83 layout3
->addLayout(layout2
);
84 QVBoxLayout
*layout4
= new QVBoxLayout
;
85 layout4
->addLayout(layout3
);
90 KeyBindingsTab::~KeyBindingsTab()
95 // Load / Update the tabs dialog from the settings
96 void KeyBindingsTab::GetSettings(void)
100 for (i
= 0; i
< NBKEYBINDINGS
; i
++)
102 KeyBindingsTable
[i
].KBLineEdit
->setText(vjs
.KBContent
[i
].KBSettingValue
);
107 // Save / Update the settings from the tabs dialog
108 void KeyBindingsTab::SetSettings(void)
112 for (i
= 0; i
< NBKEYBINDINGS
; i
++)
114 //strcpy(vjs.KBContent[i].KBSettingName, KeyBindingsTable[i].KBNameSetting);
115 strcpy(vjs
.KBContent
[i
].KBSettingValue
, KeyBindingsTable
[i
].KBLineEdit
->text().toUtf8().data());