-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateimagedialog.cpp
executable file
·126 lines (109 loc) · 3.02 KB
/
createimagedialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include "createimagedialog.h"
#include "ui_createimagedialog.h"
CreateImageDialog::CreateImageDialog(QWidget *parent) :
QDialog(parent),
m_ui(new Ui::CreateImageDialog)
{
Qt::WindowFlags flags = windowFlags();
flags = flags & (~Qt::WindowContextHelpButtonHint);
setWindowFlags(flags);
m_ui->setupUi(this);
connect(m_ui->sectorsSpin, SIGNAL(valueChanged(int)), SLOT(recalculate()));
connect(m_ui->densityCombo, SIGNAL(currentIndexChanged(int)), SLOT(recalculate()));
}
CreateImageDialog::~CreateImageDialog()
{
delete m_ui;
}
void CreateImageDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
break;
default:
break;
}
}
int CreateImageDialog::sectorCount()
{
return m_ui->sectorsSpin->value();
}
int CreateImageDialog::sectorSize()
{
switch (m_ui->densityCombo->currentIndex()) {
case 0:
return 128;
case 1:
return 256;
case 2:
return 512;
case 3:
return 8192;
default:
return 0;
}
}
void CreateImageDialog::recalculate()
{
int sectors = m_ui->sectorsSpin->value();
int size = sectors * sectorSize();
if (m_ui->densityCombo->currentIndex() == 1) {
if (sectors <= 3) {
size = sectors * 128;
} else {
size -= 384;
}
}
int sizeK = (size + 512) / 1024;
m_ui->capacityLabel->setText(tr("Total image capacity: %1 bytes (%2 K)")
.arg(size)
.arg(sizeK));
}
void CreateImageDialog::on_stdEnhancedButton_toggled(bool checked)
{
if (checked) {
m_ui->sectorsSpin->setValue(1040);
m_ui->densityCombo->setCurrentIndex(0);
m_ui->geometryWidget->setEnabled(false);
}
}
void CreateImageDialog::on_stdSingleButton_toggled(bool checked)
{
if (checked) {
m_ui->sectorsSpin->setValue(720);
m_ui->densityCombo->setCurrentIndex(0);
m_ui->geometryWidget->setEnabled(false);
}
}
void CreateImageDialog::on_stdDoubleButton_toggled(bool checked)
{
if (checked) {
m_ui->sectorsSpin->setValue(720);
m_ui->densityCombo->setCurrentIndex(1);
m_ui->geometryWidget->setEnabled(false);
}
}
void CreateImageDialog::on_doubleDoubleButton_toggled(bool checked)
{
if (checked) {
m_ui->sectorsSpin->setValue(1440);
m_ui->densityCombo->setCurrentIndex(1);
m_ui->geometryWidget->setEnabled(false);
}
}
void CreateImageDialog::on_customButton_toggled(bool checked)
{
if (checked) {
m_ui->geometryWidget->setEnabled(true);
}
}
void CreateImageDialog::on_harddiskButton_toggled(bool checked)
{
if (checked) {
m_ui->sectorsSpin->setValue(65535);
m_ui->densityCombo->setCurrentIndex(1);
m_ui->geometryWidget->setEnabled(false);
}
}