2 * Common Source Project/ Qt
3 * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
4 * History: Jan 10, 2015 : Initial
11 #include "commonclasses.h"
12 #include "mainwidget_base.h"
13 #include "menu_flags.h"
15 //extern USING_FLAGS *using_flags;
17 void Object_Menu_Control::set_boot_mode(void) {
18 emit on_boot_mode(bindValue);
21 void Object_Menu_Control::set_cpu_type(void) {
22 emit on_cpu_type(bindValue);
24 void Object_Menu_Control::set_cpupower(void) {
25 emit on_cpu_power(bindValue);
27 void Object_Menu_Control::open_debugger(void) {
28 emit on_open_debugger(bindValue);
30 void Object_Menu_Control::do_set_device_type(void){
31 emit sig_device_type(this->getValue1());
33 void Object_Menu_Control::do_set_printer_device(void){
34 emit sig_printer_device(this->getValue1());
36 void Object_Menu_Control::do_set_sound_device(void){
37 emit sig_sound_device(this->getValue1());
39 void Object_Menu_Control::do_set_drive_type(void)
41 emit sig_drive_type(getValue1());
44 void Ui_MainWindowBase::ConfigCpuSpeed(void)
46 actionSpeed_x1 = new Action_Control(this, using_flags);
47 actionSpeed_x1->setObjectName(QString::fromUtf8("actionSpeed_x1"));
48 actionSpeed_x1->setCheckable(true);
49 actionSpeed_x1->setChecked(true);
50 actionSpeed_x1->binds->setValue1(0);
51 connect(actionSpeed_x1, SIGNAL(triggered()), actionSpeed_x1->binds, SLOT(set_cpupower())); // OK?
52 connect(actionSpeed_x1->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK?
54 actionSpeed_x2 = new Action_Control(this, using_flags);
55 actionSpeed_x2->setObjectName(QString::fromUtf8("actionSpeed_x2"));
56 actionSpeed_x2->setCheckable(true);
57 actionSpeed_x2->binds->setValue1(1);
58 connect(actionSpeed_x2, SIGNAL(triggered()), actionSpeed_x2->binds, SLOT(set_cpupower())); // OK?
59 connect(actionSpeed_x2->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK?
61 actionSpeed_x4 = new Action_Control(this, using_flags);
62 actionSpeed_x4->setObjectName(QString::fromUtf8("actionSpeed_x4"));
63 actionSpeed_x4->setCheckable(true);
64 actionSpeed_x4->binds->setValue1(2);
65 connect(actionSpeed_x4, SIGNAL(triggered()), actionSpeed_x4->binds, SLOT(set_cpupower())); // OK?
66 connect(actionSpeed_x4->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK?
68 actionSpeed_x8 = new Action_Control(this, using_flags);
69 actionSpeed_x8->setObjectName(QString::fromUtf8("actionSpeed_x8"));
70 actionSpeed_x8->setCheckable(true);
71 actionSpeed_x8->binds->setValue1(3);
72 connect(actionSpeed_x8, SIGNAL(triggered()), actionSpeed_x8->binds, SLOT(set_cpupower())); // OK?
73 connect(actionSpeed_x8->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK?
75 actionSpeed_x16 = new Action_Control(this, using_flags);
76 actionSpeed_x16->setObjectName(QString::fromUtf8("actionSpeed_x16"));
77 actionSpeed_x16->setCheckable(true);
78 actionSpeed_x16->binds->setValue1(4);
79 connect(actionSpeed_x16, SIGNAL(triggered()), actionSpeed_x16->binds, SLOT(set_cpupower())); // OK?
80 connect(actionSpeed_x16->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK?
82 actionGroup_CpuSpeed = new QActionGroup(this);
83 actionGroup_CpuSpeed->setExclusive(true);
84 actionGroup_CpuSpeed->addAction(actionSpeed_x1);
85 actionGroup_CpuSpeed->addAction(actionSpeed_x2);
86 actionGroup_CpuSpeed->addAction(actionSpeed_x4);
87 actionGroup_CpuSpeed->addAction(actionSpeed_x8);
88 actionGroup_CpuSpeed->addAction(actionSpeed_x16);
90 void Ui_MainWindowBase::do_change_boot_mode(int mode)
92 if((mode < 0) || (mode >= 8)) return;
93 using_flags->get_config_ptr()->boot_mode = mode;
94 emit sig_emu_update_config();
99 void Ui_MainWindowBase::ConfigCPUBootMode(int num)
104 if(num >= 8) num = 7;
106 actionGroup_BootMode = new QActionGroup(this);
107 actionGroup_BootMode->setExclusive(true);
108 for(i = 0; i < num; i++) {
109 actionBootMode[i] = new Action_Control(this, using_flags);
110 tmps = tmps.setNum(i);
111 tmps = QString::fromUtf8("actionBootMode_") + tmps;
112 actionBootMode[i]->setObjectName(tmps);
113 actionBootMode[i]->setCheckable(true);
114 if(i == using_flags->get_config_ptr()->boot_mode) actionBootMode[i]->setChecked(true);
115 actionBootMode[i]->binds->setValue1(i);
116 menuBootMode->addAction(actionBootMode[i]);
117 actionGroup_BootMode->addAction(actionBootMode[i]);
118 connect(actionBootMode[i], SIGNAL(triggered()), actionBootMode[i]->binds, SLOT(set_boot_mode())); // OK?
119 connect(actionBootMode[i]->binds, SIGNAL(on_boot_mode(int)), this, SLOT(do_change_boot_mode(int))); // OK?
123 void Ui_MainWindowBase::do_change_cpu_type(int mode)
125 if((mode < 0) || (mode >= 8)) return;
126 using_flags->get_config_ptr()->cpu_type = mode;
127 emit sig_emu_update_config();
130 void Ui_MainWindowBase::ConfigCPUTypes(int num)
135 if(num >= 8) num = 7;
137 actionGroup_CpuType = new QActionGroup(this);
138 actionGroup_CpuType->setExclusive(true);
139 for(i = 0; i < num; i++) {
140 actionCpuType[i] = new Action_Control(this, using_flags);
141 tmps = tmps.setNum(i);
142 tmps = QString::fromUtf8("actionCpuType_") + tmps;
143 actionCpuType[i]->setObjectName(tmps);
144 actionCpuType[i]->setCheckable(true);
145 if(i == using_flags->get_config_ptr()->cpu_type) actionCpuType[i]->setChecked(true);
146 actionCpuType[i]->binds->setValue1(i);
147 menuCpuType->addAction(actionCpuType[i]);
148 actionGroup_CpuType->addAction(actionCpuType[i]);
149 connect(actionCpuType[i], SIGNAL(triggered()), actionCpuType[i]->binds, SLOT(set_cpu_type())); // OK?
150 connect(actionCpuType[i]->binds, SIGNAL(on_cpu_type(int)), this, SLOT(do_change_cpu_type(int))); // OK?
154 void Ui_MainWindowBase::ConfigControlMenu(void)
157 actionReset = new Action_Control(this, using_flags);
158 actionReset->setObjectName(QString::fromUtf8("actionReset"));
159 connect(actionReset, SIGNAL(triggered()),
160 this, SLOT(OnReset())); // OK?
161 if(using_flags->is_use_special_reset()) {
162 actionSpecial_Reset = new Action_Control(this, using_flags);
163 actionSpecial_Reset->setObjectName(QString::fromUtf8("actionSpecial_Reset"));
164 connect(actionSpecial_Reset, SIGNAL(triggered()),
165 this, SLOT(OnSpecialReset())); // OK?
168 actionExit_Emulator = new Action_Control(this, using_flags);
169 actionExit_Emulator->setObjectName(QString::fromUtf8("actionExit_Emulator"));
170 //connect(actionExit_Emulator, SIGNAL(triggered()),
171 // this, SLOT(on_actionExit_triggered())); // OnGuiExit()?
173 if(using_flags->is_use_auto_key()) {
174 actionPaste_from_Clipboard = new Action_Control(this, using_flags);
175 actionPaste_from_Clipboard->setObjectName(QString::fromUtf8("actionPaste_from_Clipboard"));
176 connect(actionPaste_from_Clipboard, SIGNAL(triggered()),
177 this, SLOT(OnStartAutoKey())); // OK?
178 actionStop_Pasting = new Action_Control(this, using_flags);
179 actionStop_Pasting->setObjectName(QString::fromUtf8("actionStop_Pasting"));
180 connect(actionStop_Pasting, SIGNAL(triggered()),
181 this, SLOT(OnStopAutoKey())); // OK?
183 if(using_flags->is_use_state()) {
184 actionSave_State = new Action_Control(this, using_flags);
185 actionSave_State->setObjectName(QString::fromUtf8("actionSave_State"));
186 connect(actionSave_State, SIGNAL(triggered()),
187 this, SLOT(OnSaveState())); // OK?
189 actionLoad_State = new Action_Control(this, using_flags);
190 actionLoad_State->setObjectName(QString::fromUtf8("actionLoad_State"));
191 connect(actionLoad_State, SIGNAL(triggered()),
192 this, SLOT(OnLoadState())); // OK?
194 if(using_flags->is_use_debugger()) {
195 for(i = 0; i < _MAX_DEBUGGER; i++) {
198 actionDebugger[i] = new Action_Control(this, using_flags);
199 actionDebugger[i]->setObjectName(QString::fromUtf8("actionDebugger") + tmps);
200 actionDebugger[i]->binds->setValue1(i);
201 connect(actionDebugger[i], SIGNAL(triggered()),
202 actionDebugger[i]->binds, SLOT(open_debugger())); // OK?
203 connect(actionDebugger[i]->binds, SIGNAL(on_open_debugger(int)),
204 this, SLOT(OnOpenDebugger(int))); // OK?
210 void Ui_MainWindowBase::connectActions_ControlMenu(void)
212 menuControl->addAction(actionReset);
213 if(using_flags->is_use_special_reset()) {
214 menuControl->addAction(actionSpecial_Reset);
216 menuControl->addSeparator();
217 menuControl->addAction(menuCpu_Speed->menuAction());
219 if(using_flags->is_use_auto_key()) {
220 menuControl->addSeparator();
221 menuControl->addAction(menuCopy_Paste->menuAction());
223 menuControl->addSeparator();
224 menuControl->addAction(menuState->menuAction());
226 if(using_flags->is_use_debugger()) {
227 menuControl->addAction(menuDebugger->menuAction());
229 menuControl->addSeparator();
230 menuControl->addAction(actionExit_Emulator);
232 if(using_flags->is_use_state()) {
233 menuState->addAction(actionSave_State);
234 menuState->addSeparator();
235 menuState->addAction(actionLoad_State);
238 if(using_flags->is_use_auto_key()) {
239 menuCopy_Paste->addAction(actionPaste_from_Clipboard);
240 menuCopy_Paste->addAction(actionStop_Pasting);
242 menuCpu_Speed->addAction(actionSpeed_x1);
243 menuCpu_Speed->addAction(actionSpeed_x2);
244 menuCpu_Speed->addAction(actionSpeed_x4);
245 menuCpu_Speed->addAction(actionSpeed_x8);
246 menuCpu_Speed->addAction(actionSpeed_x16);
248 if(using_flags->is_use_debugger()) {
250 for(i = 0; i < _MAX_DEBUGGER; i++) {
251 menuDebugger->addAction(actionDebugger[i]);
252 if(i > 0) actionDebugger[i]->setVisible(false);
257 void Ui_MainWindowBase::createContextMenu(void)
259 addAction(actionReset);
261 if(using_flags->is_use_special_reset()) {
262 addAction(actionSpecial_Reset);
264 addAction(menuCpu_Speed->menuAction());
266 if(using_flags->is_use_auto_key()) {
267 addAction(menuCopy_Paste->menuAction());
269 addAction(menuState->menuAction());
271 if(using_flags->is_use_debugger()) {
272 addAction(menuDebugger->menuAction());
274 addAction(actionExit_Emulator);
278 void Ui_MainWindowBase::retranslateControlMenu(const char *SpecialResetTitle, bool WithSpecialReset)
280 actionReset->setText(QApplication::translate("MainWindow", "Reset", 0));
281 actionReset->setToolTip(QApplication::translate("MainWindow", "Reset virtual machine.", 0));
282 actionReset->setIcon(ResetIcon);
283 if(using_flags->is_use_special_reset()) {
284 actionSpecial_Reset->setText(QApplication::translate("MainWindow", SpecialResetTitle, 0));
285 actionSpecial_Reset->setIcon(QIcon(":/icon_reset.png"));
288 actionExit_Emulator->setText(QApplication::translate("MainWindow", "Exit Emulator", 0));
289 actionExit_Emulator->setToolTip(QApplication::translate("MainWindow", "Exit emulator.\n**WARN: WITHOUT confirming.**", 0));
290 actionExit_Emulator->setIcon(ExitIcon);
292 actionSpeed_x1->setText(QApplication::translate("MainWindow", "Speed x1", 0));
293 actionSpeed_x2->setText(QApplication::translate("MainWindow", "Speed x2", 0));
294 actionSpeed_x4->setText(QApplication::translate("MainWindow", "Speed x4", 0));
295 actionSpeed_x8->setText(QApplication::translate("MainWindow", "Speed x8", 0));
296 actionSpeed_x16->setText(QApplication::translate("MainWindow", "Speed x16", 0));
298 if(using_flags->is_use_auto_key()) {
299 actionPaste_from_Clipboard->setText(QApplication::translate("MainWindow", "Paste from Clipboard", 0));
300 actionPaste_from_Clipboard->setToolTip(QApplication::translate("MainWindow", "Paste ANK text to virtual machine from desktop's clop board.", 0));
301 actionPaste_from_Clipboard->setIcon(QIcon(":/icon_paste.png"));
302 actionStop_Pasting->setText(QApplication::translate("MainWindow", "Stop Pasting", 0));
303 actionStop_Pasting->setToolTip(QApplication::translate("MainWindow", "Abort pasting ANK text to virtual machine.", 0));
304 actionStop_Pasting->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton));
306 if(using_flags->is_use_state()) {
307 actionSave_State->setText(QApplication::translate("MainWindow", "Save State", 0));
308 actionSave_State->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogSaveButton));
309 actionSave_State->setToolTip(QApplication::translate("MainWindow", "Save snapshot to fixed bin file.", 0));
310 actionLoad_State->setText(QApplication::translate("MainWindow", "Load State", 0));
311 actionLoad_State->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogOpenButton));
312 actionLoad_State->setToolTip(QApplication::translate("MainWindow", "Load snapshot from fixed bin file.", 0));
314 if(using_flags->is_use_debugger()) {
315 actionDebugger[0]->setText(QApplication::translate("MainWindow", "Main CPU", 0));
316 actionDebugger[1]->setText(QApplication::translate("MainWindow", "Sub CPU", 0));
317 actionDebugger[2]->setText(QApplication::translate("MainWindow", "Debugger 3", 0));
318 actionDebugger[3]->setText(QApplication::translate("MainWindow", "Debugger 4", 0));
319 menuDebugger->setTitle(QApplication::translate("MainWindow", "Debugger", 0));
321 menuControl->setTitle(QApplication::translate("MainWindow", "Control", 0));
322 menuState->setTitle(QApplication::translate("MainWindow", "State", 0));
324 if(using_flags->is_use_auto_key()) {
325 menuCopy_Paste->setTitle(QApplication::translate("MainWindow", "Copy/Paste", 0));
327 menuCpu_Speed->setTitle(QApplication::translate("MainWindow", "CPU Speed", 0));
328 if(using_flags->is_use_mouse()) {
329 actionMouseEnable->setText(QApplication::translate("MainWindow", "Grab MOUSE", 0));
330 actionMouseEnable->setToolTip(QApplication::translate("MainWindow", "Grabbing host's mouse.\nPress RIGHT Application key (or another) to toggle enable/disable.", 0));
334 void Ui_MainWindowBase::do_set_sound_device(int num)
336 if((num < 0) || (num >= using_flags->get_use_sound_device_type())) return;
337 using_flags->get_config_ptr()->sound_device_type = num;
338 emit sig_emu_update_config();