OSDN Git Service

[UI][Qt] Update title of main window real time.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 9 Mar 2016 12:44:11 +0000 (21:44 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 9 Mar 2016 12:44:11 +0000 (21:44 +0900)
[UI][Qt][Sound] Volume dialog: Add icons and change layouts.
[UI][Qt] Add icons to some menu entries.

12 files changed:
source/src/qt/common/emu_thread.cpp
source/src/qt/common/emu_thread.h
source/src/qt/common/qt_main.cpp
source/src/qt/gui/mainwidget.h
source/src/qt/gui/menu_cmt.cpp
source/src/qt/gui/menu_control.cpp
source/src/qt/gui/menu_main.cpp
source/src/qt/gui/menu_metaclass.cpp
source/src/qt/gui/menu_metaclass.h
source/src/qt/gui/menu_sound.cpp
source/src/qt/gui/sound_dialog.cpp
source/src/qt/gui/sound_dialog.h

index 8903b06..8588532 100644 (file)
@@ -692,9 +692,9 @@ void EmuThreadClass::print_framerate(int frames)
 #ifdef USE_POWER_OFF
                                } 
 #endif // USE_POWER_OFF         
-             
                                message = buf;
                                emit message_changed(message);
+                               emit window_title_changed(message);
                                update_fps_time += 1000;
                                total_frames = draw_frames = 0;
                                
index 37f90c9..b8a22c5 100644 (file)
@@ -165,6 +165,7 @@ public slots:
        
 signals:
        int message_changed(QString);
+       int window_title_changed(QString);
        int sig_draw_thread(bool);
        int quit_draw_thread(void);
        int sig_screen_aspect(int);
index 3dfefdb..51fa162 100644 (file)
@@ -292,6 +292,7 @@ void Ui_MainWindow::LaunchEmuThread(void)
 #endif
        AGAR_DebugLog(AGAR_LOG_DEBUG, "DrawThread : Start.");
        connect(hDrawEmu, SIGNAL(sig_draw_frames(int)), hRunEmu, SLOT(print_framerate(int)));
+       connect(hRunEmu, SIGNAL(window_title_changed(QString)), this, SLOT(do_set_window_title(QString)));
        connect(hDrawEmu, SIGNAL(message_changed(QString)), this, SLOT(message_status_bar(QString)));
        connect(actionCapture_Screen, SIGNAL(triggered()), glv, SLOT(do_save_frame_screen()));
                
index e43edf4..b74fdf9 100644 (file)
@@ -79,6 +79,7 @@ class Ui_MainWindow : public QMainWindow
 #ifdef USE_LED_DEVICE
        QTimer *ledUpdateTimer;
 #endif
+       int screen_mode_count;
        QIcon WindowIcon;
        QIcon InsertIcon;
        QIcon EjectIcon;
@@ -86,7 +87,10 @@ class Ui_MainWindow : public QMainWindow
        QIcon RecordSoundIcon;
        QIcon ResetIcon;
        QIcon ExitIcon;
-       int screen_mode_count;
+       QIcon VolumeMutedIcon;
+       QIcon VolumeLowIcon;
+       QIcon VolumeMidIcon;
+       QIcon VolumeHighIcon;
        
        // Some Functions
        void ConfigCpuSpeed(void);
@@ -385,6 +389,7 @@ class Ui_MainWindow : public QMainWindow
 public:
        Ui_MainWindow(QWidget *parent = 0);
        ~Ui_MainWindow();
+
        // Initializer : using from InitContext.
        void setCoreApplication(QApplication *p);
        
@@ -427,11 +432,15 @@ public slots:
        void doChangeMessage_EmuThread(QString str);
        void do_emu_update_config(void);
        void delete_joy_thread(void);
+       void do_set_window_title(QString s);
        virtual void redraw_status_bar(void);
 #ifdef USE_LED_DEVICE
        virtual void redraw_leds(void);
        void do_recv_data_led(quint32 d);
 #endif
+#ifndef WITHOUT_SOUND
+       void do_update_volume(int level);
+#endif 
        void set_screen_aspect(int num);
        void set_screen_size(int w, int h);
        void OnReset(void);
index dc9a631..07539c2 100644 (file)
@@ -22,13 +22,13 @@ Menu_CMTClass::Menu_CMTClass(EMU *ep, QMenuBar *root_entry, QString desc, QWidge
        ext_rec_filter.clear();
 
        icon_cmt = QIcon(":/icon_cmt.png");
-       icon_play_start = QIcon(":/icon_play_start.png");
-       icon_play_stop = QIcon(":/icon_play_stop.png");
-       icon_ff = QIcon(":/icon_tape_forward.png");
-       icon_rew = QIcon(":/icon_tape_backward.png");
-       icon_apss_forward = QIcon(":/icon_apss_forward.png");
-       icon_apss_backward = QIcon(":/icon_apss_backward.png");
-       icon_record_to_wav = QIcon(":/icon_record_to_tape.png");;
+       icon_play_start = QApplication::style()->standardIcon(QStyle::SP_MediaPlay);
+       icon_play_stop = QApplication::style()->standardIcon(QStyle::SP_MediaStop);
+       icon_ff = QApplication::style()->standardIcon(QStyle::SP_MediaSkipForward);
+       icon_rew = QApplication::style()->standardIcon(QStyle::SP_MediaSkipBackward);
+       icon_apss_forward = QApplication::style()->standardIcon(QStyle::SP_MediaSeekForward);
+       icon_apss_backward = QApplication::style()->standardIcon(QStyle::SP_MediaSeekBackward);
+       icon_record_to_wav = QIcon(":/icon_record_to_tape.png");
 }
 
 Menu_CMTClass::~Menu_CMTClass()
index e2b7867..4a4d427 100644 (file)
@@ -303,6 +303,7 @@ void Ui_MainWindow::retranslateControlMenu(const char *SpecialResetTitle,  bool
        actionReset->setIcon(ResetIcon);
 #ifdef USE_SPECIAL_RESET
        actionSpecial_Reset->setText(QApplication::translate("MainWindow", SpecialResetTitle, 0));
+       actionSpecial_Reset->setIcon(QIcon(":/icon_reset.png"));
 #endif
        actionExit_Emulator->setText(QApplication::translate("MainWindow", "Exit Emulator", 0));
        actionExit_Emulator->setIcon(ExitIcon);
@@ -315,11 +316,15 @@ void Ui_MainWindow::retranslateControlMenu(const char *SpecialResetTitle,  bool
        
 #ifdef USE_AUTO_KEY
        actionPaste_from_Clipboard->setText(QApplication::translate("MainWindow", "Paste from Clipboard", 0));
+       actionPaste_from_Clipboard->setIcon(QIcon(":/icon_paste.png"));
        actionStop_Pasting->setText(QApplication::translate("MainWindow", "Stop Pasting", 0));
+       actionStop_Pasting->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton));
 #endif
 #ifdef USE_STATE
        actionSave_State->setText(QApplication::translate("MainWindow", "Save State", 0));
+       actionSave_State->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogSaveButton));
        actionLoad_State->setText(QApplication::translate("MainWindow", "Load State", 0));
+       actionLoad_State->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogOpenButton));
 #endif
    
 #ifdef USE_DEBUGGER
index 6486de3..400172e 100644 (file)
@@ -472,19 +472,44 @@ void Ui_MainWindow::setupUi(void)
        QImageReader reader(":/default.ico");
        QImage result = reader.read();
 
+       MainWindow->setWindowIcon(QPixmap::fromImage(result));
+       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);
+       
 //     QIcon WindowIcon;
-       InsertIcon = QIcon(":/icon_open.png");
+       InsertIcon = QApplication::style()->standardIcon(QStyle::SP_FileDialogStart);
        EjectIcon  = QIcon(":/icon_eject.png");
        StopIcon = QIcon(":/icon_process_stop.png");
        RecordSoundIcon = QIcon(":/icon_record_to_wav.png");
-       ResetIcon = QIcon(":/icon_reset.png");
+       ResetIcon = QApplication::style()->standardIcon(QStyle::SP_BrowserReload);
+
+       VolumeMutedIcon = QIcon(":/icon_volume_muted.png");
+       VolumeLowIcon = QIcon(":/icon_volume_low.png");
+       VolumeMidIcon = QIcon(":/icon_volume_mid.png");
+       VolumeHighIcon = QIcon(":/icon_volume_high.png");
+       
        ExitIcon = QIcon(":/icon_exit.png");
-       MainWindow->setWindowIcon(QPixmap::fromImage(result));
-       MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0));
 
        QMetaObject::connectSlotsByName(MainWindow);
 } // setupUi
 
+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);
+}
 
 // Emulator
 #include "dropdown_joystick.h"
index 1f55685..bddcc36 100644 (file)
@@ -44,6 +44,8 @@ Menu_MetaClass::Menu_MetaClass(EMU *ep, QMenuBar *root_entry, QString desc, QWid
 
        icon_insert = QIcon(":/icon_open.png");
        icon_eject = QIcon(":/icon_eject.png");
+       icon_write_protected = QApplication::style()->standardIcon(QStyle::SP_DialogApplyButton);
+       icon_write_enabled = QIcon();
 }
 
 Menu_MetaClass::~Menu_MetaClass()
@@ -56,8 +58,14 @@ void Menu_MetaClass::do_set_write_protect(bool f)
 {
        write_protect = f;
        if(f) {
+               if(use_write_protect) {
+                       menu_write_protect->setIcon(icon_write_protected);
+               }
                action_write_protect_on->setChecked(true);
        } else {
+               if(use_write_protect) {
+                       menu_write_protect->setIcon(icon_write_enabled);
+               }
                action_write_protect_off->setChecked(true);
        }               
 }
@@ -91,19 +99,21 @@ void Menu_MetaClass::do_open_recent_media(int drv, int s_num){
 }
 void Menu_MetaClass::do_write_protect_media(void) {
        write_protect = true;
-       if(write_protect) {
+       {
+               if(use_write_protect) {
+                       menu_write_protect->setIcon(icon_write_protected);
+               }
                action_write_protect_on->setChecked(true);
-       } else {
-               action_write_protect_off->setChecked(true);
        }               
        emit sig_write_protect_media(media_drive, write_protect);
 }
 
 void Menu_MetaClass::do_write_unprotect_media(void) {
        write_protect = false;
-       if(write_protect) {
-               action_write_protect_on->setChecked(true);
-       } else {
+       {
+               if(use_write_protect) {
+                       menu_write_protect->setIcon(icon_write_enabled);
+               }
                action_write_protect_off->setChecked(true);
        }               
        emit sig_write_protect_media(media_drive, write_protect);
index 09a86c8..ebf3772 100644 (file)
@@ -39,6 +39,8 @@ protected:
 
        QIcon icon_insert;
        QIcon icon_eject;
+       QIcon icon_write_protected;
+       QIcon icon_write_enabled;
        
        class Action_Control *action_insert;
        class Action_Control *action_eject;
index d073e51..a75adce 100644 (file)
@@ -9,6 +9,8 @@
 #include "mainwidget.h"
 //#include "menuclasses.h"
 #include "sound_dialog.h"
+#include <QImageReader>
+#include <QImage>
 
 QT_BEGIN_NAMESPACE
 
@@ -36,8 +38,18 @@ void Object_Menu_Control::on_set_latency(void) {
 void Ui_MainWindow::rise_volume_dialog(void)
 {
        Ui_SoundDialog *dlg = new Ui_SoundDialog(emu, this);
-       dlg->setWindowTitle(QApplication::translate("Ui_SoundDialog", "Set Volume", 0));
+       QString tmps, s_val;
+       float n;
+       QIcon  img = QIcon(":/icon_speaker.png");
+       
+       dlg->setWindowIcon(img);
        this->retranslateVolumeLabels(dlg);
+       
+       n = (float)(((config.general_sound_level + 32768) * 100) / 65535) / 100.0;
+       s_val.setNum(n, 'f', 1);
+       tmps = QApplication::translate("Ui_SoundDialog", "Set Volume", 0);
+       tmps = tmps + QString::fromUtf8(" (") + s_val + QString::fromUtf8("%)");
+       dlg->setWindowTitle(tmps);
        dlg->show();
        //dlg->exec();
 }
@@ -146,7 +158,21 @@ void Ui_MainWindow::ConfigSoundMenu(void)
        action_VolumeDialog->setObjectName(QString::fromUtf8("actionVolumedialog"));
 #endif
 }
-
+void Ui_MainWindow::do_update_volume(int level)
+{
+#if !defined(WITHOUT_SOUND)
+       if(level <= -32768) {
+               action_VolumeDialog->setIcon(VolumeMutedIcon);
+       } else if(level < -4096) {
+               action_VolumeDialog->setIcon(VolumeLowIcon);
+       } else if(level < 16384) {
+               action_VolumeDialog->setIcon(VolumeMidIcon);
+       } else {
+               action_VolumeDialog->setIcon(VolumeHighIcon);
+       }
+#endif 
+}
+       
 void Ui_MainWindow::retranslateSoundMenu(void)
 {
 #if !defined(WITHOUT_SOUND)
@@ -175,7 +201,8 @@ void Ui_MainWindow::retranslateSoundMenu(void)
        menuOutput_Frequency->setTitle(QApplication::translate("MainWindow", "Output Frequency", 0));
        menuSound_Latency->setTitle(QApplication::translate("MainWindow", "Sound Latency", 0));
        action_VolumeDialog->setText(QApplication::translate("MainWindow", "Set Volumes", 0));
-#endif   
+#endif
+       do_update_volume(config.general_sound_level);
 }
  
 QT_END_NAMESPACE
index ed99977..3d76c21 100644 (file)
@@ -25,10 +25,18 @@ void Ui_SndSliderObject::setValue(int level)
 {
        if(bind_num < 0) return;
        if(bind_num == 0) {
+               QString tmps, s_val;
+               float n;
                if(level < -32768) level = -32678;
-               if(level > 32768)  level = 32768;
-
+               if(level > 32767)  level = 32767;
                config.general_sound_level = level;
+               
+               tmps = QApplication::translate("Ui_SoundDialog", "Set Volume", 0);
+               n = (float)(((level + 32768) * 1000) / 65535) / 10.0;
+               s_val.setNum(n, 'f', 1);
+               tmps = tmps + QString::fromUtf8(" (") + s_val + QString::fromUtf8("%)");
+               parent_widget->setWindowTitle(tmps);
+               emit sig_update_master_volume(level);
                emit sig_emu_update_config();
        }
        QSlider::setValue(level);
@@ -44,6 +52,7 @@ void Ui_SndSliderObject::setLevelValue(int level)
                if(level < -60) level = -60;
                if(level > 3)  level = 3;
                if(bind_num <= USE_SOUND_VOLUME) {
+                       emit sig_emu_update_volume_label(bind_num - 1, level);
                        emit sig_emu_update_volume_level(bind_num - 1, level);
                }
        }
@@ -95,11 +104,11 @@ Ui_SoundDialog::Ui_SoundDialog(EMU *_emu, QWidget *parent) : QWidget(0)
                parent_widget = this;
        }
        MasterLayout = new QGridLayout;
-
+       
        this->setMinimumWidth(620);
        sliderMasterVolume = new Ui_SndSliderObject(_emu, Qt::Horizontal, this, 0);
        boxMasterVolume = new QGroupBox(QApplication::translate("Ui_SoundDialog", "Main", 0));
-
+       
        connect(sliderMasterVolume, SIGNAL(sig_emu_update_config()),
                        parent_widget, SLOT(do_emu_update_config()));
 
@@ -110,10 +119,10 @@ Ui_SoundDialog::Ui_SoundDialog(EMU *_emu, QWidget *parent) : QWidget(0)
        sliderMasterVolume->setValue(config.general_sound_level);
        sliderMasterVolume->connect(sliderMasterVolume, SIGNAL(valueChanged(int)),
                                                                sliderMasterVolume, SLOT(setValue(int)));
-       
        VBoxMasterVolume = new QVBoxLayout;
        VBoxMasterVolume->addWidget(sliderMasterVolume);
        boxMasterVolume->setLayout(VBoxMasterVolume);
+       connect(sliderMasterVolume, SIGNAL(sig_update_master_volume(int)), parent_widget, SLOT(do_update_volume(int)));
 
 #ifdef USE_SOUND_VOLUME
        MasterLayout->addWidget(boxMasterVolume, 0, 0, 1, 2);
@@ -133,8 +142,6 @@ Ui_SoundDialog::Ui_SoundDialog(EMU *_emu, QWidget *parent) : QWidget(0)
                        int s_balance;
                        s_lvl = (l_val + r_val) / 2;
                        s_balance = -(l_val - r_val) / 2;
-                       //QString n_s;
-                       //n_s.setNum(ii + 1);
                        lbl = lbl;
                        
                        sliderDeviceVolume[ij] = new Ui_SndSliderObject(_emu, Qt::Horizontal, this, ii + 1);
@@ -148,7 +155,9 @@ Ui_SoundDialog::Ui_SoundDialog(EMU *_emu, QWidget *parent) : QWidget(0)
                                                                                        sliderDeviceVolume[ij], SLOT(setLevelValue(int)));
                        connect(sliderDeviceVolume[ij], SIGNAL(sig_emu_update_volume_level(int, int)),
                                        parent_widget, SLOT(do_emu_update_volume_level(int, int)));
-                       
+                       connect(sliderDeviceVolume[ij], SIGNAL(sig_emu_update_volume_label(int, int)),
+                                       this, SLOT(do_update_volume_label(int, int)));
+                                               
                        sliderDeviceVolume[ij + 1] = new Ui_SndSliderObject(_emu, Qt::Horizontal, this, ii + 1);
                        sliderDeviceVolume[ij + 1]->setMinimum(-20);
                        sliderDeviceVolume[ij + 1]->setMaximum(20);
@@ -161,12 +170,16 @@ Ui_SoundDialog::Ui_SoundDialog(EMU *_emu, QWidget *parent) : QWidget(0)
                        connect(sliderDeviceVolume[ij + 1], SIGNAL(sig_emu_update_volume_balance(int, int)),
                                        parent_widget, SLOT(do_emu_update_volume_balance(int, int)));
 
-                       ResetVolume[ii] = new QPushButton(QApplication::translate("Ui_SoundDialog", "Reset", 0));
-                       ResetBalance[ii] = new QPushButton(QApplication::translate("Ui_SoundDialog", "Reset", 0));
+                       ResetBalance[ii] = new QPushButton(QApplication::style()->standardIcon(QStyle::SP_DialogResetButton), "");
+                       ResetBalance[ii]->setFlat(true);
+                       ResetBalance[ii]->setToolTip(QApplication::translate("Ui_SoundDialog", "Reset to center.", 0));
+                                                                                          
                        LabelVolume[ii] = new QLabel(QApplication::translate("Ui_SoundDialog", "Volume", 0));
                        LabelBalance[ii] = new QLabel(QApplication::translate("Ui_SoundDialog", "Balance", 0));
-                       
-                       connect(ResetVolume[ii], SIGNAL(pressed()), sliderDeviceVolume[ij] ,SLOT(resetVolumeValue()));
+                       LabelLevel[ii] = new QLabel(QString::fromUtf8("  0db"));                        
+                       LabelLevel[ii]->setMinimumWidth(48);
+                       LabelLevel[ii]->setAlignment(Qt::AlignRight);
+                       do_update_volume_label(ii, s_lvl);
                        connect(ResetBalance[ii], SIGNAL(pressed()), sliderDeviceVolume[ij + 1] ,SLOT(resetBalanceValue()));
                        
                        boxDeviceVolume[ii] = new QGroupBox(lbl);
@@ -174,7 +187,7 @@ Ui_SoundDialog::Ui_SoundDialog(EMU *_emu, QWidget *parent) : QWidget(0)
                        
                        LayoutDeviceVolume[ii]->addWidget(LabelVolume[ii], 0, 0);
                        LayoutDeviceVolume[ii]->addWidget(LabelBalance[ii], 1, 0);
-                       LayoutDeviceVolume[ii]->addWidget(ResetVolume[ii], 0, 2);
+                       LayoutDeviceVolume[ii]->addWidget(LabelLevel[ii], 0, 2);
                        LayoutDeviceVolume[ii]->addWidget(ResetBalance[ii], 1, 2);
                        LayoutDeviceVolume[ii]->addWidget(sliderDeviceVolume[ij], 0, 1);
                        LayoutDeviceVolume[ii]->addWidget(sliderDeviceVolume[ij + 1], 1, 1);
@@ -196,6 +209,17 @@ Ui_SoundDialog::~Ui_SoundDialog()
 {
 }
 
+void Ui_SoundDialog::do_update_volume_label(int num, int level)
+{
+       QString tmps;
+       if(LabelLevel[num] != NULL) {
+               QString s_val;
+               s_val.setNum(level);
+               tmps = s_val + QString::fromUtf8("db");
+               LabelLevel[num]->setText(tmps);
+       }
+}
+
 void Ui_SoundDialog::do_emu_update_config()
 {
        if(p_emu != NULL) {
index 0a484df..501463a 100644 (file)
@@ -52,7 +52,9 @@ public slots:
 signals:       
        int sig_emu_update_config(void);
        int sig_emu_update_volume_level(int, int);
+       int sig_emu_update_volume_label(int, int);
        int sig_emu_update_volume_balance(int, int);
+       int sig_update_master_volume(int);
 };
 
 class Ui_SoundDialog : public QWidget
@@ -62,7 +64,6 @@ private:
        EMU *p_emu;
        QWidget *parent_widget;
        QGridLayout *MasterLayout;
-       
 protected:
        Ui_SndSliderObject *sliderMasterVolume;
        QGroupBox *boxMasterVolume;
@@ -73,7 +74,8 @@ protected:
        QGridLayout *LayoutDeviceVolume[USE_SOUND_VOLUME];
        QLabel *LabelVolume[USE_SOUND_VOLUME];
        QLabel *LabelBalance[USE_SOUND_VOLUME];
-       QPushButton *ResetVolume[USE_SOUND_VOLUME];
+       QLabel *LabelLevel[USE_SOUND_VOLUME];
+
        QPushButton *ResetBalance[USE_SOUND_VOLUME];
 #endif
        QPushButton *closeButton;
@@ -84,7 +86,8 @@ public:
        void setSliderVisible(int num, bool flag);
 public slots:
        void do_emu_update_config();
-signals:
+       void do_update_volume_label(int num, int level);
+       signals:
 };
 QT_END_NAMESPACE
 #endif //_CSP_QT_SOUND_DIALOG_H