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 Ui_MainWindowBase::do_stop_saving_movie(void)
60 actionStop_Record_Movie->setVisible(false);
61 actionStart_Record_Movie->setVisible(true);
62 emit sig_stop_saving_movie();
65 void Ui_MainWindowBase::do_start_saving_movie(void)
67 actionStop_Record_Movie->setVisible(true);
68 actionStart_Record_Movie->setVisible(false);
69 emit sig_start_saving_movie();
73 void Ui_MainWindowBase::set_gl_scan_line_vert(bool f)
75 using_flags->get_config_ptr()->opengl_scanline_vert = f;
78 void Ui_MainWindowBase::set_gl_scan_line_horiz(bool f)
80 using_flags->get_config_ptr()->opengl_scanline_horiz = f;
83 void Ui_MainWindowBase::ConfigScreenMenu_List(void)
89 actionGroup_ScreenSize = new QActionGroup(this);
90 actionGroup_ScreenSize->setExclusive(true);
91 screen_mode_count = 0;
92 for(i = 0; i < using_flags->get_screen_mode_num(); i++) {
93 w = (int)(screen_multiply_table[i] * (double)using_flags->get_screen_width());
94 h = (int)(screen_multiply_table[i] * (double)using_flags->get_screen_height());
95 if((w <= 0) || (h <= 0)) {
99 tmps = QString::number(i);
100 actionScreenSize[i] = new Action_Control(this, using_flags);
101 actionScreenSize[i]->setObjectName(QString::fromUtf8("actionScreenSize", -1) + tmps);
102 actionScreenSize[i]->setCheckable(true);
103 actionScreenSize[i]->binds->setNumber(i);
105 if(i == using_flags->get_config_ptr()->window_mode) actionScreenSize[i]->setChecked(true); // OK?
107 actionGroup_ScreenSize->addAction(actionScreenSize[i]);
108 actionScreenSize[i]->binds->setDoubleValue(screen_multiply_table[i]);
110 connect(actionScreenSize[i], SIGNAL(triggered()),
111 actionScreenSize[i]->binds, SLOT(set_screen_size()));
113 connect(actionScreenSize[i]->binds, SIGNAL(sig_screen_size(int, int)),
114 this, SLOT(set_screen_size(int, int)));
116 for(; i < using_flags->get_screen_mode_num(); i++) {
117 actionScreenSize[i] = NULL;
120 void Ui_MainWindowBase::ConfigScreenMenu(void)
122 actionZoom = new Action_Control(this, using_flags);
123 actionZoom->setObjectName(QString::fromUtf8("actionZoom"));
124 actionDisplay_Mode = new Action_Control(this, using_flags);
125 actionDisplay_Mode->setObjectName(QString::fromUtf8("actionDisplay_Mode"));
127 if(using_flags->is_use_scanline()) {
128 actionScanLine = new Action_Control(this, using_flags);
129 actionScanLine->setObjectName(QString::fromUtf8("actionScanLine"));
130 actionScanLine->setCheckable(true);
131 if(using_flags->get_config_ptr()->scan_line != 0) {
132 actionScanLine->setChecked(true);
134 actionScanLine->setChecked(false);
136 connect(actionScanLine, SIGNAL(toggled(bool)),
137 this, SLOT(set_scan_line(bool)));
139 if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
140 actionGLScanLineHoriz = new Action_Control(this, using_flags);
141 actionGLScanLineHoriz->setObjectName(QString::fromUtf8("actionGLScanLineHoriz"));
142 actionGLScanLineHoriz->setCheckable(true);
143 if(using_flags->get_config_ptr()->opengl_scanline_horiz != 0) {
144 actionGLScanLineHoriz->setChecked(true);
146 actionGLScanLineHoriz->setChecked(false);
148 connect(actionGLScanLineHoriz, SIGNAL(toggled(bool)),
149 this, SLOT(set_gl_scan_line_horiz(bool)));
150 if(using_flags->is_use_vertical_pixel_lines()) {
151 actionGLScanLineVert = new Action_Control(this, using_flags);
152 actionGLScanLineVert->setObjectName(QString::fromUtf8("actionGLScanLineVert"));
153 actionGLScanLineVert->setCheckable(true);
154 if(using_flags->get_config_ptr()->opengl_scanline_vert != 0) {
155 actionGLScanLineVert->setChecked(true);
157 actionGLScanLineVert->setChecked(false);
159 connect(actionGLScanLineVert, SIGNAL(toggled(bool)),
160 this, SLOT(set_gl_scan_line_vert(bool)));
163 if(using_flags->is_use_screen_rotate()) {
164 actionRotate = new Action_Control(this, using_flags);
165 actionRotate->setObjectName(QString::fromUtf8("actionScanLine"));
166 actionRotate->setCheckable(true);
167 if(using_flags->get_config_ptr()->rotate_type) {
168 actionRotate->setChecked(true);
170 actionRotate->setChecked(false);
172 connect(actionRotate, SIGNAL(toggled(bool)),
173 this, SLOT(set_screen_rotate(bool)));
175 if(using_flags->is_use_crt_filter()) {
176 actionCRT_Filter = new Action_Control(this, using_flags);
177 actionCRT_Filter->setObjectName(QString::fromUtf8("actionCRT_Filter"));
178 actionCRT_Filter->setEnabled(true);
179 actionCRT_Filter->setCheckable(true);
180 if(using_flags->get_config_ptr()->crt_filter == 0) actionCRT_Filter->setChecked(true);
181 connect(actionCRT_Filter, SIGNAL(toggled(bool)), this, SLOT(set_crt_filter(bool)));
183 actionOpenGL_Filter = new Action_Control(this, using_flags);
184 actionOpenGL_Filter->setObjectName(QString::fromUtf8("actionOpenGL_Filter"));
185 actionOpenGL_Filter->setEnabled(true);
186 actionOpenGL_Filter->setCheckable(true);
187 if(using_flags->get_config_ptr()->use_opengl_filters) actionOpenGL_Filter->setChecked(true);
188 connect(actionOpenGL_Filter, SIGNAL(toggled(bool)), this, SLOT(set_gl_crt_filter(bool)));
190 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
191 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
192 actionDot_by_Dot = new Action_Control(this, using_flags);
193 actionDot_by_Dot->setObjectName(QString::fromUtf8("actionDot_by_Dot"));
194 actionDot_by_Dot->setCheckable(true);
195 if(using_flags->get_config_ptr()->window_stretch_type == 0) actionDot_by_Dot->setChecked(true);
196 actionDot_by_Dot->binds->setValue1(0);
198 actionReferToX_Display = new Action_Control(this, using_flags);
199 actionReferToX_Display->setObjectName(QString::fromUtf8("actionReferToX_Display"));
200 actionReferToX_Display->setCheckable(true);
201 actionReferToX_Display->binds->setValue1(1);
202 if(using_flags->get_config_ptr()->window_stretch_type == 1) actionReferToX_Display->setChecked(true);
204 actionReferToY_Display = new Action_Control(this, using_flags);
205 actionReferToY_Display->setObjectName(QString::fromUtf8("actionReferToY_Display"));
206 actionReferToY_Display->setCheckable(true);
207 actionReferToY_Display->binds->setValue1(2);
208 if(using_flags->get_config_ptr()->window_stretch_type == 2) actionReferToY_Display->setChecked(true);
210 actionFill_Display = new Action_Control(this, using_flags);
211 actionFill_Display->setObjectName(QString::fromUtf8("actionFill_Display"));
212 actionFill_Display->setCheckable(true);
213 actionFill_Display->binds->setValue1(3);
214 if(using_flags->get_config_ptr()->window_stretch_type == 3) actionFill_Display->setChecked(true);
216 actionGroup_Stretch = new QActionGroup(this);
217 actionGroup_Stretch->setExclusive(true);
218 actionGroup_Stretch->addAction(actionDot_by_Dot);
219 actionGroup_Stretch->addAction(actionReferToX_Display);
220 actionGroup_Stretch->addAction(actionReferToY_Display);
221 actionGroup_Stretch->addAction(actionFill_Display);
222 connect(actionDot_by_Dot, SIGNAL(triggered()), actionDot_by_Dot->binds, SLOT(set_screen_aspect()));
223 connect(actionDot_by_Dot->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
225 connect(actionReferToX_Display, SIGNAL(triggered()), actionReferToX_Display->binds, SLOT(set_screen_aspect()));
226 connect(actionReferToX_Display->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
228 connect(actionReferToY_Display, SIGNAL(triggered()), actionReferToY_Display->binds, SLOT(set_screen_aspect()));
229 connect(actionReferToY_Display->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
231 connect(actionFill_Display, SIGNAL(triggered()), actionFill_Display->binds, SLOT(set_screen_aspect()));
232 connect(actionFill_Display->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
234 actionCapture_Screen = new Action_Control(this, using_flags);
235 actionCapture_Screen->setObjectName(QString::fromUtf8("actionCapture_Screen"));
237 actionStart_Record_Movie = new Action_Control(this, using_flags);
238 actionStart_Record_Movie->setObjectName(QString::fromUtf8("actionStart_Record_Movie"));
239 actionStart_Record_Movie->setCheckable(false);
241 actionStop_Record_Movie = new Action_Control(this, using_flags);
242 actionStop_Record_Movie->setObjectName(QString::fromUtf8("actionStop_Record_Movie"));
243 actionStop_Record_Movie->setCheckable(false);
245 ConfigScreenMenu_List();
248 void Ui_MainWindowBase::CreateScreenMenu(void)
251 menuScreen = new QMenu(menubar);
252 menuScreen->setObjectName(QString::fromUtf8("menuScreen"));
253 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
254 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
255 menuStretch_Mode = new QMenu(menuScreen);
256 menuStretch_Mode->setObjectName(QString::fromUtf8("menuStretch_Mode"));
259 menuScreenSize = new QMenu(menuScreen);
260 menuScreenSize->setObjectName(QString::fromUtf8("menuScreen_Size"));
261 menuScreen->addSeparator();
262 menuRecord_as_movie = new QMenu(menuScreen);
263 menuRecord_as_movie->setObjectName(QString::fromUtf8("menuRecord_as_movie"));
265 menuScreen->addAction(actionZoom);
266 menuScreen->addAction(menuScreenSize->menuAction());
267 for(i = 0; i < using_flags->get_screen_mode_num(); i++) {
268 if(actionScreenSize[i] == NULL) continue;
269 menuScreenSize->addAction(actionScreenSize[i]);
270 actionScreenSize[i]->setVisible(true);
273 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
274 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
275 menuScreen->addSeparator();
276 menuScreen->addAction(menuStretch_Mode->menuAction());
278 menuStretch_Mode->addAction(actionDot_by_Dot);
279 menuStretch_Mode->addAction(actionReferToX_Display);
280 menuStretch_Mode->addAction(actionReferToY_Display);
281 menuStretch_Mode->addAction(actionFill_Display);
283 menuScreen->addSeparator();
285 if(using_flags->is_use_scanline()) {
286 menuScreen->addAction(actionScanLine);
289 if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
290 menuScreen->addAction(actionGLScanLineHoriz);
291 if(using_flags->is_use_vertical_pixel_lines()) {
292 menuScreen->addAction(actionGLScanLineVert);
295 if(using_flags->is_use_screen_rotate()) {
296 menuScreen->addAction(actionRotate);
298 if(using_flags->is_use_crt_filter()) {
299 menuScreen->addAction(actionCRT_Filter);
302 menuScreen->addAction(actionOpenGL_Filter);
303 menuScreen->addAction(actionCapture_Screen);
304 menuScreen->addSeparator();
305 menuScreen->addAction(menuRecord_as_movie->menuAction());
306 menuRecord_as_movie->addAction(actionStart_Record_Movie);
307 menuRecord_as_movie->addAction(actionStop_Record_Movie);
310 void Ui_MainWindowBase::retranslateScreenMenu(void)
315 actionZoom->setText(QApplication::translate("MainWindow", "Zoom Screen", 0));
316 actionDisplay_Mode->setText(QApplication::translate("MainWindow", "Display Mode", 0));
318 if(using_flags->is_use_scanline()) {
319 actionScanLine->setText(QApplication::translate("MainWindow", "Software Scan Line", 0));
321 if(using_flags->is_use_screen_rotate()) {
322 actionRotate->setText(QApplication::translate("MainWindow", "Rotate Screen", 0));
324 if(using_flags->is_use_crt_filter()) {
325 actionCRT_Filter->setText(QApplication::translate("MainWindow", "Software Filter", 0));
327 if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
328 actionGLScanLineHoriz->setText(QApplication::translate("MainWindow", "OpenGL Scan Line", 0));
329 if(using_flags->is_use_vertical_pixel_lines()) {
330 actionGLScanLineVert->setText(QApplication::translate("MainWindow", "OpenGL Pixel Line", 0));
334 actionOpenGL_Filter->setText(QApplication::translate("MainWindow", "OpenGL Filter", 0));
336 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
337 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
338 actionDot_by_Dot->setText(QApplication::translate("MainWindow", "Dot by Dot", 0));
339 actionReferToX_Display->setText(QApplication::translate("MainWindow", "Keep Aspect: Refer to X", 0));
340 actionReferToY_Display->setText(QApplication::translate("MainWindow", "Keep Aspect: Refer to Y", 0));
341 actionFill_Display->setText(QApplication::translate("MainWindow", "Keep Aspect: Fill", 0));
342 menuStretch_Mode->setTitle(QApplication::translate("MainWindow", "Stretch Mode", 0));
345 actionCapture_Screen->setText(QApplication::translate("MainWindow", "Capture Screen", 0));
347 menuScreen->setTitle(QApplication::translate("MainWindow", "Screen", 0));
348 actionStart_Record_Movie->setText(QApplication::translate("MainWindow", "Start Recording Movie", 0));
349 actionStop_Record_Movie->setText(QApplication::translate("MainWindow", "Stop Recording Movie", 0));
351 menuRecord_as_movie->setTitle(QApplication::translate("MainWindow", "Record as Movie", 0));
354 menuScreenSize->setTitle(QApplication::translate("MainWindow", "Screen Size", 0));
356 for(i = 0; i < using_flags->get_screen_mode_num(); i++) {
357 if(actionScreenSize[i] == NULL) continue;
358 s_mul = screen_multiply_table[i];
359 if(s_mul <= 0) break;
360 tmps = QString::number(s_mul);
361 tmps = QString::fromUtf8("x", -1) + tmps;
362 actionScreenSize[i]->setText(tmps);