OSDN Git Service

[UI][Qt][HELP] Add credits and Documantation browser.
[csp-qt/common_source_project-fm7.git] / source / src / qt / gui / menu_main.cpp
1 /*
2  * Common Source code Project:
3  * Ui->Qt->gui->menu_main for generic.
4  * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
5  *   License : GPLv2
6  *   History :
7  * Jan 14, 2015 : Initial, moved from qt/x1turboz/MainWindow.cpp .
8  */
9
10 #include <QtCore/QVariant>
11 #include <QtGui>
12 #include <QIcon>
13 #include <QImage>
14 #include <QImageReader>
15 #include <QPixmap>
16
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 "qt_gldraw.h"
23 #include "emu.h"
24 #include "qt_main.h"
25
26
27 extern EMU *emu;
28
29 QT_BEGIN_NAMESPACE
30
31 Ui_MainWindow::Ui_MainWindow(QWidget *parent) : QMainWindow(parent)
32 {
33         setupUi();
34         createContextMenu();
35 }
36
37 Ui_MainWindow::~Ui_MainWindow()
38 {
39 }
40
41 void Action_Control::do_check_grab_mouse(bool flag)
42 {
43         this->toggle();
44 }
45
46 void Action_Control::do_send_string(void)
47 {
48         emit sig_send_string(bindString);
49 }
50
51 void Action_Control::do_set_string(QString s)
52 {
53         bindString = s;
54 }
55
56
57 void Ui_MainWindow::do_show_about(void)
58 {
59         Dlg_AboutCSP *dlg = new Dlg_AboutCSP;
60         dlg->show();
61 }
62
63 void Ui_MainWindow::do_browse_document(QString fname)
64 {
65         Dlg_BrowseText *dlg = new Dlg_BrowseText(fname);
66         dlg->show();
67 }
68
69
70 void Ui_MainWindow::setupUi(void)
71 {
72         int w, h;
73         //   QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
74         MainWindow = new QMainWindow();
75         if (MainWindow->objectName().isEmpty())
76                 MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
77         //MainWindow->resize(1288, 862);
78    
79         ConfigControlMenu();
80         ConfigFloppyMenu();
81         ConfigCMTMenu();
82 #if !defined(WITHOUT_SOUND)     
83         ConfigSoundMenu();
84 #endif  
85 #if defined(USE_BINARY_FILE1)
86         ConfigBinaryMenu(); 
87 #endif
88
89 #if defined(USE_QD1) || defined(USE_QD2)
90         ConfigQuickDiskMenu();
91 #endif
92
93         ConfigScreenMenu();
94 #if defined(USE_CART1) || defined(USE_CART2)
95         ConfigCartMenu();
96 #endif
97         
98         actionAbout = new Action_Control(this);
99         actionAbout->setObjectName(QString::fromUtf8("actionAbout"));
100
101    
102         graphicsView = new GLDrawClass(this);
103         graphicsView->setObjectName(QString::fromUtf8("graphicsView"));
104         graphicsView->setMaximumSize(2560, 2560); // ?
105         graphicsView->setMinimumSize(240, 192); // ?
106         ///graphicsView->setAttribute(Qt::WA_InputMethodEnabled, false); // Disable [Zenkaku / Hankaku] with IM.
107    
108 #if defined(USE_BITMAP)
109         bitmapImage = NULL;
110 #endif   
111         MainWindow->setCentralWidget(graphicsView);
112         
113         MainWindow->centralWidget()->adjustSize();
114         MainWindow->adjustSize();
115         //MainWindow->setAttribute(Qt::WA_InputMethodEnabled, false); // Disable [Zenkaku / Hankaku] with IM.
116
117         statusbar = new QStatusBar(this);
118         statusbar->setObjectName(QString::fromUtf8("statusbar"));
119         MainWindow->setStatusBar(statusbar);
120         initStatusBar();
121         
122         menubar = new QMenuBar(this);
123         menubar->setObjectName(QString::fromUtf8("menubar"));
124         menubar->setGeometry(QRect(0, 0, 1288, 27));
125         menuControl = new QMenu(menubar);
126         menuControl->setObjectName(QString::fromUtf8("menuControl"));
127         menuState = new QMenu(menuControl);
128         menuState->setObjectName(QString::fromUtf8("menuState"));
129         menuCopy_Paste = new QMenu(menuControl);
130         menuCopy_Paste->setObjectName(QString::fromUtf8("menuCopy_Paste"));
131         menuCpu_Speed = new QMenu(menuControl);
132         menuCpu_Speed->setObjectName(QString::fromUtf8("menuCpu_Speed"));
133         menuDebugger = new QMenu(menuControl);
134         menuDebugger->setObjectName(QString::fromUtf8("menuDebugger"));
135 #ifdef USE_FD1  
136         CreateFloppyMenu(0, 1);
137 #endif
138 #ifdef USE_FD2  
139         CreateFloppyMenu(1, 2);
140 #endif
141 #ifdef USE_FD3  
142         CreateFloppyMenu(2, 3);
143 #endif
144 #ifdef USE_FD4  
145         CreateFloppyMenu(3, 4);
146 #endif
147 #ifdef USE_FD5  
148         CreateFloppyMenu(4, 5);
149 #endif
150 #ifdef USE_FD6  
151         CreateFloppyMenu(5, 6);
152 #endif
153 #ifdef USE_FD7  
154         CreateFloppyMenu(6, 7);
155 #endif
156 #ifdef USE_FD8  
157         CreateFloppyMenu(7, 8);
158 #endif
159
160 #if defined(USE_QD1)
161         CreateQuickDiskMenu(0, 1);
162 #endif
163 #if defined(USE_QD2)
164         CreateQuickDiskMenu(1, 2);
165 #endif
166 #ifdef USE_TAPE
167         CreateCMTMenu();
168 #endif
169
170         CreateScreenMenu();
171 #if defined(USE_CART1)
172         CreateCartMenu(0, 1);
173 #endif
174 #if defined(USE_CART2)
175         CreateCartMenu(1, 2);
176 #endif
177 #if defined(USE_BINARY_FILE1)
178         CreateBinaryMenu(0, 1);
179 #endif
180 #if defined(USE_BINARY_FILE2)
181         CreateBinaryMenu(1, 2);
182 #endif
183         
184         menuMachine = new QMenu(menubar);
185         menuMachine->setObjectName(QString::fromUtf8("menuMachine"));
186         actionMouseEnable = new Action_Control(this);
187         actionMouseEnable->setCheckable(true);
188         actionMouseEnable->setVisible(true);
189         actionMouseEnable->setChecked(false);
190         menuMachine->addAction(actionMouseEnable);
191         connect(actionMouseEnable, SIGNAL(toggled(bool)),
192                 this, SLOT(do_set_mouse_enable(bool)));
193         connect(graphicsView, SIGNAL(sig_check_grab_mouse(bool)),
194                 actionMouseEnable, SLOT(do_check_grab_mouse(bool)));
195         
196         ConfigDeviceType();
197         ConfigDriveType();
198         ConfigSoundDeviceType();
199
200 #if !defined(WITHOUT_SOUND)     
201         menuSound = new QMenu(menubar);
202         menuSound->setObjectName(QString::fromUtf8("menuSound"));
203 #endif
204         menuEmulator = new QMenu(menubar);
205         menuEmulator->setObjectName(QString::fromUtf8("menuEmulator"));
206         menuHELP = new QMenu(menubar);
207         menuHELP->setObjectName(QString::fromUtf8("menuHELP"));
208         MainWindow->setMenuBar(menubar);
209
210         menubar->addAction(menuControl->menuAction());
211         connectActions_ControlMenu();
212 #if defined(USE_FD1)
213         menubar->addAction(menuFD[0]->menuAction());
214 #endif
215 #if defined(USE_FD2)
216         menubar->addAction(menuFD[1]->menuAction());
217 #endif
218 #if defined(USE_FD3)
219         menubar->addAction(menuFD[2]->menuAction());
220 #endif
221 #if defined(USE_FD4)
222         menubar->addAction(menuFD[3]->menuAction());
223 #endif
224 #if defined(USE_FD5)
225         menubar->addAction(menuFD[4]->menuAction());
226 #endif
227 #if defined(USE_FD6)
228         menubar->addAction(menuFD[5]->menuAction());
229 #endif
230 #if defined(USE_FD7)
231         menubar->addAction(menuFD[6]->menuAction());
232 #endif
233 #if defined(USE_FD8)
234         menubar->addAction(menuFD[7]->menuAction());
235 #endif
236 #if defined(USE_QD1)
237         menubar->addAction(menuQD[0]->menuAction());
238 #endif
239 #if defined(USE_QD2)
240         menubar->addAction(menuQD[1]->menuAction());
241 #endif
242 #if defined(USE_TAPE)
243         menubar->addAction(menuCMT->menuAction());
244 #endif
245 #if defined(USE_CART1)
246         menubar->addAction(menuCART[0]->menuAction());
247 #endif
248 #if defined(USE_CART2)
249         menubar->addAction(menuCART[1]->menuAction());
250 #endif
251 #if defined(USE_BINARY_FILE1)
252         menubar->addAction(menuBIN[0]->menuAction());
253 #endif
254 #if defined(USE_BINARY_FILE2)
255         menubar->addAction(menuBIN[1]->menuAction());
256 #endif
257         menubar->addAction(menuMachine->menuAction());
258         
259 #if !defined(WITHOUT_SOUND)     
260         menubar->addAction(menuSound->menuAction());
261 #endif   
262         menubar->addAction(menuScreen->menuAction());
263 //      menubar->addAction(menuRecord->menuAction());
264         menubar->addAction(menuEmulator->menuAction());
265         menubar->addAction(menuHELP->menuAction());
266 #if defined(USE_FD1)
267         CreateFloppyPulldownMenu(0);
268 #endif
269 #if defined(USE_FD2)
270         CreateFloppyPulldownMenu(1);
271 #endif
272 #if defined(USE_FD3)
273         CreateFloppyPulldownMenu(2);
274 #endif
275 #if defined(USE_FD4)
276         CreateFloppyPulldownMenu(3);
277 #endif
278 #if defined(USE_FD5)
279         CreateFloppyPulldownMenu(4);
280 #endif
281 #if defined(USE_FD6)
282         CreateFloppyPulldownMenu(5);
283 #endif
284 #if defined(USE_FD7)
285         CreateFloppyPulldownMenu(6);
286 #endif
287 #if defined(USE_FD8)
288         CreateFloppyPulldownMenu(7);
289 #endif
290 #ifdef USE_TAPE
291         CreateCMTPulldownMenu();
292 #endif
293 #if defined(USE_QD1)
294         CreateQuickDiskPulldownMenu(0);
295 #endif
296 #if defined(USE_QD2)
297         CreateQuickDiskPulldownMenu(1);
298 #endif
299 #if defined(USE_CART1)
300         CreateCartPulldownMenu(0);
301 #endif
302 #if defined(USE_CART2)
303         CreateCartPulldownMenu(1);
304 #endif
305 #if defined(USE_BINARY_FILE1)
306         CreateBinaryPulldownMenu(0);
307 #endif
308 #if defined(USE_BINARY_FILE2)
309         CreateBinaryPulldownMenu(1);
310 #endif
311 #if !defined(WITHOUT_SOUND)     
312         CreateSoundMenu();
313 #endif
314   
315         menuHELP->addAction(actionAbout);
316         connect(actionAbout, SIGNAL(triggered()), this, SLOT(do_show_about()));
317         menuHELP->addSeparator();
318         
319         actionHelp_AboutQt = new Action_Control(this);
320         actionHelp_AboutQt->setObjectName(QString::fromUtf8("menuHelp_AboutQt"));
321         menuHELP->addAction(actionHelp_AboutQt);
322         menuHELP->addSeparator();
323         menuHelp_Readme = new QMenu(menuHELP);
324         menuHelp_Readme->setObjectName(QString::fromUtf8("menuHelp_Readme_menu"));;
325         menuHELP->addAction(menuHelp_Readme->menuAction());
326
327         actionHelp_README = new Action_Control(this);
328         actionHelp_README->setObjectName(QString::fromUtf8("menuHelp_README"));
329         actionHelp_README->do_set_string(QString::fromUtf8("readme.txt"));
330         connect(actionHelp_README, SIGNAL(triggered()), actionHelp_README, SLOT(do_send_string()));
331         connect(actionHelp_README, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
332         menuHelp_Readme->addAction(actionHelp_README);
333         
334         actionHelp_README_QT = new Action_Control(this);
335         actionHelp_README_QT->setObjectName(QString::fromUtf8("menuHelp_README_QT"));
336         actionHelp_README_QT->do_set_string(QString::fromUtf8("readme.qt.txt"));
337         menuHelp_Readme->addAction(actionHelp_README_QT);
338         connect(actionHelp_README_QT, SIGNAL(triggered()), actionHelp_README_QT, SLOT(do_send_string()));
339         connect(actionHelp_README_QT, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
340         actionHelp_README_Artane = new Action_Control(this);
341         actionHelp_README_Artane->setObjectName(QString::fromUtf8("menuHelp_README_Artane"));
342         actionHelp_README_Artane->do_set_string(QString::fromUtf8("readme_by_artane.txt"));
343         connect(actionHelp_README_Artane, SIGNAL(triggered()), actionHelp_README_Artane, SLOT(do_send_string()));
344         connect(actionHelp_README_Artane, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
345         menuHelp_Readme->addAction(actionHelp_README_Artane);
346         menuHelp_Readme->addSeparator();
347         
348         actionHelp_README_MR_TANAM = new Action_Control(this);
349         actionHelp_README_MR_TANAM->setObjectName(QString::fromUtf8("menuHelp_README_MR_TANAM"));
350         actionHelp_README_MR_TANAM->do_set_string(QString::fromUtf8("readme_by_mr_tanam.txt"));
351         connect(actionHelp_README_MR_TANAM, SIGNAL(triggered()), actionHelp_README_MR_TANAM, SLOT(do_send_string()));
352         connect(actionHelp_README_MR_TANAM, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
353         menuHelp_Readme->addAction(actionHelp_README_MR_TANAM);
354         
355         menuHelp_Readme->addSeparator();
356         
357         actionHelp_README_FM7 = new Action_Control(this);
358         actionHelp_README_FM7->setObjectName(QString::fromUtf8("menuHelp_README_FM7"));
359         actionHelp_README_FM7->do_set_string(QString::fromUtf8("readme_fm7.txt"));
360         connect(actionHelp_README_FM7, SIGNAL(triggered()), actionHelp_README_FM7, SLOT(do_send_string()));
361         connect(actionHelp_README_FM7, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
362         menuHelp_Readme->addAction(actionHelp_README_FM7);
363         
364         actionHelp_README_FM7_JP = new Action_Control(this);
365         actionHelp_README_FM7_JP->setObjectName(QString::fromUtf8("menuHelp_README_FM7_JP"));
366         actionHelp_README_FM7_JP->do_set_string(QString::fromUtf8("readme_fm7.jp.txt"));
367         connect(actionHelp_README_FM7_JP, SIGNAL(triggered()), actionHelp_README_FM7_JP, SLOT(do_send_string()));
368         connect(actionHelp_README_FM7_JP, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
369         menuHelp_Readme->addAction(actionHelp_README_FM7_JP);
370
371         menuHelp_Histories = new QMenu(menuHELP);
372         menuHelp_Histories->setObjectName(QString::fromUtf8("menuHelp_Histories"));;
373         menuHELP->addAction(menuHelp_Histories->menuAction());
374
375         actionHelp_History = new Action_Control(this);
376         actionHelp_History->setObjectName(QString::fromUtf8("menuHelp_History"));
377         actionHelp_History->do_set_string(QString::fromUtf8("history.txt"));
378         connect(actionHelp_History, SIGNAL(triggered()), actionHelp_History, SLOT(do_send_string()));
379         connect(actionHelp_History, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
380         menuHelp_Histories->addAction(actionHelp_History);
381         
382         actionHelp_History_Relnote = new Action_Control(this);
383         actionHelp_History_Relnote->setObjectName(QString::fromUtf8("menuHelp_History_Relnote"));
384         actionHelp_History_Relnote->do_set_string(QString::fromUtf8("RELEASENOTE.txt"));
385         connect(actionHelp_History_Relnote, SIGNAL(triggered()), actionHelp_History_Relnote, SLOT(do_send_string()));
386         connect(actionHelp_History_Relnote, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
387         menuHelp_Histories->addAction(actionHelp_History_Relnote);
388         
389         actionHelp_History_ChangeLog = new Action_Control(this);
390         actionHelp_History_ChangeLog->setObjectName(QString::fromUtf8("menuHelp_History_ChangeLog"));
391         actionHelp_History_ChangeLog->do_set_string(QString::fromUtf8("ChangeLog.txt"));
392         connect(actionHelp_History_ChangeLog, SIGNAL(triggered()), actionHelp_History_ChangeLog, SLOT(do_send_string()));
393         connect(actionHelp_History_ChangeLog, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
394         menuHelp_Histories->addAction(actionHelp_History_ChangeLog);
395
396         actionHelp_History_MR_TANAM = new Action_Control(this);
397         actionHelp_History_MR_TANAM->setObjectName(QString::fromUtf8("menuHelp_History_MR_TANAM"));
398         actionHelp_History_MR_TANAM->do_set_string(QString::fromUtf8("history_by_mr_tanam.txt"));
399         connect(actionHelp_History_MR_TANAM, SIGNAL(triggered()), actionHelp_History_MR_TANAM, SLOT(do_send_string()));
400         connect(actionHelp_History_MR_TANAM, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
401         menuHelp_Histories->addAction(actionHelp_History_MR_TANAM);
402         
403         actionHelp_License = new Action_Control(this);
404         actionHelp_License->setObjectName(QString::fromUtf8("menuHelp_License"));
405         actionHelp_License->do_set_string(QString::fromUtf8("LICENSE.txt"));
406         connect(actionHelp_License, SIGNAL(triggered()), actionHelp_License, SLOT(do_send_string()));
407         connect(actionHelp_License, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
408         menuHELP->addAction(actionHelp_License);
409         
410         actionHelp_License_JP = new Action_Control(this);
411         actionHelp_License_JP->setObjectName(QString::fromUtf8("menuHelp_License_JP"));
412         actionHelp_License_JP->do_set_string(QString::fromUtf8("LICENSE.ja.txt"));
413         connect(actionHelp_License_JP, SIGNAL(triggered()), actionHelp_License_JP, SLOT(do_send_string()));
414         connect(actionHelp_License_JP, SIGNAL(sig_send_string(QString)), this, SLOT(do_browse_document(QString)));
415         menuHELP->addAction(actionHelp_License_JP);
416         
417         if(config.window_mode <= 0) config.window_mode = 0;
418         if(config.window_mode >= _SCREEN_MODE_NUM) config.window_mode = _SCREEN_MODE_NUM - 1;
419         w = SCREEN_WIDTH;
420         h = SCREEN_HEIGHT;
421         if(actionScreenSize[config.window_mode] != NULL) {
422                 double nd = actionScreenSize[config.window_mode]->binds->getDoubleValue();
423                 w = (int)(nd * (double)w);
424                 h = (int)(nd * (double)h);
425 #if defined(USE_SCREEN_ROTATE)
426                 if(config.rotate_type) {
427                         int tmp_w = w;
428                         w = h;
429                         h = tmp_w;
430                 }
431 #endif     
432         } else {
433 #if defined(USE_SCREEN_ROTATE)
434                 if(config.rotate_type) {
435                         w = 600;
436                         h = 960;
437                 } else 
438 #endif
439                 {                  
440                         w = 1280;
441                         h = 800;
442                 }
443         }
444         graphicsView->setFixedSize(w, h);
445         this->set_screen_size(w, h);
446         this->set_screen_aspect(config.stretch_type);
447         QImageReader reader(":/default.ico");
448         QImage result = reader.read();
449         MainWindow->setWindowIcon(QPixmap::fromImage(result));
450         QMetaObject::connectSlotsByName(MainWindow);
451 } // setupUi
452
453
454 void Ui_MainWindow::retranslateUI_Help(void)
455 {
456         menuHELP->setTitle(QApplication::translate("MainWindow", "HELP", 0));
457         actionHelp_AboutQt->setText(QApplication::translate("MainWindow", "About Qt", 0));
458         actionAbout->setText(QApplication::translate("MainWindow", "About...", 0));
459
460         menuHelp_Readme->setTitle(QApplication::translate("MainWindow", "READMEs", 0));
461         
462         actionHelp_README->setText(QApplication::translate("MainWindow", "General Document", 0));
463         actionHelp_README_QT->setText(QApplication::translate("MainWindow", "About Qt ports", 0));
464         actionHelp_README_Artane->setText(QApplication::translate("MainWindow", "About Qt ports (Japanese).", 0));
465         actionHelp_README_MR_TANAM->setText(QApplication::translate("MainWindow", "By Mr. tanam", 0));
466         actionHelp_README_FM7->setText(QApplication::translate("MainWindow", "About eFM-7/8/77/AV.", 0));
467         actionHelp_README_FM7_JP->setText(QApplication::translate("MainWindow", "About eFM-7/8/77/AV (Japanese).", 0));
468
469         menuHelp_Histories->setTitle(QApplication::translate("MainWindow", "Histories", 0));
470         actionHelp_History->setText(QApplication::translate("MainWindow", "General History", 0));
471         actionHelp_History_Relnote->setText(QApplication::translate("MainWindow", "Release Note", 0));
472         actionHelp_History_ChangeLog->setText(QApplication::translate("MainWindow", "Change Log", 0));
473         actionHelp_History_MR_TANAM->setText(QApplication::translate("MainWindow", "History by Tanam", 0));
474
475         actionHelp_License->setText(QApplication::translate("MainWindow", "Show License", 0));
476         actionHelp_License_JP->setText(QApplication::translate("MainWindow", "Show License (Japanese)", 0));
477         
478 }
479
480 // You can Override this function: Re-define on foo/MainWindow.cpp.
481 // This code is example: by X1(TurboZ).
482 void Ui_MainWindow::retranslateUi(void)
483 {
484         retranslateControlMenu("NMI Reset",  true);
485         retranslateFloppyMenu(0, 0);
486         retranslateFloppyMenu(1, 1);
487         retranslateCMTMenu();
488 #if !defined(WITHOUT_SOUND)     
489         retranslateSoundMenu();
490 #endif   
491         retranslateScreenMenu();
492         retranslateCartMenu(0, 1);
493         retranslateCartMenu(1, 2);
494         retranslateBinaryMenu(0, 1);
495         retranslateBinaryMenu(1, 2);
496         retranslateUI_Help();
497    
498         this->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0));
499
500
501         menuEmulator->setTitle(QApplication::translate("MainWindow", "Emulator", 0));
502         menuMachine->setTitle(QApplication::translate("MainWindow", "Machine", 0));
503 } // retranslateUi
504
505 void Ui_MainWindow::setCoreApplication(QApplication *p)
506 {
507         this->CoreApplication = p;
508         connect(actionExit_Emulator, SIGNAL(triggered()),
509                         this->CoreApplication, SLOT(closeAllWindows())); // OnGuiExit()?  
510         connect(actionHelp_AboutQt, SIGNAL(triggered()),
511                         this->CoreApplication, SLOT(aboutQt()));
512         
513 }
514 QT_END_NAMESPACE