OSDN Git Service

[BUILD] Set SOVERSION and GIT hash automatically.
[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 <QApplication>
11 #include <QVariant>
12 #include <QtGui>
13 #include <QIcon>
14 #include <QImage>
15 #include <QImageReader>
16 #include <QPixmap>
17 #include <QApplication>
18 #include <QLocale>
19 #include <QTranslator>
20 #include <QStatusBar>
21 #include <QHBoxLayout>
22 #include <QVBoxLayout>
23 #include <QDockWidget>
24 #include <QToolBar>
25 #include <QMenu>
26 #include <QMenuBar>
27 #include <QStyle>
28
29 #include "commonclasses.h"
30 #include "display_about.h"
31 #include "display_text_document.h"
32 #include "mainwidget_base.h"
33 //#include "menuclasses.h"
34 #include "menu_disk.h"
35 #include "menu_harddisk.h"
36 #include "menu_cmt.h"
37 #include "menu_cart.h"
38 #include "menu_quickdisk.h"
39 #include "menu_binary.h"
40 #include "menu_compactdisc.h"
41 #include "menu_laserdisc.h"
42 #include "menu_bubble.h"
43 #include "dock_disks.h"
44
45 #include "qt_gldraw.h"
46 //#include "emu.h"
47 #include "qt_main.h"
48 #include "menu_flags.h"
49 #include "csp_logger.h"
50 #include "common.h"
51
52 extern EMU *emu;
53 //extern USING_FLAGS *using_flags;
54 void DLL_PREFIX _resource_init(void)
55 {
56         Q_INIT_RESOURCE(commontexts);
57         Q_INIT_RESOURCE(shaders);
58 }
59
60 void DLL_PREFIX _resource_free(void)
61 {
62         Q_CLEANUP_RESOURCE(shaders);
63         Q_CLEANUP_RESOURCE(commontexts);
64 }
65
66 Ui_MainWindowBase::Ui_MainWindowBase(USING_FLAGS *p, CSP_Logger *logger, QWidget *parent) : QMainWindow(parent)
67 {
68         csp_logger = logger;
69         using_flags = p;
70         p_config = p->get_config_ptr();
71         driveData = NULL;
72         ledUpdateTimer = NULL;
73         setupUi();
74         createContextMenu();
75         max_vm_nodes = 0;
76         ui_retranslate_completed = false;
77         //csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "GUI OK");
78 }
79
80 Ui_MainWindowBase::~Ui_MainWindowBase()
81 {
82         graphicsView->releaseKeyboard();
83         if(ledUpdateTimer != NULL) delete ledUpdateTimer;
84         if(driveData != NULL) delete driveData;
85         delete using_flags;
86 }
87
88 QString Ui_MainWindowBase::get_gui_version()
89 {
90         QString retval;
91         retval.clear();
92 #if defined(__GUI_LIBRARY_NAME)
93         retval = QString::fromUtf8(__GUI_LIBRARY_NAME);
94 #endif
95         return retval;
96 }
97
98 void Action_Control::do_check_grab_mouse(bool flag)
99 {
100         this->toggle();
101 }
102
103 void Action_Control::do_send_string(void)
104 {
105         emit sig_send_string(bindString);
106 }
107
108 void Action_Control::do_set_string(QString s)
109 {
110         bindString = s;
111 }
112
113 void Action_Control::do_select_render_platform(void)
114 {
115         int num = this->binds->getValue1();
116         emit sig_select_render_platform(num);
117 }
118
119 void Action_Control::do_set_window_focus_type(bool f)
120 {
121         emit sig_set_window_focus_type(f);
122 }
123
124 void Action_Control::do_set_emulate_cursor_as(void)
125 {
126         int num = this->binds->getValue1();
127         emit sig_set_emulate_cursor_as(num);
128 }
129
130 void Action_Control::do_set_dev_log_to_console(bool f)
131 {
132         int num = this->binds->getValue1();
133         emit sig_set_dev_log_to_console(num, f);
134 }
135
136 void Action_Control::do_set_dev_log_to_syslog(bool f)
137 {
138         int num = this->binds->getValue1();
139         emit sig_set_dev_log_to_syslog(num, f);
140 }
141
142
143 void Ui_MainWindowBase::do_set_window_focus_type(bool flag)
144 {
145         p_config->focus_with_click = flag;
146         if(flag) {
147                 graphicsView->setFocusPolicy(Qt::ClickFocus);
148                 graphicsView->setFocus(0);
149         } else {
150                 graphicsView->setFocusPolicy(Qt::NoFocus);
151                 graphicsView->clearFocus();
152         }
153 }
154
155 void Ui_MainWindowBase::do_show_about(void)
156 {
157         Dlg_AboutCSP *dlg = new Dlg_AboutCSP(using_flags, static_cast<QWidget *>(this));
158         dlg->show();
159 }
160
161 void Ui_MainWindowBase::do_browse_document(QString fname)
162 {
163         Dlg_BrowseText *dlg = new Dlg_BrowseText(fname, using_flags);
164         dlg->show();
165 }
166
167 void Ui_MainWindowBase::do_set_sound_files_fdd(bool f)
168 {
169         if(f) {
170                 p_config->sound_noise_fdd = 1;
171         } else {
172                 p_config->sound_noise_fdd = 0;
173         }
174 }
175
176 void Ui_MainWindowBase::do_set_sound_files_relay(bool f)
177 {
178         if(f) {
179                 p_config->sound_noise_cmt = 1;
180         } else {
181                 p_config->sound_noise_cmt = 0;
182         }
183 }
184
185
186 void Ui_MainWindowBase::do_set_conslog(bool f)
187 {
188         p_config->log_to_console = f;
189         csp_logger->set_log_stdout(-1, f);
190 }
191
192 void Ui_MainWindowBase::do_set_syslog(bool f)
193 {
194         p_config->log_to_syslog = f;
195         csp_logger->set_log_syslog(-1, f);
196 }
197
198 void Ui_MainWindowBase::do_update_device_node_name(int id, const _TCHAR *name)
199 {
200         if(action_DevLogToConsole[id] == NULL) return;
201         if(!ui_retranslate_completed) return;
202         if(using_flags->get_vm_node_size() > id) {
203                 action_DevLogToConsole[id]->setEnabled(true);
204                 action_DevLogToConsole[id]->setVisible(true);
205 #if !defined(Q_OS_WIN)
206                 action_DevLogToSyslog[id]->setEnabled(true);
207                 action_DevLogToSyslog[id]->setVisible(true);
208 #endif
209         } else {
210                 action_DevLogToConsole[id]->setEnabled(false);
211                 action_DevLogToConsole[id]->setVisible(false);
212                 
213 #if !defined(Q_OS_WIN)
214                 action_DevLogToSyslog[id]->setEnabled(false);
215                 action_DevLogToSyslog[id]->setVisible(false);
216 #endif
217         }
218         char s[64] = {0};
219         snprintf(s, 60, "#%02d: %s", id, name);
220         action_DevLogToConsole[id]->setText(QString::fromUtf8(s));
221 #if !defined(Q_OS_WIN)
222         action_DevLogToSyslog[id]->setText(QString::fromUtf8(s));
223 #endif
224 }
225
226
227 void Ui_MainWindowBase::do_set_logging_fdc(bool f)
228 {
229         p_config->special_debug_fdc = f;
230         emit sig_emu_update_config();
231 }
232
233 void Ui_MainWindowBase::do_set_dev_log_to_console(int num, bool f)
234 {
235         csp_logger->set_device_node_log(num, 2, CSP_LOG_DEBUG, f);
236         p_config->dev_log_to_console[num][0] = f;
237 }
238
239 void Ui_MainWindowBase::do_set_state_log_to_console(bool f)
240 {
241         csp_logger->set_state_log(2, f);
242         p_config->state_log_to_console = f;
243 }
244
245 void Ui_MainWindowBase::do_set_state_log_to_syslog(bool f)
246 {
247         csp_logger->set_state_log(1, f);
248         p_config->state_log_to_syslog = f;
249 }
250
251 void Ui_MainWindowBase::do_set_state_log_to_record(bool f)
252 {
253         csp_logger->set_state_log(0, f);
254         p_config->state_log_to_recording = f;
255 }
256
257
258
259 void Ui_MainWindowBase::do_set_emulate_cursor_as(int num)
260 {
261         if((num < 0) || (num > 2)) return;
262         p_config->cursor_as_ten_key = num;
263         emit sig_emu_update_config();
264 }
265
266 void Ui_MainWindowBase::do_set_dev_log_to_syslog(int num, bool f)
267 {
268         csp_logger->set_device_node_log(num, 2, CSP_LOG_DEBUG, f);
269         p_config->dev_log_to_syslog[num][0] = f;
270 }
271
272 void Ui_MainWindowBase::do_select_render_platform(int num)
273 {
274         int _major = 0;
275         int _minor = 0;
276         int _type = -1;
277
278         switch(num) {
279         case RENDER_PLATFORMS_OPENGL_ES_2:
280                 _type = CONFIG_RENDER_PLATFORM_OPENGL_ES;
281                 _major = 2;
282                 _minor = 0;
283                 break;
284         case RENDER_PLATFORMS_OPENGL3_MAIN:
285                 _type = CONFIG_RENDER_PLATFORM_OPENGL_MAIN;
286                 _major = 3;
287                 _minor = 0;
288                 break;
289         case RENDER_PLATFORMS_OPENGL2_MAIN:
290                 _type = CONFIG_RENDER_PLATFORM_OPENGL_MAIN;
291                 _major = 2;
292                 _minor = 0;
293                 break;
294         case RENDER_PLATFORMS_OPENGL_CORE:
295                 _type = CONFIG_RENDER_PLATFORM_OPENGL_CORE;
296                 _major = 4;
297                 _minor = 3;
298                 break;
299         default:
300                 break;
301         }
302         if(_type >= 0) {
303                 p_config->render_platform = _type;
304                 p_config->render_major_version = _major;
305                 p_config->render_minor_version = _minor;
306         }
307 }
308
309 void Ui_MainWindowBase::set_dipsw(int num, bool flag)
310 {
311         if((num < 0) || (num >= 32)) return;
312         if(flag) {
313                 p_config->dipswitch = p_config->dipswitch | (1 << num);
314         } else {
315                 p_config->dipswitch = p_config->dipswitch & ~(1 << num);
316         }
317 }
318
319 bool Ui_MainWindowBase::get_dipsw(int num)
320 {
321         if((num < 0) || (num >= 32)) return false;
322         if(((1 << num) & p_config->dipswitch) == 0) return false;
323         return true;
324 }
325
326
327 void Ui_MainWindowBase::setupUi(void)
328 {
329         int w, h;
330         //   QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
331         MainWindow = new QMainWindow();
332         if (MainWindow->objectName().isEmpty())
333                 MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
334         //MainWindow->resize(1288, 862);
335         ConfigControlMenu();
336         ConfigFloppyMenu();
337         ConfigHardDiskMenu();
338         ConfigCMTMenu();
339         if(!using_flags->is_without_sound()) {
340                 ConfigSoundMenu();
341         }
342         if(using_flags->is_use_binary_file()) {
343                 ConfigBinaryMenu(); 
344         }
345         if(using_flags->is_use_qd()) {
346                 ConfigQuickDiskMenu();
347         }
348         ConfigScreenMenu();
349         if(using_flags->is_use_cart()) {
350                 ConfigCartMenu();
351         }
352         if(using_flags->is_use_compact_disc()) {
353                 ConfigCDROMMenu();
354         }
355         if(using_flags->is_use_laser_disc()) {
356                 ConfigLaserdiscMenu();
357         }
358         if(using_flags->is_use_bubble()) {
359                 ConfigBubbleMenu();
360         }
361         ConfigEmulatorMenu();   
362         actionAbout = new Action_Control(this, using_flags);
363         actionAbout->setObjectName(QString::fromUtf8("actionAbout"));
364
365         {
366
367                 QSurfaceFormat fmt;
368                 {
369                         int render_type = p_config->render_platform;
370                         QOpenGLContext *glContext = QOpenGLContext::globalShareContext();
371                         //int _major_version = p_config->render_major_version;
372                         //int _minor_version = p_config->render_minor_version;
373
374                         if(render_type == CONFIG_RENDER_PLATFORM_OPENGL_ES) {
375                                 fmt.setRenderableType(QSurfaceFormat::OpenGLES);
376                                 csp_logger->debug_log(CSP_LOG_DEBUG,  CSP_LOG_TYPE_GENERAL, "Try to use OpenGL ES.");
377                         } else if(render_type == CONFIG_RENDER_PLATFORM_OPENGL_CORE) { 
378                                 fmt.setProfile(QSurfaceFormat::CoreProfile); // Requires >=Qt-4.8.0
379                                 fmt.setVersion(4, 7); // Requires >=Qt-4.8.0
380                                 csp_logger->debug_log(CSP_LOG_DEBUG,  CSP_LOG_TYPE_GENERAL, "Try to use OpenGL CORE profile.");
381                         } else { // Fallback
382                                 fmt.setProfile(QSurfaceFormat::CompatibilityProfile); // Requires >=Qt-4.8.0
383                                 csp_logger->debug_log(CSP_LOG_DEBUG,  CSP_LOG_TYPE_GENERAL, "Try to use OpenGL Compatible(MAIN) profile.");
384                         }
385                 }
386                 graphicsView = new GLDrawClass(using_flags, csp_logger, this, fmt);
387                 graphicsView->setObjectName(QString::fromUtf8("graphicsView"));
388                 graphicsView->setMaximumSize(2560, 2560); // ?
389                 graphicsView->setMinimumSize(240, 192); // ?
390                 csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "GraphicsView OK");
391                 graphicsView->setAttribute(Qt::WA_InputMethodEnabled, false); // Disable [Zenkaku / Hankaku] with IM.
392                 graphicsView->setAttribute(Qt::WA_KeyboardFocusChange, false);
393                 graphicsView->setAttribute(Qt::WA_KeyCompression, false);
394                 connect(this, SIGNAL(sig_set_display_osd(bool)), graphicsView, SLOT(do_set_display_osd(bool)));
395                 connect(this, SIGNAL(sig_set_led_width(int)), graphicsView, SLOT(do_set_led_width(int)));
396         }
397         
398         bitmapImage = NULL;
399         driveData = new CSP_DockDisks(this, using_flags);
400         MainWindow->setDockOptions(QMainWindow::AnimatedDocks);
401         if(p_config->virtual_media_position > 0) {
402                 driveData->setVisible(true);
403         } else {        
404                 driveData->setVisible(false);
405         }       
406
407         pCentralWidget = new QWidget(this);
408         pCentralLayout = new QVBoxLayout(pCentralWidget);
409         pCentralLayout->setContentsMargins(0, 0, 0, 0);
410         pCentralLayout->addWidget(graphicsView);
411         pCentralLayout->addWidget(driveData);
412         switch(p_config->virtual_media_position) {
413         case 0:
414                 pCentralLayout->setDirection(QBoxLayout::TopToBottom);
415                 pCentralLayout->removeWidget(driveData);
416                 driveData->setVisible(false);
417                 graphicsView->setVisible(true);
418                 //emit sig_set_display_osd(true);
419                 break;
420         case 1:
421                 pCentralLayout->setDirection(QBoxLayout::BottomToTop);
422                 driveData->setVisible(true);
423                 graphicsView->setVisible(true);
424                 //emit sig_set_display_osd(false);
425                 break;
426         case 2:
427                 pCentralLayout->setDirection(QBoxLayout::TopToBottom);
428                 driveData->setVisible(true);
429                 graphicsView->setVisible(true);
430                 //emit sig_set_display_osd(false);
431                 break;
432         default:
433                 pCentralLayout->setDirection(QBoxLayout::TopToBottom);
434                 driveData->setVisible(true);
435                 graphicsView->setVisible(true);
436                 //emit sig_set_display_osd(false);
437                 break;
438         }
439         pCentralWidget->setLayout(pCentralLayout);
440         MainWindow->setCentralWidget(pCentralWidget);
441         
442         if(p_config->focus_with_click) {
443                 graphicsView->setFocusPolicy(Qt::ClickFocus);
444                 graphicsView->setFocus(0);
445         } else {
446                 graphicsView->setFocusPolicy(Qt::NoFocus);
447         }
448         driveData->setOrientation(p_config->virtual_media_position);
449         connect(this, SIGNAL(sig_set_orientation_osd(int)), driveData, SLOT(setOrientation(int)));
450         connect(graphicsView, SIGNAL(sig_resize_osd(int)), driveData, SLOT(setScreenWidth(int)));
451
452         MainWindow->setFocusProxy(graphicsView);
453         MainWindow->centralWidget()->adjustSize();
454         MainWindow->adjustSize();
455
456         statusbar = new QStatusBar(this);
457         statusbar->setObjectName(QString::fromUtf8("statusbar"));
458         MainWindow->setStatusBar(statusbar);
459         initStatusBar();
460         
461         menubar = new QMenuBar(this);
462         menubar->setObjectName(QString::fromUtf8("menubar"));
463         menubar->setGeometry(QRect(0, 0, 1288, 27));
464         menuControl = new QMenu(menubar);
465         menuControl->setToolTipsVisible(true);
466         menuControl->setObjectName(QString::fromUtf8("menuControl"));
467         menuState = new QMenu(menuControl);
468         menuState->setToolTipsVisible(true);
469         menuState->setObjectName(QString::fromUtf8("menuState"));
470
471         menuSave_State = new QMenu(menuState);
472         menuSave_State->setToolTipsVisible(true);
473         menuSave_State->setObjectName(QString::fromUtf8("menuSaveState"));
474
475         menuLoad_State = new QMenu(menuState);
476         menuLoad_State->setToolTipsVisible(true);
477         menuLoad_State->setObjectName(QString::fromUtf8("menuLoadState"));
478
479         if(using_flags->is_use_auto_key()) {
480                 menuCopy_Paste = new QMenu(menuControl);
481                 menuCopy_Paste->setObjectName(QString::fromUtf8("menuCopy_Paste"));
482                 menuCopy_Paste->setToolTipsVisible(true);
483         }
484         menuCpu_Speed = new QMenu(menuControl);
485         menuCpu_Speed->setObjectName(QString::fromUtf8("menuCpu_Speed"));
486         menuCpu_Speed->setToolTipsVisible(true);
487         menuDebugger = new QMenu(menuControl);
488         menuDebugger->setObjectName(QString::fromUtf8("menuDebugger"));
489         menuDebugger->setToolTipsVisible(true);
490         if(using_flags->is_use_fd()) {
491                 int base_drv = using_flags->get_base_floppy_disk_num();
492                 for(int i = 0; i < using_flags->get_max_drive(); i++) CreateFloppyMenu(i, base_drv + i);
493         }
494         if(using_flags->is_use_qd()) {
495                 int base_drv = using_flags->get_base_quick_disk_num();
496                 for(int i = 0; i < using_flags->get_max_qd(); i++) CreateQuickDiskMenu(i, base_drv + i);
497         }
498         if(using_flags->is_use_tape()) {
499                 int base_drv = using_flags->get_base_tape_num();
500                 for(int i = 0; i < using_flags->get_max_tape(); i++) CreateCMTMenu(i, base_drv + i);
501         }
502         if(using_flags->is_use_hdd()) {
503                 int base_drv = using_flags->get_base_hdd_num();
504                 for(int i = 0; i < using_flags->get_max_hdd(); i++) CreateHardDiskMenu(i, base_drv + i);
505         }
506         CreateScreenMenu();
507         if(using_flags->is_use_cart()) {
508                 int base_drv = using_flags->get_base_cart_num();
509                 for(int i = 0; i < using_flags->get_max_cart(); i++) {
510                         CreateCartMenu(i, base_drv + i);
511                 }
512         }
513         if(using_flags->is_use_binary_file()) {
514                 int base_drv = using_flags->get_base_binary_num();
515                 for(int i = 0; i < using_flags->get_max_binary(); i++) {
516                         CreateBinaryMenu(i, base_drv + i);
517                 }
518         }
519         if(using_flags->is_use_compact_disc()) {
520                 int base_drv = using_flags->get_base_compact_disc_num();
521                 for(int i = 0; i < using_flags->get_max_cd(); i++) {
522                         CreateCDROMMenu(i, base_drv + i);
523                 }
524         }
525         if(using_flags->is_use_laser_disc()) {
526                 int base_drv = using_flags->get_base_laser_disc_num();
527                 for(int i = 0; i < using_flags->get_max_ld(); i++) {
528                         CreateLaserdiscMenu(i, base_drv + i);
529                 }
530         }
531         if(using_flags->is_use_bubble()) {
532                 int base_drv = using_flags->get_base_bubble_num();
533                 for(int i = 0; i < using_flags->get_max_bubble(); i++) {
534                         CreateBubbleMenu(i, base_drv + i);
535                 }
536         }
537         connect(this, SIGNAL(sig_update_screen(void)), graphicsView, SLOT(update(void)));
538         //connect(this, SIGNAL(sig_update_screen(void)), graphicsView, SLOT(updateGL(void)));
539
540         menuMachine = new QMenu(menubar);
541         menuMachine->setObjectName(QString::fromUtf8("menuMachine"));
542         menuMachine->setToolTipsVisible(true);
543
544         if(using_flags->is_use_mouse()) {
545                 actionMouseEnable = new Action_Control(this, using_flags);
546                 actionMouseEnable->setCheckable(true);
547                 actionMouseEnable->setVisible(true);
548                 actionMouseEnable->setChecked(false);
549                 menuMachine->addAction(actionMouseEnable);
550                 connect(actionMouseEnable, SIGNAL(toggled(bool)),
551                                 this, SLOT(do_set_mouse_enable(bool)));
552                 connect(graphicsView, SIGNAL(sig_check_grab_mouse(bool)),
553                                 actionMouseEnable, SLOT(do_check_grab_mouse(bool)));
554         }
555
556         ConfigDeviceType();
557         ConfigMouseType();
558         ConfigKeyboardType();
559         ConfigJoystickType();
560         ConfigDriveType();
561         ConfigSoundDeviceType();
562         ConfigPrinterType();
563         ConfigMonitorType();
564         
565         if(!using_flags->is_without_sound()) {
566                 menuSound = new QMenu(menubar);
567                 menuSound->setObjectName(QString::fromUtf8("menuSound"));
568                 menuSound->setToolTipsVisible(true);
569         }
570         menuEmulator = new QMenu(menubar);
571         menuEmulator->setObjectName(QString::fromUtf8("menuEmulator"));
572         menuEmulator->setToolTipsVisible(true);
573
574         menuHELP = new QMenu(menubar);
575         menuHELP->setObjectName(QString::fromUtf8("menuHELP"));
576         menuHELP->setToolTipsVisible(true);
577         MainWindow->setMenuBar(menubar);
578
579         menubar->addAction(menuControl->menuAction());
580         connectActions_ControlMenu();
581         if(using_flags->is_use_fd()) {
582                 int i;
583                 for(i = 0; i < using_flags->get_max_drive(); i++) {
584                         menubar->addAction(menu_fds[i]->menuAction());
585                 }
586         }
587         if(using_flags->is_use_qd()) {
588                 int i;
589                 for(i = 0; i < using_flags->get_max_qd(); i++) {
590                         menubar->addAction(menu_QDs[i]->menuAction());
591                 }
592         }
593         if(using_flags->is_use_hdd()) {
594                 int i;
595                 for(i = 0; i < using_flags->get_max_hdd(); i++) {
596                         menubar->addAction(menu_hdds[i]->menuAction());
597                 }
598         }
599         if(using_flags->is_use_tape()) {
600                 for(int i = 0; i < using_flags->get_max_tape(); i++) menubar->addAction(menu_CMT[i]->menuAction());
601         }
602         if(using_flags->is_use_cart()) {
603                 int i;
604                 for(i = 0; i < using_flags->get_max_cart(); i++) {
605                         menubar->addAction(menu_Cart[i]->menuAction());
606                 }
607         }
608         if(using_flags->is_use_binary_file()) {
609                 for(int i = 0; i < using_flags->get_max_binary(); i++) {
610                         menubar->addAction(menu_BINs[i]->menuAction());
611                 }
612         }
613         if(using_flags->is_use_compact_disc()) {
614                 for(int i = 0; i < using_flags->get_max_cd(); i++) {
615                         menubar->addAction(menu_CDROM[i]->menuAction());
616                 }
617         }
618         if(using_flags->is_use_laser_disc()) {
619                 for(int i = 0; i < using_flags->get_max_ld(); i++) {
620                         menubar->addAction(menu_Laserdisc[i]->menuAction());
621                 }
622         }
623         if(using_flags->is_use_bubble()) {
624                 int i;
625                 for(i = 0; i < using_flags->get_max_bubble(); i++) {
626                         menubar->addAction(menu_bubbles[i]->menuAction());
627                 }
628         }
629         menubar->addAction(menuMachine->menuAction());
630         if(!using_flags->is_without_sound()) {
631                 menubar->addAction(menuSound->menuAction());
632         }
633
634         menubar->addAction(menuScreen->menuAction());
635 //      menubar->addAction(menuRecord->menuAction());
636         menubar->addAction(menuEmulator->menuAction());
637         menubar->addAction(menuHELP->menuAction());
638         if(using_flags->is_use_qd()) {
639                 int i;
640                 for(i = 0; i < using_flags->get_max_qd(); i++) {
641                         CreateQuickDiskPulldownMenu(i);
642                 }
643         }
644         if(using_flags->is_use_binary_file()) {
645                 int i;
646                 for(i = 0; i < using_flags->get_max_binary(); i++) {
647                         CreateBinaryPulldownMenu(1);
648                 }
649         }
650         if(!using_flags->is_without_sound()) {
651                 CreateSoundMenu();
652         }
653         CreateEmulatorMenu();
654   
655         menuHELP->addAction(actionAbout);
656         connect(actionAbout, SIGNAL(triggered()), this, SLOT(do_show_about()));
657         menuHELP->addSeparator();
658         
659         actionHelp_AboutQt = new Action_Control(this, using_flags);
660         actionHelp_AboutQt->setObjectName(QString::fromUtf8("menuHelp_AboutQt"));
661         menuHELP->addAction(actionHelp_AboutQt);
662         menuHELP->addSeparator();
663         menuHelp_Readme = new QMenu(menuHELP);
664         menuHelp_Readme->setObjectName(QString::fromUtf8("menuHelp_Readme_menu"));;
665         menuHelp_Readme->setToolTipsVisible(true);
666         menuHELP->addAction(menuHelp_Readme->menuAction());
667
668         SET_HELP_MENUENTRY(menuHelp_Readme, actionHelp_README, "menuHelp_README", "readme.txt");
669         SET_HELP_MENUENTRY(menuHelp_Readme, actionHelp_README_QT, "menuHelp_README_QT", "readme.qt.txt");
670         SET_HELP_MENUENTRY(menuHelp_Readme, actionHelp_README_Artane, "menuHelp_README_Artane", "readme_by_artane.txt");
671         SET_HELP_MENUENTRY(menuHelp_Readme, actionHelp_README_Umaiboux, "menuHelp_README_Umaiboux", "readme_by_umaiboux.txt");
672         menuHelp_Readme->addSeparator();
673         SET_HELP_MENUENTRY(menuHelp_Readme, actionHelp_README_BIOS, "menuHelp_README_BIOS", "bios_and_keys.txt");
674         menuHelp_Readme->addSeparator();
675         SET_HELP_MENUENTRY(menuHelp_Readme, actionHelp_README_MR_TANAM, "menuHelp_README_MR_TANAM", "readme_by_mr_tanam.txt");
676         menuHelp_Readme->addSeparator();
677         SET_HELP_MENUENTRY(menuHelp_Readme, actionHelp_README_FAQ, "menuHelp_README_FAQ", "FAQ.html");
678         SET_HELP_MENUENTRY(menuHelp_Readme, actionHelp_README_FAQ_JP, "menuHelp_README_FAQ_JP", "FAQ.ja.html");
679         menuHelp_Readme->addSeparator();
680         SET_HELP_MENUENTRY(menuHelp_Readme, actionHelp_README_FM7, "menuHelp_README_FM7", "readme_fm7.txt");
681         SET_HELP_MENUENTRY(menuHelp_Readme, actionHelp_README_FM7_JP, "menuHelp_README_FM7_JP", "readme_fm7.jp.txt");
682
683         menuHelp_Histories = new QMenu(menuHELP);
684         menuHelp_Histories->setObjectName(QString::fromUtf8("menuHelp_Histories"));;
685         menuHelp_Histories->setToolTipsVisible(true);
686         menuHELP->addAction(menuHelp_Histories->menuAction());
687
688         SET_HELP_MENUENTRY(menuHelp_Histories, actionHelp_History, "menuHelp_History", "history.txt");
689         SET_HELP_MENUENTRY(menuHelp_Histories, actionHelp_History_Relnote, "menuHelp_History_Relnote", "RELEASENOTE.txt");
690         SET_HELP_MENUENTRY(menuHelp_Histories, actionHelp_History_ChangeLog, "menuHelp_History_Changelog", "ChangeLog.txt");
691         SET_HELP_MENUENTRY(menuHelp_Histories, actionHelp_History_MR_TANAM, "menuHelp_History_MR_TANAM", "history_by_mr_tanam.txt");
692         
693         SET_HELP_MENUENTRY(menuHELP, actionHelp_License, "menuHelp_License", "LICENSE.txt");
694         SET_HELP_MENUENTRY(menuHELP, actionHelp_License_JP, "menuHelp_License_JP", "LICENSE.ja.txt");
695         
696         if(p_config->window_mode <= 0) p_config->window_mode = 0;
697         if(p_config->window_mode >= using_flags->get_screen_mode_num()) p_config->window_mode = using_flags->get_screen_mode_num() - 1;
698         w = using_flags->get_screen_width();
699         h = using_flags->get_screen_height();
700         if(actionScreenSize[p_config->window_mode] != NULL) {
701                 double nd = actionScreenSize[p_config->window_mode]->binds->getDoubleValue();
702                 w = (int)(nd * (double)w);
703                 h = (int)(nd * (double)h);
704                 switch(p_config->rotate_type) {
705                 case 0:
706                 case 2:
707                         break;
708                 case 1:
709                 case 4:
710                          {
711                                 int tmp_w = w;
712                                 w = h;
713                                 h = tmp_w;
714                         }
715                 }
716         } else {
717                 switch(p_config->rotate_type) {
718                 case 0:
719                 case 2:
720                         w = 1208;
721                         h = 800;
722                         break;
723                 case 1:
724                 case 4:
725                         w = 600;
726                         h = 960;
727                         break;
728                 }
729         }
730         graphicsView->setFixedSize(w, h);
731         for(int i = 0; i < using_flags->get_screen_mode_num(); i++) {
732                 if(actionScreenSize[i] != NULL) {
733                         connect(actionScreenSize[i]->binds, SIGNAL(sig_screen_multiply(float)),
734                                 graphicsView, SLOT(do_set_screen_multiply(float)));
735                 }
736         }
737         this->set_screen_size(w, h);
738         this->set_screen_aspect(p_config->window_stretch_type);
739         if(actionScreenSize[p_config->window_mode] != NULL) {
740                 double nd = actionScreenSize[p_config->window_mode]->binds->getDoubleValue();
741                 graphicsView->do_set_screen_multiply(nd);
742         }
743         if(using_flags->is_use_joystick()) {
744                 connect(action_SetupJoystick, SIGNAL(triggered()), this, SLOT(rise_joystick_dialog()));
745         }
746
747         if(using_flags->is_use_sound_files_fdd()) {
748                 connect(action_SoundFilesFDD, SIGNAL(toggled(bool)), this, SLOT(do_set_sound_files_fdd(bool)));
749         }
750         if(using_flags->is_use_sound_files_relay()) {
751                 connect(action_SoundFilesRelay, SIGNAL(toggled(bool)), this, SLOT(do_set_sound_files_relay(bool)));
752         }
753         connect(action_SetupKeyboard, SIGNAL(triggered()), this, SLOT(rise_keyboard_dialog()));
754 #if !defined(Q_OS_WIN)
755         connect(action_LogToSyslog, SIGNAL(toggled(bool)), this, SLOT(do_set_syslog(bool)));
756 #endif  
757         connect(action_LogToConsole, SIGNAL(toggled(bool)), this, SLOT(do_set_conslog(bool)));
758         csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Menu OK");
759            
760         QImageReader reader(":/default.ico");
761         QImage result = reader.read();
762
763         MainWindow->setWindowIcon(QPixmap::fromImage(result));
764         this->set_window_title();
765 //      QIcon WindowIcon;
766         InsertIcon = QApplication::style()->standardIcon(QStyle::SP_FileDialogStart);
767         EjectIcon  = QIcon(":/icon_eject.png");
768         StopIcon = QIcon(":/icon_process_stop.png");
769         RecordSoundIcon = QIcon(":/icon_record_to_wav.png");
770         ResetIcon = QApplication::style()->standardIcon(QStyle::SP_BrowserReload);
771
772         VolumeMutedIcon = QIcon(":/icon_volume_muted.png");
773         VolumeLowIcon = QIcon(":/icon_volume_low.png");
774         VolumeMidIcon = QIcon(":/icon_volume_mid.png");
775         VolumeHighIcon = QIcon(":/icon_volume_high.png");
776         
777         ExitIcon = QIcon(":/icon_exit.png");
778
779         QMetaObject::connectSlotsByName(MainWindow);
780         csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "setupUI() OK");
781 } // setupUi
782
783 // Emulator
784 #include "dropdown_joystick.h"
785 #include "dialog_set_key.h"
786
787 void Ui_MainWindowBase::retranslateEmulatorMenu(void)
788 {
789         if(using_flags->is_use_joystick()) {
790                 action_SetupJoystick->setText(QApplication::translate("MenuEmulator", "Configure Joysticks", 0));
791                 action_SetupJoystick->setToolTip(QApplication::translate("MenuEmulator", "Configure assigning buttons/directions of joysticks.", 0));
792                 action_SetupJoystick->setIcon(QIcon(":/icon_gamepad.png"));
793         }
794         if(using_flags->is_use_auto_key()) {
795                 action_UseRomaKana->setText(QApplication::translate("MenuEmulator", "ROMA-KANA Conversion", 0));
796                 action_UseRomaKana->setToolTip(QApplication::translate("MenuEmulator", "Use romaji-kana conversion assistant of emulator.", 0));
797         }
798         actionSpeed_FULL->setText(QApplication::translate("MenuEmulator", "Emulate as FULL SPEED", 0));
799         actionSpeed_FULL->setToolTip(QApplication::translate("MenuEmulator", "Run emulation thread without frame sync.", 0));
800         
801         action_NumPadEnterAsFullkey->setText(QApplication::translate("MenuEmulator", "Numpad's Enter is Fullkey's", 0));
802         action_NumPadEnterAsFullkey->setToolTip(QApplication::translate("MenuEmulator", "Numpad's enter key makes full key's enter.\nUseful for some VMs.", 0));
803
804         action_PrintCpuStatistics->setText(QApplication::translate("MenuEmulator", "Print Statistics", 0));
805         action_PrintCpuStatistics->setToolTip(QApplication::translate("MenuEmulator", "Print statistics of CPUs (or some devices).\nUseful for debugging.", 0));
806
807         if(action_Logging_FDC != NULL) {
808                 action_Logging_FDC->setText(QApplication::translate("MenuEmulator", "FDC: Turn ON Debug log.", 0));
809                 action_Logging_FDC->setToolTip(QApplication::translate("MenuEmulator", "Turn ON debug logging for FDCs.Useful to resolve issues from guest software.", 0));
810         }
811         // ToDo
812         menu_EmulateCursorAs->setTitle(QApplication::translate("MenuEmulator", "Emulate cursor as", 0));
813         menu_EmulateCursorAs->setToolTip(QApplication::translate("MenuEmulator", "Emulate cursor as ten-key.", 0));
814         action_EmulateCursorAs[0]->setText(QApplication::translate("MenuEmulator", "None", 0));
815         action_EmulateCursorAs[1]->setText(QApplication::translate("MenuEmulator", "2 4 6 8", 0));
816         action_EmulateCursorAs[2]->setText(QApplication::translate("MenuEmulator", "1 2 3 5", 0));
817         
818         menuEmulator->setTitle(QApplication::translate("MenuEmulator", "Emulator", 0));
819
820         
821         action_FocusWithClick->setText(QApplication::translate("MenuEmulator", "Focus on click", 0));
822         action_FocusWithClick->setToolTip(QApplication::translate("MenuEmulator", "If set, focus with click, not mouse-over.", 0));
823         
824         action_SetupKeyboard->setText(QApplication::translate("MenuEmulator", "Configure Keyboard", 0));
825         action_SetupKeyboard->setToolTip(QApplication::translate("MenuEmulator", "Set addignation of keyboard.", 0));
826         action_SetupKeyboard->setIcon(QIcon(":/icon_keyboard.png"));
827         action_SetupMovie->setText(QApplication::translate("MenuEmulator", "Configure movie encoding", 0));
828         action_SetupMovie->setToolTip(QApplication::translate("MenuEmulator", "Configure parameters of movie encoding.", 0));
829
830         action_LogToConsole->setText(QApplication::translate("MenuEmulator", "Log to Console", 0));
831         action_LogToConsole->setToolTip(QApplication::translate("MenuEmulator", "Enable logging to STDOUT if checked.", 0));
832 #if !defined(Q_OS_WIN)
833         action_LogToSyslog->setText(QApplication::translate("MenuEmulator", "Log to Syslog", 0));
834         action_LogToSyslog->setToolTip(QApplication::translate("MenuEmulator", "Enable logging to SYSTEM log.\nMay be having permission to system and using *nix OS.", 0));
835         //action_LogRecord->setText(QApplication::translate("MenuEmulator", "Recording Log", 0));
836 #endif
837         if(using_flags->is_use_sound_files_fdd()) {
838                 action_SoundFilesFDD->setText(QApplication::translate("MenuEmulator", "Sound FDD Seek", 0));
839                 action_SoundFilesFDD->setToolTip(QApplication::translate("MenuEmulator", "Enable FDD HEAD seeking sound.\nNeeds sound file.\nSee HELP->READMEs->Bios and Key assigns", 0));
840         }
841         if(using_flags->is_use_sound_files_relay()) {
842                 action_SoundFilesRelay->setText(QApplication::translate("MenuEmulator", "Sound CMT Relay and Buttons", 0));
843                 action_SoundFilesRelay->setToolTip(QApplication::translate("MenuEmulator", "Enable CMT relay's sound and buttons's sounds.\nNeeds sound file.\nSee HELP->READMEs->Bios and Key assigns", 0));
844                 if(using_flags->is_tape_binary_only()) action_SoundFilesRelay->setEnabled(false);
845         }
846         menuDevLogToConsole->setTitle(QApplication::translate("MenuEmulator", "Per Device", 0));
847 #if !defined(Q_OS_WIN)
848         menuDevLogToSyslog->setTitle(QApplication::translate("MenuEmulator", "Per Device", 0));
849 #endif
850         menu_SetRenderPlatform->setTitle(QApplication::translate("MenuEmulator", "Video Platform(need restart)", 0));
851         
852         action_SetRenderPlatform[RENDER_PLATFORMS_OPENGL_ES_2]->setText(QApplication::translate("MenuEmulator", "OpenGL ES v2.0", 0));
853         action_SetRenderPlatform[RENDER_PLATFORMS_OPENGL3_MAIN]->setText(QApplication::translate("MenuEmulator", "OpenGLv3.0", 0));
854         action_SetRenderPlatform[RENDER_PLATFORMS_OPENGL2_MAIN]->setText(QApplication::translate("MenuEmulator", "OpenGLv2.0", 0));
855         action_SetRenderPlatform[RENDER_PLATFORMS_OPENGL_CORE]->setText(QApplication::translate("MenuEmulator", "OpenGL(Core profile)", 0));
856         
857         action_SetRenderPlatform[RENDER_PLATFORMS_OPENGL_ES_2]->setToolTip(QApplication::translate("MenuEmulator", "Using OpenGL ES v2.0.\nThis is recommanded.\nIf changed, need to restart this emulator.", 0));
858         action_SetRenderPlatform[RENDER_PLATFORMS_OPENGL3_MAIN]->setToolTip(QApplication::translate("MenuEmulator", "Using OpenGL v3.0(MAIN).\nThis is recommanded.\nIf changed, need to restart this emulator.", 0));
859         action_SetRenderPlatform[RENDER_PLATFORMS_OPENGL2_MAIN]->setToolTip(QApplication::translate("MenuEmulator", "Using OpenGLv2.\nThis is fallback of some systems.\nIf changed, need to restart this emulator.", 0));
860         action_SetRenderPlatform[RENDER_PLATFORMS_OPENGL_CORE]->setToolTip(QApplication::translate("MenuEmulator", "Using OpenGL core profile.\nThis still not implement.\nIf changed, need to restart this emulator.", 0));
861
862         menu_DispVirtualMedias->setTitle(QApplication::translate("MenuEmulator", "Show Virtual Medias.", 0));
863         action_DispVirtualMedias[0]->setText(QApplication::translate("MenuEmulator", "None.", 0));
864         action_DispVirtualMedias[1]->setText(QApplication::translate("MenuEmulator", "Upper.", 0));
865         action_DispVirtualMedias[2]->setText(QApplication::translate("MenuEmulator", "Lower.", 0));
866         //action_DispVirtualMedias[3]->setText(QApplication::translate("MenuEmulator", "Left.", 0));
867         //action_DispVirtualMedias[4]->setText(QApplication::translate("MenuEmulator", "Right.", 0));
868         action_LogView->setText(QApplication::translate("MenuEmulator", "View Log", 0));
869         action_LogView->setToolTip(QApplication::translate("MenuEmulator", "View emulator logs with a dialog.", 0));
870 }
871
872 void Ui_MainWindowBase::retranselateUi_Depended_OSD(void)
873 {
874         for(int i=0; i < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1) ; i++) {
875                 const _TCHAR *p;
876                 p = using_flags->get_vm_node_name(i);
877                 do_update_device_node_name(i, p);
878         }
879 }
880
881 void Ui_MainWindowBase::do_set_roma_kana(bool flag)
882 {
883         p_config->romaji_to_kana = flag;
884         emit sig_set_roma_kana(flag);
885 }
886
887 void Ui_MainWindowBase::do_set_numpad_enter_as_fullkey(bool flag)
888 {
889         p_config->numpad_enter_as_fullkey = flag;
890 }
891
892 void Ui_MainWindowBase::do_set_print_cpu_statistics(bool flag)
893 {
894         p_config->print_statistics = flag;
895         emit sig_emu_update_config();
896 }
897
898 void Ui_MainWindowBase::CreateEmulatorMenu(void)
899 {
900         //menuEmulator->addAction(action_LogRecord);
901         menuEmulator->addAction(action_FocusWithClick);
902         menuEmulator->addAction(menu_DispVirtualMedias->menuAction());
903         menuEmulator->addSeparator();
904         if(using_flags->is_use_auto_key()) {
905                 menuEmulator->addAction(action_UseRomaKana);
906         }
907         menuEmulator->addAction(action_NumPadEnterAsFullkey);
908         menuEmulator->addSeparator();
909         menuEmulator->addAction(actionSpeed_FULL);
910         menuEmulator->addSeparator();
911         menuEmulator->addAction(menu_EmulateCursorAs->menuAction());
912         if(action_Logging_FDC != NULL) {
913                 menuEmulator->addSeparator();
914                 menuEmulator->addAction(action_Logging_FDC);
915         }
916         menuEmulator->addAction(action_PrintCpuStatistics);
917         menuEmulator->addSeparator();
918         menuEmulator->addAction(action_LogToConsole);
919         menuEmulator->addAction(menuDevLogToConsole->menuAction());
920         menuEmulator->addSeparator();
921 #if !defined(Q_OS_WIN)
922         menuEmulator->addAction(action_LogToSyslog);
923         menuEmulator->addAction(menuDevLogToSyslog->menuAction());
924 #endif
925         menuEmulator->addSeparator();
926         menuEmulator->addAction(action_LogView);
927         menuEmulator->addSeparator();
928         if(using_flags->is_use_sound_files_fdd() || using_flags->is_use_sound_files_relay()) {
929                 if(using_flags->is_use_sound_files_fdd())     menuEmulator->addAction(action_SoundFilesFDD);
930                 if(using_flags->is_use_sound_files_relay())   menuEmulator->addAction(action_SoundFilesRelay);
931                 menuEmulator->addSeparator();
932         }
933         menuEmulator->addAction(menu_SetRenderPlatform->menuAction());
934         
935         if(using_flags->is_use_joystick()) {
936                 menuEmulator->addAction(action_SetupJoystick);
937         }
938         menuEmulator->addAction(action_SetupKeyboard);
939         menuEmulator->addAction(action_SetupMovie);
940 }
941
942 void Ui_MainWindowBase::ConfigMonitorType(void)
943 {
944         if(using_flags->get_use_monitor_type() > 0) {
945                 int ii;
946                 menuMonitorType = new QMenu(menuMachine);
947                 menuMonitorType->setObjectName(QString::fromUtf8("menuControl_MonitorType"));
948                 menuMachine->addAction(menuMonitorType->menuAction());
949                 
950                 actionGroup_MonitorType = new QActionGroup(this);
951                 actionGroup_MonitorType->setExclusive(true);
952                 for(ii = 0; ii < using_flags->get_use_monitor_type(); ii++) {
953                         actionMonitorType[ii] = new Action_Control(this, using_flags);
954                         actionGroup_MonitorType->addAction(actionMonitorType[ii]);
955                         actionMonitorType[ii]->setCheckable(true);
956                         actionMonitorType[ii]->setVisible(true);
957                         actionMonitorType[ii]->binds->setValue1(ii);
958                         if(p_config->monitor_type == ii) actionMonitorType[ii]->setChecked(true);
959                         menuMonitorType->addAction(actionMonitorType[ii]);
960                         connect(actionMonitorType[ii], SIGNAL(triggered()),
961                                         actionMonitorType[ii]->binds, SLOT(do_set_monitor_type()));
962                         connect(actionMonitorType[ii]->binds, SIGNAL(sig_monitor_type(int)),
963                                         this, SLOT(set_monitor_type(int)));
964                 }
965         }
966 }
967
968 void Ui_MainWindowBase::ConfigEmulatorMenu(void)
969 {
970         int i;
971         QString tmps;
972         actionGroup_DispVirtualMedias = new QActionGroup(this);
973         actionGroup_DispVirtualMedias->setExclusive(true);
974         menu_DispVirtualMedias = new QMenu(this);
975         menu_DispVirtualMedias->setToolTipsVisible(true);
976         for(i = 0; i < 3; i++) {
977                 action_DispVirtualMedias[i] = new Action_Control(this, using_flags);
978                 action_DispVirtualMedias[i]->setCheckable(true);
979                 action_DispVirtualMedias[i]->setChecked(false);
980                 if(i == p_config->virtual_media_position) action_DispVirtualMedias[i]->setChecked(true);
981                 action_DispVirtualMedias[i]->setEnabled(true);
982                 actionGroup_DispVirtualMedias->addAction(action_DispVirtualMedias[i]);
983                 menu_DispVirtualMedias->addAction(action_DispVirtualMedias[i]);
984         }
985         connect(action_DispVirtualMedias[0], SIGNAL(triggered()), this, SLOT(do_set_visible_virtual_media_none()));
986         connect(action_DispVirtualMedias[1], SIGNAL(triggered()), this, SLOT(do_set_visible_virtual_media_upper()));
987         connect(action_DispVirtualMedias[2], SIGNAL(triggered()), this, SLOT(do_set_visible_virtual_media_lower()));
988                         
989         if(using_flags->is_use_auto_key()) {
990                 // ToDo: Setup if checked.
991                 SET_ACTION_SINGLE(action_UseRomaKana, true, true, (p_config->romaji_to_kana)); 
992                 connect(action_UseRomaKana, SIGNAL(toggled(bool)), this, SLOT(do_set_roma_kana(bool)));
993         }
994         SET_ACTION_SINGLE(action_NumPadEnterAsFullkey, true, true, (p_config->numpad_enter_as_fullkey));
995         connect(action_NumPadEnterAsFullkey, SIGNAL(toggled(bool)), this, SLOT(do_set_numpad_enter_as_fullkey(bool)));
996
997         SET_ACTION_SINGLE(action_PrintCpuStatistics, true, true, (p_config->print_statistics));
998         connect(action_PrintCpuStatistics, SIGNAL(toggled(bool)), this, SLOT(do_set_print_cpu_statistics(bool)));
999         
1000         // Cursor to ten key.
1001         menu_EmulateCursorAs = new QMenu(this);
1002         menu_EmulateCursorAs->setToolTipsVisible(true);
1003         actionGroup_EmulateCursorAs = new QActionGroup(this);
1004         actionGroup_EmulateCursorAs->setExclusive(true);
1005         {
1006                 for(i = 0; i < 3; i++) {
1007                         tmps = QString::number(i);
1008                         action_EmulateCursorAs[i] = new Action_Control(this, using_flags);
1009                         action_EmulateCursorAs[i]->setObjectName(QString::fromUtf8("action_EmulateCursorAs", -1) + tmps);
1010                         action_EmulateCursorAs[i]->setCheckable(true);
1011                         action_EmulateCursorAs[i]->binds->setValue1(i);
1012                         actionGroup_EmulateCursorAs->addAction(action_EmulateCursorAs[i]);
1013                         menu_EmulateCursorAs->addAction(action_EmulateCursorAs[i]);
1014                         if(i == p_config->cursor_as_ten_key) action_EmulateCursorAs[i]->setChecked(true);
1015                                 
1016                         connect(action_EmulateCursorAs[i], SIGNAL(triggered()),
1017                                         action_EmulateCursorAs[i], SLOT(do_set_emulate_cursor_as()));
1018                         connect(action_EmulateCursorAs[i], SIGNAL(sig_set_emulate_cursor_as(int)),
1019                                         this, SLOT(do_set_emulate_cursor_as(int)));
1020                 }
1021         }
1022         
1023         actionSpeed_FULL = new Action_Control(this, using_flags);
1024         actionSpeed_FULL->setObjectName(QString::fromUtf8("actionSpeed_FULL"));
1025         actionSpeed_FULL->setVisible(true);
1026         actionSpeed_FULL->setCheckable(true);
1027         actionSpeed_FULL->setChecked(false);
1028         if(p_config->full_speed) actionSpeed_FULL->setChecked(true);
1029         connect(actionSpeed_FULL, SIGNAL(toggled(bool)), this,SLOT(do_emu_full_speed(bool))); // OK?
1030         
1031         if(using_flags->is_use_joystick()) {
1032                 action_SetupJoystick = new Action_Control(this, using_flags);
1033         }
1034         if(using_flags->is_use_sound_files_fdd()) {
1035                 /*
1036                 action_SoundFilesFDD = new Action_Control(this, using_flags);
1037                 action_SoundFilesFDD->setCheckable(true);
1038                 action_SoundFilesFDD->setEnabled(true);
1039                 action_SoundFilesFDD->setChecked(false);
1040                 if(p_config->sound_noise_fdd != 0) {
1041                         action_SoundFilesFDD->setChecked(true);
1042                 }
1043                 */
1044                 SET_ACTION_SINGLE(action_SoundFilesFDD, true, true, (p_config->sound_noise_fdd != 0));
1045         }
1046         if(using_flags->is_use_sound_files_relay()) {
1047                 /*
1048                 action_SoundFilesRelay = new Action_Control(this, using_flags);
1049                 action_SoundFilesRelay->setCheckable(true);
1050                 action_SoundFilesRelay->setEnabled(true);
1051                 action_SoundFilesRelay->setChecked(false);
1052                 if(p_config->sound_noise_cmt != 0) {
1053                         action_SoundFilesRelay->setChecked(true);
1054                 }
1055                 */
1056                 SET_ACTION_SINGLE(action_SoundFilesRelay, true, true, (p_config->sound_noise_cmt != 0));
1057         }
1058         action_FocusWithClick = new Action_Control(this, using_flags);
1059         action_FocusWithClick->setCheckable(true);
1060         action_FocusWithClick->setEnabled(true);
1061         if(p_config->focus_with_click) {
1062                 action_FocusWithClick->setChecked(true);
1063         }
1064
1065         connect(action_FocusWithClick, SIGNAL(toggled(bool)),
1066                                 this, SLOT(do_set_window_focus_type(bool)));
1067         //connect(action_FocusWithClick, SIGNAL(sig_set_window_focus_type(bool)),
1068         //                      this, SLOT(do_set_window_focus_type(bool)));
1069
1070         action_Logging_FDC = NULL;
1071         if(using_flags->is_use_fd()) {
1072                 SET_ACTION_SINGLE(action_Logging_FDC, true, true, (p_config->special_debug_fdc != 0));
1073                 connect(action_Logging_FDC, SIGNAL(toggled(bool)), this, SLOT(do_set_logging_fdc(bool)));
1074         }
1075 #if !defined(Q_OS_WIN)
1076         action_LogToSyslog = new Action_Control(this, using_flags);
1077         action_LogToSyslog->setCheckable(true);
1078         action_LogToSyslog->setEnabled(true);
1079         if(p_config->log_to_syslog != 0) action_LogToSyslog->setChecked(true);
1080         menuDevLogToSyslog = new QMenu(this);
1081         menuDevLogToSyslog->setToolTipsVisible(true);
1082         for(int i = 0; i < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1); i++) {
1083                 action_DevLogToSyslog[i] = new Action_Control(this, using_flags);
1084                 action_DevLogToSyslog[i]->setCheckable(true);
1085                 action_DevLogToSyslog[i]->setEnabled(false);
1086                 action_DevLogToSyslog[i]->binds->setValue1(i);
1087                 menuDevLogToSyslog->addAction(action_DevLogToSyslog[i]);
1088                 if(p_config->dev_log_to_syslog[i][0]) action_DevLogToSyslog[i]->setChecked(true);
1089                 connect(action_DevLogToSyslog[i], SIGNAL(toggled(bool)),
1090                                 action_DevLogToSyslog[i], SLOT(do_set_dev_log_to_syslog(bool)));
1091                 connect(action_DevLogToSyslog[i], SIGNAL(sig_set_dev_log_to_syslog(int, bool)),
1092                                 this, SLOT(do_set_dev_log_to_syslog(int, bool)));
1093         }
1094 #endif
1095         action_LogToConsole = new Action_Control(this, using_flags);
1096         action_LogToConsole->setCheckable(true);
1097         action_LogToConsole->setEnabled(true);
1098         if(p_config->log_to_console != 0) action_LogToConsole->setChecked(true);
1099
1100         //menuDevLogToConsole = new QMenu(menuEmulator);
1101         menuDevLogToConsole = new QMenu(this);
1102         menuDevLogToConsole->setToolTipsVisible(true);
1103
1104         SET_ACTION_CONTROL_ARRAY(0, (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1),
1105                                                          this, using_flags,
1106                                                          menuDevLogToConsole, action_DevLogToConsole, true, false,
1107                                                          dev_log_to_console,
1108                                                          SIGNAL(toggled(bool)),
1109                                                          SLOT(do_set_dev_log_to_console(bool)),
1110                                                          SIGNAL(sig_set_dev_log_to_console(int, bool)),
1111                                                          SLOT(do_set_dev_log_to_console(int, bool)));
1112         /*
1113         for(int i = 0; i < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1); i++) {
1114                 action_DevLogToConsole[i] = new Action_Control(this, using_flags);
1115                 action_DevLogToConsole[i]->setCheckable(true);
1116                 action_DevLogToConsole[i]->setEnabled(false);
1117                 action_DevLogToConsole[i]->binds->setValue1(i);
1118                 menuDevLogToConsole->addAction(action_DevLogToConsole[i]);
1119                 if(p_config->dev_log_to_console[i][0]) action_DevLogToConsole[i]->setChecked(true);
1120                 connect(action_DevLogToConsole[i], SIGNAL(toggled(bool)),
1121                                 action_DevLogToConsole[i], SLOT(do_set_dev_log_to_console(bool)));
1122                 connect(action_DevLogToConsole[i], SIGNAL(sig_set_dev_log_to_console(int, bool)),
1123                                 this, SLOT(do_set_dev_log_to_console(int, bool)));
1124         }
1125         */
1126         action_LogView = new Action_Control(this, using_flags);
1127         connect(action_LogView, SIGNAL(triggered()),
1128                         this, SLOT(rise_log_viewer()));
1129         
1130         menu_SetRenderPlatform = new QMenu(this);
1131         menu_SetRenderPlatform->setToolTipsVisible(true);
1132         actionGroup_SetRenderPlatform = new QActionGroup(this);
1133         actionGroup_SetRenderPlatform->setExclusive(true);
1134         {
1135                         int render_type = p_config->render_platform;
1136                         int _major_version = p_config->render_major_version;
1137                         //int _minor_version = p_config->render_minor_version; // ToDo
1138                         for(i = 0; i < MAX_RENDER_PLATFORMS; i++) {
1139                                 tmps = QString::number(i);
1140                                 action_SetRenderPlatform[i] = new Action_Control(this, using_flags);
1141                                 action_SetRenderPlatform[i]->setObjectName(QString::fromUtf8("action_SetRenderPlatform", -1) + tmps);
1142                                 action_SetRenderPlatform[i]->setCheckable(true);
1143                                 action_SetRenderPlatform[i]->binds->setValue1(i);
1144                                 actionGroup_SetRenderPlatform->addAction(action_SetRenderPlatform[i]);
1145                                 menu_SetRenderPlatform->addAction(action_SetRenderPlatform[i]);
1146                                 if(i >= RENDER_PLATFORMS_END) {
1147                                         action_SetRenderPlatform[i]->setVisible(false);
1148                                 } else {
1149                                         if(render_type == CONFIG_RENDER_PLATFORM_OPENGL_ES) {
1150                                                 if(_major_version >= 2) {
1151                                                         if(i == RENDER_PLATFORMS_OPENGL_ES_2) {
1152                                                                 action_SetRenderPlatform[i]->setChecked(true);
1153                                                         }
1154                                                 }
1155                                         } else if(render_type == CONFIG_RENDER_PLATFORM_OPENGL_MAIN) {
1156                                                 if(_major_version >= 3) {
1157                                                         if(i == RENDER_PLATFORMS_OPENGL3_MAIN) {
1158                                                                 action_SetRenderPlatform[i]->setChecked(true);
1159                                                         }
1160                                                 } else if(i == RENDER_PLATFORMS_OPENGL2_MAIN) {
1161                                                         action_SetRenderPlatform[i]->setChecked(true);
1162                                                 }
1163                                         } else if(render_type == CONFIG_RENDER_PLATFORM_OPENGL_CORE) {
1164                                                 if(i == RENDER_PLATFORMS_OPENGL_CORE) {
1165                                                         action_SetRenderPlatform[i]->setChecked(true);
1166                                                 }                                               
1167                                         }                                               
1168                                 }
1169                                 connect(action_SetRenderPlatform[i], SIGNAL(triggered()),
1170                                                 action_SetRenderPlatform[i], SLOT(do_select_render_platform(void)));
1171                                 connect(action_SetRenderPlatform[i], SIGNAL(sig_select_render_platform(int)),
1172                                                 this, SLOT(do_select_render_platform(int)));
1173                         }
1174         }
1175         action_SetupKeyboard = new Action_Control(this, using_flags);
1176
1177         action_SetupMovie = new Action_Control(this, using_flags);
1178   
1179 }
1180
1181 #include "display_log.h"
1182
1183 void Ui_MainWindowBase::rise_log_viewer(void)
1184 {
1185         Dlg_LogViewer *dlg = new Dlg_LogViewer(using_flags, csp_logger, NULL);
1186         dlg->show();
1187 }
1188
1189 void Ui_MainWindowBase::rise_joystick_dialog(void)
1190 {
1191         if(graphicsView != NULL) {
1192                 QStringList *lst = graphicsView->getVKNames();
1193                 CSP_DropDownJoysticks *dlg = new CSP_DropDownJoysticks(NULL, lst, using_flags);
1194                 dlg->setWindowTitle(QApplication::translate("CSP_DropDownJoysticks", "Configure Joysticks", 0));
1195                 dlg->show();
1196         }
1197 }
1198
1199 QString Ui_MainWindowBase::get_system_version()
1200 {
1201         return QString::fromUtf8("Dummy");
1202 }
1203
1204 QString Ui_MainWindowBase::get_build_date()
1205 {
1206         return QString::fromUtf8("Dummy");
1207 }
1208
1209
1210 void Ui_MainWindowBase::rise_movie_dialog(void)
1211 {
1212
1213 }
1214
1215 void Ui_MainWindowBase::rise_keyboard_dialog(void)
1216 {
1217         if(graphicsView != NULL) {
1218                 CSP_KeySetDialog *dlg = new CSP_KeySetDialog(NULL, graphicsView);
1219                 dlg->setWindowTitle(QApplication::translate("KeySetDialog", "Configure Keyboard", 0));
1220                 dlg->show();
1221         }
1222 }
1223 // Retranslate
1224 void Ui_MainWindowBase::retranslateUI_Help(void)
1225 {
1226         menuHELP->setTitle(QApplication::translate("MenuHelp", "Help", 0));
1227         actionHelp_AboutQt->setText(QApplication::translate("MenuHelp", "About Qt", 0));
1228         actionHelp_AboutQt->setToolTip(QApplication::translate("MenuHelp", "Display Qt version.", 0));
1229         actionHelp_AboutQt->setIcon(QApplication::style()->standardIcon(QStyle::SP_TitleBarMenuButton));
1230         
1231         actionAbout->setText(QApplication::translate("MenuHelp", "About...", 0));
1232         actionAbout->setIcon(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion));
1233         actionAbout->setToolTip(QApplication::translate("MenuHelp", "About this emulator.", 0));
1234
1235         menuHelp_Readme->setTitle(QApplication::translate("MenuHelp", "READMEs", 0));
1236         
1237         actionHelp_README->setText(QApplication::translate("MenuHelp", "General Document", 0));
1238         actionHelp_README_QT->setText(QApplication::translate("MenuHelp", "About Qt ports", 0));
1239         actionHelp_README_Artane->setText(QApplication::translate("MenuHelp", "About Qt ports (Japanese).", 0));
1240         actionHelp_README_Umaiboux->setText(QApplication::translate("MenuHelp", "By Mr. Umaiboux.", 0));
1241         actionHelp_README_MR_TANAM->setText(QApplication::translate("MenuHelp", "By Mr. tanam", 0));
1242         actionHelp_README_FM7->setText(QApplication::translate("MenuHelp", "About eFM-7/8/77/AV.", 0));
1243         actionHelp_README_FM7_JP->setText(QApplication::translate("MenuHelp", "About eFM-7/8/77/AV (Japanese).", 0));
1244         actionHelp_README_FAQ->setText(QApplication::translate("MenuHelp", "FAQs(English)", 0));
1245         actionHelp_README_FAQ_JP->setText(QApplication::translate("MenuHelp", "FAQs(Japanese)", 0));
1246         actionHelp_README_BIOS->setText(QApplication::translate("MenuHelp", "BIOS and Key assigns", 0));
1247
1248         menuHelp_Histories->setTitle(QApplication::translate("MenuHelp", "Histories", 0));
1249         actionHelp_History->setText(QApplication::translate("MenuHelp", "General History", 0));
1250         actionHelp_History_Relnote->setText(QApplication::translate("MenuHelp", "Release Note", 0));
1251         actionHelp_History_ChangeLog->setText(QApplication::translate("MenuHelp", "Change Log", 0));
1252         actionHelp_History_MR_TANAM->setText(QApplication::translate("MenuHelp", "History by Tanam", 0));
1253
1254         actionHelp_License->setText(QApplication::translate("MenuHelp", "Show License", 0));
1255         actionHelp_License->setToolTip(QApplication::translate("MenuHelp", "Show general license (GPLv2).", 0));
1256         actionHelp_License_JP->setText(QApplication::translate("MenuHelp", "Show License (Japanese)", 0));
1257         actionHelp_License_JP->setToolTip(QApplication::translate("MenuHelp", "Show general license (GPLv2).\nTranslated to Japanese.", 0));
1258         ui_retranslate_completed = true;
1259 }
1260
1261 // You can Override this function: Re-define on foo/MainWindow.cpp.
1262 // This code is example: by X1(TurboZ).
1263 void Ui_MainWindowBase::retranslateMachineMenu(void)
1264 {
1265         int i;
1266         QString tmps;
1267         QString tmps2;
1268         menuMachine->setTitle(QApplication::translate("MenuMachine", "Machine", 0));
1269         if(using_flags->get_use_device_type() > 0) {
1270                 menuDeviceType->setTitle(QApplication::translate("MenuMachine", "Device Type", 0));
1271                 for(i = 0; i < using_flags->get_use_device_type(); i++) {
1272                         tmps2.setNum(i + 1);
1273                         tmps = QString::fromUtf8("Machine Device ") + tmps2;
1274                         actionDeviceType[i]->setText(tmps); 
1275                 }
1276         }
1277         if(using_flags->get_use_sound_device_type() > 0) {
1278                 menuSoundDevice->setTitle(QApplication::translate("MenuMachine", "Sound Cards", 0));
1279                 for(i = 0; i < using_flags->get_use_sound_device_type(); i++) {
1280                         tmps2.setNum(i + 1);
1281                         tmps = QString::fromUtf8("Sound Device ") + tmps2;
1282                         actionSoundDevice[i]->setText(tmps); 
1283                 }
1284         }
1285         if(using_flags->get_use_drive_type() > 0) {
1286                 menuDriveType->setTitle(QApplication::translate("MenuMachine", "Drive Type", 0));
1287                 for(i = 0; i < using_flags->get_use_drive_type(); i++) {
1288                         tmps2.setNum(i + 1);
1289                         tmps = QString::fromUtf8("Drive Type ") + tmps2;
1290                         actionDriveType[i]->setText(tmps); 
1291                 }
1292         }
1293         if(using_flags->is_use_printer()) {
1294                 menuPrintDevice->setTitle(QApplication::translate("MenuMachine", "Printer (Need RESET)", 0));
1295                 i = 1;
1296                 actionPrintDevice[0]->setText(QApplication::translate("MenuMachine", "Dump to File", 0));
1297                 actionPrintDevice[0]->setToolTip(QApplication::translate("MenuMachine", "Dump printer output to file.\nMaybe output only ascii text.", 0));
1298                 if(using_flags->get_use_printer_type() > 0) {
1299                         for(i = 1; i < (using_flags->get_use_printer_type() - 1); i++) {
1300                                 tmps2.setNum(i + 1);
1301                                 tmps = QApplication::translate("MenuMachine", "Printer", 0) + tmps2;
1302                                 actionPrintDevice[i]->setText(tmps); 
1303                                 actionPrintDevice[i]->setToolTip(tmps); 
1304                         }
1305                 }
1306                 actionPrintDevice[i]->setText(QApplication::translate("MenuMachine", "Not Connect", 0));
1307                 actionPrintDevice[i]->setToolTip(QApplication::translate("MenuMachine", "None devices connect to printer port.", 0));
1308         }
1309         if(using_flags->get_use_monitor_type() > 0) {
1310                 menuMonitorType->setTitle("Monitor Type");
1311                 menuMonitorType->setToolTipsVisible(true);
1312                 for(int ii = 0; ii < using_flags->get_use_monitor_type(); ii++) {
1313                         tmps = QString::fromUtf8("Monitor %1").arg(ii + 1);
1314                         actionMonitorType[ii]->setText(tmps);
1315                 }
1316         }
1317 }
1318 void Ui_MainWindowBase::retranslateUi(void)
1319 {
1320         retranslateControlMenu("Reset",  true);
1321         if(!using_flags->is_without_sound()) {
1322                 retranslateSoundMenu();
1323         }
1324         retranslateScreenMenu();
1325         retranslateMachineMenu();
1326         retranslateEmulatorMenu();
1327         retranslateUI_Help();
1328         if(using_flags->is_use_binary_file()) {
1329                 int basedrv = using_flags->get_base_binary_num();
1330                 for(int i = 0; i < using_flags->get_max_binary(); i++) {
1331                         retranslateBinaryMenu(i, basedrv);
1332                 }
1333         }
1334         if(using_flags->is_use_bubble()) {
1335                 int basedrv = using_flags->get_base_bubble_num();
1336                 for(int i = 0; i < using_flags->get_max_bubble(); i++) {
1337                         retranslateBubbleMenu(i, basedrv);
1338                 }
1339         }
1340         if(using_flags->is_use_cart()) {
1341                 int basedrv = using_flags->get_base_cart_num();
1342                 for(int i = 0; i < using_flags->get_max_cart(); i++) {
1343                         retranslateCartMenu(i, basedrv);
1344                 }
1345         }
1346         if(using_flags->is_use_compact_disc()) {
1347                 retranslateCDROMMenu();
1348         }
1349         if(using_flags->is_use_tape()) {
1350                 int basedrv = using_flags->get_base_tape_num();
1351                 for(int i = 0; i < using_flags->get_max_tape(); i++) {
1352                         retranslateCMTMenu(i);
1353                 }
1354         }
1355         if(using_flags->is_use_fd()) {
1356                 int basedrv = using_flags->get_base_floppy_disk_num();
1357                 for(int i = 0; i < using_flags->get_max_drive(); i++) {
1358                         retranslateFloppyMenu(i, basedrv + i);
1359                 }
1360         }
1361         if(using_flags->is_use_hdd()) {
1362                 int basedrv = using_flags->get_base_hdd_num();
1363                 for(int i = 0; i < using_flags->get_max_hdd(); i++) {
1364                         retranslateHardDiskMenu(i, basedrv + i);
1365                 }
1366         }
1367         if(using_flags->is_use_laser_disc()) {
1368                 retranslateLaserdiscMenu();
1369         }
1370         if(using_flags->is_use_qd()) {
1371                 int basedrv = using_flags->get_base_quick_disk_num();
1372                 for(int i = 0; i < using_flags->get_max_qd(); i++) {
1373                         retranslateQuickDiskMenu(i, basedrv);
1374                 }
1375         }
1376 } // retranslateUi
1377
1378 void Ui_MainWindowBase::doBeforeCloseMainWindow(void)
1379 {
1380         //emit quit_debugger_thread();
1381         emit quit_emulator_all();
1382 }
1383
1384 void Ui_MainWindowBase::setCoreApplication(QApplication *p)
1385 {
1386         this->CoreApplication = p;
1387         connect(actionExit_Emulator, SIGNAL(triggered()),
1388                         this, SLOT(doBeforeCloseMainWindow())); // OnGuiExit()?
1389         connect(this, SIGNAL(quit_emulator_all()), CoreApplication, SLOT(closeAllWindows()));
1390         connect(actionHelp_AboutQt, SIGNAL(triggered()),
1391                         this->CoreApplication, SLOT(aboutQt()));
1392         
1393 }
1394
1395 #include <string>
1396 // Move from common/qt_main.cpp
1397 // menu
1398 DLL_PREFIX std::string cpp_confdir;
1399 extern std::string my_procname;
1400 extern bool now_menuloop;
1401 // timing control
1402
1403 // screen
1404 extern unsigned int desktop_width;
1405 extern unsigned int desktop_height;
1406 //int desktop_bpp;
1407 extern int prev_window_mode;
1408 extern bool now_fullscreen;
1409 extern int window_mode_count;
1410
1411 void Ui_MainWindowBase::set_window(int mode)
1412 {
1413         //      static LONG style = WS_VISIBLE;
1414 }
1415
1416 void Ui_MainWindowBase::do_emu_update_volume_level(int num, int level)
1417 {
1418         emit sig_emu_update_volume_level(num, level);
1419 }
1420
1421 void Ui_MainWindowBase::do_emu_update_volume_balance(int num, int level)
1422 {
1423         emit sig_emu_update_volume_balance(num, level);
1424 }
1425
1426 void Ui_MainWindowBase::do_emu_update_config(void)
1427 {
1428         emit sig_emu_update_config();
1429 }
1430
1431 void Ui_MainWindowBase::doChangeMessage_EmuThread(QString message)
1432 {
1433       emit message_changed(message);
1434 }
1435
1436 void Ui_MainWindowBase::do_set_visible_virtual_media_none()
1437 {
1438         QRect rect;
1439         driveData->setVisible(false);
1440         p_config->virtual_media_position = 0;
1441         set_screen_size(graphicsView->width(), graphicsView->height());
1442         
1443         pCentralLayout->setDirection(QBoxLayout::TopToBottom);
1444         rect.setRect(0, 0, graphicsView->width(), graphicsView->height() + 2);
1445         
1446         pCentralLayout->removeWidget(driveData);
1447         pCentralWidget->setGeometry(rect);
1448         //pCentralLayout->setGeometry(rect);
1449         pCentralLayout->update();
1450         pCentralWidget->setLayout(pCentralLayout);
1451         MainWindow->setCentralWidget(pCentralWidget);
1452         //emit sig_set_display_osd(true);
1453 }
1454
1455 void Ui_MainWindowBase::do_set_visible_virtual_media_upper()
1456 {
1457         QRect rect;
1458         driveData->setVisible(true);
1459         p_config->virtual_media_position = 1;
1460         set_screen_size(graphicsView->width(), graphicsView->height());
1461         emit sig_set_orientation_osd(1);
1462         pCentralLayout->setDirection(QBoxLayout::TopToBottom);
1463         pCentralLayout->removeWidget(driveData);
1464         pCentralLayout->removeWidget(graphicsView);
1465         pCentralLayout->addWidget(driveData);
1466         pCentralLayout->addWidget(graphicsView);
1467         rect.setRect(0, 0, graphicsView->width(), graphicsView->height() + driveData->height() + 2);
1468         pCentralWidget->setGeometry(rect);
1469         //pCentralLayout->setGeometry(rect);
1470         pCentralLayout->update();
1471         pCentralWidget->setLayout(pCentralLayout);
1472         MainWindow->setCentralWidget(pCentralWidget);
1473         //emit sig_set_display_osd(false);
1474 }
1475
1476 void Ui_MainWindowBase::do_set_visible_virtual_media_lower()
1477 {
1478         QRect rect;
1479         driveData->setVisible(true);
1480         p_config->virtual_media_position = 2;
1481         set_screen_size(graphicsView->width(), graphicsView->height());
1482         emit sig_set_orientation_osd(2);
1483         pCentralLayout->setDirection(QBoxLayout::BottomToTop);
1484         pCentralLayout->removeWidget(driveData);
1485         pCentralLayout->removeWidget(graphicsView);
1486         pCentralLayout->addWidget(driveData);
1487         pCentralLayout->addWidget(graphicsView);
1488         
1489         rect.setRect(0, 0, graphicsView->width(), graphicsView->height() + driveData->height() + 2);
1490         pCentralWidget->setGeometry(rect);
1491         pCentralLayout->update();
1492         pCentralWidget->setLayout(pCentralLayout);
1493         MainWindow->setCentralWidget(pCentralWidget);
1494 }
1495
1496 void Ui_MainWindowBase::do_set_visible_virtual_media_left()
1497 {
1498 #if 0
1499         driveData->setVisible(true);
1500         p_config->virtual_media_position = 3;
1501         set_screen_size(graphicsView->width(), graphicsView->height());
1502         emit sig_set_orientation_osd(3);
1503         pCentralLayout->removeWidget(driveData);
1504         pCentralLayout->addWidget(driveData, 1, 0);
1505         //emit sig_set_display_osd(false);
1506 #endif
1507 }
1508
1509 void Ui_MainWindowBase::do_set_visible_virtual_media_right()
1510 {
1511 #if 0
1512         driveData->setVisible(true);
1513         p_config->virtual_media_position = 4;
1514         set_screen_size(graphicsView->width(), graphicsView->height());
1515         emit sig_set_orientation_osd(4);
1516         pCentralLayout->removeWidget(driveData);
1517         pCentralLayout->addWidget(driveData, 1, 2);
1518         //emit sig_set_display_osd(false);
1519 #endif
1520 }
1521
1522 void Ui_MainWindowBase::StopEmuThread(void)
1523 {
1524         emit quit_emu_thread();
1525 }
1526
1527 void Ui_MainWindowBase::delete_emu_thread(void)
1528 {
1529         //do_release_emu_resources();
1530         emit sig_quit_all();
1531 }  
1532 // Utility
1533 #include <QTextCodec>
1534 #include <QString>
1535 #include <QByteArray>
1536
1537 void Convert_CP932_to_UTF8(char *dst, char *src, int n_limit, int i_limit)
1538 {
1539         QTextCodec *srcCodec = QTextCodec::codecForName( "SJIS" );
1540         QTextCodec *dstCodec = QTextCodec::codecForName( "UTF-8" );
1541         QString dst_b;
1542         QByteArray dst_s;
1543         if(src == NULL) {
1544                 if(dst != NULL) dst[0] = '\0';
1545                 return;
1546         }
1547         if(dst == NULL) return;
1548         dst_b = srcCodec->toUnicode(src, strlen(src));
1549         dst_s = dstCodec->fromUnicode(dst_b);
1550         if(n_limit > 0) {
1551                 memset(dst, 0x00, n_limit);
1552                 strncpy(dst, dst_s.constData(), n_limit - 1);
1553         }
1554 }
1555
1556 void Ui_MainWindowBase::set_window_title()
1557 {
1558         QString tmps;
1559         tmps = QString::fromUtf8("emu");
1560         tmps = tmps + using_flags->get_config_name();
1561         tmps = tmps + QString::fromUtf8(" (");
1562         tmps = tmps + using_flags->get_device_name();
1563         tmps = tmps + QString::fromUtf8(")");
1564         MainWindow->setWindowTitle(tmps);
1565 }
1566
1567 void Ui_MainWindowBase::do_set_window_title(QString s)
1568 {
1569         QString tmps;
1570         tmps = QString::fromUtf8("emu");
1571         tmps = tmps + using_flags->get_config_name();
1572         tmps = tmps + QString::fromUtf8(" (");
1573         if(!s.isEmpty()) {
1574                 tmps = tmps + s;
1575         }
1576         tmps = tmps + QString::fromUtf8(")");
1577         MainWindow->setWindowTitle(tmps);
1578 }
1579
1580 void Ui_MainWindowBase::do_set_mouse_enable(bool flag)
1581 {
1582 }
1583
1584 void Ui_MainWindowBase::do_toggle_mouse(void)
1585 {
1586 }
1587
1588 void Ui_MainWindowBase::LaunchEmuThread(void)
1589 {
1590 }
1591
1592 void Ui_MainWindowBase::LaunchJoyThread(void)
1593 {
1594 }
1595
1596 void Ui_MainWindowBase::StopJoyThread(void)
1597 {
1598 }
1599
1600 void Ui_MainWindowBase::delete_joy_thread(void)
1601 {
1602 }
1603
1604 void Ui_MainWindowBase::on_actionExit_triggered()
1605 {
1606         OnMainWindowClosed();
1607 }
1608
1609 void Ui_MainWindowBase::OnWindowMove(void)
1610 {
1611 }
1612
1613
1614 void Ui_MainWindowBase::OnWindowRedraw(void)
1615 {
1616 }
1617
1618 bool Ui_MainWindowBase::GetPowerState(void)
1619 {
1620         return true;
1621 }
1622
1623 void Ui_MainWindowBase::OnMainWindowClosed(void)
1624 {
1625 }
1626
1627
1628 void Ui_MainWindowBase::do_release_emu_resources(void)
1629 {
1630 }
1631
1632 void Ui_MainWindowBase::OnOpenDebugger(int no)
1633 {
1634 }
1635
1636 void Ui_MainWindowBase::OnCloseDebugger(void )
1637 {
1638 }
1639
1640 /*
1641  * This is main for Qt.
1642  */
1643 DLL_PREFIX CSP_Logger *csp_logger;
1644