Hard disk dialog improvements
* Fix file field widget * Hard disk dialog is now identical to Win32
This commit is contained in:
@@ -9,7 +9,10 @@ FileField::FileField(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
connect(ui->label, &QLineEdit::editingFinished, this, [this] () { emit fileSelected(ui->label->text()); });
|
connect(ui->label, &QLineEdit::editingFinished, this, [this] () {
|
||||||
|
fileName_ = ui->label->text();
|
||||||
|
emit fileSelected(ui->label->text());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
FileField::~FileField()
|
FileField::~FileField()
|
||||||
|
@@ -22,6 +22,7 @@ public:
|
|||||||
QString selectedFilter() const { return selectedFilter_; }
|
QString selectedFilter() const { return selectedFilter_; }
|
||||||
|
|
||||||
void setCreateFile(bool createFile) { createFile_ = createFile; }
|
void setCreateFile(bool createFile) { createFile_ = createFile; }
|
||||||
|
bool createFile() { return createFile_; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void fileSelected(const QString& fileName);
|
void fileSelected(const QString& fileName);
|
||||||
|
@@ -47,7 +47,6 @@ HarddiskDialog::HarddiskDialog(bool existing, QWidget *parent) :
|
|||||||
} else {
|
} else {
|
||||||
setWindowTitle(tr("Add New Hard Disk"));
|
setWindowTitle(tr("Add New Hard Disk"));
|
||||||
ui->fileField->setCreateFile(true);
|
ui->fileField->setCreateFile(true);
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &HarddiskDialog::onCreateNewFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* model = ui->comboBoxFormat->model();
|
auto* model = ui->comboBoxFormat->model();
|
||||||
@@ -248,6 +247,14 @@ static MVHDGeom create_drive_vhd_diff(const QString& fileName, const QString& pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HarddiskDialog::onCreateNewFile() {
|
void HarddiskDialog::onCreateNewFile() {
|
||||||
|
|
||||||
|
for (auto& curObject : children())
|
||||||
|
{
|
||||||
|
if (qobject_cast<QWidget*>(curObject)) qobject_cast<QWidget*>(curObject)->setDisabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->progressBar->setEnabled(true);
|
||||||
|
setResult(QDialog::Rejected);
|
||||||
qint64 size = ui->lineEditSize->text().toUInt() << 20U;
|
qint64 size = ui->lineEditSize->text().toUInt() << 20U;
|
||||||
if (size > 0x1FFFFFFE00ll) {
|
if (size > 0x1FFFFFFE00ll) {
|
||||||
QMessageBox::critical(this, tr("Disk image too large"), tr("Disk images cannot be larger than 127 GB."));
|
QMessageBox::critical(this, tr("Disk image too large"), tr("Disk images cannot be larger than 127 GB."));
|
||||||
@@ -323,18 +330,16 @@ void HarddiskDialog::onCreateNewFile() {
|
|||||||
} else if (img_format >= 3) { /* VHD file */
|
} else if (img_format >= 3) { /* VHD file */
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
MVHDGeom _86box_geometry;
|
MVHDGeom _86box_geometry{};
|
||||||
int block_size = ui->comboBoxBlockSize->currentIndex() == 0 ? MVHD_BLOCK_LARGE : MVHD_BLOCK_SMALL;
|
int block_size = ui->comboBoxBlockSize->currentIndex() == 0 ? MVHD_BLOCK_LARGE : MVHD_BLOCK_SMALL;
|
||||||
switch (img_format) {
|
switch (img_format) {
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
QProgressDialog progress(tr("86Box"), QString(), 0, 100, this);
|
connect(this, &HarddiskDialog::fileProgress, this, [this] (int value) { ui->progressBar->setValue(value); QApplication::processEvents(); } );
|
||||||
connect(this, &HarddiskDialog::fileProgress, &progress, &QProgressDialog::setValue);
|
ui->progressBar->setVisible(true);
|
||||||
std::thread writer([&_86box_geometry, fileName, this] {
|
[&_86box_geometry, fileName, this] {
|
||||||
_86box_geometry = create_drive_vhd_fixed(fileName, this, cylinders_, heads_, sectors_);
|
_86box_geometry = create_drive_vhd_fixed(fileName, this, cylinders_, heads_, sectors_);
|
||||||
});
|
}();
|
||||||
progress.exec();
|
|
||||||
writer.join();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
@@ -357,7 +362,14 @@ void HarddiskDialog::onCreateNewFile() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (img_format != 5) {
|
if (_86box_geometry.cyl == 0 &&
|
||||||
|
_86box_geometry.heads == 0 &&
|
||||||
|
_86box_geometry.spt == 0)
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Unable to write file"), tr("Make sure the file is being saved to a writable directory."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (img_format != 5) {
|
||||||
QMessageBox::information(this, tr("Disk image created"), tr("Remember to partition and format the newly-created drive."));
|
QMessageBox::information(this, tr("Disk image created"), tr("Remember to partition and format the newly-created drive."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,14 +379,15 @@ void HarddiskDialog::onCreateNewFile() {
|
|||||||
cylinders_ = _86box_geometry.cyl;
|
cylinders_ = _86box_geometry.cyl;
|
||||||
heads_ = _86box_geometry.heads;
|
heads_ = _86box_geometry.heads;
|
||||||
sectors_ = _86box_geometry.spt;
|
sectors_ = _86box_geometry.spt;
|
||||||
|
setResult(QDialog::Accepted);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// formats 0, 1 and 2
|
// formats 0, 1 and 2
|
||||||
QProgressDialog progress(tr("86Box"), QString(), 0, 100, this);
|
connect(this, &HarddiskDialog::fileProgress, this, [this] (int value) { ui->progressBar->setValue(value); QApplication::processEvents(); } );
|
||||||
connect(this, &HarddiskDialog::fileProgress, &progress, &QProgressDialog::setValue);
|
ui->progressBar->setVisible(true);
|
||||||
std::thread writer([size, &file, this] {
|
[size, &file, this] {
|
||||||
QDataStream stream(&file);
|
QDataStream stream(&file);
|
||||||
stream.setByteOrder(QDataStream::LittleEndian);
|
stream.setByteOrder(QDataStream::LittleEndian);
|
||||||
|
|
||||||
@@ -393,11 +406,10 @@ void HarddiskDialog::onCreateNewFile() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit fileProgress(100);
|
emit fileProgress(100);
|
||||||
});
|
}();
|
||||||
|
|
||||||
progress.exec();
|
|
||||||
writer.join();
|
|
||||||
QMessageBox::information(this, tr("Disk image created"), tr("Remember to partition and format the newly-created drive."));
|
QMessageBox::information(this, tr("Disk image created"), tr("Remember to partition and format the newly-created drive."));
|
||||||
|
setResult(QDialog::Accepted);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void adjust_vhd_geometry_for_86box(MVHDGeom *vhd_geometry) {
|
static void adjust_vhd_geometry_for_86box(MVHDGeom *vhd_geometry) {
|
||||||
@@ -718,3 +730,10 @@ void HarddiskDialog::on_comboBoxType_currentIndexChanged(int index) {
|
|||||||
checkAndAdjustHeads();
|
checkAndAdjustHeads();
|
||||||
checkAndAdjustSectors();
|
checkAndAdjustSectors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HarddiskDialog::accept()
|
||||||
|
{
|
||||||
|
if (ui->fileField->createFile()) onCreateNewFile();
|
||||||
|
else setResult(QDialog::Accepted);
|
||||||
|
QDialog::done(result());
|
||||||
|
}
|
||||||
|
@@ -25,6 +25,9 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void fileProgress(int i);
|
void fileProgress(int i);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void accept() override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_comboBoxType_currentIndexChanged(int index);
|
void on_comboBoxType_currentIndexChanged(int index);
|
||||||
void on_lineEditSectors_textEdited(const QString &arg1);
|
void on_lineEditSectors_textEdited(const QString &arg1);
|
||||||
@@ -35,7 +38,6 @@ private slots:
|
|||||||
void on_comboBoxFormat_currentIndexChanged(int index);
|
void on_comboBoxFormat_currentIndexChanged(int index);
|
||||||
void onCreateNewFile();
|
void onCreateNewFile();
|
||||||
void onExistingFileSelected(const QString& fileName);
|
void onExistingFileSelected(const QString& fileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::HarddiskDialog *ui;
|
Ui::HarddiskDialog *ui;
|
||||||
|
|
||||||
|
@@ -6,18 +6,107 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>393</width>
|
<width>421</width>
|
||||||
<height>223</height>
|
<height>269</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="3" column="2">
|
<item row="0" column="1" colspan="5">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="FileField" name="fileField" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="4">
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Heads:</string>
|
<string>Channel:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="4">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Sectors:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="2">
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>Type:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEditCylinders">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>64</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEditSize">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>64</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Size (MB):</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="5">
|
||||||
|
<widget class="QComboBox" name="comboBoxChannel"/>
|
||||||
|
</item>
|
||||||
|
<item row="11" column="0" colspan="6">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="0" colspan="6">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cylinders:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -40,75 +129,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1" colspan="3">
|
|
||||||
<widget class="QComboBox" name="comboBoxFormat"/>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="5">
|
|
||||||
<widget class="QComboBox" name="comboBoxChannel"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>File name:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QLineEdit" name="lineEditCylinders">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>64</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="8" column="0" colspan="6">
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="1" colspan="3">
|
|
||||||
<widget class="QComboBox" name="comboBoxBlockSize"/>
|
|
||||||
</item>
|
|
||||||
<item row="9" column="0" colspan="6">
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Cylinders:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="4">
|
|
||||||
<widget class="QLabel" name="label_7">
|
|
||||||
<property name="text">
|
|
||||||
<string>Channel:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QLabel" name="labelFormat">
|
<widget class="QLabel" name="labelFormat">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -116,22 +136,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="3" column="2">
|
||||||
<widget class="QLineEdit" name="lineEditSize">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="sizePolicy">
|
<property name="text">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<string>Heads:</string>
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>64</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="3" colspan="3">
|
||||||
|
<widget class="QComboBox" name="comboBoxType"/>
|
||||||
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QLabel" name="label_8">
|
<widget class="QLabel" name="label_8">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -139,39 +153,11 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1" colspan="3">
|
<item row="6" column="1" colspan="3">
|
||||||
<widget class="QComboBox" name="comboBoxBus"/>
|
<widget class="QComboBox" name="comboBoxFormat"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="4">
|
<item row="7" column="1" colspan="3">
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QComboBox" name="comboBoxBlockSize"/>
|
||||||
<property name="text">
|
|
||||||
<string>Sectors:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="0">
|
|
||||||
<widget class="QLabel" name="labelBlockSize">
|
|
||||||
<property name="text">
|
|
||||||
<string>Block Size:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="3" colspan="3">
|
|
||||||
<widget class="QComboBox" name="comboBoxType"/>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="2">
|
|
||||||
<widget class="QLabel" name="label_6">
|
|
||||||
<property name="text">
|
|
||||||
<string>Type:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Size (MB):</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="3">
|
<item row="3" column="3">
|
||||||
<widget class="QLineEdit" name="lineEditHeads">
|
<widget class="QLineEdit" name="lineEditHeads">
|
||||||
@@ -192,8 +178,35 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" colspan="5">
|
<item row="5" column="1" colspan="3">
|
||||||
<widget class="FileField" name="fileField" native="true"/>
|
<widget class="QComboBox" name="comboBoxBus"/>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0">
|
||||||
|
<widget class="QLabel" name="labelBlockSize">
|
||||||
|
<property name="text">
|
||||||
|
<string>Block Size:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>File name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0" colspan="6">
|
||||||
|
<widget class="QProgressBar" name="progressBar">
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="textVisible">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="visible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
Reference in New Issue
Block a user