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 using_flags->get_config_ptr()->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(using_flags->get_config_ptr()->window_stretch_type == 1) { // refer to X, scale Y.
45 } else if(using_flags->get_config_ptr()->window_stretch_type == 2) { // refer to Y, scale X only
47 } else if(using_flags->get_config_ptr()->window_stretch_type == 3) { // Scale both X, Y
54 emit sig_screen_size(w, h);
55 emit sig_screen_multiply(nd);
58 void Object_Menu_Control::do_save_as_movie(void)
60 int fps = using_flags->get_config_ptr()->video_frame_rate;
61 emit sig_start_record_movie(fps);
64 void Object_Menu_Control::do_stop_saving_movie(void)
66 emit sig_stop_record_movie();
70 void Ui_MainWindowBase::do_stop_saving_movie(void)
72 emit sig_stop_saving_movie();
75 void Ui_MainWindowBase::do_start_saving_movie(void)
77 emit sig_start_saving_movie();
80 void Ui_MainWindowBase::do_set_render_mode_std(void)
82 using_flags->get_config_ptr()->rendering_type = CONFIG_RENDER_TYPE_STD;
85 void Ui_MainWindowBase::do_set_render_mode_tv(void)
87 using_flags->get_config_ptr()->rendering_type = CONFIG_RENDER_TYPE_TV;
90 void Ui_MainWindowBase::do_set_state_saving_movie(bool state)
92 actionStop_Record_Movie->setVisible(state);
93 actionStart_Record_Movie->setVisible(!state);
96 void Ui_MainWindowBase::set_gl_scan_line_vert(bool f)
98 using_flags->get_config_ptr()->opengl_scanline_vert = f;
101 void Ui_MainWindowBase::set_gl_scan_line_horiz(bool f)
103 using_flags->get_config_ptr()->opengl_scanline_horiz = f;
106 void Ui_MainWindowBase::ConfigScreenMenu_List(void)
112 actionGroup_ScreenSize = new QActionGroup(this);
113 actionGroup_ScreenSize->setExclusive(true);
114 screen_mode_count = 0;
115 for(i = 0; i < using_flags->get_screen_mode_num(); i++) {
116 w = (int)(screen_multiply_table[i] * (double)using_flags->get_screen_width());
117 h = (int)(screen_multiply_table[i] * (double)using_flags->get_screen_height());
118 if((w <= 0) || (h <= 0)) {
122 tmps = QString::number(i);
123 actionScreenSize[i] = new Action_Control(this, using_flags);
124 actionScreenSize[i]->setObjectName(QString::fromUtf8("actionScreenSize", -1) + tmps);
125 actionScreenSize[i]->setCheckable(true);
126 actionScreenSize[i]->binds->setNumber(i);
128 if(i == using_flags->get_config_ptr()->window_mode) actionScreenSize[i]->setChecked(true); // OK?
130 actionGroup_ScreenSize->addAction(actionScreenSize[i]);
131 actionScreenSize[i]->binds->setDoubleValue(screen_multiply_table[i]);
133 connect(actionScreenSize[i], SIGNAL(triggered()),
134 actionScreenSize[i]->binds, SLOT(set_screen_size()));
136 connect(actionScreenSize[i]->binds, SIGNAL(sig_screen_size(int, int)),
137 this, SLOT(set_screen_size(int, int)));
139 for(; i < using_flags->get_screen_mode_num(); i++) {
140 actionScreenSize[i] = NULL;
143 void Ui_MainWindowBase::ConfigScreenMenu(void)
145 actionZoom = new Action_Control(this, using_flags);
146 actionZoom->setObjectName(QString::fromUtf8("actionZoom"));
147 actionDisplay_Mode = new Action_Control(this, using_flags);
148 actionDisplay_Mode->setObjectName(QString::fromUtf8("actionDisplay_Mode"));
150 if(using_flags->is_use_scanline()) {
151 actionScanLine = new Action_Control(this, using_flags);
152 actionScanLine->setObjectName(QString::fromUtf8("actionScanLine"));
153 actionScanLine->setCheckable(true);
154 if(using_flags->get_config_ptr()->scan_line != 0) {
155 actionScanLine->setChecked(true);
157 actionScanLine->setChecked(false);
159 connect(actionScanLine, SIGNAL(toggled(bool)),
160 this, SLOT(set_scan_line(bool)));
162 if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
163 actionGLScanLineHoriz = new Action_Control(this, using_flags);
164 actionGLScanLineHoriz->setObjectName(QString::fromUtf8("actionGLScanLineHoriz"));
165 actionGLScanLineHoriz->setCheckable(true);
166 if(using_flags->get_config_ptr()->opengl_scanline_horiz != 0) {
167 actionGLScanLineHoriz->setChecked(true);
169 actionGLScanLineHoriz->setChecked(false);
171 connect(actionGLScanLineHoriz, SIGNAL(toggled(bool)),
172 this, SLOT(set_gl_scan_line_horiz(bool)));
173 if(using_flags->is_use_vertical_pixel_lines()) {
174 actionGLScanLineVert = new Action_Control(this, using_flags);
175 actionGLScanLineVert->setObjectName(QString::fromUtf8("actionGLScanLineVert"));
176 actionGLScanLineVert->setCheckable(true);
177 if(using_flags->get_config_ptr()->opengl_scanline_vert != 0) {
178 actionGLScanLineVert->setChecked(true);
180 actionGLScanLineVert->setChecked(false);
182 connect(actionGLScanLineVert, SIGNAL(toggled(bool)),
183 this, SLOT(set_gl_scan_line_vert(bool)));
186 if(using_flags->is_use_screen_rotate()) {
187 actionRotate = new Action_Control(this, using_flags);
188 actionRotate->setObjectName(QString::fromUtf8("actionScanLine"));
189 actionRotate->setCheckable(true);
190 if(using_flags->get_config_ptr()->rotate_type) {
191 actionRotate->setChecked(true);
193 actionRotate->setChecked(false);
195 connect(actionRotate, SIGNAL(toggled(bool)),
196 this, SLOT(set_screen_rotate(bool)));
198 if(using_flags->is_use_crt_filter()) {
199 actionCRT_Filter = new Action_Control(this, using_flags);
200 actionCRT_Filter->setObjectName(QString::fromUtf8("actionCRT_Filter"));
201 actionCRT_Filter->setEnabled(true);
202 actionCRT_Filter->setCheckable(true);
203 if(using_flags->get_config_ptr()->crt_filter == 0) actionCRT_Filter->setChecked(true);
204 connect(actionCRT_Filter, SIGNAL(toggled(bool)), this, SLOT(set_crt_filter(bool)));
206 actionOpenGL_Filter = new Action_Control(this, using_flags);
207 actionOpenGL_Filter->setObjectName(QString::fromUtf8("actionOpenGL_Filter"));
208 actionOpenGL_Filter->setEnabled(true);
209 actionOpenGL_Filter->setCheckable(true);
210 if(using_flags->get_config_ptr()->use_opengl_filters) actionOpenGL_Filter->setChecked(true);
211 connect(actionOpenGL_Filter, SIGNAL(toggled(bool)), this, SLOT(set_gl_crt_filter(bool)));
213 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
214 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
215 actionDot_by_Dot = new Action_Control(this, using_flags);
216 actionDot_by_Dot->setObjectName(QString::fromUtf8("actionDot_by_Dot"));
217 actionDot_by_Dot->setCheckable(true);
218 if(using_flags->get_config_ptr()->window_stretch_type == 0) actionDot_by_Dot->setChecked(true);
219 actionDot_by_Dot->binds->setValue1(0);
221 actionReferToX_Display = new Action_Control(this, using_flags);
222 actionReferToX_Display->setObjectName(QString::fromUtf8("actionReferToX_Display"));
223 actionReferToX_Display->setCheckable(true);
224 actionReferToX_Display->binds->setValue1(1);
225 if(using_flags->get_config_ptr()->window_stretch_type == 1) actionReferToX_Display->setChecked(true);
227 actionReferToY_Display = new Action_Control(this, using_flags);
228 actionReferToY_Display->setObjectName(QString::fromUtf8("actionReferToY_Display"));
229 actionReferToY_Display->setCheckable(true);
230 actionReferToY_Display->binds->setValue1(2);
231 if(using_flags->get_config_ptr()->window_stretch_type == 2) actionReferToY_Display->setChecked(true);
233 actionFill_Display = new Action_Control(this, using_flags);
234 actionFill_Display->setObjectName(QString::fromUtf8("actionFill_Display"));
235 actionFill_Display->setCheckable(true);
236 actionFill_Display->binds->setValue1(3);
237 if(using_flags->get_config_ptr()->window_stretch_type == 3) actionFill_Display->setChecked(true);
239 actionGroup_Stretch = new QActionGroup(this);
240 actionGroup_Stretch->setExclusive(true);
241 actionGroup_Stretch->addAction(actionDot_by_Dot);
242 actionGroup_Stretch->addAction(actionReferToX_Display);
243 actionGroup_Stretch->addAction(actionReferToY_Display);
244 actionGroup_Stretch->addAction(actionFill_Display);
245 connect(actionDot_by_Dot, SIGNAL(triggered()), actionDot_by_Dot->binds, SLOT(set_screen_aspect()));
246 connect(actionDot_by_Dot->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
248 connect(actionReferToX_Display, SIGNAL(triggered()), actionReferToX_Display->binds, SLOT(set_screen_aspect()));
249 connect(actionReferToX_Display->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
251 connect(actionReferToY_Display, SIGNAL(triggered()), actionReferToY_Display->binds, SLOT(set_screen_aspect()));
252 connect(actionReferToY_Display->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
254 connect(actionFill_Display, SIGNAL(triggered()), actionFill_Display->binds, SLOT(set_screen_aspect()));
255 connect(actionFill_Display->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
257 actionCapture_Screen = new Action_Control(this, using_flags);
258 actionCapture_Screen->setObjectName(QString::fromUtf8("actionCapture_Screen"));
260 actionStart_Record_Movie = new Action_Control(this, using_flags);
261 actionStart_Record_Movie->setObjectName(QString::fromUtf8("actionStart_Record_Movie"));
262 actionStart_Record_Movie->setCheckable(false);
264 actionStop_Record_Movie = new Action_Control(this, using_flags);
265 actionStop_Record_Movie->setObjectName(QString::fromUtf8("actionStop_Record_Movie"));
266 actionStop_Record_Movie->setCheckable(false);
268 bool b_support_tv_render = using_flags->is_support_tv_render();
269 if(b_support_tv_render) {
270 int ii = CONFIG_RENDER_TYPE_END;
273 if((ii >= 8) || (ii < 0)) ii = 8;
274 actionGroup_RenderMode = new QActionGroup(this);
275 actionGroup_RenderMode->setExclusive(true);
277 for(i = 0; i < ii; i++) {
278 action_SetRenderMode[i] = new Action_Control(this, using_flags);
279 action_SetRenderMode[i]->setCheckable(true);
280 action_SetRenderMode[i]->setEnabled(false);
281 action_SetRenderMode[i]->setVisible(false);
282 action_SetRenderMode[i]->binds->setValue1(i);
284 if(i == using_flags->get_config_ptr()->rendering_type) action_SetRenderMode[i]->setChecked(true);
286 if(i == CONFIG_RENDER_TYPE_STD) {
287 action_SetRenderMode[i]->setEnabled(true);
288 action_SetRenderMode[i]->setVisible(true);
289 actionGroup_RenderMode->addAction(action_SetRenderMode[i]);
290 connect(action_SetRenderMode[i], SIGNAL(triggered()), this, SLOT(do_set_render_mode_std()));
292 if(b_support_tv_render && (i == CONFIG_RENDER_TYPE_TV)) {
293 action_SetRenderMode[i]->setEnabled(true);
294 action_SetRenderMode[i]->setVisible(true);
295 actionGroup_RenderMode->addAction(action_SetRenderMode[i]);
296 connect(action_SetRenderMode[i], SIGNAL(triggered()), this, SLOT(do_set_render_mode_tv()));
300 ConfigScreenMenu_List();
303 void Ui_MainWindowBase::CreateScreenMenu(void)
306 menuScreen = new QMenu(menubar);
307 menuScreen->setObjectName(QString::fromUtf8("menuScreen"));
308 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
309 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
310 menuStretch_Mode = new QMenu(menuScreen);
311 menuStretch_Mode->setObjectName(QString::fromUtf8("menuStretch_Mode"));
313 bool b_support_tv_render = using_flags->is_support_tv_render();
314 if(b_support_tv_render) {
315 menuScreen_Render = new QMenu(menuScreen);
316 menuScreen_Render->setObjectName(QString::fromUtf8("menuRender_Mode"));
317 menuScreen_Render->addAction(action_SetRenderMode[CONFIG_RENDER_TYPE_STD]);
318 if(b_support_tv_render) {
319 menuScreen_Render->addAction(action_SetRenderMode[CONFIG_RENDER_TYPE_TV]);
321 menuScreen->addAction(menuScreen_Render->menuAction());
323 menuScreenSize = new QMenu(menuScreen);
324 menuScreenSize->setObjectName(QString::fromUtf8("menuScreen_Size"));
325 menuScreen->addSeparator();
326 menuRecord_as_movie = new QMenu(menuScreen);
327 menuRecord_as_movie->setObjectName(QString::fromUtf8("menuRecord_as_movie"));
329 menuScreen->addAction(actionZoom);
330 menuScreen->addAction(menuScreenSize->menuAction());
331 for(i = 0; i < using_flags->get_screen_mode_num(); i++) {
332 if(actionScreenSize[i] == NULL) continue;
333 menuScreenSize->addAction(actionScreenSize[i]);
334 actionScreenSize[i]->setVisible(true);
337 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
338 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
339 menuScreen->addSeparator();
340 menuScreen->addAction(menuStretch_Mode->menuAction());
342 menuStretch_Mode->addAction(actionDot_by_Dot);
343 menuStretch_Mode->addAction(actionReferToX_Display);
344 menuStretch_Mode->addAction(actionReferToY_Display);
345 menuStretch_Mode->addAction(actionFill_Display);
347 menuScreen->addSeparator();
349 if(using_flags->is_use_scanline()) {
350 menuScreen->addAction(actionScanLine);
353 if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
354 menuScreen->addAction(actionGLScanLineHoriz);
355 if(using_flags->is_use_vertical_pixel_lines()) {
356 menuScreen->addAction(actionGLScanLineVert);
359 if(using_flags->is_use_screen_rotate()) {
360 menuScreen->addAction(actionRotate);
362 if(using_flags->is_use_crt_filter()) {
363 menuScreen->addAction(actionCRT_Filter);
366 menuScreen->addAction(actionOpenGL_Filter);
367 menuScreen->addAction(actionCapture_Screen);
368 menuScreen->addSeparator();
369 menuScreen->addAction(menuRecord_as_movie->menuAction());
370 menuRecord_as_movie->addAction(actionStart_Record_Movie);
371 menuRecord_as_movie->addAction(actionStop_Record_Movie);
374 void Ui_MainWindowBase::retranslateScreenMenu(void)
379 actionZoom->setText(QApplication::translate("MainWindow", "Zoom Screen", 0));
380 actionDisplay_Mode->setText(QApplication::translate("MainWindow", "Display Mode", 0));
382 if(using_flags->is_use_scanline()) {
383 actionScanLine->setText(QApplication::translate("MainWindow", "Software Scan Line", 0));
385 if(using_flags->is_use_screen_rotate()) {
386 actionRotate->setText(QApplication::translate("MainWindow", "Rotate Screen", 0));
388 if(using_flags->is_use_crt_filter()) {
389 actionCRT_Filter->setText(QApplication::translate("MainWindow", "Software Filter", 0));
391 if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
392 actionGLScanLineHoriz->setText(QApplication::translate("MainWindow", "OpenGL Scan Line", 0));
393 if(using_flags->is_use_vertical_pixel_lines()) {
394 actionGLScanLineVert->setText(QApplication::translate("MainWindow", "OpenGL Pixel Line", 0));
398 actionOpenGL_Filter->setText(QApplication::translate("MainWindow", "OpenGL Filter", 0));
400 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
401 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
402 actionDot_by_Dot->setText(QApplication::translate("MainWindow", "Dot by Dot", 0));
403 actionReferToX_Display->setText(QApplication::translate("MainWindow", "Keep Aspect: Refer to X", 0));
404 actionReferToY_Display->setText(QApplication::translate("MainWindow", "Keep Aspect: Refer to Y", 0));
405 actionFill_Display->setText(QApplication::translate("MainWindow", "Keep Aspect: Fill", 0));
406 menuStretch_Mode->setTitle(QApplication::translate("MainWindow", "Stretch Mode", 0));
409 actionCapture_Screen->setText(QApplication::translate("MainWindow", "Capture Screen", 0));
411 menuScreen->setTitle(QApplication::translate("MainWindow", "Screen", 0));
412 actionStart_Record_Movie->setText(QApplication::translate("MainWindow", "Start Recording Movie", 0));
413 actionStop_Record_Movie->setText(QApplication::translate("MainWindow", "Stop Recording Movie", 0));
415 menuRecord_as_movie->setTitle(QApplication::translate("MainWindow", "Record as Movie", 0));
418 menuScreenSize->setTitle(QApplication::translate("MainWindow", "Screen Size", 0));
420 for(i = 0; i < using_flags->get_screen_mode_num(); i++) {
421 if(actionScreenSize[i] == NULL) continue;
422 s_mul = screen_multiply_table[i];
423 if(s_mul <= 0) break;
424 tmps = QString::number(s_mul);
425 tmps = QString::fromUtf8("x", -1) + tmps;
426 actionScreenSize[i]->setText(tmps);
428 bool b_support_tv_render = using_flags->is_support_tv_render();
429 if(b_support_tv_render) {
430 menuScreen_Render->setTitle(QApplication::translate("MainWindow", "Render Mode", 0));
431 action_SetRenderMode[CONFIG_RENDER_TYPE_STD]->setText(QApplication::translate("MainWindow", "Standard", 0));
432 if(b_support_tv_render) {
433 action_SetRenderMode[CONFIG_RENDER_TYPE_TV]->setText(QApplication::translate("MainWindow", "TV", 0));