OSDN Git Service

[UI][Qt] Update menu structure at FLOPPY and TAPE.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 8 Feb 2023 14:47:03 +0000 (23:47 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 8 Feb 2023 14:47:03 +0000 (23:47 +0900)
Note:
 - Still not implement BINARY, BUBBLE, CART, CD, HDD, LD and QD.
 - This still be imcomplete none upsate virtual media label.
 - Still not update write-protect icon when opening.
 - Still not reset counter of tape with new file.

12 files changed:
source/src/qt/common/emu_thread_slots.cpp
source/src/qt/common/qt_utils.cpp
source/src/qt/common/util_fd2.cpp
source/src/qt/gui/emu_thread_tmpl.h
source/src/qt/gui/mainwidget_base.h
source/src/qt/gui/menu_cmt.cpp
source/src/qt/gui/menu_cmt.h
source/src/qt/gui/menu_metaclass.cpp
source/src/qt/gui/menu_metaclass.h
source/src/qt/gui/util_cmt.cpp
source/src/qt/gui/util_fd.cpp
source/src/qt/osd_base.h

index 2b7eb95..7eb4420 100644 (file)
@@ -20,6 +20,8 @@
 #include "csp_logger.h"
 #include "../gui/menu_flags.h"
 #include "dock_disks.h"
+#include "menu_metaclass.h"
+
 // buttons
 #ifdef MAX_BUTTONS
 #define MAX_FONT_SIZE 32
@@ -508,7 +510,16 @@ void EmuThreadClassBase::do_write_protect_floppy_disk(int drv, bool flag)
        }
 }
 
-void EmuThreadClassBase::do_close_floppy_disk(int drv)
+void EmuThreadClassBase::do_close_floppy_disk()
+{
+       QAction *cp = qobject_cast<QAction*>(QObject::sender());
+       if(cp == nullptr) return;
+       struct CSP_Ui_Menu::DriveIndexPair tmp = cp->data().value<CSP_Ui_Menu::DriveIndexPair>();
+       int drv = tmp.drive;
+       sub_close_floppy_disk_internal(drv);
+}
+
+void EmuThreadClassBase::sub_close_floppy_disk_internal(int drv)
 {
        //QMutexLocker _locker(&uiMutex);
        std::shared_ptr<USING_FLAGS> p = using_flags;
@@ -556,7 +567,6 @@ void EmuThreadClassBase::do_select_floppy_disk_d88(int drive, int slot)
        }
 }
 
-
 void EmuThreadClassBase::do_play_tape(int drv, QString name)
 {
        if(p_emu == nullptr) return;
@@ -577,58 +587,120 @@ void EmuThreadClassBase::do_rec_tape(int drv, QString name)
                emit sig_change_virtual_media(CSP_DockDisks_Domain_CMT, drv, name);
        }
 }
-
-void EmuThreadClassBase::do_close_tape(int drv)
+void EmuThreadClassBase::sub_close_tape_internal(int drv)
 {
        if(using_flags->is_use_tape()) {
                //QMutexLocker _locker(&uiMutex);
                p_emu->close_tape(drv);
-               emit sig_change_virtual_media(CSP_DockDisks_Domain_CMT, drv, QString::fromUtf8(""));
+               //emit sig_change_virtual_media(CSP_DockDisks_Domain_CMT, drv, QString::fromUtf8(""));
+       }
+}
+
+void EmuThreadClassBase::do_close_tape()
+{
+       QAction *cp = qobject_cast<QAction*>(QObject::sender());
+       if(cp == nullptr) return;
+       struct CSP_Ui_Menu::DriveIndexPair tmp = cp->data().value<CSP_Ui_Menu::DriveIndexPair>();
+       int drv = tmp.drive;
+       sub_close_tape_internal(drv);
+}
+
+void EmuThreadClassBase::do_cmt_wave_shaper(bool stat)
+{
+       QAction *cp = qobject_cast<QAction*>(QObject::sender());
+       if(cp == nullptr) return;
+       struct CSP_Ui_Menu::DriveIndexPair tmp = cp->data().value<CSP_Ui_Menu::DriveIndexPair>();
+       int drv = tmp.drive;
+       // ToDo: limit drive.
+       // ToDo: Need update config?
+       if(p_config != nullptr) {
+               p_config->wave_shaper[drv] = stat;
+       }
+}
+void EmuThreadClassBase::do_cmt_direct_load_from_mzt(bool stat)
+{
+       QAction *cp = qobject_cast<QAction*>(QObject::sender());
+       if(cp == nullptr) return;
+       struct CSP_Ui_Menu::DriveIndexPair tmp = cp->data().value<CSP_Ui_Menu::DriveIndexPair>();
+       int drv = tmp.drive;
+       // ToDo: limit drive.
+       if(p_config != nullptr) {
+               p_config->direct_load_mzt[drv] = stat;
        }
 }
 
-void EmuThreadClassBase::do_cmt_push_play(int drv)
+void EmuThreadClassBase::do_cmt_push_play()
 {
+       QAction *cp = qobject_cast<QAction*>(QObject::sender());
+       if(cp == nullptr) return;
+       struct CSP_Ui_Menu::DriveIndexPair tmp = cp->data().value<CSP_Ui_Menu::DriveIndexPair>();
+       int drv = tmp.drive;
+       // ToDo: limit drive.
        if(using_flags->is_use_tape()) {
                //QMutexLocker _locker(&uiMutex);
                p_emu->push_play(drv);
        }
 }
 
-void EmuThreadClassBase::do_cmt_push_stop(int drv)
+void EmuThreadClassBase::do_cmt_push_stop()
 {
+       QAction *cp = qobject_cast<QAction*>(QObject::sender());
+       if(cp == nullptr) return;
+       struct CSP_Ui_Menu::DriveIndexPair tmp = cp->data().value<CSP_Ui_Menu::DriveIndexPair>();
+       int drv = tmp.drive;
+       // ToDo: limit drive.
        if(using_flags->is_use_tape()) {
                //QMutexLocker _locker(&uiMutex);
                p_emu->push_stop(drv);
        }
 }
 
-void EmuThreadClassBase::do_cmt_push_fast_forward(int drv)
+void EmuThreadClassBase::do_cmt_push_fast_forward()
 {
+       QAction *cp = qobject_cast<QAction*>(QObject::sender());
+       if(cp == nullptr) return;
+       struct CSP_Ui_Menu::DriveIndexPair tmp = cp->data().value<CSP_Ui_Menu::DriveIndexPair>();
+       int drv = tmp.drive;
+       // ToDo: limit drive.
        if(using_flags->is_use_tape()) {
                //QMutexLocker _locker(&uiMutex);
                p_emu->push_fast_forward(drv);
        }
 }
 
-void EmuThreadClassBase::do_cmt_push_fast_rewind(int drv)
+void EmuThreadClassBase::do_cmt_push_fast_rewind()
 {
+       QAction *cp = qobject_cast<QAction*>(QObject::sender());
+       if(cp == nullptr) return;
+       struct CSP_Ui_Menu::DriveIndexPair tmp = cp->data().value<CSP_Ui_Menu::DriveIndexPair>();
+       int drv = tmp.drive;
+       // ToDo: limit drive.
        if(using_flags->is_use_tape()) {
                //QMutexLocker _locker(&uiMutex);
                p_emu->push_fast_rewind(drv);
        }
 }
 
-void EmuThreadClassBase::do_cmt_push_apss_forward(int drv)
+void EmuThreadClassBase::do_cmt_push_apss_forward()
 {
+       QAction *cp = qobject_cast<QAction*>(QObject::sender());
+       if(cp == nullptr) return;
+       struct CSP_Ui_Menu::DriveIndexPair tmp = cp->data().value<CSP_Ui_Menu::DriveIndexPair>();
+       int drv = tmp.drive;
+       // ToDo: limit drive.
        if(using_flags->is_use_tape()) {
                ////QMutexLocker _locker(&uiMutex);
                p_emu->push_apss_forward(drv);
        }
 }
 
-void EmuThreadClassBase::do_cmt_push_apss_rewind(int drv)
+void EmuThreadClassBase::do_cmt_push_apss_rewind()
 {
+       QAction *cp = qobject_cast<QAction*>(QObject::sender());
+       if(cp == nullptr) return;
+       struct CSP_Ui_Menu::DriveIndexPair tmp = cp->data().value<CSP_Ui_Menu::DriveIndexPair>();
+       int drv = tmp.drive;
+       // ToDo: limit drive.
        if(using_flags->is_use_tape()) {
                ////QMutexLocker _locker(&uiMutex);
                p_emu->push_apss_rewind(drv);
index a1a6c4a..b19fcfb 100644 (file)
 #include "qt_gldraw.h"
 #include "../gui/gl2/qt_glutil_gl2_0.h"
 #include "csp_logger.h"
+
 #include "dock_disks.h"
 #include "menu_disk.h"
+#include "menu_cmt.h"
 #include "menu_bubble.h"
+
 #include "menu_flags_ext.h"
 #include "dialog_movie.h"
 #include "../avio/movie_saver.h"
@@ -187,16 +190,28 @@ void Ui_MainWindow::LaunchEmuThread(EmuThreadClassBase *m)
        //connect(hRunEmu, SIGNAL(sig_change_osd_fd(int, QString)), this, SLOT(do_change_osd_fd(int, QString)));
 #endif
 #if defined(USE_TAPE)
+       for(int ii = 0; ii < USE_TAPE; ii++) {
+               if(ii >= USE_TAPE_TMP) break;
+               Menu_CMTClass *mp = menu_CMT[ii];
+               if(mp != nullptr) {
+                       mp->connect_via_emu_thread(hRunEmu);
+               }
+       }
        connect(this, SIGNAL(sig_play_tape(int, QString)), hRunEmu, SLOT(do_play_tape(int, QString)));
        connect(this, SIGNAL(sig_rec_tape(int, QString)),  hRunEmu, SLOT(do_rec_tape(int, QString)));
-       connect(this, SIGNAL(sig_close_tape(int)),   hRunEmu, SLOT(do_close_tape(int)));
+
+       connect(p_osd, SIGNAL(sig_ui_tape_play_insert_history(int, QString)),
+                                        this, SLOT(do_ui_tape_play_insert_history(int, QString)),
+                                        Qt::QueuedConnection);
+       connect(p_osd, SIGNAL(sig_ui_tape_record_insert_history(int, QString)),
+                                        this, SLOT(do_ui_tape_record_insert_history(int, QString)),
+                                        Qt::QueuedConnection);
+       connect(p_osd, SIGNAL(sig_ui_tape_write_protect(int, quint64)),
+                       this, SLOT(do_ui_write_protect_tape(int, quint64)),
+                       Qt::QueuedConnection);
+
        //connect(hRunEmu, SIGNAL(sig_change_osd_cmt(QString)), this, SLOT(do_change_osd_cmt(QString)));
-       connect(this, SIGNAL(sig_cmt_push_play(int)), hRunEmu, SLOT(do_cmt_push_play(int)));
-       connect(this, SIGNAL(sig_cmt_push_stop(int)), hRunEmu, SLOT(do_cmt_push_stop(int)));
-       connect(this, SIGNAL(sig_cmt_push_fast_forward(int)), hRunEmu, SLOT(do_cmt_push_fast_forward(int)));
-       connect(this, SIGNAL(sig_cmt_push_fast_rewind(int)),  hRunEmu, SLOT(do_cmt_push_fast_rewind(int)));
-       connect(this, SIGNAL(sig_cmt_push_apss_forward(int)), hRunEmu, SLOT(do_cmt_push_apss_forward(int)));
-       connect(this, SIGNAL(sig_cmt_push_apss_rewind(int)),  hRunEmu, SLOT(do_cmt_push_apss_rewind(int)));
+
 #endif
 #if defined(USE_QUICK_DISK)
        connect(this, SIGNAL(sig_write_protect_quickdisk(int, bool)), hRunEmu, SLOT(do_write_protect_quickdisk(int, bool)));
index 1c23a67..d2a7099 100644 (file)
@@ -84,13 +84,13 @@ void Ui_MainWindowBase::do_ui_floppy_insert_history(int drv, QString fname, quin
 
 void Ui_MainWindowBase::_open_disk(int drv, const QString fname)
 {
-       char path_shadow[PATH_MAX];
+       char path_shadow[_MAX_PATH];
 
        if(fname.length() <= 0) return;
        if(using_flags->get_max_drive() <= drv) return;
        if(!(FILEIO::IsFileExisting(fname.toLocal8Bit().constData()))) return; // File not found.
 //     drv = drv & 7;
-       strncpy(path_shadow, fname.toLocal8Bit().constData(), PATH_MAX - 1);
+       strncpy(path_shadow, fname.toLocal8Bit().constData(), _MAX_PATH - 1);
        emit sig_close_floppy_disk(drv);
        emit sig_open_floppy_disk(drv, fname, 0);
 
index 1b6af00..fa94d3a 100644 (file)
@@ -230,6 +230,10 @@ protected:
                QMutexLocker n(&keyMutex);
                key_fifo->clear();
        };
+       // Thread HOOK.
+       void sub_close_floppy_disk_internal(int drv);
+
+       void sub_close_tape_internal(int drv);
 
 public:
        EmuThreadClassBase(Ui_MainWindowBase *rootWindow, std::shared_ptr<USING_FLAGS> p, QObject *parent = 0);
@@ -249,7 +253,6 @@ public:
        void set_floppy_disk_protected(int drive, bool flag);
        QString get_d88_file_path(int drive);
 
-
 public slots:
        void doExit(void);
 
@@ -281,7 +284,7 @@ public slots:
        void moved_mouse(double x, double y, double globalx, double globaly);
 
        void do_write_protect_floppy_disk(int drv, bool flag);
-       void do_close_floppy_disk(int);
+       void do_close_floppy_disk();
        void do_open_floppy_disk(int, QString, int);
 
        void do_close_hard_disk(int);
@@ -289,13 +292,16 @@ public slots:
 
        void do_play_tape(int drv, QString name);
        void do_rec_tape(int drv, QString name);
-       void do_close_tape(int drv);
-       void do_cmt_push_play(int drv);
-       void do_cmt_push_stop(int drv);
-       void do_cmt_push_fast_forward(int drv);
-       void do_cmt_push_fast_rewind(int drv);
-       void do_cmt_push_apss_forward(int drv);
-       void do_cmt_push_apss_rewind(int drv);
+       void do_close_tape();
+
+       void do_cmt_push_play();
+       void do_cmt_push_stop();
+       void do_cmt_push_fast_forward();
+       void do_cmt_push_fast_rewind();
+       void do_cmt_push_apss_forward();
+       void do_cmt_push_apss_rewind();
+       void do_cmt_direct_load_from_mzt(bool stat);
+       void do_cmt_wave_shaper(bool stat);
 
        void do_write_protect_quickdisk(int drv, bool flag);
        void do_close_quickdisk(int drv);
index b45b887..2e976f8 100644 (file)
@@ -820,19 +820,10 @@ public slots:
        void do_change_boot_mode();
        void do_change_cpu_type();
 
-       void do_write_protect_cmt(int drv, bool flag);
        int  set_recent_cmt(int drv, int num);
-       void set_wave_shaper(int drive, bool f);
-       void set_direct_load_from_mzt(int drive, bool f);
        void do_open_write_cmt(int drive, QString);
        void do_open_read_cmt(int drive, QString path);
 
-       void do_push_play_tape(int drive);
-       void do_push_stop_tape(int drive);
-       void do_push_fast_forward_tape(int drive);
-       void do_push_rewind_tape(int drive);
-       void do_push_apss_forward_tape(int drive);
-       void do_push_apss_rewind_tape(int drive);
        void set_cmt_sound(bool);
 
        int do_emu_write_protect_floppy_disk(int drv, bool flag);
@@ -905,10 +896,13 @@ public slots:
        void do_set_visible_virtual_media_right();
 
        void do_update_floppy_history(int drive, QStringList lst);
-       void do_insert_floppy_history(int drive, QString path);
        void do_ui_floppy_insert_history(int drv, QString fname, quint64 bank);
        void do_ui_write_protect_floppy_disk(int drv, quint64 flag);
 
+       void do_ui_tape_play_insert_history(int drv, QString fname);
+       void do_ui_tape_record_insert_history(int drv, QString fname);
+       void do_ui_write_protect_tape(int drv, quint64 flag);
+
        void do_set_emulate_cursor_as(void);
        void do_set_logging_fdc(bool onoff);
        void do_set_separate_thread_draw(bool f);
index 4cfe904..f5953ad 100644 (file)
@@ -2,7 +2,7 @@
  * Qt / Tape Menu, Utilities
  * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
  * License : GPLv2
- *   History : 
+ *   History :
  *     Jan 13 2015 : Start
  */
 
@@ -14,6 +14,7 @@
 #include "mainwidget_base.h"
 #include "menu_cmt.h"
 
+#include "emu_thread_tmpl.h"
 #include "qt_dialogs.h"
 //#include "emu.h"
 
@@ -39,44 +40,27 @@ Menu_CMTClass::~Menu_CMTClass()
 {
 }
 
-void Menu_CMTClass::do_push_play_tape(void)
+void Menu_CMTClass::connect_via_emu_thread(EmuThreadClassBase *p)
 {
-       emit sig_push_play_tape(media_drive);
-}
-
-void Menu_CMTClass::do_push_stop_tape(void)
-{
-       emit sig_push_stop_tape(media_drive);
-}
-
-void Menu_CMTClass::do_push_fast_forward_tape(void)
-{
-       emit sig_push_fast_forward_tape(media_drive);
-}
-
-void Menu_CMTClass::do_push_rewind_tape(void)
-{
-       emit sig_push_rewind_tape(media_drive);
-}
+       if(p == nullptr) return;
 
-void Menu_CMTClass::do_push_apss_forward_tape(void)
-{
-       emit sig_push_apss_forward_tape(media_drive);
-}
-
-void Menu_CMTClass::do_push_apss_rewind_tape(void)
-{
-       emit sig_push_apss_rewind_tape(media_drive);
-}
+       connect(action_eject, SIGNAL(triggered()), p, SLOT(do_close_tape()), Qt::QueuedConnection);
 
-void Menu_CMTClass::set_wave_shaper(bool flag)
-{
-       emit sig_wave_shaper(media_drive, flag);
-}
+       connect(action_play_start, SIGNAL(triggered()), p, SLOT(do_cmt_push_play()), Qt::QueuedConnection);
+       connect(action_play_stop, SIGNAL(triggered()), p, SLOT(do_cmt_push_stop()), Qt::QueuedConnection);
+       connect(action_fast_forward, SIGNAL(triggered()), p, SLOT(do_cmt_push_fast_forward()), Qt::QueuedConnection);
+       connect(action_fast_rewind, SIGNAL(triggered()), p, SLOT(do_cmt_push_fast_rewind()), Qt::QueuedConnection);
+       connect(action_apss_forward, SIGNAL(triggered()), p, SLOT(do_cmt_push_apss_forward()), Qt::QueuedConnection);
+       connect(action_apss_rewind, SIGNAL(triggered()), p, SLOT(do_cmt_push_apss_rewind()), Qt::QueuedConnection);
+       connect(action_wave_shaper, SIGNAL(toggled(bool)), p, SLOT(do_cmt_wave_shaper(bool)), Qt::QueuedConnection);
 
-void Menu_CMTClass::set_direct_load_mzt(bool flag)
-{
-       emit sig_direct_load_mzt(media_drive, flag);
+       if(using_flags->is_machine_cmt_mz_series()) {
+               if(action_direct_load_mzt != nullptr) {
+                       connect(action_direct_load_mzt, SIGNAL(toggled(bool)),
+                                       p, SLOT(do_cmt_direct_load_from_mzt(bool)),
+                                       Qt::QueuedConnection);
+               }
+       }
 }
 
 void Menu_CMTClass::do_open_write_cmt(QString s)
@@ -87,14 +71,23 @@ void Menu_CMTClass::do_open_write_cmt(QString s)
 
 void Menu_CMTClass::create_pulldown_menu_device_sub(void)
 {
+       struct CSP_Ui_Menu::DriveIndexPair tmp;
+       QVariant _tmp_ins;
+
+       tmp.drive = media_drive;
+       tmp.index = 0;
+       _tmp_ins.setValue(tmp);
+
        action_wave_shaper = new Action_Control(p_wid, using_flags);
        action_wave_shaper->setVisible(true);
        action_wave_shaper->setCheckable(true);
+       action_wave_shaper->setData(_tmp_ins);
 
        if(using_flags->is_machine_cmt_mz_series()) {
                action_direct_load_mzt = new Action_Control(p_wid, using_flags);
                action_direct_load_mzt->setVisible(true);
                action_direct_load_mzt->setCheckable(true);
+               action_direct_load_mzt->setData(_tmp_ins);
        }
        action_recording = new Action_Control(p_wid, using_flags);
        action_recording->setVisible(true);
@@ -116,26 +109,32 @@ void Menu_CMTClass::create_pulldown_menu_device_sub(void)
                action_play_start = new Action_Control(p_wid, using_flags);
                action_play_start->setVisible(true);
                action_play_start->setCheckable(true);
-               
+               action_play_start->setData(_tmp_ins);
+
                action_play_stop = new Action_Control(p_wid, using_flags);
                action_play_stop->setVisible(true);
                action_play_stop->setCheckable(true);
-               
+               action_play_stop->setData(_tmp_ins);
+
                action_fast_forward = new Action_Control(p_wid, using_flags);
                action_fast_forward->setVisible(true);
                action_fast_forward->setCheckable(true);
-               
+               action_fast_forward->setData(_tmp_ins);
+
                action_fast_rewind = new Action_Control(p_wid, using_flags);
                action_fast_rewind->setVisible(true);
                action_fast_rewind->setCheckable(true);
-               
+               action_fast_rewind->setData(_tmp_ins);
+
                action_apss_forward = new Action_Control(p_wid, using_flags);
                action_apss_forward->setVisible(true);
                action_apss_forward->setCheckable(true);
-               
+               action_apss_forward->setData(_tmp_ins);
+
                action_apss_rewind = new Action_Control(p_wid, using_flags);
                action_apss_rewind->setVisible(true);
                action_apss_rewind->setCheckable(true);
+               action_apss_rewind->setData(_tmp_ins);
 
                action_group_tape_button = new QActionGroup(p_wid);
 
@@ -160,46 +159,25 @@ void Menu_CMTClass::connect_menu_device_sub(void)
                        this->addAction(action_play_start);
                        this->addAction(action_play_stop);
                        this->addSeparator();
-                       
+
                        this->addAction(action_fast_forward);
                        this->addAction(action_fast_rewind);
                        this->addSeparator();
-       
+
                        this->addAction(action_apss_forward);
                        this->addAction(action_apss_rewind);
                        this->addSeparator();
                }
                this->addAction(action_wave_shaper);
-               connect(action_wave_shaper, SIGNAL(toggled(bool)), this, SLOT(set_wave_shaper(bool)));
-               connect(this, SIGNAL(sig_wave_shaper(int, bool)), p_wid, SLOT(set_wave_shaper(int, bool)));
-               
+
                if(using_flags->is_machine_cmt_mz_series()) {
                        this->addAction(action_direct_load_mzt);
-                       connect(action_direct_load_mzt, SIGNAL(toggled(bool)), this, SLOT(set_direct_load_mzt(bool)));
-                       connect(this, SIGNAL(sig_direct_load_mzt(int, bool)), p_wid, SLOT(set_direct_load_from_mzt(int, bool)));
                }
                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)));
-               
-               connect(this, SIGNAL(sig_eject_media(int)),     this, SLOT(do_eject_cmt(int)));
-               connect(this, SIGNAL(sig_close_tape(int)), p_wid, SLOT(eject_cmt(int)));
-               
-               connect(this, SIGNAL(sig_write_protect_media(int, bool)), p_wid, SLOT(do_write_protect_cmt(int, bool)));        
+
                connect(this, SIGNAL(sig_set_recent_media(int, int)), p_wid, SLOT(set_recent_cmt(int, int)));
                /*if(using_flags->is_use_tape_button())*/ {
-                       connect(action_play_start, SIGNAL(triggered()), this, SLOT(do_push_play_tape(void)));
-                       connect(action_play_stop,  SIGNAL(triggered()), this, SLOT(do_push_stop_tape(void)));
-                       connect(action_fast_forward,  SIGNAL(triggered()), this, SLOT(do_push_fast_forward_tape(void)));
-                       connect(action_fast_rewind,   SIGNAL(triggered()), this, SLOT(do_push_rewind_tape(void)));
-                       connect(action_apss_forward,  SIGNAL(triggered()), this, SLOT(do_push_apss_forward_tape(void)));
-                       connect(action_apss_rewind,   SIGNAL(triggered()), this, SLOT(do_push_apss_rewind_tape(void)));
-
-                       connect(this, SIGNAL(sig_push_play_tape(int)), p_wid, SLOT(do_push_play_tape(int)));
-                       connect(this,  SIGNAL(sig_push_stop_tape(int)), p_wid, SLOT(do_push_stop_tape(int)));
-                       connect(this,  SIGNAL(sig_push_fast_forward_tape(int)), p_wid, SLOT(do_push_fast_forward_tape(int)));
-                       connect(this,   SIGNAL(sig_push_rewind_tape(int)), p_wid, SLOT(do_push_rewind_tape(int)));
-                       connect(this,  SIGNAL(sig_push_apss_forward_tape(int)), p_wid, SLOT(do_push_apss_forward_tape(int)));
-                       connect(this,   SIGNAL(sig_push_apss_rewind_tape(int)), p_wid, SLOT(do_push_apss_rewind_tape(int)));
                }
        }
 }
@@ -217,15 +195,15 @@ void Menu_CMTClass::do_add_rec_media_extension(QString ext, QString description)
 
        ext_rec_filter << tmps;
        ext_rec_filter << all;
-       
+
        ext_rec_filter.removeDuplicates();
 }
 
 void Menu_CMTClass::do_open_rec_dialog()
 {
        CSP_DiskDialog *dlg = new CSP_DiskDialog(nullptr);
-       
-       if(initial_dir.isEmpty()) { 
+
+       if(initial_dir.isEmpty()) {
                QDir dir;
                char app[PATH_MAX];
                initial_dir = dir.currentPath();
@@ -240,13 +218,13 @@ void Menu_CMTClass::do_open_rec_dialog()
        dlg->setNameFilters(ext_rec_filter);
        dlg->setWindowTitle(desc_rec);
        dlg->setWindowTitle(QApplication::translate("MenuMedia", "Save Tape", 0));
-       
-       connect(dlg, SIGNAL(fileSelected(QString)), this, SLOT(do_open_write_cmt(QString))); 
-       connect(this, SIGNAL(sig_open_write_cmt(int, QString)), p_wid, SLOT(do_open_write_cmt(int, QString))); 
-       connect(dlg, SIGNAL(accepted()), this, SLOT(do_close_window()), Qt::QueuedConnection); 
-       connect(dlg, SIGNAL(rejected()), this, SLOT(do_close_window()), Qt::QueuedConnection); 
-       connect(dlg, SIGNAL(finished(int)), this, SLOT(do_finish(int)), Qt::QueuedConnection); 
-       
+
+       connect(dlg, SIGNAL(fileSelected(QString)), this, SLOT(do_open_write_cmt(QString)));
+       connect(this, SIGNAL(sig_open_write_cmt(int, QString)), p_wid, SLOT(do_open_write_cmt(int, QString)));
+       connect(dlg, SIGNAL(accepted()), this, SLOT(do_close_window()), Qt::QueuedConnection);
+       connect(dlg, SIGNAL(rejected()), this, SLOT(do_close_window()), Qt::QueuedConnection);
+       connect(dlg, SIGNAL(finished(int)), this, SLOT(do_finish(int)), Qt::QueuedConnection);
+
        dialogs.append(dlg);
        dlg->setModal(false);
        dlg->show();
@@ -254,10 +232,6 @@ void Menu_CMTClass::do_open_rec_dialog()
        return;
 }
 
-void Menu_CMTClass::do_eject_cmt(int drive) 
-{
-       emit sig_close_tape(drive);
-}
 
 void Menu_CMTClass::retranslate_pulldown_menu_device_sub(void)
 {
@@ -283,7 +257,7 @@ void Menu_CMTClass::retranslate_pulldown_menu_device_sub(void)
                action_fast_rewind->setIcon(icon_rew);
                action_apss_forward->setIcon(icon_apss_forward);
                action_apss_rewind->setIcon(icon_apss_backward);
-               
+
                action_play_stop->setText(QApplication::translate("MenuMedia", "Play Stop", 0));
                action_play_start->setText(QApplication::translate("MenuMedia", "Play Start", 0));
                action_fast_forward->setText(QApplication::translate("MenuMedia", "Fast Forward", 0));
index 0cd7b19..f98bec5 100644 (file)
@@ -17,7 +17,7 @@ class DLL_PREFIX Menu_CMTClass: public Menu_MetaClass {
 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;
@@ -42,32 +42,17 @@ protected:
 public:
        Menu_CMTClass(QMenuBar *root_entry, QString desc, std::shared_ptr<USING_FLAGS> p, QWidget *parent = 0, int drv = 0, int base_drv = 1);
        ~Menu_CMTClass();
-       void create_pulldown_menu_device_sub();
-       void connect_menu_device_sub(void);
-       void retranslate_pulldown_menu_device_sub(void);
+       void create_pulldown_menu_device_sub() override;
+       void connect_menu_device_sub(void) override;
+       void retranslate_pulldown_menu_device_sub(void) override;
+       void connect_via_emu_thread(EmuThreadClassBase *p) override;
+
 public slots:
        void do_open_rec_dialog();
        void do_add_rec_media_extension(QString ext, QString description);
-       void do_eject_cmt(int drv);
-       void do_push_play_tape(void);
-       void do_push_stop_tape(void);
-       void do_push_fast_forward_tape(void);
-       void do_push_rewind_tape(void);
-       void do_push_apss_forward_tape(void);
-       void do_push_apss_rewind_tape(void);
-       void set_wave_shaper(bool flag);
-       void set_direct_load_mzt(bool flag);
        void do_open_write_cmt(QString s);
-signals:
-       int sig_close_tape(int);
-       int sig_push_play_tape(int);
-       int sig_push_stop_tape(int);
-       int sig_push_fast_forward_tape(int);
-       int sig_push_rewind_tape(int);
-       int sig_push_apss_forward_tape(int);
-       int sig_push_apss_rewind_tape(int);
 
-       int sig_wave_shaper(int, bool);
+signals:
        int sig_direct_load_mzt(int, bool);
        int sig_open_write_cmt(int, QString);
 };
index 562638d..8e62c4e 100644 (file)
 #include <QApplication>
 #include <QMenuBar>
 
-//#include "emu.h"
-//#include "vm.h"
 #include "qt_dialogs.h"
 #include "menu_metaclass.h"
 #include "commonclasses.h"
 #include "mainwidget_base.h"
-#include "commonclasses.h"
+#include "emu_thread_tmpl.h"
+
 #include "qt_main.h"
 
 Menu_MetaClass::Menu_MetaClass(QMenuBar *root_entry, QString desc, std::shared_ptr<USING_FLAGS> p, QWidget *parent, int drv, int base_drv) : QMenu(root_entry)
 {
        QString tmps;
        int ii;
-       
+
        p_wid = parent;
        menu_root = root_entry;
 
        //p_emu = ep;
        using_flags = p;
        p_config = p->get_config_ptr();
-       
+
        media_drive = drv;
        base_drive = base_drv;
-       
+
        tmps.setNum(drv);
        object_desc = QString::fromUtf8("Obj_") + desc;
        object_desc.append(tmps);
@@ -48,13 +47,13 @@ Menu_MetaClass::Menu_MetaClass(QMenuBar *root_entry, QString desc, std::shared_p
        use_write_protect = true;
        use_d88_menus = false;
        initial_dir = QString::fromUtf8("");
-       
+
        ext_filter.clear();
 
        history.clear();
 
        dialogs.clear();
-       
+
        inner_media_list.clear();
        window_title = QString::fromUtf8("");
 
@@ -63,9 +62,9 @@ Menu_MetaClass::Menu_MetaClass(QMenuBar *root_entry, QString desc, std::shared_p
        icon_write_protected = QApplication::style()->standardIcon(QStyle::SP_DialogApplyButton);
        icon_write_enabled = QIcon();
        setToolTipsVisible(true);
-       
+
        connect(this, SIGNAL(sig_emu_update_config()), p_wid, SLOT(do_emu_update_config()));
-       
+
        tmps = QString::fromUtf8("%1").arg(drv + base_drv);
        tmps = desc + tmps;
        setTitle(tmps);
@@ -81,6 +80,11 @@ Menu_MetaClass::~Menu_MetaClass()
        }
 }
 
+// This is dummy.Please implement.
+void Menu_MetaClass::connect_via_emu_thread(EmuThreadClassBase *p)
+{
+       if(p == nullptr) return;
+}
 
 // This is virtual function, pls. override.
 void Menu_MetaClass::do_set_write_protect(bool f)
@@ -96,7 +100,7 @@ void Menu_MetaClass::do_set_write_protect(bool f)
                        menu_write_protect->setIcon(icon_write_enabled);
                }
                action_write_protect_off->setChecked(true);
-       }               
+       }
 }
 
 void Menu_MetaClass::do_set_initialize_directory(const char *s)
@@ -106,13 +110,13 @@ void Menu_MetaClass::do_set_initialize_directory(const char *s)
 
 void Menu_MetaClass::do_open_media(int drv, QString name)
 {
-       //write_protect = false; // Right? On D88, May be writing entry  exists. 
+       //write_protect = false; // Right? On D88, May be writing entry  exists.
        emit sig_open_media(drv, name);
 }
 
 void Menu_MetaClass::do_insert_media(void)
 {
-       //write_protect = false; // Right? On D88, May be writing entry  exists. 
+       //write_protect = false; // Right? On D88, May be writing entry  exists.
        emit sig_insert_media(media_drive);
 }
 
@@ -127,7 +131,7 @@ void Menu_MetaClass::do_open_inner_media(void)
        QAction *cp = qobject_cast<QAction*>(QObject::sender());
        if(cp == nullptr) return;
        struct CSP_Ui_Menu::DriveIndexPair tmp = cp->data().value<CSP_Ui_Menu::DriveIndexPair>();
-       
+
        emit sig_set_inner_slot(tmp.drive, tmp.index);
 }
 
@@ -136,8 +140,8 @@ void Menu_MetaClass::do_open_recent_media(void)
        QAction *cp = qobject_cast<QAction*>(QObject::sender());
        if(cp == nullptr) return;
        struct CSP_Ui_Menu::DriveIndexPair tmp = cp->data().value<CSP_Ui_Menu::DriveIndexPair>();
-       
-  //   write_protect = false; // Right? On D88, May be writing entry  exists. 
+
+  //   write_protect = false; // Right? On D88, May be writing entry  exists.
        emit sig_set_recent_media(tmp.drive, tmp.index);
 }
 
@@ -149,7 +153,7 @@ void Menu_MetaClass::do_write_protect_media(void)
                        menu_write_protect->setIcon(icon_write_protected);
                }
                action_write_protect_on->setChecked(true);
-       }               
+       }
        emit sig_write_protect_media(media_drive, write_protect);
 }
 
@@ -160,7 +164,7 @@ void Menu_MetaClass::do_write_unprotect_media(void) {
                        menu_write_protect->setIcon(icon_write_enabled);
                }
                action_write_protect_off->setChecked(true);
-       }               
+       }
        emit sig_write_protect_media(media_drive, write_protect);
 }
 
@@ -215,11 +219,11 @@ void Menu_MetaClass::do_open_dialog()
        CSP_DiskDialog *dlg = new CSP_DiskDialog(this);
        do_open_dialog_common(dlg);
        emit sig_show();
-}      
+}
 void Menu_MetaClass::do_open_dialog_common(CSP_DiskDialog* dlg)
 {
        // ToDo : Load State of Qt.
-       if(initial_dir.isEmpty()) { 
+       if(initial_dir.isEmpty()) {
                QDir dir;
                char app[PATH_MAX];
                initial_dir = dir.currentPath();
@@ -248,17 +252,17 @@ void Menu_MetaClass::do_open_dialog_common(CSP_DiskDialog* dlg)
 
        dlg->setModal(false);
 
-       connect(dlg, SIGNAL(fileSelected(QString)), dlg->param, SLOT(_open_disk(QString))); 
+       connect(dlg, SIGNAL(fileSelected(QString)), dlg->param, SLOT(_open_disk(QString)));
        connect(dlg->param, SIGNAL(sig_open_disk(int, QString)), this, SLOT(do_open_media(int, QString)));
-       connect(dlg, SIGNAL(accepted()), this, SLOT(do_close_window()), Qt::QueuedConnection); 
-       connect(dlg, SIGNAL(rejected()), this, SLOT(do_close_window()), Qt::QueuedConnection); 
-       connect(dlg, SIGNAL(finished(int)), this, SLOT(do_finish(int)), Qt::QueuedConnection); 
+       connect(dlg, SIGNAL(accepted()), this, SLOT(do_close_window()), Qt::QueuedConnection);
+       connect(dlg, SIGNAL(rejected()), this, SLOT(do_close_window()), Qt::QueuedConnection);
+       connect(dlg, SIGNAL(finished(int)), this, SLOT(do_finish(int)), Qt::QueuedConnection);
 
-       connect(this, SIGNAL(sig_show()), dlg, SLOT(show()), Qt::QueuedConnection); 
+       connect(this, SIGNAL(sig_show()), dlg, SLOT(show()), Qt::QueuedConnection);
        dlg->do_update_params(); // update Extensions, directories
 
        dialogs.append(dlg);
-       
+
        //dlg->open();
        //dlg->show();
        //dlg->exec();
@@ -299,7 +303,7 @@ void Menu_MetaClass::do_update_histories(QStringList lst)
        for(int i = ptr; i < MAX_HISTORY; i++) {
                action_recent_list[i]->setText(QString::fromUtf8(""));
                action_recent_list[i]->setVisible(false);
-       }       
+       }
 }
 
 
@@ -358,18 +362,18 @@ void Menu_MetaClass::create_pulldown_menu_sub(void)
 {
        action_insert = new Action_Control(p_wid, using_flags);
        action_insert->setObjectName(QString::fromUtf8("action_insert_") + object_desc);
-       
+
        struct CSP_Ui_Menu::DriveIndexPair tmp;
        QVariant _tmp_ins;
-       
+
        tmp.drive = media_drive;
        tmp.index = 0;
        _tmp_ins.setValue(tmp);
        action_insert->setData(_tmp_ins);
-       
+
        connect(action_insert, SIGNAL(triggered()), this, SLOT(do_open_dialog()), Qt::QueuedConnection);
        action_insert->setIcon(icon_insert);
-       
+
        action_eject = new Action_Control(p_wid, using_flags);
        action_eject->setObjectName(QString::fromUtf8("action_eject_") + object_desc);
 
@@ -378,17 +382,14 @@ void Menu_MetaClass::create_pulldown_menu_sub(void)
        tmp.index = 0;
        _tmp_eject.setValue(tmp);
        action_eject->setData(_tmp_eject);
-
-       connect(action_eject, SIGNAL(triggered()), this, SLOT(do_eject_media()));
        action_eject->setIcon(icon_eject);
 
-       
        {
                QString tmps;
                int ii;
                action_group_recent = new QActionGroup(p_wid);
                action_group_recent->setExclusive(true);
-               
+
                for(ii = 0; ii < MAX_HISTORY; ii++) {
                        tmps = history.value(ii, "");
                        action_recent_list[ii] = new Action_Control(p_wid, using_flags);
@@ -397,16 +398,16 @@ void Menu_MetaClass::create_pulldown_menu_sub(void)
                        tmp2.index = ii;
                        QVariant _tmp2v;
                        _tmp2v.setValue(tmp2);
-                       
+
                        action_recent_list[ii]->setData(_tmp2v);
                        action_recent_list[ii]->setText(tmps);
-                       
+
                        action_group_recent->addAction(action_recent_list[ii]);
                        if(!tmps.isEmpty()) {
                                action_recent_list[ii]->setVisible(true);
                        } else {
                                action_recent_list[ii]->setVisible(false);
-                       }                       
+                       }
                }
        }
        if(use_d88_menus) {
@@ -414,7 +415,7 @@ void Menu_MetaClass::create_pulldown_menu_sub(void)
                QString tmps;
                action_group_inner_media = new QActionGroup(p_wid);
                action_group_inner_media->setExclusive(true);
-               
+
                for(ii = 0; ii < using_flags->get_max_d88_banks(); ii++) {
                        tmps = history.value(ii, "");
                        action_select_media_list[ii] = new Action_Control(p_wid, using_flags);
@@ -424,7 +425,7 @@ void Menu_MetaClass::create_pulldown_menu_sub(void)
                        QVariant _tmp2v;
                        _tmp2v.setValue(tmp2);
                        action_select_media_list[ii]->setData(_tmp2v);
-                       
+
                        action_select_media_list[ii]->setText(tmps);
                        action_select_media_list[ii]->setCheckable(true);
                        if(ii == 0) action_select_media_list[ii]->setChecked(true);
@@ -433,7 +434,7 @@ void Menu_MetaClass::create_pulldown_menu_sub(void)
                                action_select_media_list[ii]->setVisible(true);
                        } else {
                                action_select_media_list[ii]->setVisible(false);
-                       }                       
+                       }
                }
        }
        if(use_write_protect) {
@@ -445,12 +446,12 @@ void Menu_MetaClass::create_pulldown_menu_sub(void)
                action_write_protect_on->setCheckable(true);
                action_write_protect_on->setChecked(true);
                action_write_protect_on->setData(QVariant(media_drive));
-               
+
                action_write_protect_off = new Action_Control(p_wid, using_flags);
                action_write_protect_off->setObjectName(QString::fromUtf8("action_write_protect_off_") + object_desc);
                action_write_protect_off->setCheckable(true);
                action_write_protect_off->setData(QVariant(media_drive));
-               
+
                action_group_protect->addAction(action_write_protect_on);
                action_group_protect->addAction(action_write_protect_off);
                connect(action_write_protect_on, SIGNAL(triggered()), this, SLOT(do_write_protect_media()));
@@ -486,7 +487,7 @@ void Menu_MetaClass::create_pulldown_menu(void)
        // Example:: Disk.
        create_pulldown_menu_sub();
        create_pulldown_menu_device_sub();
-       // Create 
+       // Create
 
        menu_history = new QMenu(this);
        menu_history->setObjectName(QString::fromUtf8("menu_history_") + object_desc);
@@ -514,7 +515,7 @@ void Menu_MetaClass::create_pulldown_menu(void)
        // Connect extra menus to this.
        connect_menu_device_sub();
        this->addSeparator();
-       
+
        // More actions
        this->addAction(menu_history->menuAction());
        if(use_d88_menus) {
@@ -527,7 +528,7 @@ void Menu_MetaClass::create_pulldown_menu(void)
                menu_write_protect->addAction(action_write_protect_off);
        }
        // Do connect!
-       
+
        for(ii = 0; ii < MAX_HISTORY; ii++) {
                connect(action_recent_list[ii], SIGNAL(triggered()),
                                this, SLOT(do_open_recent_media()));
@@ -554,12 +555,12 @@ void Menu_MetaClass::retranslate_pulldown_menu_sub(void)
                action_write_protect_off->setText(QApplication::translate("MenuMedia", "Off", 0));
                action_write_protect_off->setToolTip(QApplication::translate("MenuMedia", "Disable write protection.\nYou *can* write datas to this media.", 0));
        }
-       
+
        if(use_d88_menus) {
                menu_inner_media->setTitle(QApplication::translate("MenuMedia", "Select D88 Image", 0));
        } else {
                //menu_inner_media->setVisible(false);
-       }               
+       }
        menu_history->setTitle(QApplication::translate("MenuMedia", "Recent opened", 0));
 
 }
@@ -578,4 +579,3 @@ void Menu_MetaClass::setEmu(EMU_TEMPLATE *p)
 {
 
 }
-
index addd172..aa3db87 100644 (file)
@@ -29,8 +29,9 @@ class QMenuBar;
 class QAction;
 class QActionGroup;
 class QFileDialog;
-class CSP_DiskDialog;
 
+class CSP_DiskDialog;
+class EmuThreadClassBase;
 class USING_FLAGS;
 class Action_Control;
 
@@ -52,7 +53,7 @@ protected:
        QWidget *p_wid;
        QMenuBar *menu_root;
        config_t *p_config;
-       
+
        QMenu *menu_inner_media;
        QMenu *menu_history;
        QMenu *menu_write_protect;
@@ -61,7 +62,7 @@ protected:
        QIcon icon_eject;
        QIcon icon_write_protected;
        QIcon icon_write_enabled;
-       
+
        class Action_Control *action_insert;
        class Action_Control *action_eject;
        class Action_Control *action_recent;
@@ -74,21 +75,21 @@ protected:
        QActionGroup *action_group_recent;
        QActionGroup *action_group_inner_media;
        QActionGroup *action_group_protect;
-       
+
        QString object_desc;
-       
+
        int media_drive;
        int base_drive;
-       
+
        bool use_write_protect;
        bool use_d88_menus;
-       
+
        bool write_protect;
-       
+
        void create_pulldown_menu_sub(void);
        void retranslate_pulldown_menu_sub(void);
        void do_open_dialog_common(CSP_DiskDialog* dlg);
-  
+
        QString window_title;
        QString initial_dir;
        QStringList ext_filter;
@@ -110,6 +111,8 @@ public:
        bool getWriteProtect(void) {
                return write_protect;
        }
+       virtual void connect_via_emu_thread(EmuThreadClassBase *p);
+
        //QAction *menuAction(void);
 public slots:
        void do_set_write_protect(bool f);
@@ -122,7 +125,7 @@ public slots:
        void do_write_protect_media(void);
        void do_write_unprotect_media(void);
        void do_add_media_extension(QString ext, QString description);
-       
+
        void do_set_initialize_directory(const char *dir);
        virtual void do_open_dialog(void);
        void do_clear_inner_media(void);
@@ -135,7 +138,7 @@ public slots:
        void do_set_window_title(QString s);
        void do_close_window();
        void do_finish(int i);
-       
+
 signals:
        int sig_open_media(int, QString);
        int sig_eject_media(int);
index 944c031..894af6f 100644 (file)
 
 #include "menu_cmt.h"
 #include "menu_flags.h"
+#include "osdcall_types.h"
 
-//extern std::shared_ptr<USING_FLAGS> using_flags;
 void Ui_MainWindowBase::CreateCMTMenu(int drive, int base_drv)
 {
        QString ext_play;
        QString ext_rec;
        QString desc_play;
        QString desc_rec;
-       
+
        listCMT[drive].clear();
        menu_CMT[drive] = new Menu_CMTClass(menubar, QString::fromUtf8("CMT"), using_flags, this, drive, base_drv);
        menu_CMT[drive]->setObjectName(QString::fromUtf8("menuCMT", -1));
-       
-       menu_CMT[drive]->create_pulldown_menu();        
+
+       menu_CMT[drive]->create_pulldown_menu();
        // Translate Menu
        SETUP_HISTORY(p_config->recent_tape_path[drive], listCMT[drive]);
        menu_CMT[drive]->do_set_write_protect(false);
@@ -70,139 +70,72 @@ void Ui_MainWindowBase::CreateCMTMenu(int drive, int base_drv)
        menu_CMT[drive]->do_add_rec_media_extension(ext_rec, desc_rec);
 }
 
-int Ui_MainWindowBase::set_recent_cmt(int drv, int num) 
+int Ui_MainWindowBase::set_recent_cmt(int drv, int num)
 {
        QString s_path;
-       char path_shadow[PATH_MAX];
 
-       if((num < 0) || (num >= MAX_HISTORY)) return -1;
-    
-       s_path = QString::fromLocal8Bit(p_config->recent_tape_path[drv][num]);
-       memset(path_shadow, 0x00, PATH_MAX * sizeof(char));
-       strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX - 1);
-       UPDATE_HISTORY(path_shadow, p_config->recent_tape_path[drv], listCMT[drv]);
-   
-       strcpy(p_config->initial_tape_dir, get_parent_dir(path_shadow));
-       memset(path_shadow, 0x00, PATH_MAX * sizeof(char));
-       strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX - 1);
-       csp_logger->debug_log(CSP_LOG_DEBUG, CSP_LOG_TYPE_VFILE_CMT + 0, "Open READ (from history) : filename = %s", s_path.toLocal8Bit().constData());
-       
-       emit sig_close_tape(drv);
-       emit sig_play_tape(drv, s_path);
-       menu_CMT[drv]->do_update_histories(listCMT[drv]);
-       menu_CMT[drv]->do_set_initialize_directory(p_config->initial_tape_dir);
-       return 0;
-}
+       if(using_flags.get() == nullptr) return -1;
 
-void Ui_MainWindowBase::do_write_protect_cmt(int drv, bool flag)
-{
-       //cmt_write_protect[drv] = flag;
-}
-
-
-void Ui_MainWindowBase::do_push_play_tape(int drive)
-{
-       // Do notify?
-       emit sig_cmt_push_play(drive);
-}
-
-void Ui_MainWindowBase::do_push_stop_tape(int drive)
-{
-       // Do notify?
-       emit sig_cmt_push_stop(drive);
-}
-
-void Ui_MainWindowBase::do_push_fast_forward_tape(int drive)
-{
-       // Do notify?
-       emit sig_cmt_push_fast_forward(drive);
-}
-void Ui_MainWindowBase::do_push_rewind_tape(int drive)
-{
-       // Do notify?
-       emit sig_cmt_push_fast_rewind(drive);
-}
-void Ui_MainWindowBase::do_push_apss_forward_tape(int drive)
-{
-       // Do notify?
-       emit sig_cmt_push_apss_forward(drive);
-}
-void Ui_MainWindowBase::do_push_apss_rewind_tape(int drive)
-{
-       // Do notify?
-       emit sig_cmt_push_apss_rewind(drive);
-}
+       std::shared_ptr<USING_FLAGS> p = using_flags;
+       if(p->get_max_tape() <= drv) return -1;
+       if(drv < 0) return -1;
+       if((num < 0) || (num >= MAX_HISTORY)) return -1;
 
-void Ui_MainWindowBase::set_wave_shaper(int drive, bool f)
-{
-       if(f) {
-               p_config->wave_shaper[drive] = 1;
-       } else {
-               p_config->wave_shaper[drive] = 0;
+       s_path = QString::fromLocal8Bit(p_config->recent_tape_path[drv][num]);
+       if(!(s_path.isEmpty())) {
+               do_open_read_cmt(drv, s_path);
+               return 0;
        }
+       return -1;
 }
 
+
 bool Ui_MainWindowBase::get_wave_shaper(int drive)
 {
        if(p_config->wave_shaper[drive] == 0) return false;
        return true;
 }
 
-void Ui_MainWindowBase::set_direct_load_from_mzt(int drive, bool f)
-{
-       if(f) {
-               p_config->direct_load_mzt[drive] = 1;
-       } else {
-               p_config->direct_load_mzt[drive] = 0;
-       }
-}
-
 bool Ui_MainWindowBase::get_direct_load_mzt(int drive)
 {
        if(p_config->direct_load_mzt[drive] == 0) return false;
        return true;
 }
 
-void Ui_MainWindowBase::eject_cmt(int drv) 
+void Ui_MainWindowBase::eject_cmt(int drv)
 {
        emit sig_close_tape(drv);
 }
 
-void Ui_MainWindowBase::do_open_read_cmt(int drive, QString path) 
+void Ui_MainWindowBase::do_open_read_cmt(int drive, QString path)
 {
-       char path_shadow[PATH_MAX];
-
+       if(using_flags.get() == nullptr) return;
        if(path.length() <= 0) return;
-       memset(path_shadow, 0x00, PATH_MAX * sizeof(char));
-       strncpy(path_shadow, path.toLocal8Bit().constData(), PATH_MAX - 1);
-       UPDATE_HISTORY(path_shadow, p_config->recent_tape_path[drive], listCMT[drive]);
-       strcpy(p_config->initial_tape_dir, get_parent_dir(path_shadow));
-       // Copy filename again.
-       memset(path_shadow, 0x00, PATH_MAX * sizeof(char));
-       strncpy(path_shadow, path.toLocal8Bit().constData(), PATH_MAX - 1);
+       std::shared_ptr<USING_FLAGS> p = using_flags;
+       if(p->get_max_tape() <= drive) return;
+       if(drive < 0) return;
 
        emit sig_close_tape(drive);
-       csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_VFILE_CMT + 0, "Open READ : filename = %s", path_shadow);
+
+       if(!(FILEIO::IsFileExisting(path.toLocal8Bit().constData()))) return;
        emit sig_play_tape(drive, path);
-       menu_CMT[drive]->do_update_histories(listCMT[drive]);
-       menu_CMT[drive]->do_set_initialize_directory(p_config->initial_tape_dir);
 }
 
-void Ui_MainWindowBase::do_open_write_cmt(int drive, QString path) 
+void Ui_MainWindowBase::do_open_write_cmt(int drive, QString path)
 {
-       char path_shadow[PATH_MAX];
-
+       if(using_flags.get() == nullptr) return;
        if(path.length() <= 0) return;
-       memset(path_shadow, 0x00, PATH_MAX * sizeof(char));
-       strncpy(path_shadow, path.toLocal8Bit().constData(), PATH_MAX - 1);
-       UPDATE_HISTORY(path_shadow, p_config->recent_tape_path[drive], listCMT[drive]);
-       get_parent_dir(path_shadow);
-       strcpy(p_config->initial_tape_dir,      get_parent_dir(path_shadow));
-       // Copy filename again.
-       memset(path_shadow, 0x00, PATH_MAX * sizeof(char));
-       strncpy(path_shadow, path.toLocal8Bit().constData(), PATH_MAX - 1);
+       std::shared_ptr<USING_FLAGS> p = using_flags;
+       if(p->get_max_tape() <= drive) return;
+       if(drive < 0) return;
+
+       if(menu_CMT[drive] == nullptr) return;
+       _TCHAR path_shadow[_MAX_PATH] = {0};
+       my_tcscpy_s(path_shadow, _MAX_PATH - 1, path.toLocal8Bit().constData());
 
        emit sig_close_tape(drive);
+       if(!(FILEIO::IsFileExisting(path_shadow))) return;
+
        if(menu_CMT[drive]->getWriteProtect() != false) {
                csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_VFILE_CMT + 0, "Open READ : filename = %s", path_shadow);
                emit sig_play_tape(drive, path);
@@ -210,10 +143,47 @@ void Ui_MainWindowBase::do_open_write_cmt(int drive, QString path)
                csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_VFILE_CMT + 0, "Open Write : filename = %s", path_shadow);
                emit sig_rec_tape(drive, path);
        }
-       menu_CMT[drive]->do_update_histories(listCMT[drive]);
-       menu_CMT[drive]->do_set_initialize_directory(p_config->initial_tape_dir);
+//     menu_CMT[drive]->do_update_histories(listCMT[drive]);
+//     menu_CMT[drive]->do_set_initialize_directory(p_config->initial_tape_dir);
 }
 
+void Ui_MainWindowBase::do_ui_tape_play_insert_history(int drv, QString fname)
+{
+       if(fname.length() <= 0) return;
+       if(using_flags->get_max_tape() <= drv) return;
+
+       _TCHAR path_shadow[_MAX_PATH] = {0};
+       strncpy(path_shadow, fname.toLocal8Bit().constData(), _MAX_PATH - 1);
+       if(!(FILEIO::IsFileExisting(path_shadow))) return;
+
+       UPDATE_HISTORY(fname, p_config->recent_tape_path[drv], listCMT[drv]);
+       strcpy(p_config->initial_tape_dir,      get_parent_dir((const _TCHAR *)path_shadow));
+       // Update List
+       if(menu_CMT[drv] != nullptr) {
+               menu_CMT[drv]->do_set_initialize_directory(p_config->initial_tape_dir);
+               menu_CMT[drv]->do_update_histories(listCMT[drv]);
+       }
+}
+void Ui_MainWindowBase::do_ui_tape_record_insert_history(int drv, QString fname)
+{
+       do_ui_tape_play_insert_history(drv, fname);
+}
+
+void Ui_MainWindowBase::do_ui_write_protect_tape(int drive, quint64 flag)
+{
+       if(drive < 0) return;
+
+       std::shared_ptr<USING_FLAGS>p = using_flags;
+       if(p.get() == nullptr) return;
+       if(!(p->is_use_tape()) || (p->get_max_tape() <= drive)) return;
+       if(menu_CMT[drive] != nullptr) return;
+
+       if((flag & EMU_MESSAGE_TYPE::WRITE_PROTECT) != 0) {
+               menu_CMT[drive]->do_set_write_protect(true);
+       } else {
+               menu_CMT[drive]->do_set_write_protect(false);
+       }
+}
 
 void Ui_MainWindowBase::retranslateCMTMenu(int drive)
 {
index 48a6f4d..436f025 100644 (file)
@@ -25,15 +25,15 @@ int Ui_MainWindowBase::do_emu_write_protect_floppy_disk(int drv, bool flag)
 {
        std::shared_ptr<USING_FLAGS> p = using_flags;
        if(p.get() == nullptr) return -1;
-       
+
        if((drv < 0) || (drv >= p->get_max_drive())) return -1;
-       
+
        emit sig_write_protect_floppy_disk(drv, flag);
        return 0;
 }
-  
 
-void Ui_MainWindowBase::eject_fd(int drv) 
+
+void Ui_MainWindowBase::eject_fd(int drv)
 {
        emit sig_close_floppy_disk(drv);
        menu_fds[drv]->do_clear_inner_media();
@@ -48,11 +48,11 @@ void Ui_MainWindowBase::CreateFloppyMenu(int drv, int drv_base)
                QString desc1 = "Floppy Disk";
                menu_fds[drv] = new Menu_FDClass(menubar, QString::fromUtf8("Floppy"), using_flags, this, drv, drv_base);
                menu_fds[drv]->create_pulldown_menu();
-               
+
                menu_fds[drv]->do_clear_inner_media();
                menu_fds[drv]->do_add_media_extension(ext, desc1);
 
-       
+
                SETUP_HISTORY(p_config->recent_floppy_disk_path[drv], listFDs[drv]);
                menu_fds[drv]->do_update_histories(listFDs[drv]);
                menu_fds[drv]->do_set_initialize_directory(p_config->initial_floppy_disk_dir);
@@ -81,7 +81,7 @@ void Ui_MainWindowBase::retranslateFloppyMenu(int drv, int basedrv, QString spec
        drive_name = QString::fromUtf8("[") + QString::number(basedrv) + QString::fromUtf8(":] ");
        drive_name = drive_name + specName;
        //drive_name += QString::number(basedrv);
-  
+
        if((drv < 0) || (drv >= using_flags->get_max_drive())) return;
        menu_fds[drv]->setTitle(QApplication::translate("MenuMedia", drive_name.toUtf8().constData() , 0));
        menu_fds[drv]->retranslateUi();
@@ -101,12 +101,3 @@ void Ui_MainWindowBase::do_update_floppy_history(int drive, QStringList lst)
                menu_fds[drive]->do_update_histories(lst);
        }
 }
-
-void Ui_MainWindowBase::do_insert_floppy_history(int drive, QString path)
-{
-       if((drive < 0) || (drive >= using_flags->get_max_drive())) {
-               if(menu_fds[drive] != nullptr) {
-                       menu_fds[drive]->do_insert_history(path);
-               }
-       }
-}
index 3c9497e..4ffd26a 100644 (file)
@@ -795,6 +795,7 @@ signals:
        int sig_ui_tape_eject(int);
        int sig_ui_tape_position(int, int);
        int sig_ui_tape_message(int, QString);
+       int sig_ui_tape_write_protect(int, quint64);
 
        int sig_ui_tape_push_play(int);
        int sig_ui_tape_push_stop(int);