OSDN Git Service

[UI][Qt] Update UIs, related by src/rc/foo.rc .
[csp-qt/common_source_project-fm7.git] / source / src / qt / machines / pc8801 / 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 <QApplication>
13 #include <QMenu>
14
15 #include "commonclasses.h"
16 #include "menuclasses.h"
17 #include "emu.h"
18 #include "qt_main.h"
19 #include "sound_dialog.h"
20
21 //QT_BEGIN_NAMESPACE
22
23 extern config_t config;
24
25 Object_Menu_Control_88::Object_Menu_Control_88(QObject *parent, USING_FLAGS *p) : Object_Menu_Control(parent, p)
26 {
27 }
28
29 Object_Menu_Control_88::~Object_Menu_Control_88()
30 {
31 }
32
33 void Object_Menu_Control_88::do_set_display_mode(void)
34 {
35         emit sig_display_mode(getValue1());
36 }
37
38
39 void Object_Menu_Control_88::do_set_memory_wait(bool flag)
40 {
41         emit sig_set_dipsw(0, flag);
42 }
43
44
45 Action_Control_88::Action_Control_88(QObject *parent, USING_FLAGS *p) : Action_Control(parent, p)
46 {
47         pc88_binds = new Object_Menu_Control_88(parent, p);
48         pc88_binds->setValue1(0);
49 }
50
51 Action_Control_88::~Action_Control_88()
52 {
53         delete pc88_binds;
54 }
55
56 void META_MainWindow::retranslateVolumeLabels(Ui_SoundDialog *p)
57 {
58         if(p != NULL) {
59                 p->setDeviceLabel(1, QApplication::translate("MenuPC88", "CMT", 0));
60                 switch(config_sound_device_type) {
61                 case 0:
62                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPNA", 0));
63                         p->setSliderVisible(2, true);
64                         p->setSliderVisible(3, false);
65                         break;
66                 case 1:
67                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPN", 0));
68                         p->setSliderVisible(2, true);
69                         p->setSliderVisible(3, false);
70                         break;
71 #ifdef SUPPORT_PC88_SB2
72                 case 2:
73                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPN", 0));
74                         p->setDeviceLabel(3, QApplication::translate("MenuPC88", "OPNA", 0));
75                         p->setSliderVisible(2, true);
76                         p->setSliderVisible(3, true);
77                         break;
78                 case 3:
79                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPN-1", 0));
80                         p->setDeviceLabel(3, QApplication::translate("MenuPC88", "OPN-2", 0));
81                         p->setSliderVisible(2, true);
82                         p->setSliderVisible(3, true);
83                         break;
84                 case 4:
85                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPNA-1", 0));
86                         p->setDeviceLabel(3, QApplication::translate("MenuPC88", "OPNA-2", 0));
87                         p->setSliderVisible(2, true);
88                         p->setSliderVisible(3, true);
89                         break;
90                 case 5:
91                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPNA", 0));
92                         p->setDeviceLabel(3, QApplication::translate("MenuPC88", "OPN", 0));
93                         p->setSliderVisible(2, true);
94                         p->setSliderVisible(3, true);
95                         break;
96 #endif
97                 }
98                 
99         }
100 }
101
102 void META_MainWindow::retranslateUi(void)
103 {
104         const char *title="";
105         Ui_MainWindowBase::retranslateUi();
106         retranslateControlMenu(title, false);
107         config_sound_device_type = config.sound_type;
108         
109         this->setWindowTitle(QApplication::translate("MenuPC88", "MainWindow", 0));
110         
111         // PC88 Specified
112         menuCpuType->setTitle(QApplication::translate("MenuPC88", "CPU Frequency", 0));
113 #if defined(_PC8801MA)
114         actionCpuType[0]->setText(QString::fromUtf8("8MHz"));
115         actionCpuType[1]->setText(QString::fromUtf8("4MHz"));
116         actionCpuType[2]->setText(QString::fromUtf8("8MHz (FE2/MC)"));
117 #else // _PC8001SR
118         actionCpuType[0]->setText(QString::fromUtf8("4MHz"));
119         //menuCpuType->setVisible(false);
120         //actionCpuType[0]->setVisible(false);
121 #endif
122   
123 #if defined(_PC8801MA)
124         menuBootMode->setTitle(QApplication::translate("MenuPC88", "Machine Mode", 0));
125         menuBootMode->setToolTipsVisible(true);
126         actionBootMode[0]->setText(QString::fromUtf8("N88-V1(S) Mode"));
127         actionBootMode[1]->setText(QString::fromUtf8("N88-V1(H) Mode"));        
128         actionBootMode[2]->setText(QString::fromUtf8("N88-V2 Mode"));
129         actionBootMode[3]->setText(QString::fromUtf8("N Mode (N80 compatible)"));
130         actionBootMode[0]->setToolTip(QApplication::translate("MenuPC88", "V1(Standard) Mode.\nYou can run softwares of PC-8801/mk2.", 0));
131         actionBootMode[1]->setToolTip(QApplication::translate("MenuPC88", "V1(High Speed) Mode.\nYou can run softwares of PC-8801/mk2 faster.", 0));    
132         actionBootMode[2]->setToolTip(QApplication::translate("MenuPC88", "V2 Mode.\nYou can run only softwares for PC-8801SR or later.", 0));
133         actionBootMode[3]->setToolTip(QApplication::translate("MenuPC88", "N Mode.\nYou can run softwares of PC-8001/mk2.", 0));
134 #elif defined(_PC8001SR)
135         menuBootMode->setTitle("Machine Mode");
136         menuBootMode->setToolTipsVisible(true);
137         actionBootMode[0]->setText(QString::fromUtf8("N80-V1     Mode"));
138         actionBootMode[1]->setText(QString::fromUtf8("N80-V2(SR) Mode"));       
139         actionBootMode[2]->setText(QString::fromUtf8("N Mode"));
140         actionBootMode[0]->setToolTip(QApplication::translate("MenuPC88", "V1 Mode.\nYou can run softwares of PC-8001/mk2.", 0));
141         actionBootMode[1]->setToolTip(QApplication::translate("MenuPC88", "V2 Mode.\nYou can run only softwares for PC-8001mk2SR or later.", 0));
142         actionBootMode[2]->setToolTip(QApplication::translate("MenuPC88", "N  Mode.\nYou can run only softwares for PC-8001.", 0));
143 #endif
144
145         menuSoundDevice->setTitle(QApplication::translate("MenuPC88", "Sound Boards", 0));
146 #if defined(SUPPORT_PC88_SB2)
147         menuSoundDevice->setTitle(QApplication::translate("MenuPC88", "Sound Board", 0));
148         actionSoundDevice[0]->setText(QString::fromUtf8("PC-8801-23 (OPNA)"));
149         actionSoundDevice[1]->setText(QString::fromUtf8("PC-8801-11 (OPN)"));   
150         actionSoundDevice[2]->setText(QString::fromUtf8("Sound Board 2 (OPN + OPNA)"));   
151         actionSoundDevice[3]->setText(QString::fromUtf8("Sound Board 2(OPN + OPN)"));   
152         actionSoundDevice[4]->setText(QString::fromUtf8("Sound Board 2 (OPNA + OPNA)"));   
153         actionSoundDevice[5]->setText(QString::fromUtf8("Sound Board 2 (OPNA + OPN)"));
154         actionSoundDevice[0]->setToolTip(QApplication::translate("MenuPC88", "PC-8801-23 (OPNA).", 0));
155         actionSoundDevice[1]->setToolTip(QApplication::translate("MenuPC88", "PC-8801-11 (OPN).", 0));   
156         actionSoundDevice[2]->setToolTip(QApplication::translate("MenuPC88", "Sound Board 2 (OPN + OPNA).", 0));   
157         actionSoundDevice[3]->setToolTip(QApplication::translate("MenuPC88", "Sound Board 2 (OPN + OPN).", 0));   
158         actionSoundDevice[4]->setToolTip(QApplication::translate("MenuPC88", "Sound Board 2 (OPNA + OPNA).", 0));   
159         actionSoundDevice[5]->setToolTip(QApplication::translate("MenuPC88", "Sound Board 2 (OPNA + OPN).", 0));   
160 #elif defined(SUPPORT_PC88_OPNA)
161         menuSoundDevice->setTitle(QApplication::translate("MenuPC88", "Sound Board", 0));
162         actionSoundDevice[0]->setText(QString::fromUtf8("PC-8801-23 (OPNA)"));
163         actionSoundDevice[1]->setText(QString::fromUtf8("PC-8801-11 (OPN)"));
164         actionSoundDevice[0]->setToolTip(QApplication::translate("MenuPC88", "PC-8801-23 (OPNA).", 0));
165         actionSoundDevice[1]->setToolTip(QApplication::translate("MenuPC88", "PC-8801-11 (OPN).", 0));
166 #endif
167 #ifdef USE_DEBUGGER
168         actionDebugger[0]->setText(QApplication::translate("MenuPC88", "Main CPU", 0));
169 #if defined(_PC8001SR)  
170         actionDebugger[1]->setText(QApplication::translate("MenuPC88", "PC-80S31K CPU", 0));
171 #else
172         actionDebugger[1]->setText(QApplication::translate("MenuPC88", "Sub CPU", 0));
173 #endif  
174         actionDebugger[0]->setVisible(true);
175         actionDebugger[1]->setVisible(true);
176         
177         actionDebugger[2]->setVisible(false);
178         actionDebugger[3]->setVisible(false);
179 #endif  
180 #if defined(USE_JOYSTICK_TYPE)
181         actionJoystickType[0]->setText(QApplication::translate("MenuPC88", "Joystick", 0));
182         actionJoystickType[1]->setText(QApplication::translate("MenuPC88", "Bus Mouse", 0));
183         actionJoystickType[0]->setToolTip(QApplication::translate("MenuPC88", "Connect joystick to JOY PORT.", 0));
184         actionJoystickType[1]->setToolTip(QApplication::translate("MenuPC88", "Connect bus-mouse to JOY PORT.", 0));
185         menuJoystickType->setTitle(QApplication::translate("MenuPC88", "Joy Port", 0));
186 #endif
187 #if defined(USE_PRINTER)
188         actionPrintDevice[1]->setText(QString::fromUtf8("PC-PR201"));
189         actionPrintDevice[1]->setToolTip(QApplication::translate("MenuPC88", "NEC PC-PR201 kanji serial printer.", 0));
190         actionPrintDevice[1]->setEnabled(false);
191 #endif
192         if(actionSoundPlayTape != NULL) actionSoundPlayTape->setEnabled(false);
193         if(action_SoundFilesRelay != NULL) action_SoundFilesRelay->setEnabled(false);
194         
195         actionMemoryWait->setText(QApplication::translate("MenuPC88", "Wait Memory", 0));
196         actionMemoryWait->setToolTip(QApplication::translate("MenuPC88", "Simulate waiting memory.", 0));
197 #if defined(USE_MONITOR_TYPE)
198         menu_Emu_DisplayMode->setTitle(QApplication::translate("MenuPC88", "Display Mode", 0));
199         action_Emu_DisplayMode[0]->setText(QApplication::translate("MenuPC88", "High Resolution", 0));
200         action_Emu_DisplayMode[1]->setText(QApplication::translate("MenuPC88", "Standard", 0));
201 #endif
202 // End.
203    // Set Labels
204   
205 } // retranslateUi
206
207
208 void META_MainWindow::setupUI_Emu(void)
209 {
210 #if defined(USE_CPU_TYPE)
211         ConfigCPUTypes(USE_CPU_TYPE);
212 #endif
213
214 #if defined(_PC8801MA)
215         ConfigCPUBootMode(4);
216 #elif defined(_PC8001SR)
217         ConfigCPUBootMode(3);
218 #endif
219         actionMemoryWait = new Action_Control_88(this, using_flags);
220         actionMemoryWait->setCheckable(true);
221         actionMemoryWait->setVisible(true);
222         actionMemoryWait->setChecked(false);
223    
224         menuMachine->addAction(actionMemoryWait);
225         if((config.dipswitch & 0x0001) != 0) actionMemoryWait->setChecked(true);
226         connect(actionMemoryWait, SIGNAL(toggled(bool)),
227                         actionMemoryWait->pc88_binds, SLOT(do_set_memory_wait(bool)));
228         connect(actionMemoryWait->pc88_binds, SIGNAL(sig_set_dipsw(int, bool)),
229                         this, SLOT(set_dipsw(int, bool)));
230 #if defined(USE_MONITOR_TYPE)
231    menu_Emu_DisplayMode = new QMenu(menuMachine);
232    menu_Emu_DisplayMode->setObjectName(QString::fromUtf8("menu_DisplayMode"));
233    
234    actionGroup_DisplayMode = new QActionGroup(this);
235    actionGroup_DisplayMode->setObjectName(QString::fromUtf8("actionGroup_DisplayMode"));
236    actionGroup_DisplayMode->setExclusive(true);
237    menuMachine->addAction(menu_Emu_DisplayMode->menuAction());   
238    for(int i = 0; i < USE_MONITOR_TYPE; i++) {
239            action_Emu_DisplayMode[i] = new Action_Control_88(this, using_flags);
240            action_Emu_DisplayMode[i]->setCheckable(true);
241            action_Emu_DisplayMode[i]->pc88_binds->setValue1(i);
242            if(i == config.monitor_type) action_Emu_DisplayMode[i]->setChecked(true); // Need to write configure
243    }
244    action_Emu_DisplayMode[0]->setObjectName(QString::fromUtf8("action_Emu_DisplayMode_High"));
245    action_Emu_DisplayMode[1]->setObjectName(QString::fromUtf8("action_Emu_DisplayMode_Standard"));
246    for(int i = 0; i < 2; i++) {
247            menu_Emu_DisplayMode->addAction(action_Emu_DisplayMode[i]);
248            actionGroup_DisplayMode->addAction(action_Emu_DisplayMode[i]);
249            connect(action_Emu_DisplayMode[i], SIGNAL(triggered()),
250                            action_Emu_DisplayMode[i]->pc88_binds, SLOT(do_set_display_mode()));
251            connect(action_Emu_DisplayMode[i]->pc88_binds, SIGNAL(sig_display_mode(int)),
252                            this, SLOT(set_monitor_type(int)));
253    }
254 #endif
255
256 }
257
258
259 META_MainWindow::META_MainWindow(USING_FLAGS *p, CSP_Logger *logger, QWidget *parent) : Ui_MainWindow(p, logger, parent)
260 {
261         config_sound_device_type = 0;
262         setupUI_Emu();
263         retranslateUi();
264 }
265
266
267 META_MainWindow::~META_MainWindow()
268 {
269 }
270
271 //QT_END_NAMESPACE
272
273
274