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 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
}
32 #define NBKEYBINDINGS sizeof(KeyBindingsTable)/sizeof(KeyBindings)
36 KeyBindingsTab::KeyBindingsTab(QWidget
* parent
/*= 0*/): QWidget(parent
)
40 QVBoxLayout
*layout1
= new QVBoxLayout
;
41 QVBoxLayout
*layout2
= new QVBoxLayout
;
43 // Initialisation for each layout line
44 for (i
= 0; i
< NBKEYBINDINGS
; i
++)
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
);
52 // Check if keybinding can be editable
53 if (KeyBindingsTable
[i
].KBType
!= KB_TYPEGENERAL
)
55 if (vjs
.hardwareTypeAlpine
&& (KeyBindingsTable
[i
].KBType
& KB_TYPEALPINE
))
60 if (vjs
.softTypeDebugger
&& (KeyBindingsTable
[i
].KBType
& KB_TYPEDEBUGGER
))
65 KeyBindingsTable
[i
].KBLabel
->hide();
66 KeyBindingsTable
[i
].KBLineEdit
->hide();
73 QHBoxLayout
*layout3
= new QHBoxLayout
;
74 layout3
->addLayout(layout1
);
75 layout3
->addLayout(layout2
);
76 QVBoxLayout
*layout4
= new QVBoxLayout
;
77 layout4
->addLayout(layout3
);
82 KeyBindingsTab::~KeyBindingsTab()
87 // Load / Update the tabs dialog from the settings
88 void KeyBindingsTab::GetSettings(void)
92 for (i
= 0; i
< NBKEYBINDINGS
; i
++)
94 KeyBindingsTable
[i
].KBLineEdit
->setText(vjs
.KBContent
[i
].KBSettingValue
);
99 // Save / Update the settings from the tabs dialog
100 void KeyBindingsTab::SetSettings(void)
104 for (i
= 0; i
< NBKEYBINDINGS
; i
++)
106 //strcpy(vjs.KBContent[i].KBSettingName, KeyBindingsTable[i].KBNameSetting);
107 strcpy(vjs
.KBContent
[i
].KBSettingValue
, KeyBindingsTable
[i
].KBLineEdit
->text().toUtf8().data());