OSDN Git Service

[UI][Qt][EMU] Available to build.Some features still be wrong :-(
[csp-qt/common_source_project-fm7.git] / source / src / qt / gui / util_fd.cpp
1 /*
2  * UI->Qt->MainWindow : FDD Utils.
3  * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
4  * License: GPLv2
5  *
6  * History:
7  * Jan 24, 2014 : Moved from some files.
8  */
9 #include <QApplication>
10
11 #include "mainwidget_base.h"
12 #include "commonclasses.h"
13 #include "menu_disk.h"
14
15 #include "qt_dialogs.h"
16 #include "csp_logger.h"
17
18 #include "menu_flags.h"
19
20 //extern std::shared_ptr<USING_FLAGS> using_flags;
21 //extern class EMU *emu;
22
23
24 int Ui_MainWindowBase::write_protect_fd(int drv, bool flag)
25 {
26         if((drv < 0) || (drv >= using_flags->get_max_drive())) return -1;
27         emit sig_write_protect_disk(drv, flag);
28         return 0;
29 }
30   
31
32 void Ui_MainWindowBase::eject_fd(int drv) 
33 {
34         emit sig_close_disk(drv);
35         menu_fds[drv]->do_clear_inner_media();
36 }
37
38 // Common Routine
39
40 void Ui_MainWindowBase::CreateFloppyMenu(int drv, int drv_base)
41 {
42         {
43                 QString ext = "*.d88 *.d77 *.1dd *.td0 *.imd *.dsk *.nfd *.fdi *.hdm *.hd5 *.hd4 *.hdb *.dd9 *.dd6 *.tfd *.xdf *.2d *.sf7 *.img *.ima *.vfd";
44                 QString desc1 = "Floppy Disk";
45                 menu_fds[drv] = new Menu_FDClass(menubar, QString::fromUtf8("Floppy"), using_flags, this, drv, drv_base);
46                 menu_fds[drv]->create_pulldown_menu();
47                 
48                 menu_fds[drv]->do_clear_inner_media();
49                 menu_fds[drv]->do_add_media_extension(ext, desc1);
50
51         
52                 SETUP_HISTORY(p_config->recent_floppy_disk_path[drv], listFDs[drv]);
53                 menu_fds[drv]->do_update_histories(listFDs[drv]);
54                 menu_fds[drv]->do_set_initialize_directory(p_config->initial_floppy_disk_dir);
55                 listD88[drv].clear();
56         }
57 }
58
59 void Ui_MainWindowBase::CreateFloppyPulldownMenu(int drv)
60 {
61 }
62
63 void Ui_MainWindowBase::ConfigFloppyMenuSub(int drv)
64 {
65 }
66
67 void Ui_MainWindowBase::retranslateFloppyMenu(int drv, int basedrv)
68 {
69         QString s = QApplication::translate("MenuMedia", "FDD", 0);
70         s = s + QString::number(basedrv);
71         retranslateFloppyMenu(drv, basedrv, s);
72 }
73
74 void Ui_MainWindowBase::retranslateFloppyMenu(int drv, int basedrv, QString specName)
75 {
76         QString drive_name;
77         drive_name = QString::fromUtf8("[") + QString::number(basedrv) + QString::fromUtf8(":] ");
78         drive_name = drive_name + specName;
79         //drive_name += QString::number(basedrv);
80   
81         if((drv < 0) || (drv >= using_flags->get_max_drive())) return;
82         menu_fds[drv]->setTitle(QApplication::translate("MenuMedia", drive_name.toUtf8().constData() , 0));
83         menu_fds[drv]->retranslateUi();
84 }
85
86 void Ui_MainWindowBase::ConfigFloppyMenu(void)
87 {
88         for(int i = 0; i < using_flags->get_max_drive(); i++) {
89                 ConfigFloppyMenuSub(i);
90         }
91 }
92
93 void Ui_MainWindowBase::do_update_floppy_history(int drive, QStringList lst)
94 {
95         if((drive < 0) || (drive >= using_flags->get_max_drive())) {
96                 if(menu_fds[drive] != nullptr) {
97                         menu_fds[drive]->do_update_histories(lst);
98                 }
99         }
100 }
101
102 void Ui_MainWindowBase::do_insert_floppy_history(int drive, QString path)
103 {
104         if((drive < 0) || (drive >= using_flags->get_max_drive())) {
105                 if(menu_fds[drive] != nullptr) {
106                         menu_fds[drive]->do_insert_history(path);
107                 }
108         }
109 }