OSDN Git Service

[UI][Qt] Not liking config, using_flags directly.
[csp-qt/common_source_project-fm7.git] / source / src / qt / machines / mz700 / MainWindow.cpp
1 /*
2  * Common Source code Project:
3  * Ui->Qt->MainWindow for X1TurboZ .
4  * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
5  *   License : GPLv2
6  *   History :
7  * Jan 14, 2015 : Initial, many of constructors were moved to qt/gui/menu_main.cpp.
8  */
9
10 #include <QVariant>
11 #include <QtGui>
12 #include "vm.h"
13 #include "commonclasses.h"
14 #include "menuclasses.h"
15 #include "emu.h"
16 #include "qt_main.h"
17
18 //QT_BEGIN_NAMESPACE
19
20 extern config_t config;
21
22 Action_Control_MZ700::Action_Control_MZ700(QObject *parent, USING_FLAGS *p) : Action_Control(parent, p)
23 {
24         mz_binds = new Object_Menu_Control_MZ700(parent, p);
25 }
26
27 Action_Control_MZ700::~Action_Control_MZ700(){
28         delete mz_binds;
29 }
30
31 Object_Menu_Control_MZ700::Object_Menu_Control_MZ700(QObject *parent, USING_FLAGS *p) : Object_Menu_Control(parent, p)
32 {
33 }
34
35 Object_Menu_Control_MZ700::~Object_Menu_Control_MZ700(){
36 }
37
38 void Object_Menu_Control_MZ700::do_monitor_type(void)
39 {
40         emit sig_monitor_type(getValue1());
41 }
42
43 void META_MainWindow::set_monitor_type(int num)
44 {
45 #ifdef USE_MONITOR_TYPE
46         if((num < 0) || (num >= USE_MONITOR_TYPE)) return;
47         config.monitor_type = num;
48         this->do_emu_update_config();
49 #endif
50 }
51
52 void META_MainWindow::do_set_pcg(bool flag)
53 {
54 #ifdef _MZ700
55         this->set_dipsw(0, flag);
56         //this->do_emu_update_config();
57 #endif
58 }
59
60 void META_MainWindow::setupUI_Emu(void)
61 {
62 #if !defined(_MZ800)
63         //menuMachine->setVisible(false);
64 #endif   
65 #if defined(_MZ700)
66         action_PCG700 = new QAction(menuMachine);
67         action_PCG700->setCheckable(true);
68         if((config.dipswitch & 0x0001) != 0) action_PCG700->setChecked(true);
69         connect(action_PCG700, SIGNAL(toggled(bool)), this, SLOT(do_set_pcg(bool)));
70         menuMachine->addAction(action_PCG700);
71         menuMachine->addSeparator();
72 #endif
73 #if defined(USE_BOOT_MODE)
74         menuBootMode = new QMenu(menuMachine);
75         menuBootMode->setObjectName(QString::fromUtf8("menuControl_BootMode"));
76         menuMachine->addAction(menuBootMode->menuAction());
77         ConfigCPUBootMode(USE_BOOT_MODE);
78 #endif
79 #if defined(USE_MONITOR_TYPE)
80         {
81                 int ii;
82                 menuMonitorType = new QMenu(menuMachine);
83                 menuMonitorType->setObjectName(QString::fromUtf8("menuControl_MonitorType"));
84                 menuMachine->addAction(menuMonitorType->menuAction());
85                 
86                 actionGroup_MonitorType = new QActionGroup(this);
87                 actionGroup_MonitorType->setExclusive(true);
88                 for(ii = 0; ii < USE_MONITOR_TYPE; ii++) {
89                         actionMonitorType[ii] = new Action_Control_MZ700(this, using_flags);
90                         actionGroup_MonitorType->addAction(actionMonitorType[ii]);
91                         actionMonitorType[ii]->setCheckable(true);
92                         actionMonitorType[ii]->setVisible(true);
93                         actionMonitorType[ii]->mz_binds->setValue1(ii);
94                         if(config.monitor_type == ii) actionMonitorType[ii]->setChecked(true);
95                         menuMonitorType->addAction(actionMonitorType[ii]);
96                         connect(actionMonitorType[ii], SIGNAL(triggered()),
97                                         actionMonitorType[ii]->mz_binds, SLOT(do_monitor_type()));
98                         connect(actionMonitorType[ii]->mz_binds, SIGNAL(sig_monitor_type(int)),
99                                         this, SLOT(set_monitor_type(int)));
100                 }
101         }
102 #endif
103
104 }
105
106 void META_MainWindow::retranslateUi(void)
107 {
108         retranslateControlMenu(" ",  true);
109         retranslateFloppyMenu(0, 0);
110         retranslateFloppyMenu(1, 1);
111         retranslateQuickDiskMenu(0, 0);
112         retranslateCMTMenu();
113         retranslateSoundMenu();
114         retranslateScreenMenu();
115         retranslateMachineMenu();
116         retranslateEmulatorMenu();
117         retranslateUI_Help();
118         
119         this->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0));
120 #if defined(_MZ800)
121         menuBootMode->setTitle("BOOT Mode");
122         actionBootMode[0]->setText(QString::fromUtf8("MZ-800"));
123         actionBootMode[1]->setText(QString::fromUtf8("MZ-700"));
124    
125         menuMonitorType->setTitle("Monitor Type");
126         actionMonitorType[0]->setText(QApplication::translate("MainWindow", "Color", 0));
127         actionMonitorType[1]->setText(QApplication::translate("MainWindow", "Monochrome", 0));
128         menuMachine->setTitle(QApplication::translate("MainWindow", "Machine", 0));;
129 #elif defined(_MZ700)
130         action_PCG700->setText(QApplication::translate("MainWindow", "PCG-700", 0));
131 #endif
132 #if defined(_MZ1500)
133         actionPrintDevice[1]->setText(QString::fromUtf8("Sharp MZ-1P17"));
134 #endif
135 #ifdef USE_DEBUGGER
136         actionDebugger[0]->setVisible(true);
137         actionDebugger[1]->setVisible(false);
138         actionDebugger[2]->setVisible(false);
139         actionDebugger[3]->setVisible(false);
140 #endif
141         // Set Labels
142 } // retranslateUi
143
144
145 META_MainWindow::META_MainWindow(USING_FLAGS *p, QWidget *parent) : Ui_MainWindow(p, parent)
146 {
147         setupUI_Emu();
148         retranslateUi();
149 }
150
151
152 META_MainWindow::~META_MainWindow()
153 {
154 }
155
156 //QT_END_NAMESPACE
157
158
159