OSDN Git Service

[UI][Qt][MENU] CMT: Using child of Menu_MetaClass.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 12 Nov 2015 11:09:06 +0000 (20:09 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 12 Nov 2015 11:09:06 +0000 (20:09 +0900)
source/src/qt/gui/CMakeLists.txt
source/src/qt/gui/mainwidget.h
source/src/qt/gui/menu_cmt.cpp
source/src/qt/gui/menu_cmt.h [new file with mode: 0644]
source/src/qt/gui/menu_main.cpp
source/src/qt/gui/menu_metaclass.h
source/src/qt/gui/util_cmt.cpp

index 1300abd..e6fa9e7 100644 (file)
@@ -5,6 +5,7 @@ set(s_qt_gui_headers
          mainwidget.h
          menu_metaclass.h
          menu_disk.h
+         menu_cmt.h
          display_about.h
          display_text_document.h
 )
index 71f7faf..976c520 100644 (file)
@@ -54,6 +54,7 @@ class GLDrawClass;
 class Action_Control;
 class Menu_MetaClass;
 class Menu_FDClass;
+class Menu_CMTClass;
 
 #ifndef _SCREEN_MODE_NUM
 #define _SCREEN_MODE_NUM 32
@@ -183,28 +184,8 @@ class Ui_MainWindow : public QMainWindow
        QStringList listQDs[2];
 #endif
 #ifdef USE_TAPE    
-       QActionGroup   *actionGroup_Opened_CMT;
-       QActionGroup   *actionGroup_Protect_CMT;
-       class Action_Control *actionWaveShaper;
-       class Action_Control *actionDirectLoadMZT;
-       class Action_Control *actionRecent_Opened_CMT;
-       class Action_Control *action_Recent_List_CMT[MAX_HISTORY];
-       class Action_Control *actionInsert_CMT;
-       class Action_Control *actionEject_CMT;
-#ifdef USE_TAPE_BUTTON
-       QActionGroup *actionGroup_PlayTape;
-       class Action_Control *actionPlay_Start;
-       class Action_Control *actionPlay_Stop;
-       class Action_Control *actionPlay_FastForward;
-       class Action_Control *actionPlay_Rewind;
-       class Action_Control *actionPlay_Apss_Forward;
-       class Action_Control *actionPlay_Apss_Rewind;
        QStringList listCMT;
-#endif    
-       class Action_Control *actionRecording;
-       class Action_Control *actionProtection_ON_CMT;
-       class Action_Control *actionProtection_OFF_CMT;
-       bool write_protect;
+       bool cmt_write_protect;
 #endif    
 #if defined(USE_LASER_DISC)
        class Action_Control *actionInsert_LD;
@@ -319,9 +300,7 @@ class Ui_MainWindow : public QMainWindow
        QMenu *menuWrite_Protection_QD[2];
 #endif
 #ifdef USE_TAPE    
-       QMenu *menuCMT;
-       QMenu *menuCMT_Recent;
-       QMenu *menuWrite_Protection_CMT;
+       Menu_CMTClass *menu_CMT;
 #endif
 #ifdef USE_LASER_DISC    
        QMenu *menuLD;
@@ -504,6 +483,8 @@ public slots:
        int  set_recent_cmt(int num);
        void set_wave_shaper(bool f);
        void set_direct_load_from_mzt(bool f);
+       void do_open_write_cmt(QString);
+       void do_open_read_cmt(int dummy, QString path);
 # ifdef USE_TAPE_BUTTON
        void do_push_play_tape(void);
        void do_push_stop_tape(void);
index a9e1205..c706918 100644 (file)
 
 #include "commonclasses.h"
 #include "mainwidget.h"
-//#include "menuclasses.h"
+#include "menu_cmt.h"
+
 #include "emu_utils.h"
 #include "qt_dialogs.h"
 #include "emu.h"
-#include "agar_logger.h"
 
 
-void Object_Menu_Control::start_insert_play_cmt(void) {
-       //AGAR_DebugLog(AGAR_LOG_DEBUG, "%d", play);
-       emit sig_insert_play_cmt(play);
-}
-void Object_Menu_Control::eject_cmt(void) {
-       emit sig_eject_cmt();
-}
-void Object_Menu_Control::on_recent_cmt(){
-       emit sig_recent_cmt(s_num);
-}
-void Object_Menu_Control::do_set_write_protect_cmt(void) {
-        write_protect = true;
-        emit sig_set_write_protect_cmt(write_protect);
-}
-void Object_Menu_Control::do_unset_write_protect_cmt(void) {
-       write_protect = false;
-       emit sig_set_write_protect_cmt(write_protect);
-}
-
-//QT_BEGIN_NAMESPACE
-// Common Routine
-#if defined(USE_TAPE)
-void Ui_MainWindow::open_cmt_dialog(bool play)
+Menu_CMTClass::Menu_CMTClass(EMU *ep, QMenuBar *root_entry, QString desc, QWidget *parent, int drv) : Menu_MetaClass(ep, root_entry, desc, parent, drv)
 {
-       QString ext;
-       QString desc1;
-       QString desc2;
-       CSP_DiskDialog dlg;
-       QString dirname;
-  
-#if defined(_PC6001) || defined(_PC6001MK2) || defined(_PC6001MK2SR) || defined(_PC6601) || defined(_PC6601SR)
-       ext = "*.wav *.p6 *.cas";
-#elif defined(_PC8001SR) || defined(_PC8801MA) || defined(_PC98DO)
-       ext = play ? "*.cas *.cmt *.n80 *.t88" : "*.cas *.cmt";
-#elif defined(_MZ80A) || defined(_MZ80K) || defined(_MZ1200) || defined(_MZ700) || defined(_MZ800) || defined(_MZ1500)
-       ext = play ? "*.wav *.cas *.mzt *.m12 *.t77" :"*.wav *.cas";
-#elif defined(_MZ80B) || defined(_MZ2000) || defined(_MZ2200)
-       ext = play ? "*.wav *.cas *.mzt *.mti *.mtw *.dat" : "*.wav *.cas";
-#elif defined(_X1) || defined(_X1TWIN) || defined(_X1TURBO) || defined(_X1TURBOZ)
-       ext = play ? "*.wav *.cas *.tap *.t77" : "*.wav *.cas";
-#elif defined(_FM8) || defined(_FM7) || defined(_FMNEW7) || defined(_FM77_VARIANTS) || defined(_FM77AV_VARIANTS)
-       ext = "*.wav *.t77";
-#elif defined(TAPE_BINARY_ONLY)
-       ext = "*.cas *.cmt";
-#else
-       ext = "*.wav *.cas";
-#endif
-       desc1 = play ? "Data Recorder Tape [Play]" : "Data Recorder Tape [Rec]";
-       if(play) {
-               dlg.setWindowTitle("Open Tape");
-       } else {
-               dlg.setWindowTitle("Record Tape");
-       }
-       desc2 = desc1 + " (" + ext.toLower() + " " + ext.toUpper() + ")";
-//     desc1 = desc1 + " (" + ext.toUpper() + ")";
-       if(config.initial_tape_dir != NULL) {
-               dirname = QString::fromUtf8(config.initial_tape_dir);           
-       } else {
-               char app[PATH_MAX];
-               QDir df;
-               dirname = df.currentPath();
-               strncpy(app, dirname.toUtf8().constData(), PATH_MAX);
-               dirname = get_parent_dir(app);
-       }
-       QStringList filter;
-       filter << desc2;
-       dlg.param->setRecMode(play);
-       dlg.setDirectory(dirname);
-       dlg.setNameFilters(filter); 
-       QObject::connect(&dlg, SIGNAL(fileSelected(QString)), dlg.param, SLOT(_open_cmt(QString))); 
-       QObject::connect(dlg.param, SIGNAL(do_open_cmt(bool, QString)), this, SLOT(_open_cmt(bool, QString))); 
-       dlg.show();
-       dlg.exec();
-       return;
-}
+       use_write_protect = true;
+       use_d88_menus = false;
 
-#endif
-
-void Ui_MainWindow::CreateCMTMenu(void)
-{
-#if defined(USE_TAPE)
-       menuCMT = new QMenu(menubar);
-       menuCMT->setObjectName(QString::fromUtf8("menuCMT", -1));
-       menuWrite_Protection_CMT = new QMenu(menuCMT);
-       menuWrite_Protection_CMT->setObjectName(QString::fromUtf8("menuWrite_Protection_CMT", -1));
-       listCMT.clear();
-       //CreateCMTPulldownMenu(p);
-#endif // USE_TAPE
+       ext_rec_filter.clear();
 }
 
-void Ui_MainWindow::CreateCMTPulldownMenu(void)
+Menu_CMTClass::~Menu_CMTClass()
 {
-#if defined(USE_TAPE)
-       menuCMT->addAction(actionInsert_CMT);
-       menuCMT->addAction(actionEject_CMT);
-       menuCMT->addSeparator();
-#ifdef USE_TAPE_BUTTON
-       menuCMT->addAction(actionPlay_Start);
-       menuCMT->addAction(actionPlay_Stop);
-       menuCMT->addAction(actionPlay_FastForward);
-       menuCMT->addAction(actionPlay_Rewind);
-       menuCMT->addSeparator();
-       menuCMT->addAction(actionPlay_Apss_Forward);
-       menuCMT->addAction(actionPlay_Apss_Rewind);
-       menuCMT->addSeparator();
-#endif  
-       menuCMT->addAction(actionWaveShaper);
-       menuCMT->addAction(actionDirectLoadMZT);
-       menuCMT->addSeparator();
-  
-       menuCMT_Recent = new QMenu(menuCMT);
-       menuCMT_Recent->setObjectName(QString::fromUtf8("Recent_CMT", -1));
-       menuCMT->addAction(menuCMT_Recent->menuAction());
-       //        menuCMT->addAction(actionRecent_Opened_FD[0]);
-       {
-               int ii;
-               for(ii = 0; ii < MAX_HISTORY; ii++) {
-                       menuCMT_Recent->addAction(action_Recent_List_CMT[ii]);
-                       action_Recent_List_CMT[ii]->setVisible(true);
-               }
-    
-       }
-       menuCMT->addSeparator();
-       menuCMT->addAction(menuWrite_Protection_CMT->menuAction());
-       menuWrite_Protection_CMT->addAction(actionProtection_ON_CMT);
-       menuWrite_Protection_CMT->addAction(actionProtection_OFF_CMT);
-#endif // USE_TAPE
 }
 
-void Ui_MainWindow::ConfigCMTMenuSub(void)
+void Menu_CMTClass::create_pulldown_menu_device_sub(void)
 {
-#if defined(USE_TAPE)
-       actionInsert_CMT = new Action_Control(this);
-       actionInsert_CMT->setObjectName(QString::fromUtf8("actionInsert_CMT"));
-       actionInsert_CMT->binds->setPlay(true);
-       actionInsert_CMT->binds->setNumber(0);
-  
-       actionEject_CMT = new Action_Control(this);
-       actionEject_CMT->setObjectName(QString::fromUtf8("actionEject_CMT"));
-       actionEject_CMT->binds->setPlay(true);
+#ifdef USE_TAPE
+       action_wave_shaper = new Action_Control(p_wid);
+       action_wave_shaper->setVisible(true);
+       action_wave_shaper->setCheckable(true);
+
+       action_direct_load_mzt = new Action_Control(p_wid);
+       action_direct_load_mzt->setVisible(true);
+       action_direct_load_mzt->setCheckable(true);
+
+       action_recording = new Action_Control(p_wid);
+       action_recording->setVisible(true);
+       action_recording->setCheckable(true);
 
-       actionWaveShaper = new Action_Control(this);
-       actionWaveShaper->setObjectName(QString::fromUtf8("actionWaveShaper"));
-       actionWaveShaper->setCheckable(true);
        if(config.wave_shaper == 0) {
-               actionWaveShaper->setChecked(false);
+               action_wave_shaper->setChecked(false);
        } else {
-               actionWaveShaper->setChecked(true);
+               action_wave_shaper->setChecked(true);
        }
-       connect(actionWaveShaper, SIGNAL(toggled(bool)),
-               this, SLOT(set_wave_shaper(bool)));
-
-       actionDirectLoadMZT = new Action_Control(this);
-       actionDirectLoadMZT->setObjectName(QString::fromUtf8("actionDirectLoadMZT"));
-       actionDirectLoadMZT->setCheckable(true);
        if(config.direct_load_mzt == 0) {
-               actionDirectLoadMZT->setChecked(false);
+               action_direct_load_mzt->setChecked(false);
        } else {
-               actionDirectLoadMZT->setChecked(true);
+               action_direct_load_mzt->setChecked(true);
        }
-       connect(actionDirectLoadMZT, SIGNAL(toggled(bool)),
-               this, SLOT(set_direct_load_from_mzt(bool)));
-  
-#ifdef USE_TAPE_BUTTON
-       actionGroup_PlayTape = new QActionGroup(this);
-       actionGroup_PlayTape->setExclusive(true);
-       actionGroup_PlayTape->setObjectName(QString::fromUtf8("actionGroup_PlayTape"));
-  
-       actionPlay_Start = new Action_Control(this);
-       actionPlay_Start->setObjectName(QString::fromUtf8("actionPlay_Start"));
-       actionGroup_PlayTape->addAction(actionPlay_Start);
-       actionPlay_Start->setCheckable(true);
-       actionPlay_Start->setChecked(false);
-       connect(actionPlay_Start, SIGNAL(triggered()),
-               this, SLOT(do_push_play_tape()));
-       actionGroup_PlayTape->addAction(actionPlay_Start);
-
-       actionPlay_Stop = new Action_Control(this);
-       actionPlay_Stop->setObjectName(QString::fromUtf8("actionPlay_Stop"));
-       actionPlay_Stop->binds->setPlay(true);
-       actionPlay_Stop->setCheckable(true);
-       actionPlay_Stop->setChecked(true);
-       connect(actionPlay_Stop, SIGNAL(triggered()),
-               this, SLOT(do_push_stop_tape()));
-       actionGroup_PlayTape->addAction(actionPlay_Stop);
-
-       actionPlay_FastForward = new Action_Control(this);
-       actionPlay_FastForward->setObjectName(QString::fromUtf8("actionPlay_FastForward"));
-       actionPlay_FastForward->setCheckable(true);
-       actionPlay_FastForward->setChecked(false);
-       connect(actionPlay_FastForward, SIGNAL(triggered()),
-               this, SLOT(do_push_fast_forward_tape()));
-       actionGroup_PlayTape->addAction(actionPlay_FastForward);
+# if defined(USE_TAPE_BUTTON)
+       action_play_start = new Action_Control(p_wid);
+       action_play_start->setVisible(true);
+       action_play_start->setCheckable(true);
+
+       action_play_stop = new Action_Control(p_wid);
+       action_play_stop->setVisible(true);
+       action_play_stop->setCheckable(true);
+
+       action_fast_forward = new Action_Control(p_wid);
+       action_fast_forward->setVisible(true);
+       action_fast_forward->setCheckable(true);
+
+       action_fast_rewind = new Action_Control(p_wid);
+       action_fast_rewind->setVisible(true);
+       action_fast_rewind->setCheckable(true);
+
+       action_apss_forward = new Action_Control(p_wid);
+       action_apss_forward->setVisible(true);
+       action_apss_forward->setCheckable(true);
+
+       action_apss_rewind = new Action_Control(p_wid);
+       action_apss_rewind->setVisible(true);
+       action_apss_rewind->setCheckable(true);
+
+       action_group_tape_button = new QActionGroup(p_wid);
+
+       action_group_tape_button->setExclusive(true);
+       action_group_tape_button->addAction(action_play_start);
+       action_group_tape_button->addAction(action_play_stop);
+       action_group_tape_button->addAction(action_fast_forward);
+       action_group_tape_button->addAction(action_fast_rewind);
+       action_group_tape_button->addAction(action_apss_forward);
+       action_group_tape_button->addAction(action_apss_rewind);
+# endif
+#endif
+}
 
-       actionPlay_Rewind = new Action_Control(this);
-       actionPlay_Rewind->setObjectName(QString::fromUtf8("actionPlay_Rewind"));
-       actionPlay_Rewind->setCheckable(true);
-       actionPlay_Rewind->setChecked(false);
-       connect(actionPlay_Rewind, SIGNAL(triggered()),
-               this, SLOT(do_push_rewind_tape()));
-       actionGroup_PlayTape->addAction(actionPlay_Rewind);
 
-       actionPlay_Apss_Forward = new Action_Control(this);
-       actionPlay_Apss_Forward->setObjectName(QString::fromUtf8("actionPlay_Apss_Forward"));
-       actionPlay_Apss_Forward->setCheckable(true);
-       actionPlay_Apss_Forward->setChecked(false);
-       connect(actionPlay_Apss_Forward, SIGNAL(triggered()),
-               this, SLOT(do_push_apss_forward_tape()));
-       actionGroup_PlayTape->addAction(actionPlay_Apss_Forward);
+void Menu_CMTClass::connect_menu_device_sub(void)
+{
+#ifdef USE_TAPE
+       this->addSeparator();
+       this->addAction(action_recording);
+       this->addSeparator();
+#if defined(USE_TAPE_BUTTON)
+       this->addAction(action_play_start);
+       this->addAction(action_play_stop);
+       this->addSeparator();
        
-       actionPlay_Apss_Rewind = new Action_Control(this);
-       actionPlay_Apss_Rewind->setObjectName(QString::fromUtf8("actionPlay_Apss_Rewind"));
-       actionPlay_Apss_Rewind->setCheckable(true);
-       actionPlay_Apss_Rewind->setChecked(false);
-       connect(actionPlay_Apss_Rewind, SIGNAL(triggered()),
-               this, SLOT(do_push_apss_rewind_tape()));
-       actionGroup_PlayTape->addAction(actionPlay_Apss_Rewind);
+       this->addAction(action_fast_forward);
+       this->addAction(action_fast_rewind);
+       this->addSeparator();
+       
+       this->addAction(action_apss_forward);
+       this->addAction(action_apss_rewind);
+       this->addSeparator();
 #endif
-       actionRecording = new Action_Control(this);
-       actionRecording->setObjectName(QString::fromUtf8("actionRecording"));
-       actionRecording->binds->setPlay(false);
-       actionRecording->binds->setNumber(0);
+       this->addAction(action_wave_shaper);
+       this->addAction(action_direct_load_mzt);
+       
+       connect(action_direct_load_mzt, SIGNAL(toggled(bool)),
+                       p_wid, SLOT(set_direct_load_from_mzt(bool)));
+       connect(action_wave_shaper, SIGNAL(toggled(bool)),
+                       p_wid, SLOT(set_wave_shaper(bool)));
        
-       actionGroup_Opened_CMT = new QActionGroup(this);
-       actionRecent_Opened_CMT = new Action_Control(this);
-       actionRecent_Opened_CMT->setObjectName(QString::fromUtf8("actionRecent_Opened_CMT"));
-       actionRecent_Opened_CMT->binds->setPlay(true);
-       {
-               int ii;
-               actionGroup_Opened_CMT = new QActionGroup(this);
-               actionGroup_Opened_CMT->setExclusive(true);
+       connect(action_recording, SIGNAL(triggered()),
+                       this, SLOT(do_open_rec_dialog()));
+       connect(this, SIGNAL(sig_open_media(int, QString)),
+                       p_wid, SLOT(do_open_read_cmt(int, QString)));
+
+#if defined(USE_TAPE_BUTTON)
+       connect(action_play_start, SIGNAL(triggered()), p_wid, SLOT(do_push_play_tape(void)));
+       connect(action_play_stop,  SIGNAL(triggered()), p_wid, SLOT(do_push_stop_tape(void)));
+       connect(action_fast_forward,  SIGNAL(triggered()), p_wid, SLOT(do_push_fast_forward_tape(void)));
+       connect(action_fast_rewind,   SIGNAL(triggered()), p_wid, SLOT(do_push_fast_rewind_tape(void)));
+       connect(action_apss_forward,  SIGNAL(triggered()), p_wid, SLOT(do_push_apss_forward_tape(void)));
+       connect(action_apss_rewind,   SIGNAL(triggered()), p_wid, SLOT(do_push_apss_rewind_tape(void)));
+#endif 
+       connect(this, SIGNAL(sig_eject_media(int)),
+                       this, SLOT(do_eject_cmt(int)));
+       connect(this, SIGNAL(sig_close_tape()),
+                       p_wid, SLOT(eject_cmt()));
+#endif 
+}
 
-               actionRecent_Opened_CMT = new Action_Control(this);
-               actionRecent_Opened_CMT->setObjectName(QString::fromUtf8("actionSelect_Recent_CMT"));
-               actionRecent_Opened_CMT->binds->setPlay(true); // For safety
-               for(ii = 0; ii < MAX_HISTORY; ii++) {
-                       action_Recent_List_CMT[ii] = new Action_Control(this);
-                       action_Recent_List_CMT[ii]->binds->setPlay(true);
-                       action_Recent_List_CMT[ii]->binds->setNumber(ii);
-                       action_Recent_List_CMT[ii]->setText(QString::fromUtf8(config.recent_tape_path[ii]));
-                       actionGroup_Opened_CMT->addAction(action_Recent_List_CMT[ii]);
-                       connect(action_Recent_List_CMT[ii], SIGNAL(triggered()),
-                               action_Recent_List_CMT[ii]->binds, SLOT(on_recent_cmt()));
-                       connect(action_Recent_List_CMT[ii]->binds, SIGNAL(sig_recent_cmt(int)),
-                               this, SLOT(set_recent_cmt(int)));
-               }
-       }
-       {
-               int ii;
-               actionProtection_ON_CMT = new Action_Control(this);
-               actionProtection_ON_CMT->setObjectName(QString::fromUtf8("actionProtection_ON_CMT"));
-               actionProtection_ON_CMT->setCheckable(true);
-               actionProtection_ON_CMT->setChecked(true);
-               actionProtection_OFF_CMT = new Action_Control(this);
-               actionProtection_OFF_CMT->setObjectName(QString::fromUtf8("actionProtection_OFF_CMT"));
-               actionProtection_OFF_CMT->setCheckable(true);
-               actionProtection_OFF_CMT->setChecked(false);
-               connect(actionProtection_OFF_CMT, SIGNAL(triggered()),
-                       actionProtection_OFF_CMT->binds, SLOT(do_unset_write_protect_cmt()));
-               connect(actionProtection_OFF_CMT->binds, SIGNAL(sig_set_write_protect_cmt(bool)),
-                       this,   SLOT(do_write_protect_cmt(bool)));
+void Menu_CMTClass::do_add_rec_media_extension(QString ext, QString description)
+{
+       QString tmps = description;
+       QString all = QString::fromUtf8("All Files (*.*)");
 
-               connect(actionProtection_ON_CMT, SIGNAL(triggered()),
-                       actionProtection_ON_CMT->binds, SLOT(do_set_write_protect_cmt()));
-               connect(actionProtection_ON_CMT->binds, SIGNAL(sig_set_write_protect_cmt(bool)),
-                       this, SLOT(do_write_protect_cmt(bool)));
+       tmps.append(QString::fromUtf8(" ("));
+       tmps.append(ext.toLower());
+       tmps.append(QString::fromUtf8(" "));
+       tmps.append(ext.toUpper());
+       tmps.append(QString::fromUtf8(")"));
 
-               actionGroup_Protect_CMT = new QActionGroup(this);
-               //actionGroup_Protect_CMT->setExclusive(true);
-               actionGroup_Protect_CMT->addAction(actionProtection_ON_CMT);
-               actionGroup_Protect_CMT->addAction(actionProtection_OFF_CMT);
-               actionProtection_ON_CMT->setActionGroup(actionGroup_Protect_CMT);
-               actionProtection_OFF_CMT->setActionGroup(actionGroup_Protect_CMT);
-       }
-       connect(actionRecording, SIGNAL(triggered()),
-               actionRecording->binds, SLOT(start_insert_play_cmt()));
-       connect(actionRecording->binds, SIGNAL(sig_insert_play_cmt(bool)),
-               this, SLOT(open_cmt_dialog(bool)));
-       connect(actionInsert_CMT, SIGNAL(triggered()),
-               actionInsert_CMT->binds, SLOT(start_insert_play_cmt()));
-       connect(actionInsert_CMT->binds, SIGNAL(sig_insert_play_cmt(bool)),
-               this, SLOT(open_cmt_dialog(bool)));
-       connect(actionEject_CMT, SIGNAL(triggered()),
-               this, SLOT(eject_cmt()));
-       // Translate Menu
-       SETUP_HISTORY(config.recent_tape_path, listCMT);
-#endif // USE_TAPE
+       ext_rec_filter << tmps;
+       ext_rec_filter << all;
+       
+       ext_rec_filter.removeDuplicates();
+}
 
+void Menu_CMTClass::do_open_rec_dialog()
+{
+#ifdef USE_TAPE
+       CSP_DiskDialog dlg;
+       
+       if(initial_dir.isEmpty()) { 
+               QDir dir;
+               char app[PATH_MAX];
+               initial_dir = dir.currentPath();
+               strncpy(app, initial_dir.toLocal8Bit().constData(), PATH_MAX);
+               initial_dir = QString::fromLocal8Bit(get_parent_dir(app));
+       }
+       dlg.param->setDrive(media_drive);
+       dlg.setDirectory(initial_dir);
+       dlg.setNameFilters(ext_rec_filter);
+       dlg.setWindowTitle(desc_rec);
+       QObject::connect(&dlg, SIGNAL(fileSelected(QString)),
+                                        p_wid, SLOT(do_open_write_cmt(QString))); 
+       dlg.show();
+       dlg.exec();
+       return;
+#endif
 }
 
-void Ui_MainWindow::retranslateCMTMenu(void)
+void Menu_CMTClass::do_eject_cmt(int dummy) 
 {
 #ifdef USE_TAPE
-       actionInsert_CMT->setText(QApplication::translate("MainWindow", "Insert CMT", 0));
-       actionEject_CMT->setText(QApplication::translate("MainWindow", "Eject CMT", 0));
+       emit sig_close_tape();
+#endif
+}
 
-       actionWaveShaper->setText(QApplication::translate("MainWindow", "Enable Wave Shaper", 0));
-       actionDirectLoadMZT->setText(QApplication::translate("MainWindow", "Direct load from MZT", 0));
-  
-       menuCMT_Recent->setTitle(QApplication::translate("MainWindow", "Recent Opened", 0));
-  
-       actionProtection_ON_CMT->setText(QApplication::translate("MainWindow", "Protection ON", 0));
-       actionProtection_OFF_CMT->setText(QApplication::translate("MainWindow", "Protection OFF", 0));
+void Menu_CMTClass::retranslate_pulldown_menu_device_sub(void)
+{
+#ifdef USE_TAPE        
+       action_insert->setText(QApplication::translate("MainWindow", "Insert CMT", 0));
+       action_eject->setText(QApplication::translate("MainWindow", "Eject CMT", 0));
 
-       menuCMT->setTitle(QApplication::translate("MainWindow", "Casette tape" , 0));
-       menuWrite_Protection_CMT->setTitle(QApplication::translate("MainWindow", "Write Protection", 0));
+       action_wave_shaper->setText(QApplication::translate("MainWindow", "Enable Wave Shaper", 0));
+       action_direct_load_mzt->setText(QApplication::translate("MainWindow", "Direct load from MZT", 0));
+  
+       this->setTitle(QApplication::translate("MainWindow", "Casette tape" , 0));
 
 #ifdef USE_TAPE_BUTTON
-       actionPlay_Stop->setText(QApplication::translate("MainWindow", "Play Stop", 0));
-       actionPlay_Start->setText(QApplication::translate("MainWindow", "Play Start", 0));
-       actionPlay_FastForward->setText(QApplication::translate("MainWindow", "Fast Forward", 0));
-       actionPlay_Rewind->setText(QApplication::translate("MainWindow", "Rewind", 0));
-       actionPlay_Apss_Forward->setText(QApplication::translate("MainWindow", "APSS Forward", 0));
-       actionPlay_Apss_Rewind->setText(QApplication::translate("MainWindow", "APSS Rewind", 0));
+       action_play_stop->setText(QApplication::translate("MainWindow", "Play Stop", 0));
+       action_play_start->setText(QApplication::translate("MainWindow", "Play Start", 0));
+       action_fast_forward->setText(QApplication::translate("MainWindow", "Fast Forward", 0));
+       action_fast_rewind->setText(QApplication::translate("MainWindow", "Rewind", 0));
+       action_apss_forward->setText(QApplication::translate("MainWindow", "APSS Forward", 0));
+       action_apss_rewind->setText(QApplication::translate("MainWindow", "APSS Rewind", 0));
 #endif
-   
-       actionRecording->setText(QApplication::translate("MainWindow", "Recording", 0));
-#endif
-}
-
-void Ui_MainWindow::ConfigCMTMenu(void)
-{
-#if defined(USE_TAPE)
-       write_protect = true;
-       ConfigCMTMenuSub(); 
+       action_recording->setText(QApplication::translate("MainWindow", "Recording", 0));
 #endif
 }
-//QT_END_NAMESPACE
diff --git a/source/src/qt/gui/menu_cmt.h b/source/src/qt/gui/menu_cmt.h
new file mode 100644 (file)
index 0000000..0057e9c
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Menu_MetaClass : Defines
+ * (C) 2015 by K.Ohta <whatisthis.sowhat _at_ gmail.com>
+ * Please use this file as templete.
+ */
+
+
+#ifndef _CSP_QT_MENU_CMT_CLASSES_H
+#define _CSP_QT_MENU_CMT_CLASSES_H
+
+#include "menu_metaclass.h"
+
+QT_BEGIN_NAMESPACE
+
+class Menu_CMTClass: public Menu_MetaClass {
+       Q_OBJECT
+protected:
+       QString desc_rec;
+       QStringList ext_rec_filter;
+       
+       QActionGroup *action_group_tape_button;
+       class Action_Control *action_play_start;
+       class Action_Control *action_play_stop;
+       class Action_Control *action_fast_forward;
+       class Action_Control *action_fast_rewind;
+       class Action_Control *action_apss_forward;
+       class Action_Control *action_apss_rewind;
+       class Action_Control *action_recording;
+
+       class Action_Control *action_wave_shaper;
+       class Action_Control *action_direct_load_mzt;
+       
+
+public:
+       Menu_CMTClass(EMU *ep, QMenuBar *root_entry, QString desc, QWidget *parent = 0, int drv = 0);
+       ~Menu_CMTClass();
+       void create_pulldown_menu_device_sub();
+       void connect_menu_device_sub(void);
+       void retranslate_pulldown_menu_device_sub(void);
+public slots:
+       void do_open_rec_dialog();
+       void do_add_rec_media_extension(QString ext, QString description);
+       void do_eject_cmt(int dummy);
+signals:
+       int sig_close_tape(void);
+};
+
+QT_END_NAMESPACE
+
+#endif
index ee22187..8df90ed 100644 (file)
@@ -20,6 +20,7 @@
 #include "mainwidget.h"
 #include "menuclasses.h"
 #include "menu_disk.h"
+#include "menu_cmt.h"
 
 #include "qt_gldraw.h"
 #include "emu.h"
@@ -246,7 +247,7 @@ void Ui_MainWindow::setupUi(void)
        menubar->addAction(menuQD[1]->menuAction());
 #endif
 #if defined(USE_TAPE)
-       menubar->addAction(menuCMT->menuAction());
+       menubar->addAction(menu_CMT->menuAction());
 #endif
 #if defined(USE_CART1)
        menubar->addAction(menuCART[0]->menuAction());
index 8953cad..f9fc7dd 100644 (file)
@@ -28,6 +28,11 @@ class Menu_MetaClass : public QMenu {
        Q_OBJECT
 private:
 
+protected:
+       QWidget *p_wid;
+       QMenuBar *menu_root;
+       EMU *p_emu;
+
        QMenu *menu_inner_media;
        QMenu *menu_history;
        QMenu *menu_write_protect;
@@ -46,11 +51,7 @@ private:
        QActionGroup *action_group_recent;
        QActionGroup *action_group_inner_media;
        QActionGroup *action_group_protect;
-protected:
-       QWidget *p_wid;
-       QMenuBar *menu_root;
-       EMU *p_emu;
-
+       
        QString object_desc;
        
        int media_drive;
@@ -78,6 +79,10 @@ public:
        void retranslateUi(void);
        //void setTitle(QString);
        void setEmu(EMU *p);
+
+       bool getWriteProtect(void) {
+               return write_protect;
+       }
        //QAction *menuAction(void);
 public slots:
        void do_set_write_protect(bool f);
index a79262c..b418e10 100644 (file)
  */
 
 
-#include "mainwidget.h"
 #include "commonclasses.h"
+#include "mainwidget.h"
 //#include "menuclasses.h"
 #include "emu_utils.h"
 #include "qt_dialogs.h"
 #include "emu.h"
 #include "agar_logger.h"
 
+#include "menu_cmt.h"
+
+
+void Object_Menu_Control::start_insert_play_cmt(void) {
+       //AGAR_DebugLog(AGAR_LOG_DEBUG, "%d", play);
+       emit sig_insert_play_cmt(play);
+}
+void Object_Menu_Control::eject_cmt(void) {
+       emit sig_eject_cmt();
+}
+void Object_Menu_Control::on_recent_cmt(){
+       emit sig_recent_cmt(s_num);
+}
+void Object_Menu_Control::do_set_write_protect_cmt(void) {
+        write_protect = true;
+        emit sig_set_write_protect_cmt(write_protect);
+}
+void Object_Menu_Control::do_unset_write_protect_cmt(void) {
+       write_protect = false;
+       emit sig_set_write_protect_cmt(write_protect);
+}
+
+#if defined(USE_TAPE)
+void Ui_MainWindow::open_cmt_dialog(bool play)
+{
+       QString ext;
+       QString desc1;
+       QString desc2;
+       CSP_DiskDialog dlg;
+       QString dirname;
+  
+#if defined(_PC6001) || defined(_PC6001MK2) || defined(_PC6001MK2SR) || defined(_PC6601) || defined(_PC6601SR)
+       ext = "*.wav *.p6 *.cas";
+#elif defined(_PC8001SR) || defined(_PC8801MA) || defined(_PC98DO)
+       ext = play ? "*.cas *.cmt *.n80 *.t88" : "*.cas *.cmt";
+#elif defined(_MZ80A) || defined(_MZ80K) || defined(_MZ1200) || defined(_MZ700) || defined(_MZ800) || defined(_MZ1500)
+       ext = play ? "*.wav *.cas *.mzt *.m12 *.t77" :"*.wav *.cas";
+#elif defined(_MZ80B) || defined(_MZ2000) || defined(_MZ2200)
+       ext = play ? "*.wav *.cas *.mzt *.mti *.mtw *.dat" : "*.wav *.cas";
+#elif defined(_X1) || defined(_X1TWIN) || defined(_X1TURBO) || defined(_X1TURBOZ)
+       ext = play ? "*.wav *.cas *.tap *.t77" : "*.wav *.cas";
+#elif defined(_FM8) || defined(_FM7) || defined(_FMNEW7) || defined(_FM77_VARIANTS) || defined(_FM77AV_VARIANTS)
+       ext = "*.wav *.t77";
+#elif defined(TAPE_BINARY_ONLY)
+       ext = "*.cas *.cmt";
+#else
+       ext = "*.wav *.cas";
+#endif
+       desc1 = play ? "Data Recorder Tape [Play]" : "Data Recorder Tape [Rec]";
+       if(play) {
+               dlg.setWindowTitle("Open Tape");
+       } else {
+               dlg.setWindowTitle("Record Tape");
+       }
+       desc2 = desc1 + " (" + ext.toLower() + " " + ext.toUpper() + ")";
+//     desc1 = desc1 + " (" + ext.toUpper() + ")";
+       if(config.initial_tape_dir != NULL) {
+               dirname = QString::fromUtf8(config.initial_tape_dir);           
+       } else {
+               char app[PATH_MAX];
+               QDir df;
+               dirname = df.currentPath();
+               strncpy(app, dirname.toUtf8().constData(), PATH_MAX);
+               dirname = get_parent_dir(app);
+       }
+       QStringList filter;
+       filter << desc2;
+       dlg.param->setRecMode(play);
+       dlg.setDirectory(dirname);
+       dlg.setNameFilters(filter); 
+       QObject::connect(&dlg, SIGNAL(fileSelected(QString)), dlg.param, SLOT(_open_cmt(QString))); 
+       QObject::connect(dlg.param, SIGNAL(do_open_cmt(bool, QString)), this, SLOT(_open_cmt(bool, QString))); 
+       dlg.show();
+       dlg.exec();
+       return;
+}
+
+#endif
+
+void Ui_MainWindow::CreateCMTMenu(void)
+{
+#if defined(USE_TAPE)
+       listCMT.clear();
+       //CreateCMTPulldownMenu(p);
+#endif // USE_TAPE
+}
+
+void Ui_MainWindow::CreateCMTPulldownMenu(void)
+{
+}
+
+
 #ifdef USE_TAPE
 int Ui_MainWindow::set_recent_cmt(int num) 
 {
@@ -27,31 +119,23 @@ int Ui_MainWindow::set_recent_cmt(int num)
        s_path = QString::fromUtf8(config.recent_tape_path[num]);
        strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX);
        UPDATE_HISTORY(path_shadow, config.recent_tape_path, listCMT);
-       //strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX);
    
        get_parent_dir(path_shadow);
        strcpy(config.initial_tape_dir, path_shadow);
        strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX);
-       //   for(int i = num; i > 0; i--) {
-       //      strcpy(config.recent_tape_path[i], config.recent_tape_path[i - 1]);
-       //    }
-       //    strcpy(config.recent_tape_path[0], path.c_str());
        AGAR_DebugLog(AGAR_LOG_DEBUG, "Tape: Open READ");
        
        emit sig_close_tape();
        emit sig_play_tape(s_path);
-
-       for(i = 0; i < MAX_HISTORY; i++) {
-               if(action_Recent_List_CMT[i] != NULL) { 
-                 action_Recent_List_CMT[i]->setText(QString::fromUtf8(config.recent_tape_path[i]));
-               }
-       }
+       menu_CMT->do_update_histories(listCMT);
+       menu_CMT->do_set_initialize_directory(config.initial_tape_dir);
        return 0;
 }
 
 void Ui_MainWindow::do_write_protect_cmt(bool flag)
 {
-       write_protect = flag;
+       //cmt_write_protect = flag;
+       menu_CMT->do_set_write_protect(flag);
 }
 
 
@@ -60,14 +144,12 @@ void Ui_MainWindow::do_push_play_tape(void)
 {
        // Do notify?
        emit sig_cmt_push_play();
-       actionPlay_Start->setChecked(true);
 }
 
 void Ui_MainWindow::do_push_stop_tape(void)
 {
        // Do notify?
        emit sig_cmt_push_stop();
-       actionPlay_Stop->setChecked(true);
 }
 
 void Ui_MainWindow::do_display_tape_play(bool flag)
@@ -83,25 +165,21 @@ void Ui_MainWindow::do_push_fast_forward_tape(void)
 {
        // Do notify?
        emit sig_cmt_push_fast_forward();
-       actionPlay_FastForward->setChecked(true);
 }
 void Ui_MainWindow::do_push_rewind_tape(void)
 {
        // Do notify?
        emit sig_cmt_push_fast_rewind();
-       actionPlay_Rewind->setChecked(true);
 }
 void Ui_MainWindow::do_push_apss_forward_tape(void)
 {
        // Do notify?
        emit sig_cmt_push_apss_forward();
-       actionPlay_Apss_Forward->setChecked(true);
 }
 void Ui_MainWindow::do_push_apss_rewind_tape(void)
 {
        // Do notify?
        emit sig_cmt_push_apss_rewind();
-       actionPlay_Apss_Rewind->setChecked(true);
 }
 # endif
 #endif
@@ -142,12 +220,94 @@ bool Ui_MainWindow::get_direct_load_mzt(void)
 
 void Ui_MainWindow::_open_cmt(bool mode, const QString path)
 {
+}
+
+void Ui_MainWindow::eject_cmt(void) 
+{
+#ifdef USE_TAPE
+       emit sig_close_tape();
+#endif
+}
+
+void Ui_MainWindow::ConfigCMTMenuSub(void)
+{
+#if defined(USE_TAPE)
+       QString ext_play;
+       QString ext_rec;
+       QString desc_play;
+       QString desc_rec;
+       
+       menu_CMT = new Menu_CMTClass(emu, menubar, "Object_CMT_Menu", this, 0);
+       menu_CMT->setObjectName(QString::fromUtf8("menuCMT", -1));
+       
+       menu_CMT->create_pulldown_menu();       
+       // Translate Menu
+       SETUP_HISTORY(config.recent_tape_path, listCMT);
+       menu_CMT->do_set_write_protect(false);
+       menu_CMT->do_update_histories(listCMT);
+       menu_CMT->do_set_initialize_directory(config.initial_tape_dir);
+       
+#if defined(_PC6001) || defined(_PC6001MK2) || defined(_PC6001MK2SR) || defined(_PC6601) || defined(_PC6601SR)
+       ext_play = "*.wav *.p6 *.cas";
+       ext_rec = "*.wav *.p6 *.cas";
+#elif defined(_PC8001SR) || defined(_PC8801MA) || defined(_PC98DO)
+       ext_play = "*.cas *.cmt *.n80 *.t88";
+       ext_rec  = "*.cas *.cmt";
+#elif defined(_MZ80A) || defined(_MZ80K) || defined(_MZ1200) || defined(_MZ700) || defined(_MZ800) || defined(_MZ1500)
+       ext_play = "*.wav *.cas *.mzt *.m12 *.t77";
+       ext_rec = "*.wav *.cas";
+#elif defined(_MZ80B) || defined(_MZ2000) || defined(_MZ2200)
+       ext_play = "*.wav *.cas *.mzt *.mti *.mtw *.dat";
+       ext_rec =  "*.wav *.cas";
+#elif defined(_X1) || defined(_X1TWIN) || defined(_X1TURBO) || defined(_X1TURBOZ)
+       ext_play = "*.wav *.cas *.tap *.t77";
+       ext_rec =  "*.wav *.cas";
+#elif defined(_FM8) || defined(_FM7) || defined(_FMNEW7) || defined(_FM77_VARIANTS) || defined(_FM77AV_VARIANTS)
+       ext_play = "*.wav *.t77";
+       ext_rec = "*.wav *.t77";
+#elif defined(TAPE_BINARY_ONLY)
+       ext_play = "*.cas *.cmt";
+       ext_rec = "*.cas *.cmt";
+#else
+       ext_play = "*.wav *.cas";
+       ext_rec = "*.wav *.cas";
+#endif
+       desc_play = "Data Recorder Tape [Play]";
+       desc_rec  = "Data Recorder Tape [Rec]";
+
+       menu_CMT->do_add_media_extension(ext_play, desc_play);
+       menu_CMT->do_add_rec_media_extension(ext_rec, desc_rec);
+#endif // USE_TAPE
+}
+
+void Ui_MainWindow::do_open_read_cmt(int dummy, QString path) 
+{
+#ifdef USE_TAPE
        char path_shadow[PATH_MAX];
-       int play;
        int i;
-   
-       play = (mode == false) ? 0 : 1;
+
+       if(path.length() <= 0) return;
+       strncpy(path_shadow, path.toUtf8().constData(), PATH_MAX);
+       UPDATE_HISTORY(path_shadow, config.recent_tape_path, listCMT);
+       get_parent_dir(path_shadow);
+       strcpy(config.initial_tape_dir, path_shadow);
+       // Copy filename again.
+       strncpy(path_shadow, path.toUtf8().constData(), PATH_MAX);
+
+       emit sig_close_tape();
+       AGAR_DebugLog(AGAR_LOG_DEBUG, "Tape: Open READ : filename = %s", path_shadow);
+       emit sig_play_tape(path);
+       menu_CMT->do_update_histories(listCMT);
+       menu_CMT->do_set_initialize_directory(config.initial_tape_dir);
+#endif
+}
+
+void Ui_MainWindow::do_open_write_cmt(QString path) 
+{
 #ifdef USE_TAPE
+       char path_shadow[PATH_MAX];
+       int i;
+
        if(path.length() <= 0) return;
        strncpy(path_shadow, path.toUtf8().constData(), PATH_MAX);
        UPDATE_HISTORY(path_shadow, config.recent_tape_path, listCMT);
@@ -157,26 +317,30 @@ void Ui_MainWindow::_open_cmt(bool mode, const QString path)
        strncpy(path_shadow, path.toUtf8().constData(), PATH_MAX);
 
        emit sig_close_tape();
-       if((play != false) || (write_protect != false)) {
+       if(menu_CMT->getWriteProtect() != false) {
                AGAR_DebugLog(AGAR_LOG_DEBUG, "Tape: Open READ : filename = %s", path_shadow);
                emit sig_play_tape(path);
        } else {
                AGAR_DebugLog(AGAR_LOG_DEBUG, "Tape: Open Write : filename = %s", path_shadow);
                emit sig_rec_tape(path);
        }
-       for(i = 0; i < MAX_HISTORY; i++) {
-               if(action_Recent_List_CMT[i] != NULL) { 
-                       action_Recent_List_CMT[i]->setText(QString::fromUtf8(config.recent_tape_path[i]));
-                       //emit action_Recent_List_FD[drive][i]->changed();
-               }
-       }
+       menu_CMT->do_update_histories(listCMT);
+       menu_CMT->do_set_initialize_directory(config.initial_tape_dir);
+
 #endif
 }
 
-void Ui_MainWindow::eject_cmt(void) 
+
+void Ui_MainWindow::retranslateCMTMenu(void)
 {
 #ifdef USE_TAPE
-       emit sig_close_tape();
-#endif
+       menu_CMT->retranslateUi();
+#endif 
 }
 
+void Ui_MainWindow::ConfigCMTMenu(void)
+{
+#if defined(USE_TAPE)
+       ConfigCMTMenuSub(); 
+#endif
+}