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
12 #include "keybindingstab.h"
17 KeyBindings KeyBindingsTable
[KB_END
] = {
18 { KB_TYPEGENERAL
, "KB_Quit", "Quit", "Quit key binding", "Ctrl+Q", NULL
, NULL
},
19 { KB_TYPEGENERAL
, "KB_PickFile", "Pick file", "Pick file key binding", "Ctrl+I", NULL
, NULL
},
20 { KB_TYPEGENERAL
, "KB_Configure", "Configure", "Configure key binding", "Ctrl+C", NULL
, NULL
},
21 { KB_TYPEGENERAL
, "KB_EmuStatus", "Emulator Status", "Emulator status key binding", "Ctrl+S", NULL
, NULL
},
22 { KB_TYPEGENERAL
, "KB_Pause", "Pause", "Pause key binding", "Esc", NULL
, NULL
},
23 { KB_TYPEGENERAL
, "KB_FrameAdvance", "Frame Advance", "Frame advance key binding", "F7", NULL
, NULL
},
24 { KB_TYPEGENERAL
, "KB_FullScreen", "Full Screen", "Full screen key binding", "F9", NULL
, NULL
},
25 { KB_TYPEGENERAL
, "KB_Screenshot", "Screenshot", "Screenshot key binding", "F8", NULL
, NULL
},
26 { KB_TYPEDEBUGGER
, "KB_Restart", "Restart", "Restart key binding", "Ctrl+Shift+F5", NULL
, NULL
},
27 { KB_TYPEDEBUGGER
, "KB_StepInto", "Step Into", "Step into key binding", "F11", NULL
, NULL
},
28 { KB_TYPEDEBUGGER
, "KB_StepOver", "Step Over", "Step over key binding", "F10", NULL
, NULL
}
33 #define NBKEYBINDINGS sizeof(KeyBindingsTable)/sizeof(KeyBindings)
37 KeyBindingsTab::KeyBindingsTab(QWidget
* parent
/*= 0*/): QWidget(parent
)
41 QVBoxLayout
*layout1
= new QVBoxLayout
;
42 QVBoxLayout
*layout2
= new QVBoxLayout
;
44 // Initialisation for each layout line
45 for (i
= 0; i
< NBKEYBINDINGS
; i
++)
47 // Prepare the keybinding line
48 layout1
->addWidget(KeyBindingsTable
[i
].KBLabel
= new QLabel(KeyBindingsTable
[i
].KBNameLabel
));
49 layout2
->addWidget(KeyBindingsTable
[i
].KBLineEdit
= new QLineEdit(""));
50 KeyBindingsTable
[i
].KBLineEdit
->setMaxLength(30);
51 KeyBindingsTable
[i
].KBLineEdit
->setPlaceholderText(KeyBindingsTable
[i
].KBPlaceholderText
);
53 // Check if keybinding can be editable
54 if (KeyBindingsTable
[i
].KBType
!= KB_TYPEGENERAL
)
56 if (vjs
.hardwareTypeAlpine
&& (KeyBindingsTable
[i
].KBType
& KB_TYPEALPINE
))
61 if (vjs
.softTypeDebugger
&& (KeyBindingsTable
[i
].KBType
& KB_TYPEDEBUGGER
))
66 KeyBindingsTable
[i
].KBLabel
->hide();
67 KeyBindingsTable
[i
].KBLineEdit
->hide();
74 QHBoxLayout
*layout3
= new QHBoxLayout
;
75 layout3
->addLayout(layout1
);
76 layout3
->addLayout(layout2
);
77 QVBoxLayout
*layout4
= new QVBoxLayout
;
78 layout4
->addLayout(layout3
);
83 KeyBindingsTab::~KeyBindingsTab()
88 // Load / Update the tabs dialog from the settings
89 void KeyBindingsTab::GetSettings(void)
93 for (i
= 0; i
< NBKEYBINDINGS
; i
++)
95 KeyBindingsTable
[i
].KBLineEdit
->setText(vjs
.KBContent
[i
].KBSettingValue
);
100 // Save / Update the settings from the tabs dialog
101 void KeyBindingsTab::SetSettings(void)
105 for (i
= 0; i
< NBKEYBINDINGS
; i
++)
107 //strcpy(vjs.KBContent[i].KBSettingName, KeyBindingsTable[i].KBNameSetting);
108 strcpy(vjs
.KBContent
[i
].KBSettingValue
, KeyBindingsTable
[i
].KBLineEdit
->text().toUtf8().data());