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
15 #include "keybindingstab.h"
20 KeyBindings KeyBindingsTable
[KB_END
] = {
21 { KB_TYPEGENERAL
, "KB_Quit", "Quit", "Quit key binding", "Ctrl+Q", NULL
, NULL
},
22 { KB_TYPEGENERAL
, "KB_PickFile", "Pick file", "Pick file key binding", "Ctrl+I", NULL
, NULL
},
23 { KB_TYPEGENERAL
, "KB_Configure", "Configure", "Configure key binding", "Ctrl+C", NULL
, NULL
},
24 { KB_TYPEGENERAL
, "KB_EmuStatus", "Emulator Status", "Emulator status key binding", "Ctrl+S", NULL
, NULL
},
25 { KB_TYPEGENERAL
, "KB_Pause", "Pause", "Pause key binding", "Esc", NULL
, NULL
},
26 { KB_TYPEGENERAL
, "KB_FrameAdvance", "Frame Advance", "Frame advance key binding", "F7", NULL
, NULL
},
27 { KB_TYPEGENERAL
, "KB_FullScreen", "Full Screen", "Full screen key binding", "F9", NULL
, NULL
},
28 { KB_TYPEGENERAL
, "KB_Screenshot", "Screenshot", "Screenshot key binding", "F8", NULL
, NULL
},
29 { KB_TYPEDEBUGGER
, "KB_Restart", "Restart", "Restart key binding", "Ctrl+Shift+F5", NULL
, NULL
},
30 { KB_TYPEDEBUGGER
, "KB_StepInto", "Step Into", "Step into key binding", "F11", NULL
, NULL
},
31 { KB_TYPEDEBUGGER
, "KB_StepOver", "Step Over", "Step over key binding", "F10", NULL
, NULL
}
36 #define NBKEYBINDINGS sizeof(KeyBindingsTable)/sizeof(KeyBindings)
40 KeyBindingsTab::KeyBindingsTab(QWidget
* parent
/*= 0*/): QWidget(parent
)
44 QVBoxLayout
*layout1
= new QVBoxLayout
;
45 QVBoxLayout
*layout2
= new QVBoxLayout
;
47 // Initialisation for each layout line
48 for (i
= 0; i
< NBKEYBINDINGS
; i
++)
50 // Prepare the keybinding line
51 layout1
->addWidget(KeyBindingsTable
[i
].KBLabel
= new QLabel(KeyBindingsTable
[i
].KBNameLabel
));
52 layout2
->addWidget(KeyBindingsTable
[i
].KBLineEdit
= new QLineEdit(""));
53 KeyBindingsTable
[i
].KBLineEdit
->setMaxLength(30);
54 KeyBindingsTable
[i
].KBLineEdit
->setPlaceholderText(KeyBindingsTable
[i
].KBPlaceholderText
);
56 // Check if keybinding can be editable
57 if (KeyBindingsTable
[i
].KBType
!= KB_TYPEGENERAL
)
59 if (vjs
.hardwareTypeAlpine
&& (KeyBindingsTable
[i
].KBType
& KB_TYPEALPINE
))
64 if (vjs
.softTypeDebugger
&& (KeyBindingsTable
[i
].KBType
& KB_TYPEDEBUGGER
))
69 KeyBindingsTable
[i
].KBLabel
->hide();
70 KeyBindingsTable
[i
].KBLineEdit
->hide();
77 QHBoxLayout
*layout3
= new QHBoxLayout
;
78 layout3
->addLayout(layout1
);
79 layout3
->addLayout(layout2
);
80 QVBoxLayout
*layout4
= new QVBoxLayout
;
81 layout4
->addLayout(layout3
);
86 KeyBindingsTab::~KeyBindingsTab()
91 // Load / Update the tabs dialog from the settings
92 void KeyBindingsTab::GetSettings(void)
96 for (i
= 0; i
< NBKEYBINDINGS
; i
++)
98 KeyBindingsTable
[i
].KBLineEdit
->setText(vjs
.KBContent
[i
].KBSettingValue
);
103 // Save / Update the settings from the tabs dialog
104 void KeyBindingsTab::SetSettings(void)
108 for (i
= 0; i
< NBKEYBINDINGS
; i
++)
110 //strcpy(vjs.KBContent[i].KBSettingName, KeyBindingsTable[i].KBNameSetting);
111 strcpy(vjs
.KBContent
[i
].KBSettingValue
, KeyBindingsTable
[i
].KBLineEdit
->text().toUtf8().data());