2 * Common Source code Project:
3 * Ui->Qt->gui->menu_main for generic.
4 * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
7 * Jan 14, 2015 : Initial, moved from qt/x1turboz/MainWindow.cpp .
10 #include <QtCore/QVariant>
12 #include "commonclasses.h"
13 #include "mainwidget_base.h"
14 //#include "menuclasses.h"
16 #include "qt_gldraw.h"
17 #include "menu_flags.h"
19 extern USING_FLAGS *using_flags;
20 // WIP: Move another header.
21 #if (SCREEN_WIDTH > 320)
22 const static float screen_multiply_table[] = {0.5, 1.0, 1.5, 2.0, 2.25, 2.5, 3.0, 3.5, 4.0, 5.0, 6.0, 8.0, 0.0};
24 const static float screen_multiply_table[] = {0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 7.5, 10.0, 12.0, 15.0, 0.0};
26 void Object_Menu_Control::set_screen_aspect(void) {
27 int num = getValue1();
28 emit sig_screen_aspect(num);
31 void Object_Menu_Control::set_screen_size(void) {
34 config.window_mode = getNumber();
35 nd = getDoubleValue();
36 ww = nd * (double)using_flags->get_screen_width();
37 hh = nd * (double)using_flags->get_screen_height();
38 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
39 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
40 double par_w = (double)using_flags->get_screen_width_aspect() / (double)using_flags->get_screen_width();
41 double par_h = (double)using_flags->get_screen_height_aspect() / (double)using_flags->get_screen_height();
42 double par = par_h / par_w;
43 if(config.window_stretch_type == 1) { // refer to X, scale Y.
45 } else if(config.window_stretch_type == 2) { // refer to Y, scale X only
47 } else if(config.window_stretch_type == 3) { // Scale both X, Y
54 emit sig_screen_size(w, h);
55 emit sig_screen_multiply(nd);
58 void Ui_MainWindowBase::set_gl_scan_line_vert(bool f)
60 config.opengl_scanline_vert = f;
63 void Ui_MainWindowBase::set_gl_scan_line_horiz(bool f)
65 config.opengl_scanline_horiz = f;
68 void Ui_MainWindowBase::ConfigScreenMenu_List(void)
74 actionGroup_ScreenSize = new QActionGroup(this);
75 actionGroup_ScreenSize->setExclusive(true);
76 screen_mode_count = 0;
77 for(i = 0; i < using_flags->get_screen_mode_num(); i++) {
78 w = (int)(screen_multiply_table[i] * (double)using_flags->get_screen_width());
79 h = (int)(screen_multiply_table[i] * (double)using_flags->get_screen_height());
80 if((w <= 0) || (h <= 0)) {
84 tmps = QString::number(i);
85 actionScreenSize[i] = new Action_Control(this);
86 actionScreenSize[i]->setObjectName(QString::fromUtf8("actionScreenSize", -1) + tmps);
87 actionScreenSize[i]->setCheckable(true);
88 actionScreenSize[i]->binds->setNumber(i);
90 if(i == config.window_mode) actionScreenSize[i]->setChecked(true); // OK?
92 actionGroup_ScreenSize->addAction(actionScreenSize[i]);
93 actionScreenSize[i]->binds->setDoubleValue(screen_multiply_table[i]);
95 connect(actionScreenSize[i], SIGNAL(triggered()),
96 actionScreenSize[i]->binds, SLOT(set_screen_size()));
98 connect(actionScreenSize[i]->binds, SIGNAL(sig_screen_size(int, int)),
99 this, SLOT(set_screen_size(int, int)));
101 for(; i < using_flags->get_screen_mode_num(); i++) {
102 actionScreenSize[i] = NULL;
105 void Ui_MainWindowBase::ConfigScreenMenu(void)
107 actionZoom = new Action_Control(this);
108 actionZoom->setObjectName(QString::fromUtf8("actionZoom"));
109 actionDisplay_Mode = new Action_Control(this);
110 actionDisplay_Mode->setObjectName(QString::fromUtf8("actionDisplay_Mode"));
112 if(using_flags->is_use_scanline()) {
113 actionScanLine = new Action_Control(this);
114 actionScanLine->setObjectName(QString::fromUtf8("actionScanLine"));
115 actionScanLine->setCheckable(true);
116 if(config.scan_line != 0) {
117 actionScanLine->setChecked(true);
119 actionScanLine->setChecked(false);
121 connect(actionScanLine, SIGNAL(toggled(bool)),
122 this, SLOT(set_scan_line(bool)));
124 if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
125 actionGLScanLineHoriz = new Action_Control(this);
126 actionGLScanLineHoriz->setObjectName(QString::fromUtf8("actionGLScanLineHoriz"));
127 actionGLScanLineHoriz->setCheckable(true);
128 if(config.opengl_scanline_horiz != 0) {
129 actionGLScanLineHoriz->setChecked(true);
131 actionGLScanLineHoriz->setChecked(false);
133 connect(actionGLScanLineHoriz, SIGNAL(toggled(bool)),
134 this, SLOT(set_gl_scan_line_horiz(bool)));
135 if(using_flags->is_use_vertical_pixel_lines()) {
136 actionGLScanLineVert = new Action_Control(this);
137 actionGLScanLineVert->setObjectName(QString::fromUtf8("actionGLScanLineVert"));
138 actionGLScanLineVert->setCheckable(true);
139 if(config.opengl_scanline_vert != 0) {
140 actionGLScanLineVert->setChecked(true);
142 actionGLScanLineVert->setChecked(false);
144 connect(actionGLScanLineVert, SIGNAL(toggled(bool)),
145 this, SLOT(set_gl_scan_line_vert(bool)));
148 if(using_flags->is_use_screen_rotate()) {
149 actionRotate = new Action_Control(this);
150 actionRotate->setObjectName(QString::fromUtf8("actionScanLine"));
151 actionRotate->setCheckable(true);
152 if(config.rotate_type) {
153 actionRotate->setChecked(true);
155 actionRotate->setChecked(false);
157 connect(actionRotate, SIGNAL(toggled(bool)),
158 this, SLOT(set_screen_rotate(bool)));
160 if(using_flags->is_use_crt_filter()) {
161 actionCRT_Filter = new Action_Control(this);
162 actionCRT_Filter->setObjectName(QString::fromUtf8("actionCRT_Filter"));
163 actionCRT_Filter->setEnabled(true);
164 actionCRT_Filter->setCheckable(true);
165 if(config.crt_filter == 0) actionCRT_Filter->setChecked(true);
166 connect(actionCRT_Filter, SIGNAL(toggled(bool)), this, SLOT(set_crt_filter(bool)));
168 actionOpenGL_Filter = new Action_Control(this);
169 actionOpenGL_Filter->setObjectName(QString::fromUtf8("actionOpenGL_Filter"));
170 actionOpenGL_Filter->setEnabled(true);
171 actionOpenGL_Filter->setCheckable(true);
172 if(config.use_opengl_filters) actionOpenGL_Filter->setChecked(true);
173 connect(actionOpenGL_Filter, SIGNAL(toggled(bool)), this, SLOT(set_gl_crt_filter(bool)));
175 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
176 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
177 actionDot_by_Dot = new Action_Control(this);
178 actionDot_by_Dot->setObjectName(QString::fromUtf8("actionDot_by_Dot"));
179 actionDot_by_Dot->setCheckable(true);
180 if(config.window_stretch_type == 0) actionDot_by_Dot->setChecked(true);
181 actionDot_by_Dot->binds->setValue1(0);
183 actionReferToX_Display = new Action_Control(this);
184 actionReferToX_Display->setObjectName(QString::fromUtf8("actionReferToX_Display"));
185 actionReferToX_Display->setCheckable(true);
186 actionReferToX_Display->binds->setValue1(1);
187 if(config.window_stretch_type == 1) actionReferToX_Display->setChecked(true);
189 actionReferToY_Display = new Action_Control(this);
190 actionReferToY_Display->setObjectName(QString::fromUtf8("actionReferToY_Display"));
191 actionReferToY_Display->setCheckable(true);
192 actionReferToY_Display->binds->setValue1(2);
193 if(config.window_stretch_type == 2) actionReferToY_Display->setChecked(true);
195 actionFill_Display = new Action_Control(this);
196 actionFill_Display->setObjectName(QString::fromUtf8("actionFill_Display"));
197 actionFill_Display->setCheckable(true);
198 actionFill_Display->binds->setValue1(3);
199 if(config.window_stretch_type == 3) actionFill_Display->setChecked(true);
201 actionGroup_Stretch = new QActionGroup(this);
202 actionGroup_Stretch->setExclusive(true);
203 actionGroup_Stretch->addAction(actionDot_by_Dot);
204 actionGroup_Stretch->addAction(actionReferToX_Display);
205 actionGroup_Stretch->addAction(actionReferToY_Display);
206 actionGroup_Stretch->addAction(actionFill_Display);
207 connect(actionDot_by_Dot, SIGNAL(triggered()), actionDot_by_Dot->binds, SLOT(set_screen_aspect()));
208 connect(actionDot_by_Dot->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
210 connect(actionReferToX_Display, SIGNAL(triggered()), actionReferToX_Display->binds, SLOT(set_screen_aspect()));
211 connect(actionReferToX_Display->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
213 connect(actionReferToY_Display, SIGNAL(triggered()), actionReferToY_Display->binds, SLOT(set_screen_aspect()));
214 connect(actionReferToY_Display->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
216 connect(actionFill_Display, SIGNAL(triggered()), actionFill_Display->binds, SLOT(set_screen_aspect()));
217 connect(actionFill_Display->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
219 actionCapture_Screen = new Action_Control(this);
220 actionCapture_Screen->setObjectName(QString::fromUtf8("actionCapture_Screen"));
222 actionStart_Record_Movie = new Action_Control(this);
223 actionStart_Record_Movie->setObjectName(QString::fromUtf8("actionStart_Record_Movie"));
224 actionStart_Record_Movie->setCheckable(true);
226 actionStop_Record_Movie = new Action_Control(this);
227 actionStop_Record_Movie->setObjectName(QString::fromUtf8("actionStop_Record_Movie"));
228 actionStop_Record_Movie->setCheckable(false);
230 ConfigScreenMenu_List();
233 void Ui_MainWindowBase::CreateScreenMenu(void)
236 menuScreen = new QMenu(menubar);
237 menuScreen->setObjectName(QString::fromUtf8("menuScreen"));
238 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
239 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
240 menuStretch_Mode = new QMenu(menuScreen);
241 menuStretch_Mode->setObjectName(QString::fromUtf8("menuStretch_Mode"));
244 menuScreenSize = new QMenu(menuScreen);
245 menuScreenSize->setObjectName(QString::fromUtf8("menuScreen_Size"));
246 menuScreen->addSeparator();
247 menuRecord_as_movie = new QMenu(menuScreen);
248 menuRecord_as_movie->setObjectName(QString::fromUtf8("menuRecord_as_movie"));
250 menuScreen->addAction(actionZoom);
251 menuScreen->addAction(menuScreenSize->menuAction());
252 for(i = 0; i < using_flags->get_screen_mode_num(); i++) {
253 if(actionScreenSize[i] == NULL) continue;
254 menuScreenSize->addAction(actionScreenSize[i]);
255 actionScreenSize[i]->setVisible(true);
258 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
259 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
260 menuScreen->addSeparator();
261 menuScreen->addAction(menuStretch_Mode->menuAction());
263 menuStretch_Mode->addAction(actionDot_by_Dot);
264 menuStretch_Mode->addAction(actionReferToX_Display);
265 menuStretch_Mode->addAction(actionReferToY_Display);
266 menuStretch_Mode->addAction(actionFill_Display);
268 menuScreen->addSeparator();
270 if(using_flags->is_use_scanline()) {
271 menuScreen->addAction(actionScanLine);
274 if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
275 menuScreen->addAction(actionGLScanLineHoriz);
276 if(using_flags->is_use_vertical_pixel_lines()) {
277 menuScreen->addAction(actionGLScanLineVert);
280 if(using_flags->is_use_screen_rotate()) {
281 menuScreen->addAction(actionRotate);
283 if(using_flags->is_use_crt_filter()) {
284 menuScreen->addAction(actionCRT_Filter);
287 menuScreen->addAction(actionOpenGL_Filter);
288 menuScreen->addAction(actionCapture_Screen);
289 menuScreen->addSeparator();
290 menuScreen->addAction(menuRecord_as_movie->menuAction());
291 menuRecord_as_movie->addAction(actionStart_Record_Movie);
292 menuRecord_as_movie->addAction(actionStop_Record_Movie);
295 void Ui_MainWindowBase::retranslateScreenMenu(void)
300 actionZoom->setText(QApplication::translate("MainWindow", "Zoom Screen", 0));
301 actionDisplay_Mode->setText(QApplication::translate("MainWindow", "Display Mode", 0));
303 if(using_flags->is_use_scanline()) {
304 actionScanLine->setText(QApplication::translate("MainWindow", "Software Scan Line", 0));
306 if(using_flags->is_use_screen_rotate()) {
307 actionRotate->setText(QApplication::translate("MainWindow", "Rotate Screen", 0));
309 if(using_flags->is_use_crt_filter()) {
310 actionCRT_Filter->setText(QApplication::translate("MainWindow", "Software Filter", 0));
312 if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
313 actionGLScanLineHoriz->setText(QApplication::translate("MainWindow", "OpenGL Scan Line", 0));
314 if(using_flags->is_use_vertical_pixel_lines()) {
315 actionGLScanLineVert->setText(QApplication::translate("MainWindow", "OpenGL Pixel Line", 0));
319 actionOpenGL_Filter->setText(QApplication::translate("MainWindow", "OpenGL Filter", 0));
321 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
322 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
323 actionDot_by_Dot->setText(QApplication::translate("MainWindow", "Dot by Dot", 0));
324 actionReferToX_Display->setText(QApplication::translate("MainWindow", "Keep Aspect: Refer to X", 0));
325 actionReferToY_Display->setText(QApplication::translate("MainWindow", "Keep Aspect: Refer to Y", 0));
326 actionFill_Display->setText(QApplication::translate("MainWindow", "Keep Aspect: Fill", 0));
327 menuStretch_Mode->setTitle(QApplication::translate("MainWindow", "Stretch Mode", 0));
330 actionCapture_Screen->setText(QApplication::translate("MainWindow", "Capture Screen", 0));
332 menuScreen->setTitle(QApplication::translate("MainWindow", "Screen", 0));
333 actionStart_Record_Movie->setText(QApplication::translate("MainWindow", "Start Recording Movie", 0));
334 actionStop_Record_Movie->setText(QApplication::translate("MainWindow", "Stop Recording Movie", 0));
336 menuRecord_as_movie->setTitle(QApplication::translate("MainWindow", "Record as Movie", 0));
339 menuScreenSize->setTitle(QApplication::translate("MainWindow", "Screen Size", 0));
341 for(i = 0; i < using_flags->get_screen_mode_num(); i++) {
342 if(actionScreenSize[i] == NULL) continue;
343 s_mul = screen_multiply_table[i];
344 if(s_mul <= 0) break;
345 tmps = QString::number(s_mul);
346 tmps = QString::fromUtf8("x", -1) + tmps;
347 actionScreenSize[i]->setText(tmps);