OSDN Git Service

[UI][Qt] Remove unneeded Qt classes from GUI.
[csp-qt/common_source_project-fm7.git] / source / src / qt / gui / menu_screen.cpp
index 1daaa47..3c0d64a 100644 (file)
@@ -6,9 +6,9 @@
  *   History :
  * Jan 14, 2015 : Initial, moved from qt/x1turboz/MainWindow.cpp .
  */
+#include <QMenu>
+#include <QMenuBar>
 
-#include <QtCore/QVariant>
-#include <QtGui>
 #include "commonclasses.h"
 #include "mainwidget_base.h"
 //#include "menuclasses.h"
@@ -16,7 +16,7 @@
 #include "qt_gldraw.h"
 #include "menu_flags.h"
 
-extern USING_FLAGS *using_flags;
+//extern USING_FLAGS *using_flags;
 // WIP: Move another header.
 #if (SCREEN_WIDTH > 320)
 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};
@@ -31,7 +31,7 @@ void Object_Menu_Control::set_screen_aspect(void) {
 void Object_Menu_Control::set_screen_size(void) {
        int w, h;
        double nd, ww, hh;
-       config.window_mode = getNumber();
+       using_flags->get_config_ptr()->window_mode = getNumber();
        nd = getDoubleValue();
        ww = nd * (double)using_flags->get_screen_width();
        hh = nd * (double)using_flags->get_screen_height();
@@ -40,11 +40,11 @@ void Object_Menu_Control::set_screen_size(void) {
                double par_w = (double)using_flags->get_screen_width_aspect() / (double)using_flags->get_screen_width();
                double par_h = (double)using_flags->get_screen_height_aspect() / (double)using_flags->get_screen_height();
                double par = par_h / par_w;
-               if(config.window_stretch_type == 1) { // refer to X, scale Y.
+               if(using_flags->get_config_ptr()->window_stretch_type == 1) { // refer to X, scale Y.
                        hh = hh * par_h;
-               } else if(config.window_stretch_type == 2) { // refer to Y, scale X only
+               } else if(using_flags->get_config_ptr()->window_stretch_type == 2) { // refer to Y, scale X only
                        ww = ww / par_h;
-               } else if(config.window_stretch_type == 3) { // Scale both X, Y
+               } else if(using_flags->get_config_ptr()->window_stretch_type == 3) { // Scale both X, Y
                        ww = ww * par_w;
                        hh = hh * par_h;
                }
@@ -55,29 +55,52 @@ void Object_Menu_Control::set_screen_size(void) {
        emit sig_screen_multiply(nd);
 }
 
+void Object_Menu_Control::do_save_as_movie(void)
+{
+       int fps = using_flags->get_config_ptr()->video_frame_rate;
+       emit sig_start_record_movie(fps);
+}
+
+void Object_Menu_Control::do_stop_saving_movie(void)
+{
+       emit sig_stop_record_movie();
+}
+
+
 void Ui_MainWindowBase::do_stop_saving_movie(void)
 {
-       actionStop_Record_Movie->setVisible(false);
-       actionStart_Record_Movie->setVisible(true);
        emit sig_stop_saving_movie();
 }
 
 void Ui_MainWindowBase::do_start_saving_movie(void)
 {
-       actionStop_Record_Movie->setVisible(true);
-       actionStart_Record_Movie->setVisible(false);
        emit sig_start_saving_movie();
 }
 
+void Ui_MainWindowBase::do_set_render_mode_std(void)
+{
+       using_flags->get_config_ptr()->rendering_type = CONFIG_RENDER_TYPE_STD;
+}
+
+void Ui_MainWindowBase::do_set_render_mode_tv(void)
+{
+       using_flags->get_config_ptr()->rendering_type = CONFIG_RENDER_TYPE_TV;
+}
+
+void Ui_MainWindowBase::do_set_state_saving_movie(bool state)
+{
+       actionStop_Record_Movie->setVisible(state);
+       actionStart_Record_Movie->setVisible(!state);
+}      
 
 void Ui_MainWindowBase::set_gl_scan_line_vert(bool f)
 {
-       config.opengl_scanline_vert = f;
+       using_flags->get_config_ptr()->opengl_scanline_vert = f;
 }
 
 void Ui_MainWindowBase::set_gl_scan_line_horiz(bool f)
 {
-       config.opengl_scanline_horiz = f;
+       using_flags->get_config_ptr()->opengl_scanline_horiz = f;
 }
 
 void Ui_MainWindowBase::ConfigScreenMenu_List(void)
@@ -97,12 +120,12 @@ void Ui_MainWindowBase::ConfigScreenMenu_List(void)
                }
                screen_mode_count++;
                tmps = QString::number(i);
-               actionScreenSize[i] = new Action_Control(this);
+               actionScreenSize[i] = new Action_Control(this, using_flags);
                actionScreenSize[i]->setObjectName(QString::fromUtf8("actionScreenSize", -1) + tmps);
                actionScreenSize[i]->setCheckable(true);
                actionScreenSize[i]->binds->setNumber(i);
 
-               if(i == config.window_mode)  actionScreenSize[i]->setChecked(true);  // OK?
+               if(i == using_flags->get_config_ptr()->window_mode)  actionScreenSize[i]->setChecked(true);  // OK?
 
                actionGroup_ScreenSize->addAction(actionScreenSize[i]);
                actionScreenSize[i]->binds->setDoubleValue(screen_multiply_table[i]);
@@ -119,16 +142,16 @@ void Ui_MainWindowBase::ConfigScreenMenu_List(void)
 }
 void Ui_MainWindowBase::ConfigScreenMenu(void)
 {
-       actionZoom = new Action_Control(this);
+       actionZoom = new Action_Control(this, using_flags);
        actionZoom->setObjectName(QString::fromUtf8("actionZoom"));
-       actionDisplay_Mode = new Action_Control(this);
+       actionDisplay_Mode = new Action_Control(this, using_flags);
        actionDisplay_Mode->setObjectName(QString::fromUtf8("actionDisplay_Mode"));
        
        if(using_flags->is_use_scanline()) {
-               actionScanLine = new Action_Control(this);
+               actionScanLine = new Action_Control(this, using_flags);
                actionScanLine->setObjectName(QString::fromUtf8("actionScanLine"));
                actionScanLine->setCheckable(true);
-               if(config.scan_line != 0) {
+               if(using_flags->get_config_ptr()->scan_line != 0) {
                        actionScanLine->setChecked(true);
                } else {
                        actionScanLine->setChecked(false);
@@ -137,10 +160,10 @@ void Ui_MainWindowBase::ConfigScreenMenu(void)
                        this, SLOT(set_scan_line(bool)));
        }
        if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
-               actionGLScanLineHoriz = new Action_Control(this);
+               actionGLScanLineHoriz = new Action_Control(this, using_flags);
                actionGLScanLineHoriz->setObjectName(QString::fromUtf8("actionGLScanLineHoriz"));
                actionGLScanLineHoriz->setCheckable(true);
-               if(config.opengl_scanline_horiz != 0) {
+               if(using_flags->get_config_ptr()->opengl_scanline_horiz != 0) {
                        actionGLScanLineHoriz->setChecked(true);
                } else {
                        actionGLScanLineHoriz->setChecked(false);
@@ -148,10 +171,10 @@ void Ui_MainWindowBase::ConfigScreenMenu(void)
                connect(actionGLScanLineHoriz, SIGNAL(toggled(bool)),
                                this, SLOT(set_gl_scan_line_horiz(bool)));
                if(using_flags->is_use_vertical_pixel_lines()) {
-                       actionGLScanLineVert = new Action_Control(this);
+                       actionGLScanLineVert = new Action_Control(this, using_flags);
                        actionGLScanLineVert->setObjectName(QString::fromUtf8("actionGLScanLineVert"));
                        actionGLScanLineVert->setCheckable(true);
-                       if(config.opengl_scanline_vert != 0) {
+                       if(using_flags->get_config_ptr()->opengl_scanline_vert != 0) {
                                actionGLScanLineVert->setChecked(true);
                        } else {
                                actionGLScanLineVert->setChecked(false);
@@ -161,10 +184,10 @@ void Ui_MainWindowBase::ConfigScreenMenu(void)
                }
        }
        if(using_flags->is_use_screen_rotate()) {
-               actionRotate = new Action_Control(this);
+               actionRotate = new Action_Control(this, using_flags);
                actionRotate->setObjectName(QString::fromUtf8("actionScanLine"));
                actionRotate->setCheckable(true);
-               if(config.rotate_type) {
+               if(using_flags->get_config_ptr()->rotate_type) {
                        actionRotate->setChecked(true);
                } else {
                        actionRotate->setChecked(false);
@@ -173,45 +196,45 @@ void Ui_MainWindowBase::ConfigScreenMenu(void)
                                this, SLOT(set_screen_rotate(bool)));
        }
        if(using_flags->is_use_crt_filter()) {
-               actionCRT_Filter = new Action_Control(this);
+               actionCRT_Filter = new Action_Control(this, using_flags);
                actionCRT_Filter->setObjectName(QString::fromUtf8("actionCRT_Filter"));
                actionCRT_Filter->setEnabled(true);
                actionCRT_Filter->setCheckable(true);
-               if(config.crt_filter == 0) actionCRT_Filter->setChecked(true);
+               if(using_flags->get_config_ptr()->crt_filter == 0) actionCRT_Filter->setChecked(true);
                connect(actionCRT_Filter, SIGNAL(toggled(bool)), this, SLOT(set_crt_filter(bool)));
        }
-       actionOpenGL_Filter = new Action_Control(this);
+       actionOpenGL_Filter = new Action_Control(this, using_flags);
        actionOpenGL_Filter->setObjectName(QString::fromUtf8("actionOpenGL_Filter"));
        actionOpenGL_Filter->setEnabled(true);
        actionOpenGL_Filter->setCheckable(true);
-       if(config.use_opengl_filters) actionOpenGL_Filter->setChecked(true);
+       if(using_flags->get_config_ptr()->use_opengl_filters) actionOpenGL_Filter->setChecked(true);
        connect(actionOpenGL_Filter, SIGNAL(toggled(bool)), this, SLOT(set_gl_crt_filter(bool)));
 
        if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
           (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
-               actionDot_by_Dot = new Action_Control(this);
+               actionDot_by_Dot = new Action_Control(this, using_flags);
                actionDot_by_Dot->setObjectName(QString::fromUtf8("actionDot_by_Dot"));
                actionDot_by_Dot->setCheckable(true);
-               if(config.window_stretch_type == 0) actionDot_by_Dot->setChecked(true);
+               if(using_flags->get_config_ptr()->window_stretch_type == 0) actionDot_by_Dot->setChecked(true);
                actionDot_by_Dot->binds->setValue1(0);
                
-               actionReferToX_Display = new Action_Control(this);
+               actionReferToX_Display = new Action_Control(this, using_flags);
                actionReferToX_Display->setObjectName(QString::fromUtf8("actionReferToX_Display"));
                actionReferToX_Display->setCheckable(true);
                actionReferToX_Display->binds->setValue1(1);
-               if(config.window_stretch_type == 1) actionReferToX_Display->setChecked(true);
+               if(using_flags->get_config_ptr()->window_stretch_type == 1) actionReferToX_Display->setChecked(true);
                
-               actionReferToY_Display = new Action_Control(this);
+               actionReferToY_Display = new Action_Control(this, using_flags);
                actionReferToY_Display->setObjectName(QString::fromUtf8("actionReferToY_Display"));
                actionReferToY_Display->setCheckable(true);
                actionReferToY_Display->binds->setValue1(2);
-               if(config.window_stretch_type == 2) actionReferToY_Display->setChecked(true);
+               if(using_flags->get_config_ptr()->window_stretch_type == 2) actionReferToY_Display->setChecked(true);
        
-               actionFill_Display = new Action_Control(this);
+               actionFill_Display = new Action_Control(this, using_flags);
                actionFill_Display->setObjectName(QString::fromUtf8("actionFill_Display"));
                actionFill_Display->setCheckable(true);
                actionFill_Display->binds->setValue1(3);
-               if(config.window_stretch_type == 3) actionFill_Display->setChecked(true);
+               if(using_flags->get_config_ptr()->window_stretch_type == 3) actionFill_Display->setChecked(true);
        
                actionGroup_Stretch = new QActionGroup(this);
                actionGroup_Stretch->setExclusive(true);
@@ -231,17 +254,49 @@ void Ui_MainWindowBase::ConfigScreenMenu(void)
                connect(actionFill_Display, SIGNAL(triggered()), actionFill_Display->binds, SLOT(set_screen_aspect()));
                connect(actionFill_Display->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int)));
        }
-       actionCapture_Screen = new Action_Control(this);
+       actionCapture_Screen = new Action_Control(this, using_flags);
        actionCapture_Screen->setObjectName(QString::fromUtf8("actionCapture_Screen"));
 
-       actionStart_Record_Movie = new Action_Control(this);
+       actionStart_Record_Movie = new Action_Control(this, using_flags);
        actionStart_Record_Movie->setObjectName(QString::fromUtf8("actionStart_Record_Movie"));
        actionStart_Record_Movie->setCheckable(false);
        
-       actionStop_Record_Movie = new Action_Control(this);
+       actionStop_Record_Movie = new Action_Control(this, using_flags);
        actionStop_Record_Movie->setObjectName(QString::fromUtf8("actionStop_Record_Movie"));
        actionStop_Record_Movie->setCheckable(false);
 
+       bool b_support_tv_render = using_flags->is_support_tv_render();
+       if(b_support_tv_render) {
+               int ii = CONFIG_RENDER_TYPE_END;
+               int i;
+               
+               if((ii >= 8) || (ii < 0)) ii = 8;
+               actionGroup_RenderMode = new QActionGroup(this);
+               actionGroup_RenderMode->setExclusive(true);
+               
+               for(i = 0; i < ii; i++) {
+                       action_SetRenderMode[i] = new Action_Control(this, using_flags);
+                       action_SetRenderMode[i]->setCheckable(true);
+                       action_SetRenderMode[i]->setEnabled(false);
+                       action_SetRenderMode[i]->setVisible(false);
+                       action_SetRenderMode[i]->binds->setValue1(i);
+                       
+                       if(i == using_flags->get_config_ptr()->rendering_type) action_SetRenderMode[i]->setChecked(true);
+               
+                       if(i == CONFIG_RENDER_TYPE_STD) {
+                               action_SetRenderMode[i]->setEnabled(true);
+                               action_SetRenderMode[i]->setVisible(true);
+                               actionGroup_RenderMode->addAction(action_SetRenderMode[i]);
+                               connect(action_SetRenderMode[i], SIGNAL(triggered()), this, SLOT(do_set_render_mode_std()));
+                       }
+                       if(b_support_tv_render && (i == CONFIG_RENDER_TYPE_TV)) {
+                               action_SetRenderMode[i]->setEnabled(true);
+                               action_SetRenderMode[i]->setVisible(true);
+                               actionGroup_RenderMode->addAction(action_SetRenderMode[i]);
+                               connect(action_SetRenderMode[i], SIGNAL(triggered()), this, SLOT(do_set_render_mode_tv()));
+                       }
+               }
+       }                               
        ConfigScreenMenu_List();  
 }
 
@@ -255,7 +310,16 @@ void Ui_MainWindowBase::CreateScreenMenu(void)
                menuStretch_Mode = new QMenu(menuScreen);
                menuStretch_Mode->setObjectName(QString::fromUtf8("menuStretch_Mode"));
        }
-
+       bool b_support_tv_render = using_flags->is_support_tv_render();
+       if(b_support_tv_render) {
+               menuScreen_Render = new QMenu(menuScreen);
+               menuScreen_Render->setObjectName(QString::fromUtf8("menuRender_Mode"));
+               menuScreen_Render->addAction(action_SetRenderMode[CONFIG_RENDER_TYPE_STD]);
+               if(b_support_tv_render) {
+                       menuScreen_Render->addAction(action_SetRenderMode[CONFIG_RENDER_TYPE_TV]);
+               }
+               menuScreen->addAction(menuScreen_Render->menuAction());
+       }
        menuScreenSize = new QMenu(menuScreen);
        menuScreenSize->setObjectName(QString::fromUtf8("menuScreen_Size"));
        menuScreen->addSeparator();
@@ -317,21 +381,27 @@ void Ui_MainWindowBase::retranslateScreenMenu(void)
 
        if(using_flags->is_use_scanline()) {
                actionScanLine->setText(QApplication::translate("MainWindow", "Software Scan Line", 0));
+               actionScanLine->setToolTip(QApplication::translate("MainWindow", "Display scan line by software.", 0));
        }
        if(using_flags->is_use_screen_rotate()) {
                actionRotate->setText(QApplication::translate("MainWindow", "Rotate Screen", 0));
+               actionRotate->setToolTip(QApplication::translate("MainWindow", "Rotate screen.", 0));
        }
        if(using_flags->is_use_crt_filter()) {
                actionCRT_Filter->setText(QApplication::translate("MainWindow", "Software Filter", 0));
+               actionCRT_Filter->setToolTip(QApplication::translate("MainWindow", "Use display filter by software.", 0));
        }
        if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
                actionGLScanLineHoriz->setText(QApplication::translate("MainWindow", "OpenGL Scan Line", 0));
+               actionGLScanLineHoriz->setToolTip(QApplication::translate("MainWindow", "Display scan line by OpenGL.", 0));
                if(using_flags->is_use_vertical_pixel_lines()) {
                        actionGLScanLineVert->setText(QApplication::translate("MainWindow", "OpenGL Pixel Line", 0));
+                       actionGLScanLineVert->setToolTip(QApplication::translate("MainWindow", "Display pixel line by OpenGL.", 0));
                }
        }
        
        actionOpenGL_Filter->setText(QApplication::translate("MainWindow", "OpenGL Filter", 0));
+       actionOpenGL_Filter->setToolTip(QApplication::translate("MainWindow", "Use display filter by OpenGL", 0));
 
        if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
           (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
@@ -343,13 +413,17 @@ void Ui_MainWindowBase::retranslateScreenMenu(void)
        }
 
        actionCapture_Screen->setText(QApplication::translate("MainWindow", "Capture Screen", 0));
+       actionCapture_Screen->setToolTip(QApplication::translate("MainWindow", "Capture screen to a PNG file.", 0));
 
        menuScreen->setTitle(QApplication::translate("MainWindow", "Screen", 0));
        actionStart_Record_Movie->setText(QApplication::translate("MainWindow", "Start Recording Movie", 0));
+       actionStart_Record_Movie->setToolTip(QApplication::translate("MainWindow", "Start Recording Movie", 0));
        actionStop_Record_Movie->setText(QApplication::translate("MainWindow", "Stop Recording Movie", 0));
-
+       actionStop_Record_Movie->setToolTip(QApplication::translate("MainWindow", "Stop Recording Movie", 0));
+       menuScreen->setToolTipsVisible(true);
+       
        menuRecord_as_movie->setTitle(QApplication::translate("MainWindow", "Record as Movie", 0));
-
+       menuRecord_as_movie->setToolTipsVisible(true);
 
        menuScreenSize->setTitle(QApplication::translate("MainWindow", "Screen Size", 0));
        double s_mul;
@@ -361,5 +435,16 @@ void Ui_MainWindowBase::retranslateScreenMenu(void)
                tmps = QString::fromUtf8("x", -1) + tmps;
                actionScreenSize[i]->setText(tmps);
        }
+       bool b_support_tv_render = using_flags->is_support_tv_render();
+       if(b_support_tv_render) {
+               menuScreen_Render->setTitle(QApplication::translate("MainWindow", "Render Mode", 0));
+               menuScreen_Render->setToolTipsVisible(true);
+               action_SetRenderMode[CONFIG_RENDER_TYPE_STD]->setText(QApplication::translate("MainWindow", "Standard", 0));
+               action_SetRenderMode[CONFIG_RENDER_TYPE_STD]->setToolTip(QApplication::translate("MainWindow", "Standard render.", 0));
+               if(b_support_tv_render) {
+                       action_SetRenderMode[CONFIG_RENDER_TYPE_TV]->setText(QApplication::translate("MainWindow", "TV", 0));
+                       action_SetRenderMode[CONFIG_RENDER_TYPE_TV]->setToolTip(QApplication::translate("MainWindow", "Rendering like tubed  television with RF modulator.\nNeeds OpenGL 3.0 or later.Not effect with OpenGL 2.0.", 0));
+               }
+       }
 }