OSDN Git Service

[UI][Qt] Fix not display label texts.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 7 Apr 2016 12:19:12 +0000 (21:19 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 7 Apr 2016 12:19:12 +0000 (21:19 +0900)
[UI][Qt] More push to libCSPgui.so .

16 files changed:
source/src/qt/common/CMakeLists.txt
source/src/qt/common/agar_logger.cpp
source/src/qt/common/mainwidget.h
source/src/qt/common/menu_flags.cpp
source/src/qt/common/menu_flags.h
source/src/qt/common/qt_main.cpp
source/src/qt/common/util_bubble2.cpp
source/src/qt/gui/CMakeLists.txt
source/src/qt/gui/display_about.cpp [moved from source/src/qt/common/display_about.cpp with 94% similarity]
source/src/qt/gui/display_about.h [moved from source/src/qt/common/display_about.h with 100% similarity]
source/src/qt/gui/display_text_document.cpp
source/src/qt/gui/dropdown_jspage.cpp [moved from source/src/qt/common/dropdown_jspage.cpp with 88% similarity]
source/src/qt/gui/dropdown_jspage.h [moved from source/src/qt/common/dropdown_jspage.h with 100% similarity]
source/src/qt/gui/menu_main.cpp
source/src/qt/gui/qt_glevents.cpp
source/src/qt/gui/sound_dialog.cpp

index 1585824..58e9736 100644 (file)
@@ -5,8 +5,6 @@ set(s_qt_common_headers
          draw_thread.h
          menu_metaclass.h
          mainwidget.h
-         display_about.h
-         dropdown_jspage.h
 )
 
 if(WITH_JOYSTICK)
@@ -24,8 +22,6 @@ set(QT_COMMON_BASE
          qt_main.cpp
          menu_flags.cpp
          menu_metaclass.cpp
-         display_about.cpp
-         dropdown_jspage.cpp
          emu_thread.cpp
          draw_thread.cpp
          util_fd2.cpp
index 2e2a42b..018aa10 100644 (file)
@@ -10,6 +10,7 @@
 #include <string.h>
 #include "emu.h"
 #include "vm/vm.h"
+#include "menu_flags.h"
 
 static int syslog_flag = 0;
 static int log_cons = 0;
@@ -17,6 +18,7 @@ static int log_onoff = 0;
 static int log_opened = FALSE;
 static char log_sysname[256];
 
+extern class USING_FLAGS *using_flags;
 extern "C" 
 {
    
index afe1aee..0857af2 100644 (file)
@@ -65,9 +65,7 @@ public slots:
 #endif
        void on_actionExit_triggered();
        void do_release_emu_resources(void);
-       void set_window_title();
        void delete_joy_thread(void);
-       void do_set_window_title(QString s);
        void do_set_mouse_enable(bool flag);
        void do_toggle_mouse(void);
        //virtual void redraw_status_bar(void);
index 65eee0f..b6c223b 100644 (file)
@@ -2,6 +2,12 @@
 #include "vm.h"
 #include "menu_flags.h"
 
+#ifndef USE_SOUND_VOLUME
+static const _TCHAR *sound_device_caption[] = {""};
+#endif
+#ifndef USE_JOY_BUTTON_CAPTIONS
+static const _TCHAR *joy_button_captions[] = {""};
+#endif
 
 USING_FLAGS::USING_FLAGS()
 {
@@ -34,6 +40,7 @@ USING_FLAGS::USING_FLAGS()
        max_draw_ranges = 0;
        
        use_joystick = use_joy_button_captions = false;
+       num_joy_button_captions = 0;
 
        use_laser_disc = false;
        use_led_device = 0;
@@ -78,6 +85,16 @@ USING_FLAGS::USING_FLAGS()
        use_vertical_pixel_lines = false;
        notify_key_down_lr_shift = false;
        tape_binary_only = false;
+#if defined(DEVICE_NAME)
+       device_name = QString::fromUtf8(DEVICE_NAME);
+#else
+       device_name = QString::fromUtf8("");
+#endif
+#if defined(CONFIG_NAME)
+       config_name = QString::fromUtf8(CONFIG_NAME);
+#else
+       config_name = QString::fromUtf8("");
+#endif
        
        machine_pasopia_variants = false;
 #if defined(_PASOPIA7) || defined(_PASOPIA)
@@ -308,6 +325,7 @@ USING_FLAGS::USING_FLAGS()
        use_joystick = true;
        #if defined(USE_JOY_BUTTON_CAPTIONS)
                use_joy_button_captions = true;
+               num_joy_button_captions = sizeof(joy_button_captions) / sizeof(_TCHAR *);
        #endif  
 #endif
 #if defined(USE_LASER_DISC)
@@ -431,3 +449,30 @@ USING_FLAGS::USING_FLAGS()
 USING_FLAGS::~USING_FLAGS()
 {
 }
+
+const _TCHAR *USING_FLAGS::get_joy_button_captions(int num)
+{
+#ifdef USE_JOY_BUTTON_CAPTIONS
+       if((num < 0) || (num >= num_joy_button_captions)) {
+               return "";
+       } else  {
+               return joy_button_captions[num];
+       }
+#else
+       return "";
+#endif 
+}
+
+const _TCHAR *USING_FLAGS::get_sound_device_caption(int num)
+{
+#ifdef USE_SOUND_VOLUME
+       if((num < 0) || (num >= USE_SOUND_VOLUME)) {
+               return "";
+       } else  {
+               return sound_device_caption[num];
+       }
+#else
+       return "";
+#endif 
+}
+
index b260f24..5a959d4 100644 (file)
@@ -2,6 +2,7 @@
 #ifndef __CSP_QT_COMMON_MENU_FLAGS_H
 #define __CSP_QT_COMMON_MENU_FLAGS_H
 
+#include <QString>
 #include "common.h"
 #ifndef _SCREEN_MODE_NUM
 #define _SCREEN_MODE_NUM 32
@@ -17,6 +18,8 @@ typedef struct {
 
 class USING_FLAGS {
 private:
+       QString config_name;
+       QString device_name;
        // USE_* flags
        bool use_access_lamp;
        bool use_alt_f10_key;
@@ -61,7 +64,7 @@ private:
        
        bool use_joystick;
        bool use_joy_button_captions;
-
+       int num_joy_button_captions;
        bool use_laser_disc;
        int use_led_device;
 
@@ -139,6 +142,8 @@ private:
 public:
        USING_FLAGS();
        ~USING_FLAGS();
+       QString get_config_name() { return config_name; }
+       QString get_device_name() { return device_name; }
        
     bool is_use_access_lamp() { return use_access_lamp; }
        bool is_use_alt_f10_key() { return use_alt_f10_key; }
@@ -184,6 +189,7 @@ public:
        
        bool is_use_joystick() { return use_joystick; }
        bool is_use_joy_button_captions() { return use_joy_button_captions; }
+       int  get_num_joy_button_captions() { return num_joy_button_captions; }
 
        bool is_use_laser_disc() {return use_laser_disc; }
        int get_use_led_device() { return use_led_device; }
@@ -256,13 +262,9 @@ public:
        bool is_machine_has_pcengine() { return machine_has_pcengine; }
        bool is_machine_sc3000() { return machine_sc3000; }
        bool is_machine_z80tvgame() { return machine_z80tvgame; }
+       const _TCHAR *get_joy_button_captions(int num);
+       const _TCHAR *get_sound_device_caption(int num);
 };
        
-#ifndef USE_SOUND_VOLUME
-static const _TCHAR sound_device_caption[] = {""};
-#endif
-#ifndef USE_JOY_BUTTON_CAPTIONS
-static const _TCHAR *joy_button_captions[] = {""};
-#endif
 
 #endif //#ifndef __CSP_QT_COMMON_MENU_FLAGS_H
index 00ab445..950b045 100644 (file)
@@ -65,30 +65,6 @@ bool now_fullscreen = false;
 
 int window_mode_count;
 
-void Ui_MainWindow::set_window_title()
-{
-       QString tmps;
-       tmps = QString::fromUtf8("emu");
-       tmps = tmps + QString::fromUtf8(CONFIG_NAME);
-       tmps = tmps + QString::fromUtf8(" (");
-       tmps = tmps + QString::fromUtf8(DEVICE_NAME);
-       tmps = tmps + QString::fromUtf8(")");
-       MainWindow->setWindowTitle(tmps);
-}
-
-void Ui_MainWindow::do_set_window_title(QString s)
-{
-       QString tmps;
-       tmps = QString::fromUtf8("emu");
-       tmps = tmps + QString::fromUtf8(CONFIG_NAME);
-       tmps = tmps + QString::fromUtf8(" (");
-       if(!s.isEmpty()) {
-               tmps = tmps + s;
-       }
-       tmps = tmps + QString::fromUtf8(")");
-       MainWindow->setWindowTitle(tmps);
-}
-
 void Ui_MainWindow::do_set_mouse_enable(bool flag)
 {
 #ifdef USE_MOUSE
index b869c9f..22da7fa 100644 (file)
@@ -8,6 +8,7 @@
 #include "agar_logger.h"
 
 #if defined(USE_BUBBLE1)
+extern EMU *emu;
 
 #ifndef UPDATE_B77_LIST
 #define UPDATE_B77_LIST(__d, lst) { \
@@ -15,8 +16,8 @@
        QString __tmps; \
        for(int iii = 0; iii < MAX_B77_BANKS; iii++) { \
                __tmps = QString::fromUtf8(""); \
-               if(iii < p_emu->b77_file[__d].bank_num) { \
-                       __tmps = QString::fromUtf8(p_emu->b77_file[__d].bubble_name[iii]); \
+               if(iii < emu->b77_file[__d].bank_num) { \
+                       __tmps = QString::fromUtf8(emu->b77_file[__d].bubble_name[iii]); \
                } \
        lst << __tmps; \
        } \
@@ -27,12 +28,12 @@ int Ui_MainWindow::set_b77_slot(int drive, int num)
 {
        QString path;
        if((num < 0) || (num >= using_flags->get_max_b77_banks())) return -1;
-       path = QString::fromUtf8(p_emu->b77_file[drive].path);
+       path = QString::fromUtf8(emu->b77_file[drive].path);
        menu_bubbles[drive]->do_select_inner_media(num);
 
-       if(emu && p_emu->b77_file[drive].cur_bank != num) {
+       if(emu && emu->b77_file[drive].cur_bank != num) {
                emit sig_open_bubble(drive, path, num);
-               if(p_emu->is_bubble_casette_protected(drive)) {
+               if(emu->is_bubble_casette_protected(drive)) {
                        menu_bubbles[drive]->do_set_write_protect(true);
                } else {
                        menu_bubbles[drive]->do_set_write_protect(false);
@@ -47,7 +48,7 @@ void Ui_MainWindow::do_update_recent_bubble(int drv)
        if(emu == NULL) return;
        menu_bubbles[drv]->do_update_histories(listBubbles[drv]);
        menu_bubbles[drv]->do_set_initialize_directory(config.initial_bubble_casette_dir);
-       if(p_emu->is_bubble_casette_protected(drv)) {
+       if(emu->is_bubble_casette_protected(drv)) {
                menu_bubbles[drv]->do_write_protect_media();
        } else {
                menu_bubbles[drv]->do_write_unprotect_media();
@@ -100,7 +101,7 @@ void Ui_MainWindow::_open_bubble(int drv, const QString fname)
        strncpy(path_shadow, fname.toLocal8Bit().constData(), PATH_MAX);
        if(emu) {
                emit sig_close_bubble(drv);
-               //p_emu->LockVM();
+               //emu->LockVM();
                emit sig_open_bubble(drv, fname, 0);
                menu_bubbles[drv]->do_update_histories(listBubbles[drv]);
                menu_bubbles[drv]->do_set_initialize_directory(config.initial_bubble_casette_dir);
index 98323c4..2034b36 100644 (file)
@@ -16,11 +16,12 @@ set(s_qt_gui_headers
          menu_compactdisc.h
          menu_binary.h
          menu_bubble.h
-#        display_about.h
+         display_about.h
          display_text_document.h
          dropdown_keyset.h
          dropdown_joystick.h
          dropdown_jsbutton.h
+         dropdown_jspage.h
          dialog_set_key.h
          dialog_set_key_combo.h
 )
@@ -55,12 +56,13 @@ set(s_qt_gui_srcs
          util_binary.cpp
          util_bubble.cpp
          display_statusbar.cpp
-#        display_about.cpp
+         display_about.cpp
          display_text_document.cpp
          sound_dialog.cpp
          dropdown_keyset.cpp
          dropdown_joystick.cpp
          dropdown_jsbutton.cpp
+         dropdown_jspage.cpp
          dialog_set_key.cpp
          dialog_set_key_combo.cpp
 )
similarity index 94%
rename from source/src/qt/common/display_about.cpp
rename to source/src/qt/gui/display_about.cpp
index 479cb9b..4f3bc0f 100644 (file)
 #include <QIODevice>
 #include <QStringList>
 
-#include "menuclasses.h"
 #include "display_about.h"
+#include "menu_flags.h"
 
+extern USING_FLAGS *using_flags;
 
 Dlg_AboutCSP::Dlg_AboutCSP(QWidget *parent) : QWidget(parent)
 {
@@ -58,7 +59,7 @@ Dlg_AboutCSP::Dlg_AboutCSP(QWidget *parent) : QWidget(parent)
        titlearea = new QLabel(parent);
        name = QString::fromUtf8("<div align=left><B><FONT SIZE=+1>Common Source Code Project</B></div>");
        name.append(QString::fromUtf8("<div align=center>for&nbsp;&nbsp;<FONT SIZE=+1><B>"));
-       name.append(QString::fromUtf8(DEVICE_NAME));
+       name.append(using_flags->get_device_name());
        name.append(QString::fromUtf8("</B></FONT></div>"));
        titlearea->setText(name);
        titlearea->setAlignment(Qt::AlignRight);
@@ -92,7 +93,7 @@ Dlg_AboutCSP::Dlg_AboutCSP(QWidget *parent) : QWidget(parent)
 
        QString title;
        title = QString::fromUtf8("About emu");
-       title.append(QString::fromUtf8(CONFIG_NAME));
+       title.append(using_flags->get_config_name());
        if(parent == NULL) this->setWindowTitle(title);
 }
 
index 1219d79..bc7ef6a 100644 (file)
@@ -13,7 +13,9 @@
 
 #include "mainwidget_base.h"
 #include "display_text_document.h"
+#include "menu_flags.h"
 
+extern USING_FLAGS * using_flags;
 
 Dlg_BrowseText::Dlg_BrowseText(QString fname, bool internal, QWidget *parent) : QWidget(parent)
 {
@@ -57,9 +59,9 @@ Dlg_BrowseText::Dlg_BrowseText(QString fname, bool internal, QWidget *parent) :
        this->setLayout(VBox);
 
        QString title;
-//     title = QString::fromUtf8("emu");
-//     title.append(QString::fromUtf8(CONFIG_NAME));
-//     title.append(QString::fromUtf8(" / "));
+       title = QString::fromUtf8("emu");
+       title.append(using_flags->get_config_name());
+       title.append(QString::fromUtf8(" / "));
        title.append(fname);
        if(parent == NULL) this->setWindowTitle(title);
 }
similarity index 88%
rename from source/src/qt/common/dropdown_jspage.cpp
rename to source/src/qt/gui/dropdown_jspage.cpp
index fd08e90..a0d14ab 100644 (file)
@@ -1,9 +1,11 @@
 
-#include "vm.h"
 #include "dropdown_keyset.h"
 #include "dropdown_jsbutton.h"
 #include "dropdown_jspage.h"
 #include <QApplication>
+#include "menu_flags.h"
+
+extern USING_FLAGS *using_flags;
 
 CSP_DropDownJSPage::CSP_DropDownJSPage(QWidget *parent, QStringList *lst, int jsnum)
 {
@@ -30,30 +32,25 @@ CSP_DropDownJSPage::CSP_DropDownJSPage(QWidget *parent, QStringList *lst, int js
        layout->addWidget(combo_js[2], 2, 2, Qt::AlignRight);
        label_buttons = new QLabel(QApplication::translate("MainWindow", "<B>Physical Buttons:</B>", 0), this);
        layout->addWidget(label_buttons, 4, 0, Qt::AlignLeft);
-#if defined(USE_JOY_BUTTON_CAPTIONS)
-       int joybuttons = sizeof(joy_button_captions) / sizeof(_TCHAR *) - 4;
-#endif
+
+       int joybuttons = using_flags->get_num_joy_button_captions();
+
        
        for(i = 0; i < 12; i++) {
-
-#if defined(USE_JOY_BUTTON_CAPTIONS)           
                if(joybuttons > i) {
-#endif                 
                        memset(tmps, 0x00, sizeof(char) * 20);
                        label_button[i] = new QLabel(this);
                        js_button[i] = new CSP_DropDownJSButton(this, lst, jsnum, i + 4);
-#if defined(USE_JOY_BUTTON_CAPTIONS)           
-                       snprintf(tmps, 32, "<B>%s</B>", joy_button_captions[i + 4]);
-#else          
-                       snprintf(tmps, 32, "<B>#%02d:</B>", i + 1);
-#endif         
+                       if(using_flags->is_use_joy_button_captions()) {
+                               snprintf(tmps, 32, "<B>%s</B>", using_flags->get_joy_button_captions(i + 4));
+                       } else {
+                               snprintf(tmps, 32, "<B>#%02d:</B>", i + 1);
+                       }
                        nm = QString::fromUtf8(tmps);
                        label_button[i]->setText(nm);
                        layout->addWidget(label_button[i], (i / 4) * 2 + 5 + 0, i % 4, Qt::AlignLeft);
                        layout->addWidget(js_button[i], (i / 4) * 2 + 5 + 1, i % 4, Qt::AlignLeft);
-#if defined(USE_JOY_BUTTON_CAPTIONS)
                }
-#endif
        }
        this->setLayout(layout);
        connect(this, SIGNAL(sig_select_js_button(int, int, int)), parent, SLOT(do_set_js_button(int, int, int)));
index 3376509..9fc648c 100644 (file)
@@ -724,6 +724,10 @@ void Ui_MainWindowBase::set_window_title()
 {
        QString tmps;
        tmps = QString::fromUtf8("emu");
+       tmps = tmps + using_flags->get_config_name();
+       tmps = tmps + QString::fromUtf8(" (");
+       tmps = tmps + using_flags->get_device_name();
+       tmps = tmps + QString::fromUtf8(")");
        MainWindow->setWindowTitle(tmps);
 }
 
@@ -731,6 +735,7 @@ void Ui_MainWindowBase::do_set_window_title(QString s)
 {
        QString tmps;
        tmps = QString::fromUtf8("emu");
+       tmps = tmps + using_flags->get_config_name();
        tmps = tmps + QString::fromUtf8(" (");
        if(!s.isEmpty()) {
                tmps = tmps + s;
index 600cf31..ea2e346 100644 (file)
@@ -131,7 +131,7 @@ void GLDrawClass::do_save_frame_screen(void)
                save_pixmap_req = true;
                QDateTime nowTime = QDateTime::currentDateTime();
                QString tmps = QString::fromUtf8("Screen_Save_emu");
-               //tmps = tmps + QString::fromUtf8(CONFIG_NAME);
+               tmps = tmps + using_flags->get_config_name();
                tmps = tmps + QString::fromUtf8("_");
                tmps = tmps + nowTime.toString(QString::fromUtf8("yyyy-MM-dd_hh-mm-ss.zzz"));
                tmps = tmps + QString::fromUtf8(".png");
index 77d3695..d449900 100644 (file)
@@ -131,7 +131,7 @@ Ui_SoundDialog::Ui_SoundDialog(EMU *_emu, QWidget *parent) : QWidget(0)
                int ii;
                int ij = 0;
                for(ii = 0; ii < using_flags->get_use_sound_volume(); ii++) {
-                       QString lbl = QApplication::translate("Ui_SoundDialog", sound_device_caption[ii], 0);
+                       QString lbl = QApplication::translate("Ui_SoundDialog", using_flags->get_sound_device_caption(ii), 0);
                        int l_val = config.sound_volume_l[ii];
                        int r_val = config.sound_volume_r[ii];