OSDN Git Service

[UI][Qt] Implement new feature of upstream 2018-12-28.
[csp-qt/common_source_project-fm7.git] / source / src / qt / gui / qt_dialogs.cpp
1 /*
2         Skelton for retropc emulator
3
4         Author : K.Ohta <whatisthis.sowhat _at_ gmail.com>
5         Date   : 2015.01.07
6
7         [Qt dialogs]
8 */
9
10 #include <stdio.h>
11 #include <string>
12 #include <vector>
13 #include "common.h"
14 //#include "emu.h"
15 #include "qt_main.h"
16 #include "qt_dialogs.h"
17
18 //#include "csp_logger.h"
19 #include "commonclasses.h"
20 //#include "menuclasses.h"
21
22 void CSP_DiskParams::_open_disk(QString s)
23 {
24         int d = getDrive();
25         //int n = d + CSP_LOG_TYPE_VFILE_FLOPPY;
26         //csp_logger->debug_log(CSP_LOG_INFO, n, "Try to open media image: %s", s.toLocal8Bit().constData());
27         emit do_open_disk(d, s);
28 }
29
30 void CSP_DiskParams::_open_cart(QString s)
31 {
32         int d = getDrive();
33         emit sig_open_cart(d, s);
34 }
35 void CSP_DiskParams::_open_cmt(QString s)
36 {
37         emit do_open_cmt(play, s);
38 }
39
40 void CSP_DiskParams::_open_binary(QString s) {
41         emit sig_open_binary_file(drive, s, play);
42 }
43
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