• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

Common Source Code Project for Qt (a.k.a for FM-7).


Commit MetaInfo

Revision5c2ed532f5698e6b97188043844aad5a44fedbc9 (tree)
Time2019-01-12 22:41:19
AuthorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[UI][Qt] Implement new feature of upstream 2018-12-28.

Change Summary

Incremental Difference

--- a/source/src/common.cpp
+++ b/source/src/common.cpp
@@ -399,6 +399,7 @@ DWORD DLL_PREFIX MyGetPrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName,
399399 lpp[0] = '\0';
400400 }
401401 FILEIO* fio = new FILEIO();
402+ if(!(fio->IsFileExisting(lpFileName))) return 0;
402403 if(fio->Fopen(lpFileName, FILEIO_READ_ASCII)) {
403404 bool in_section = false;
404405 char section[1024], line[1024], *equal;
@@ -424,7 +425,7 @@ DWORD DLL_PREFIX MyGetPrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName,
424425 fio->Fclose();
425426 }
426427 delete fio;
427- //csp_logger->debug_log(CSP_LOG_DEBUG, CSP_LOG_TYPE_GENERAL, "Try App: %s Key: %s", lpAppName, lpKeyName);
428+ csp_logger->debug_log(CSP_LOG_DEBUG, CSP_LOG_TYPE_GENERAL, "Try App: %s Key: %s", lpAppName, lpKeyName);
428429 return strlen(lpp);
429430 }
430431
--- a/source/src/qt/common/util_fd2.cpp
+++ b/source/src/qt/common/util_fd2.cpp
@@ -31,16 +31,6 @@ int Ui_MainWindowBase::set_d88_slot(int drive, int num)
3131 //path = QString::fromUtf8(emu->d88_file[drive].path);
3232 path = hRunEmu->get_d88_file_path(drive);
3333 menu_fds[drive]->do_select_inner_media(num);
34-#if 0
35- if(emu && emu->d88_file[drive].cur_bank != num) {
36- emit sig_open_disk(drive, path, num);
37- if(emu->is_floppy_disk_protected(drive)) {
38- menu_fds[drive]->do_set_write_protect(true);
39- } else {
40- menu_fds[drive]->do_set_write_protect(false);
41- }
42- }
43-#else
4434 if(hRunEmu->get_d88_file_cur_bank(drive) != num) {
4535 emit sig_open_disk(drive, path, num);
4636 if(hRunEmu->is_floppy_disk_protected(drive)) {
@@ -49,7 +39,6 @@ int Ui_MainWindowBase::set_d88_slot(int drive, int num)
4939 menu_fds[drive]->do_set_write_protect(false);
5040 }
5141 }
52-#endif
5342 return 0;
5443 }
5544
--- a/source/src/qt/gui/menu_disk.cpp
+++ b/source/src/qt/gui/menu_disk.cpp
@@ -19,12 +19,109 @@ Menu_FDClass::Menu_FDClass(QMenuBar *root_entry, QString desc, USING_FLAGS *p, Q
1919 use_write_protect = true;
2020 use_d88_menus = true;
2121 icon_floppy = QIcon(":/icon_floppy.png");
22+
23+ for(int i = 0; i < 4; i++) {
24+ type_mask[i] = true;
25+ }
2226 }
2327
2428 Menu_FDClass::~Menu_FDClass()
2529 {
2630 }
2731
32+void Menu_FDClass::do_set_create_mask(quint8 type, bool flag)
33+{
34+ switch(type) {
35+ case 0x00: // 2D
36+ type_mask[0] = flag;
37+ break;
38+ case 0x10: // 2DD
39+ type_mask[1] = flag;
40+ break;
41+ case 0x20: // 2HD
42+ type_mask[2] = flag;
43+ break;
44+ case 0x30: // 2HD/1.44M
45+ type_mask[3] = flag;
46+ break;
47+ }
48+}
49+
50+void Menu_FDClass::do_open_dialog_create_fd()
51+{
52+ CSP_CreateDiskDialog dlg(type_mask);
53+
54+ if(initial_dir.isEmpty()) {
55+ QDir dir;
56+ char app[PATH_MAX];
57+ initial_dir = dir.currentPath();
58+ strncpy(app, initial_dir.toLocal8Bit().constData(), PATH_MAX - 1);
59+ initial_dir = QString::fromLocal8Bit(get_parent_dir(app));
60+ }
61+
62+ dlg.dlg->setDirectory(initial_dir);
63+ QString create_ext = QString::fromUtf8("*.d88 *.d77");
64+ QString create_desc = QString::fromUtf8("D88/D77 Virtual Floppy Image.");
65+ QString all = QString::fromUtf8("All Files (*.*)");
66+ QString tmps = create_desc;
67+ tmps.append(QString::fromUtf8(" ("));
68+ tmps.append(create_ext.toLower());
69+ tmps.append(QString::fromUtf8(" "));
70+ tmps.append(create_ext.toUpper());
71+ tmps.append(QString::fromUtf8(")"));
72+ QStringList __filter;
73+ __filter.clear();
74+ __filter << tmps;
75+ __filter << all;
76+ __filter.removeDuplicates();
77+ dlg.dlg->setNameFilters(__filter);
78+
79+ tmps.clear();
80+ tmps = QApplication::translate("MenuMedia", "Create D88/D77 virtual floppy", 0);
81+ if(!window_title.isEmpty()) {
82+ tmps = tmps + QString::fromUtf8(" ") + window_title;
83+ } else {
84+ tmps = tmps + QString::fromUtf8(" ") + this->title();
85+ }
86+ dlg.dlg->setWindowTitle(tmps);
87+
88+ QObject::connect(&dlg, SIGNAL(sig_create_disk(quint8, QString)), this, SLOT(do_create_media(quint8, QString)));
89+
90+ dlg.show();
91+ dlg.dlg->exec();
92+ return;
93+}
94+
95+void Menu_FDClass::do_create_media(quint8 media_type, QString name)
96+{
97+
98+ if(!(name.isEmpty())) {
99+#pragma pack(1)
100+ struct {
101+ char title[17];
102+ uint8_t rsrv[9];
103+ uint8_t protect;
104+ uint8_t type;
105+ uint32_t size;
106+ uint32_t trkptr[164];
107+ } d88_hdr;
108+#pragma pack()
109+ memset(&d88_hdr, 0, sizeof(d88_hdr));
110+ my_strcpy_s(d88_hdr.title, sizeof(d88_hdr.title), "BLANK");
111+ d88_hdr.type = media_type;
112+ d88_hdr.size = sizeof(d88_hdr);
113+
114+ FILEIO *fio = new FILEIO();
115+ if(fio->Fopen(name.toUtf8().data(), FILEIO_WRITE_BINARY)) {
116+ fio->Fwrite(&d88_hdr, sizeof(d88_hdr), 1);
117+ fio->Fclose();
118+ emit sig_open_media(media_drive, name);
119+ }
120+ delete fio;
121+ }
122+}
123+
124+
28125 void Menu_FDClass::create_pulldown_menu_device_sub(void)
29126 {
30127 config_t *p;
@@ -43,6 +140,10 @@ void Menu_FDClass::create_pulldown_menu_device_sub(void)
43140 action_count_immediate->setCheckable(true);
44141 action_count_immediate->binds->setDrive(media_drive);
45142
143+ action_create_fd = new Action_Control(p_wid, using_flags);
144+ action_create_fd->setVisible(true);
145+ action_create_fd->setCheckable(false);
146+
46147 p = p_config;
47148 if(p != NULL) {
48149 if(p->correct_disk_timing[media_drive]) action_correct_timing->setChecked(true);
@@ -55,6 +156,8 @@ void Menu_FDClass::create_pulldown_menu_device_sub(void)
55156 void Menu_FDClass::connect_menu_device_sub(void)
56157 {
57158 this->addSeparator();
159+ this->addAction(action_create_fd);
160+ this->addSeparator();
58161 this->addAction(action_ignore_crc_error);
59162 this->addAction(action_correct_timing);
60163 this->addAction(action_count_immediate);
@@ -67,7 +170,9 @@ void Menu_FDClass::connect_menu_device_sub(void)
67170
68171 connect(action_count_immediate, SIGNAL(toggled(bool)),
69172 action_count_immediate->binds, SLOT(do_set_disk_count_immediate(bool)));
70-
173+
174+ connect(action_create_fd, SIGNAL(triggered()), this, SLOT(do_open_dialog_create_fd()));
175+
71176 connect(this, SIGNAL(sig_open_media(int, QString)), p_wid, SLOT(_open_disk(int, QString)));
72177 connect(this, SIGNAL(sig_eject_media(int)), p_wid, SLOT(eject_fd(int)));
73178 connect(this, SIGNAL(sig_write_protect_media(int, bool)), p_wid, SLOT(write_protect_fd(int, bool)));
@@ -86,6 +191,9 @@ void Menu_FDClass::retranslate_pulldown_menu_device_sub(void)
86191 action_correct_timing->setText(QApplication::translate("MenuMedia", "Correct transfer timing", 0));
87192 action_correct_timing->setToolTip(QApplication::translate("MenuMedia", "Correct transferring timing.\nUseful for some softwares\n needs strict transfer timing.", 0));
88193
194+ action_create_fd->setText(QApplication::translate("MenuMedia", "Create Virtual Floppy", 0));
195+ action_create_fd->setToolTip(QApplication::translate("MenuMedia", "Create and mount virtual blank-floppy disk.\nThis makes only D88/D77 format.", 0));
196+
89197 action_count_immediate->setText(QApplication::translate("MenuMedia", "Immediate increment", 0));
90198 action_count_immediate->setToolTip(QApplication::translate("MenuMedia", "Increment data pointer immediately.\nThis is test hack for MB8877.\nUseful for some softwares\n needs strict transfer timing.", 0));
91199 }
--- a/source/src/qt/gui/menu_disk.h
+++ b/source/src/qt/gui/menu_disk.h
@@ -16,16 +16,23 @@ QT_BEGIN_NAMESPACE
1616 class DLL_PREFIX Menu_FDClass: public Menu_MetaClass {
1717 Q_OBJECT
1818 protected:
19+ class Action_Control *action_create_fd;
1920 class Action_Control *action_ignore_crc_error;
2021 class Action_Control *action_correct_timing;
2122 class Action_Control *action_count_immediate;
2223 QIcon icon_floppy;
24+ bool type_mask[6];
2325 public:
2426 Menu_FDClass(QMenuBar *root_entry, QString desc, USING_FLAGS *p, QWidget *parent = 0, int drv = 0, int base_drv = 1);
2527 ~Menu_FDClass();
2628 void create_pulldown_menu_device_sub();
2729 void connect_menu_device_sub(void);
2830 void retranslate_pulldown_menu_device_sub(void);
31+
32+public slots:
33+ void do_open_dialog_create_fd();
34+ void do_create_media(quint8 media_type, QString name);
35+ void do_set_create_mask(quint8 type, bool flag);
2936 };
3037
3138 QT_END_NAMESPACE
--- a/source/src/qt/gui/qt_dialogs.cpp
+++ b/source/src/qt/gui/qt_dialogs.cpp
@@ -41,3 +41,34 @@ void CSP_DiskParams::_open_binary(QString s) {
4141 emit sig_open_binary_file(drive, s, play);
4242 }
4343
44+
45+CSP_CreateDiskDialog::CSP_CreateDiskDialog(bool *masks, QWidget *parent = 0) : QWidget(parent)
46+{
47+ __real_media_type = 0x00;
48+ dlg = new QFileDialog(NULL, Qt::Widget);
49+ dlg->setParent(this);
50+ dlg->setOption(QFileDialog::ReadOnly, false);
51+ dlg->setOption(QFileDialog::DontConfirmOverwrite, false);
52+ dlg->setOption(QFileDialog::DontUseNativeDialog, true);
53+ dlg->setAcceptMode(QFileDialog::AcceptSave);
54+ dlg->setFileMode(QFileDialog::AnyFile);
55+
56+ param = new CSP_FileParams();
57+ if(masks[0]) media_type.addItem(QString::fromUtf8("2D"), (const quint8)0x00);
58+ if(masks[1]) media_type.addItem(QString::fromUtf8("2DD"), (const quint8)0x10);
59+ if(masks[2]) media_type.addItem(QString::fromUtf8("2HD"), (const quint8)0x20);
60+ if(masks[3]) media_type.addItem(QString::fromUtf8("2HD/1.44M"), (const quint8)0x30);
61+
62+ type_label.setText(QApplication::translate("MenuMedia", "Virtual FD type:", 0));
63+ type_label.setToolTip(QApplication::translate("MenuMedia", "Select type of virtual floppy.", 0));
64+
65+ layout.addWidget(&type_label, 1, 0);
66+ layout.addWidget(&media_type, 1, 1);
67+ layout.addWidget(dlg, 2, 0, 2, 4);
68+
69+ this->setLayout(&layout);
70+ connect(&media_type, SIGNAL(activated(int)), this, SLOT(do_set_type(int)));
71+ connect(dlg, SIGNAL(fileSelected(QString)), this, SLOT(do_create_disk(QString)));
72+
73+}
74+
--- a/source/src/qt/gui/qt_dialogs.h
+++ b/source/src/qt/gui/qt_dialogs.h
@@ -11,6 +11,11 @@
1111 #define _CSP_QT_DIALOGS_H
1212
1313 #include <QFileDialog>
14+#include <QComboBox>
15+#include <QGridLayout>
16+#include <QLabel>
17+#include <QApplication>
18+#include <QWindow>
1419
1520 #include "qt_main.h"
1621
@@ -66,6 +71,32 @@ public:
6671 delete param;
6772 }
6873 } CSP_DiskDialog;
74+
75+class CSP_CreateDiskDialog : public QWidget {
76+ Q_OBJECT
77+ quint8 __real_media_type;
78+ QComboBox media_type;
79+ QLabel type_label;
80+ QGridLayout layout;
81+public:
82+ QFileDialog* dlg;
83+ CSP_FileParams *param;
84+ CSP_CreateDiskDialog(bool *masks, QWidget *parent = 0);
85+ ~CSP_CreateDiskDialog() {
86+ delete param;
87+ delete dlg;
88+ }
89+signals:
90+ int sig_create_disk(quint8, QString);
91+public slots:
92+ void do_set_type(int i) {
93+ __real_media_type = media_type.itemData(i).toUInt();
94+ }
95+ void do_create_disk(QString s) {
96+ emit sig_create_disk(__real_media_type, s);
97+ }
98+};
99+
69100 QT_END_NAMESPACE
70101
71102 #endif //End.
--- a/source/src/qt/gui/util_fd.cpp
+++ b/source/src/qt/gui/util_fd.cpp
@@ -61,6 +61,7 @@ void Object_Menu_Control::do_set_disk_count_immediate(bool flag)
6161 emit sig_emu_update_config();
6262 }
6363
64+
6465 int Ui_MainWindowBase::write_protect_fd(int drv, bool flag)
6566 {
6667 if((drv < 0) || (drv >= using_flags->get_max_drive())) return -1;
@@ -87,6 +88,8 @@ void Ui_MainWindowBase::CreateFloppyMenu(int drv, int drv_base)
8788
8889 menu_fds[drv]->do_clear_inner_media();
8990 menu_fds[drv]->do_add_media_extension(ext, desc1);
91+
92+
9093 SETUP_HISTORY(p_config->recent_floppy_disk_path[drv], listFDs[drv]);
9194 menu_fds[drv]->do_update_histories(listFDs[drv]);
9295 menu_fds[drv]->do_set_initialize_directory(p_config->initial_floppy_disk_dir);
Show on old repository browser