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.h"
14 //#include "menuclasses.h"
17 #include "qt_gldraw.h"
18 #include "menu_flags.h"
20 extern USING_FLAGS *using_flags;
21 // WIP: Move another header.
22 #if (SCREEN_WIDTH > 320)
23 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};
25 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};
27 void Object_Menu_Control::set_screen_aspect(void) {
28 int num = getValue1();
29 emit sig_screen_aspect(num);
32 void Object_Menu_Control::set_screen_size(void) {
35 config.window_mode = getNumber();
36 nd = getDoubleValue();
37 ww = nd * (double)using_flags->get_screen_width();
38 hh = nd * (double)using_flags->get_screen_height();
39 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
40 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
41 double par_w = (double)using_flags->get_screen_width_aspect() / (double)using_flags->get_screen_width();
42 double par_h = (double)using_flags->get_screen_height_aspect() / (double)using_flags->get_screen_height();
43 double par = par_h / par_w;
44 if(config.window_stretch_type == 1) { // refer to X, scale Y.
46 } else if(config.window_stretch_type == 2) { // refer to Y, scale X only
48 } else if(config.window_stretch_type == 3) { // Scale both X, Y
55 emit sig_screen_size(w, h);
56 emit sig_screen_multiply(nd);
59 void Ui_MainWindow::set_gl_scan_line_vert(bool f)
61 config.opengl_scanline_vert = f;
64 void Ui_MainWindow::set_gl_scan_line_horiz(bool f)
66 config.opengl_scanline_horiz = f;
69 void Ui_MainWindow::ConfigScreenMenu_List(void)
75 actionGroup_ScreenSize = new QActionGroup(this);
76 actionGroup_ScreenSize->setExclusive(true);
77 screen_mode_count = 0;
78 for(i = 0; i < _SCREEN_MODE_NUM; i++) {
79 w = (int)(screen_multiply_table[i] * (double)using_flags->get_screen_width());
80 h = (int)(screen_multiply_table[i] * (double)using_flags->get_screen_height());
81 if((w <= 0) || (h <= 0)) {
85 tmps = QString::number(i);
86 actionScreenSize[i] = new Action_Control(this);
87 actionScreenSize[i]->setObjectName(QString::fromUtf8("actionScreenSize", -1) + tmps);
88 actionScreenSize[i]->setCheckable(true);
89 actionScreenSize[i]->binds->setNumber(i);
91 if(i == config.window_mode) actionScreenSize[i]->setChecked(true); // OK?
93 actionGroup_ScreenSize->addAction(actionScreenSize[i]);
94 actionScreenSize[i]->binds->setDoubleValue(screen_multiply_table[i]);
96 connect(actionScreenSize[i], SIGNAL(triggered()),
97 actionScreenSize[i]->binds, SLOT(set_screen_size()));
99 connect(actionScreenSize[i]->binds, SIGNAL(sig_screen_size(int, int)),
100 this, SLOT(set_screen_size(int, int)));
102 for(; i < _SCREEN_MODE_NUM; i++) {
103 actionScreenSize[i] = NULL;
106 void Ui_MainWindow::ConfigScreenMenu(void)
108 actionZoom = new Action_Control(this);
109 actionZoom->setObjectName(QString::fromUtf8("actionZoom"));
110 actionDisplay_Mode = new Action_Control(this);
111 actionDisplay_Mode->setObjectName(QString::fromUtf8("actionDisplay_Mode"));
113 if(using_flags->is_use_scanline()) {
114 actionScanLine = new Action_Control(this);
115 actionScanLine->setObjectName(QString::fromUtf8("actionScanLine"));
116 actionScanLine->setCheckable(true);
117 if(config.scan_line != 0) {
118 actionScanLine->setChecked(true);
120 actionScanLine->setChecked(false);
122 connect(actionScanLine, SIGNAL(toggled(bool)),
123 this, SLOT(set_scan_line(bool)));
125 if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
126 actionGLScanLineHoriz = new Action_Control(this);
127 actionGLScanLineHoriz->setObjectName(QString::fromUtf8("actionGLScanLineHoriz"));
128 actionGLScanLineHoriz->setCheckable(true);
129 if(config.opengl_scanline_horiz != 0) {
130 actionGLScanLineHoriz->setChecked(true);
132 actionGLScanLineHoriz->setChecked(false);
134 connect(actionGLScanLineHoriz, SIGNAL(toggled(bool)),
135 this, SLOT(set_gl_scan_line_horiz(bool)));
136 if(using_flags->is_use_vertical_pixel_lines()) {
137 actionGLScanLineVert = new Action_Control(this);
138 actionGLScanLineVert->setObjectName(QString::fromUtf8("actionGLScanLineVert"));
139 actionGLScanLineVert->setCheckable(true);
140 if(config.opengl_scanline_vert != 0) {
141 actionGLScanLineVert->setChecked(true);
143 actionGLScanLineVert->setChecked(false);
145 connect(actionGLScanLineVert, SIGNAL(toggled(bool)),
146 this, SLOT(set_gl_scan_line_vert(bool)));
149 if(using_flags->is_use_screen_rotate()) {
150 actionRotate = new Action_Control(this);
151 actionRotate->setObjectName(QString::fromUtf8("actionScanLine"));
152 actionRotate->setCheckable(true);
153 if(config.rotate_type) {
154 actionRotate->setChecked(true);
156 actionRotate->setChecked(false);
158 connect(actionRotate, SIGNAL(toggled(bool)),
159 this, SLOT(set_screen_rotate(bool)));
161 if(using_flags->is_use_crt_filter()) {
162 actionCRT_Filter = new Action_Control(this);
163 actionCRT_Filter->setObjectName(QString::fromUtf8("actionCRT_Filter"));
164 actionCRT_Filter->setEnabled(true);
165 actionCRT_Filter->setCheckable(true);
166 if(config.crt_filter == 0) actionCRT_Filter->setChecked(true);
167 connect(actionCRT_Filter, SIGNAL(toggled(bool)), this, SLOT(set_crt_filter(bool)));
169 actionOpenGL_Filter = new Action_Control(this);
170 actionOpenGL_Filter->setObjectName(QString::fromUtf8("actionOpenGL_Filter"));
171 actionOpenGL_Filter->setEnabled(true);
172 actionOpenGL_Filter->setCheckable(true);
173 if(config.use_opengl_filters) actionOpenGL_Filter->setChecked(true);
174 connect(actionOpenGL_Filter, SIGNAL(toggled(bool)), this, SLOT(set_gl_crt_filter(bool)));
176 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
177 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
178 actionDot_by_Dot = new Action_Control(this);
179 actionDot_by_Dot->setObjectName(QString::fromUtf8("actionDot_by_Dot"));
180 actionDot_by_Dot->setCheckable(true);
181 if(config.window_stretch_type == 0) actionDot_by_Dot->setChecked(true);
182 actionDot_by_Dot->binds->setValue1(0);
184 actionReferToX_Display = new Action_Control(this);
185 actionReferToX_Display->setObjectName(QString::fromUtf8("actionReferToX_Display"));
186 actionReferToX_Display->setCheckable(true);
187 actionReferToX_Display->binds->setValue1(1);
188 if(config.window_stretch_type == 1) actionReferToX_Display->setChecked(true);
190 actionReferToY_Display = new Action_Control(this);
191 actionReferToY_Display->setObjectName(QString::fromUtf8("actionReferToY_Display"));
192 actionReferToY_Display->setCheckable(true);
193 actionReferToY_Display->binds->setValue1(2);
194 if(config.window_stretch_type == 2) actionReferToY_Display->setChecked(true);
196 actionFill_Display = new Action_Control(this);
197 actionFill_Display->setObjectName(QString::fromUtf8("actionFill_Display"));
198 actionFill_Display->setCheckable(true);
199 actionFill_Display->binds->setValue1(3);
200 if(config.window_stretch_type == 3) actionFill_Display->setChecked(true);
202 actionGroup_Stretch = new QActionGroup(this);
203 actionGroup_Stretch->setExclusive(true);
204 actionGroup_Stretch->addAction(actionDot_by_Dot);
205 actionGroup_Stretch->addAction(actionReferToX_Display);
206 actionGroup_Stretch->addAction(actionReferToY_Display);
207 actionGroup_Stretch->addAction(actionFill_Display);
208 connect(actionDot_by_Dot, SIGNAL(triggered()), actionDot_by_Dot->binds, SLOT(set_screen_aspect()));
209 connect(actionDot_by_Dot->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
211 connect(actionReferToX_Display, SIGNAL(triggered()), actionReferToX_Display->binds, SLOT(set_screen_aspect()));
212 connect(actionReferToX_Display->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
214 connect(actionReferToY_Display, SIGNAL(triggered()), actionReferToY_Display->binds, SLOT(set_screen_aspect()));
215 connect(actionReferToY_Display->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
217 connect(actionFill_Display, SIGNAL(triggered()), actionFill_Display->binds, SLOT(set_screen_aspect()));
218 connect(actionFill_Display->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
220 actionCapture_Screen = new Action_Control(this);
221 actionCapture_Screen->setObjectName(QString::fromUtf8("actionCapture_Screen"));
223 actionStart_Record_Movie = new Action_Control(this);
224 actionStart_Record_Movie->setObjectName(QString::fromUtf8("actionStart_Record_Movie"));
225 actionStart_Record_Movie->setCheckable(true);
227 actionStop_Record_Movie = new Action_Control(this);
228 actionStop_Record_Movie->setObjectName(QString::fromUtf8("actionStop_Record_Movie"));
229 actionStop_Record_Movie->setCheckable(false);
231 ConfigScreenMenu_List();
234 void Ui_MainWindow::CreateScreenMenu(void)
237 menuScreen = new QMenu(menubar);
238 menuScreen->setObjectName(QString::fromUtf8("menuScreen"));
239 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
240 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
241 menuStretch_Mode = new QMenu(menuScreen);
242 menuStretch_Mode->setObjectName(QString::fromUtf8("menuStretch_Mode"));
245 menuScreenSize = new QMenu(menuScreen);
246 menuScreenSize->setObjectName(QString::fromUtf8("menuScreen_Size"));
247 menuScreen->addSeparator();
248 menuRecord_as_movie = new QMenu(menuScreen);
249 menuRecord_as_movie->setObjectName(QString::fromUtf8("menuRecord_as_movie"));
251 menuScreen->addAction(actionZoom);
252 menuScreen->addAction(menuScreenSize->menuAction());
253 for(i = 0; i < _SCREEN_MODE_NUM; i++) {
254 if(actionScreenSize[i] == NULL) continue;
255 menuScreenSize->addAction(actionScreenSize[i]);
256 actionScreenSize[i]->setVisible(true);
259 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
260 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
261 menuScreen->addSeparator();
262 menuScreen->addAction(menuStretch_Mode->menuAction());
264 menuStretch_Mode->addAction(actionDot_by_Dot);
265 menuStretch_Mode->addAction(actionReferToX_Display);
266 menuStretch_Mode->addAction(actionReferToY_Display);
267 menuStretch_Mode->addAction(actionFill_Display);
269 menuScreen->addSeparator();
271 if(using_flags->is_use_scanline()) {
272 menuScreen->addAction(actionScanLine);
275 if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
276 menuScreen->addAction(actionGLScanLineHoriz);
277 if(using_flags->is_use_vertical_pixel_lines()) {
278 menuScreen->addAction(actionGLScanLineVert);
281 if(using_flags->is_use_screen_rotate()) {
282 menuScreen->addAction(actionRotate);
284 if(using_flags->is_use_crt_filter()) {
285 menuScreen->addAction(actionCRT_Filter);
288 menuScreen->addAction(actionOpenGL_Filter);
289 menuScreen->addAction(actionCapture_Screen);
290 menuScreen->addSeparator();
291 menuScreen->addAction(menuRecord_as_movie->menuAction());
292 menuRecord_as_movie->addAction(actionStart_Record_Movie);
293 menuRecord_as_movie->addAction(actionStop_Record_Movie);
296 void Ui_MainWindow::retranslateScreenMenu(void)
301 actionZoom->setText(QApplication::translate("MainWindow", "Zoom Screen", 0));
302 actionDisplay_Mode->setText(QApplication::translate("MainWindow", "Display Mode", 0));
304 if(using_flags->is_use_scanline()) {
305 actionScanLine->setText(QApplication::translate("MainWindow", "Software Scan Line", 0));
307 if(using_flags->is_use_screen_rotate()) {
308 actionRotate->setText(QApplication::translate("MainWindow", "Rotate Screen", 0));
310 if(using_flags->is_use_crt_filter()) {
311 actionCRT_Filter->setText(QApplication::translate("MainWindow", "Software Filter", 0));
313 if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
314 actionGLScanLineHoriz->setText(QApplication::translate("MainWindow", "OpenGL Scan Line", 0));
315 if(using_flags->is_use_vertical_pixel_lines()) {
316 actionGLScanLineVert->setText(QApplication::translate("MainWindow", "OpenGL Pixel Line", 0));
320 actionOpenGL_Filter->setText(QApplication::translate("MainWindow", "OpenGL Filter", 0));
322 if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
323 (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
324 actionDot_by_Dot->setText(QApplication::translate("MainWindow", "Dot by Dot", 0));
325 actionReferToX_Display->setText(QApplication::translate("MainWindow", "Keep Aspect: Refer to X", 0));
326 actionReferToY_Display->setText(QApplication::translate("MainWindow", "Keep Aspect: Refer to Y", 0));
327 actionFill_Display->setText(QApplication::translate("MainWindow", "Keep Aspect: Fill", 0));
328 menuStretch_Mode->setTitle(QApplication::translate("MainWindow", "Stretch Mode", 0));
331 actionCapture_Screen->setText(QApplication::translate("MainWindow", "Capture Screen", 0));
333 menuScreen->setTitle(QApplication::translate("MainWindow", "Screen", 0));
334 actionStart_Record_Movie->setText(QApplication::translate("MainWindow", "Start Recording Movie", 0));
335 actionStop_Record_Movie->setText(QApplication::translate("MainWindow", "Stop Recording Movie", 0));
337 menuRecord_as_movie->setTitle(QApplication::translate("MainWindow", "Record as Movie", 0));
340 menuScreenSize->setTitle(QApplication::translate("MainWindow", "Screen Size", 0));
342 for(i = 0; i < _SCREEN_MODE_NUM; i++) {
343 if(actionScreenSize[i] == NULL) continue;
344 s_mul = screen_multiply_table[i];
345 if(s_mul <= 0) break;
346 tmps = QString::number(s_mul);
347 tmps = QString::fromUtf8("x", -1) + tmps;
348 actionScreenSize[i]->setText(tmps);