2 * Common Source code Project:
3 * Ui->Qt->gui->menu_main for generic.
4 * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
7 * Jan 14, 2015 : Initial, moved from qt/x1turboz/MainWindow.cpp .
10 #include <QtCore/QVariant>
14 #include <QImageReader>
17 #include "commonclasses.h"
18 #include "display_about.h"
19 #include "display_text_document.h"
20 #include "mainwidget.h"
21 #include "menuclasses.h"
22 #include "menu_disk.h"
24 #include "menu_cart.h"
25 #include "menu_quickdisk.h"
26 #include "menu_binary.h"
28 #include "qt_gldraw.h"
37 Ui_MainWindow::Ui_MainWindow(QWidget *parent) : QMainWindow(parent)
43 Ui_MainWindow::~Ui_MainWindow()
45 graphicsView->releaseKeyboard();
49 void Action_Control::do_check_grab_mouse(bool flag)
54 void Action_Control::do_send_string(void)
56 emit sig_send_string(bindString);
59 void Action_Control::do_set_string(QString s)
65 void Ui_MainWindow::do_show_about(void)
67 Dlg_AboutCSP *dlg = new Dlg_AboutCSP;
71 void Ui_MainWindow::do_browse_document(QString fname)
73 Dlg_BrowseText *dlg = new Dlg_BrowseText(fname);
78 void Ui_MainWindow::setupUi(void)
81 // QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
82 MainWindow = new QMainWindow();
83 if (MainWindow->objectName().isEmpty())
84 MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
85 //MainWindow->resize(1288, 862);
90 #if !defined(WITHOUT_SOUND)
93 #if defined(USE_BINARY_FILE1)
97 #if defined(USE_QD1) || defined(USE_QD2)
98 ConfigQuickDiskMenu();
102 #if defined(USE_CART1) || defined(USE_CART2)
106 actionAbout = new Action_Control(this);
107 actionAbout->setObjectName(QString::fromUtf8("actionAbout"));
109 graphicsView = new GLDrawClass(this);
110 graphicsView->setObjectName(QString::fromUtf8("graphicsView"));
111 graphicsView->setMaximumSize(2560, 2560); // ?
112 graphicsView->setMinimumSize(240, 192); // ?
113 //graphicsView->grabKeyboard();
114 graphicsView->setAttribute(Qt::WA_InputMethodEnabled, false); // Disable [Zenkaku / Hankaku] with IM.
115 graphicsView->setAttribute(Qt::WA_KeyboardFocusChange, false);
116 //graphicsView->setFocusPolicy(Qt::StrongFocus);
117 //this->setFocusPolicy(Qt::ClickFocus);
119 #if defined(USE_BITMAP)
122 MainWindow->setCentralWidget(graphicsView);
123 MainWindow->setFocusProxy(graphicsView);
125 MainWindow->centralWidget()->adjustSize();
126 MainWindow->adjustSize();
128 statusbar = new QStatusBar(this);
129 statusbar->setObjectName(QString::fromUtf8("statusbar"));
130 MainWindow->setStatusBar(statusbar);
133 menubar = new QMenuBar(this);
134 menubar->setObjectName(QString::fromUtf8("menubar"));
135 menubar->setGeometry(QRect(0, 0, 1288, 27));
136 menuControl = new QMenu(menubar);
137 menuControl->setObjectName(QString::fromUtf8("menuControl"));
138 menuState = new QMenu(menuControl);
139 menuState->setObjectName(QString::fromUtf8("menuState"));
141 menuCopy_Paste = new QMenu(menuControl);
142 menuCopy_Paste->setObjectName(QString::fromUtf8("menuCopy_Paste"));
144 menuCpu_Speed = new QMenu(menuControl);
145 menuCpu_Speed->setObjectName(QString::fromUtf8("menuCpu_Speed"));
146 menuDebugger = new QMenu(menuControl);
147 menuDebugger->setObjectName(QString::fromUtf8("menuDebugger"));
149 CreateFloppyMenu(0, 1);
152 CreateFloppyMenu(1, 2);
155 CreateFloppyMenu(2, 3);
158 CreateFloppyMenu(3, 4);
161 CreateFloppyMenu(4, 5);
164 CreateFloppyMenu(5, 6);
167 CreateFloppyMenu(6, 7);
170 CreateFloppyMenu(7, 8);
174 CreateQuickDiskMenu(0, 1);
177 CreateQuickDiskMenu(1, 2);
184 #if defined(USE_CART1)
185 CreateCartMenu(0, 1);
187 #if defined(USE_CART2)
188 CreateCartMenu(1, 2);
190 #if defined(USE_BINARY_FILE1)
191 CreateBinaryMenu(0, 1);
193 #if defined(USE_BINARY_FILE2)
194 CreateBinaryMenu(1, 2);
197 connect(this, SIGNAL(sig_update_screen(void)), graphicsView, SLOT(update(void)));
199 menuMachine = new QMenu(menubar);
200 menuMachine->setObjectName(QString::fromUtf8("menuMachine"));
201 actionMouseEnable = new Action_Control(this);
202 actionMouseEnable->setCheckable(true);
203 actionMouseEnable->setVisible(true);
204 actionMouseEnable->setChecked(false);
205 menuMachine->addAction(actionMouseEnable);
206 connect(actionMouseEnable, SIGNAL(toggled(bool)),
207 this, SLOT(do_set_mouse_enable(bool)));
208 connect(graphicsView, SIGNAL(sig_check_grab_mouse(bool)),
209 actionMouseEnable, SLOT(do_check_grab_mouse(bool)));
213 ConfigSoundDeviceType();
216 #if !defined(WITHOUT_SOUND)
217 menuSound = new QMenu(menubar);
218 menuSound->setObjectName(QString::fromUtf8("menuSound"));
220 menuEmulator = new QMenu(menubar);
221 menuEmulator->setObjectName(QString::fromUtf8("menuEmulator"));
222 menuHELP = new QMenu(menubar);
223 menuHELP->setObjectName(QString::fromUtf8("menuHELP"));
224 MainWindow->setMenuBar(menubar);
226 menubar->addAction(menuControl->menuAction());
227 connectActions_ControlMenu();
229 menubar->addAction(menu_fds[0]->menuAction());
232 menubar->addAction(menu_fds[1]->menuAction());
235 menubar->addAction(menu_fds[2]->menuAction());
238 menubar->addAction(menu_fds[3]->menuAction());
241 menubar->addAction(menu_fds[4]->menuAction());
244 menubar->addAction(menu_fds[5]->menuAction());
247 menubar->addAction(menu_fds[6]->menuAction());
250 menubar->addAction(menu_fds[7]->menuAction());
253 menubar->addAction(menu_QDs[0]->menuAction());
256 menubar->addAction(menu_QDs[1]->menuAction());
258 #if defined(USE_TAPE)
259 menubar->addAction(menu_CMT->menuAction());
261 #if defined(USE_CART1)
262 menubar->addAction(menu_Cart[0]->menuAction());
264 #if defined(USE_CART2)
265 menubar->addAction(menu_Cart[1]->menuAction());
267 #if defined(USE_BINARY_FILE1)
268 menubar->addAction(menu_BINs[0]->menuAction());
270 #if defined(USE_BINARY_FILE2)
271 menubar->addAction(menu_BINs[1]->menuAction());
273 menubar->addAction(menuMachine->menuAction());
275 #if !defined(WITHOUT_SOUND)
276 menubar->addAction(menuSound->menuAction());
278 menubar->addAction(menuScreen->menuAction());
279 // menubar->addAction(menuRecord->menuAction());
280 menubar->addAction(menuEmulator->menuAction());
281 menubar->addAction(menuHELP->menuAction());
283 CreateQuickDiskPulldownMenu(0);
286 CreateQuickDiskPulldownMenu(1);
288 #if defined(USE_BINARY_FILE1)
289 CreateBinaryPulldownMenu(0);
291 #if defined(USE_BINARY_FILE2)
292 CreateBinaryPulldownMenu(1);
294 #if !defined(WITHOUT_SOUND)
298 menuHELP->addAction(actionAbout);
299 connect(actionAbout, SIGNAL(triggered()), this, SLOT(do_show_about()));
300 menuHELP->addSeparator();
302 actionHelp_AboutQt = new Action_Control(this);
303 actionHelp_AboutQt->setObjectName(QString::fromUtf8("menuHelp_AboutQt"));
304 menuHELP->addAction(actionHelp_AboutQt);
305 menuHELP->addSeparator();
306 menuHelp_Readme = new QMenu(menuHELP);
307 menuHelp_Readme->setObjectName(QString::fromUtf8("menuHelp_Readme_menu"));;
308 menuHELP->addAction(menuHelp_Readme->menuAction());
310 actionHelp_README = new Action_Control(this);
311 actionHelp_README->setObjectName(QString::fromUtf8("menuHelp_README"));
312 actionHelp_README->do_set_string(QString::fromUtf8("readme.txt"));
313 connect(actionHelp_README, SIGNAL(triggered()), actionHelp_README, SLOT(do_send_string()));
314 connect(actionHelp_README, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
315 menuHelp_Readme->addAction(actionHelp_README);
317 actionHelp_README_QT = new Action_Control(this);
318 actionHelp_README_QT->setObjectName(QString::fromUtf8("menuHelp_README_QT"));
319 actionHelp_README_QT->do_set_string(QString::fromUtf8("readme.qt.txt"));
320 menuHelp_Readme->addAction(actionHelp_README_QT);
321 connect(actionHelp_README_QT, SIGNAL(triggered()), actionHelp_README_QT, SLOT(do_send_string()));
322 connect(actionHelp_README_QT, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
323 actionHelp_README_Artane = new Action_Control(this);
324 actionHelp_README_Artane->setObjectName(QString::fromUtf8("menuHelp_README_Artane"));
325 actionHelp_README_Artane->do_set_string(QString::fromUtf8("readme_by_artane.txt"));
326 connect(actionHelp_README_Artane, SIGNAL(triggered()), actionHelp_README_Artane, SLOT(do_send_string()));
327 connect(actionHelp_README_Artane, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
328 menuHelp_Readme->addAction(actionHelp_README_Artane);
329 menuHelp_Readme->addSeparator();
331 actionHelp_README_MR_TANAM = new Action_Control(this);
332 actionHelp_README_MR_TANAM->setObjectName(QString::fromUtf8("menuHelp_README_MR_TANAM"));
333 actionHelp_README_MR_TANAM->do_set_string(QString::fromUtf8("readme_by_mr_tanam.txt"));
334 connect(actionHelp_README_MR_TANAM, SIGNAL(triggered()), actionHelp_README_MR_TANAM, SLOT(do_send_string()));
335 connect(actionHelp_README_MR_TANAM, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
336 menuHelp_Readme->addAction(actionHelp_README_MR_TANAM);
338 menuHelp_Readme->addSeparator();
340 actionHelp_README_FM7 = new Action_Control(this);
341 actionHelp_README_FM7->setObjectName(QString::fromUtf8("menuHelp_README_FM7"));
342 actionHelp_README_FM7->do_set_string(QString::fromUtf8("readme_fm7.txt"));
343 connect(actionHelp_README_FM7, SIGNAL(triggered()), actionHelp_README_FM7, SLOT(do_send_string()));
344 connect(actionHelp_README_FM7, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
345 menuHelp_Readme->addAction(actionHelp_README_FM7);
347 actionHelp_README_FM7_JP = new Action_Control(this);
348 actionHelp_README_FM7_JP->setObjectName(QString::fromUtf8("menuHelp_README_FM7_JP"));
349 actionHelp_README_FM7_JP->do_set_string(QString::fromUtf8("readme_fm7.jp.txt"));
350 connect(actionHelp_README_FM7_JP, SIGNAL(triggered()), actionHelp_README_FM7_JP, SLOT(do_send_string()));
351 connect(actionHelp_README_FM7_JP, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
352 menuHelp_Readme->addAction(actionHelp_README_FM7_JP);
354 menuHelp_Histories = new QMenu(menuHELP);
355 menuHelp_Histories->setObjectName(QString::fromUtf8("menuHelp_Histories"));;
356 menuHELP->addAction(menuHelp_Histories->menuAction());
358 actionHelp_History = new Action_Control(this);
359 actionHelp_History->setObjectName(QString::fromUtf8("menuHelp_History"));
360 actionHelp_History->do_set_string(QString::fromUtf8("history.txt"));
361 connect(actionHelp_History, SIGNAL(triggered()), actionHelp_History, SLOT(do_send_string()));
362 connect(actionHelp_History, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
363 menuHelp_Histories->addAction(actionHelp_History);
365 actionHelp_History_Relnote = new Action_Control(this);
366 actionHelp_History_Relnote->setObjectName(QString::fromUtf8("menuHelp_History_Relnote"));
367 actionHelp_History_Relnote->do_set_string(QString::fromUtf8("RELEASENOTE.txt"));
368 connect(actionHelp_History_Relnote, SIGNAL(triggered()), actionHelp_History_Relnote, SLOT(do_send_string()));
369 connect(actionHelp_History_Relnote, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
370 menuHelp_Histories->addAction(actionHelp_History_Relnote);
372 actionHelp_History_ChangeLog = new Action_Control(this);
373 actionHelp_History_ChangeLog->setObjectName(QString::fromUtf8("menuHelp_History_ChangeLog"));
374 actionHelp_History_ChangeLog->do_set_string(QString::fromUtf8("ChangeLog.txt"));
375 connect(actionHelp_History_ChangeLog, SIGNAL(triggered()), actionHelp_History_ChangeLog, SLOT(do_send_string()));
376 connect(actionHelp_History_ChangeLog, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
377 menuHelp_Histories->addAction(actionHelp_History_ChangeLog);
379 actionHelp_History_MR_TANAM = new Action_Control(this);
380 actionHelp_History_MR_TANAM->setObjectName(QString::fromUtf8("menuHelp_History_MR_TANAM"));
381 actionHelp_History_MR_TANAM->do_set_string(QString::fromUtf8("history_by_mr_tanam.txt"));
382 connect(actionHelp_History_MR_TANAM, SIGNAL(triggered()), actionHelp_History_MR_TANAM, SLOT(do_send_string()));
383 connect(actionHelp_History_MR_TANAM, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
384 menuHelp_Histories->addAction(actionHelp_History_MR_TANAM);
386 actionHelp_License = new Action_Control(this);
387 actionHelp_License->setObjectName(QString::fromUtf8("menuHelp_License"));
388 actionHelp_License->do_set_string(QString::fromUtf8("LICENSE.txt"));
389 connect(actionHelp_License, SIGNAL(triggered()), actionHelp_License, SLOT(do_send_string()));
390 connect(actionHelp_License, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
391 menuHELP->addAction(actionHelp_License);
393 actionHelp_License_JP = new Action_Control(this);
394 actionHelp_License_JP->setObjectName(QString::fromUtf8("menuHelp_License_JP"));
395 actionHelp_License_JP->do_set_string(QString::fromUtf8("LICENSE.ja.txt"));
396 connect(actionHelp_License_JP, SIGNAL(triggered()), actionHelp_License_JP, SLOT(do_send_string()));
397 connect(actionHelp_License_JP, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
398 menuHELP->addAction(actionHelp_License_JP);
400 if(config.window_mode <= 0) config.window_mode = 0;
401 if(config.window_mode >= _SCREEN_MODE_NUM) config.window_mode = _SCREEN_MODE_NUM - 1;
404 if(actionScreenSize[config.window_mode] != NULL) {
405 double nd = actionScreenSize[config.window_mode]->binds->getDoubleValue();
406 w = (int)(nd * (double)w);
407 h = (int)(nd * (double)h);
408 #if defined(USE_SCREEN_ROTATE)
409 if(config.rotate_type) {
416 #if defined(USE_SCREEN_ROTATE)
417 if(config.rotate_type) {
427 graphicsView->setFixedSize(w, h);
428 for(int i = 0; i < _SCREEN_MODE_NUM; i++) {
429 if(actionScreenSize[i] != NULL) {
430 connect(actionScreenSize[i]->binds, SIGNAL(sig_screen_multiply(float)),
431 graphicsView, SLOT(do_set_screen_multiply(float)));
434 this->set_screen_size(w, h);
435 this->set_screen_aspect(config.stretch_type);
436 if(actionScreenSize[config.window_mode] != NULL) {
437 double nd = actionScreenSize[config.window_mode]->binds->getDoubleValue();
438 graphicsView->do_set_screen_multiply(nd);
441 QImageReader reader(":/default.ico");
442 QImage result = reader.read();
443 MainWindow->setWindowIcon(QPixmap::fromImage(result));
444 QMetaObject::connectSlotsByName(MainWindow);
448 void Ui_MainWindow::retranslateUI_Help(void)
450 menuHELP->setTitle(QApplication::translate("MainWindow", "HELP", 0));
451 actionHelp_AboutQt->setText(QApplication::translate("MainWindow", "About Qt", 0));
452 actionAbout->setText(QApplication::translate("MainWindow", "About...", 0));
454 menuHelp_Readme->setTitle(QApplication::translate("MainWindow", "READMEs", 0));
456 actionHelp_README->setText(QApplication::translate("MainWindow", "General Document", 0));
457 actionHelp_README_QT->setText(QApplication::translate("MainWindow", "About Qt ports", 0));
458 actionHelp_README_Artane->setText(QApplication::translate("MainWindow", "About Qt ports (Japanese).", 0));
459 actionHelp_README_MR_TANAM->setText(QApplication::translate("MainWindow", "By Mr. tanam", 0));
460 actionHelp_README_FM7->setText(QApplication::translate("MainWindow", "About eFM-7/8/77/AV.", 0));
461 actionHelp_README_FM7_JP->setText(QApplication::translate("MainWindow", "About eFM-7/8/77/AV (Japanese).", 0));
463 menuHelp_Histories->setTitle(QApplication::translate("MainWindow", "Histories", 0));
464 actionHelp_History->setText(QApplication::translate("MainWindow", "General History", 0));
465 actionHelp_History_Relnote->setText(QApplication::translate("MainWindow", "Release Note", 0));
466 actionHelp_History_ChangeLog->setText(QApplication::translate("MainWindow", "Change Log", 0));
467 actionHelp_History_MR_TANAM->setText(QApplication::translate("MainWindow", "History by Tanam", 0));
469 actionHelp_License->setText(QApplication::translate("MainWindow", "Show License", 0));
470 actionHelp_License_JP->setText(QApplication::translate("MainWindow", "Show License (Japanese)", 0));
474 // You can Override this function: Re-define on foo/MainWindow.cpp.
475 // This code is example: by X1(TurboZ).
476 void Ui_MainWindow::retranslateMachineMenu(void)
481 #if defined(USE_DEVICE_TYPE)
482 menuDeviceType->setTitle(QApplication::translate("MainWindow", "Device Type", 0));
483 for(i = 0; i < USE_DEVICE_TYPE; i++) {
485 tmps = QString::fromUtf8("Machine Device ") + tmps2;
486 actionDeviceType[i]->setText(tmps);
489 #if defined(USE_SOUND_DEVICE_TYPE)
490 menuSoundDevice->setTitle(QApplication::translate("MainWindow", "Sound Cards", 0));
491 for(i = 0; i < USE_SOUND_DEVICE_TYPE; i++) {
493 tmps = QString::fromUtf8("Sound Device ") + tmps2;
494 actionSoundDevice[i]->setText(tmps);
497 #if defined(USE_DRIVE_TYPE)
498 menuDriveType->setTitle(QApplication::translate("MainWindow", "Drive Type", 0));
499 for(i = 0; i < USE_DRIVE_TYPE; i++) {
501 tmps = QString::fromUtf8("Drive Type ") + tmps2;
502 actionDriveType[i]->setText(tmps);
505 #if defined(USE_PRINTER)
506 menuPrintDevice->setTitle(QApplication::translate("MainWindow", "Printer (Need RESET)", 0));
508 actionPrintDevice[0]->setText(QApplication::translate("MainWindow", "Dump to File", 0));
509 #if defined(USE_PRINTER_TYPE)
510 for(i = 1; i < (USE_PRINTER_TYPE - 1); i++) {
512 tmps = QApplication::translate("MainWindow", "Printer", 0) + tmps2;
513 actionPrintDevice[i]->setText(tmps);
516 actionPrintDevice[i]->setText(QApplication::translate("MainWindow", "Not connect", 0));
519 void Ui_MainWindow::retranslateUi(void)
521 retranslateControlMenu("NMI Reset", true);
522 retranslateFloppyMenu(0, 0);
523 retranslateFloppyMenu(1, 1);
524 retranslateCMTMenu();
525 #if !defined(WITHOUT_SOUND)
526 retranslateSoundMenu();
528 retranslateScreenMenu();
529 retranslateCartMenu(0, 1);
530 retranslateCartMenu(1, 2);
531 retranslateBinaryMenu(0, 1);
532 retranslateBinaryMenu(1, 2);
533 retranslateMachineMenu();
534 retranslateUI_Help();
536 this->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0));
539 menuEmulator->setTitle(QApplication::translate("MainWindow", "Emulator", 0));
540 menuMachine->setTitle(QApplication::translate("MainWindow", "Machine", 0));
543 void Ui_MainWindow::setCoreApplication(QApplication *p)
545 this->CoreApplication = p;
546 connect(actionExit_Emulator, SIGNAL(triggered()),
547 this->CoreApplication, SLOT(closeAllWindows())); // OnGuiExit()?
548 connect(actionHelp_AboutQt, SIGNAL(triggered()),
549 this->CoreApplication, SLOT(aboutQt()));