Use PartResizerWidget in CreatePartitionDialog
This commit is contained in:
parent
38c685dc10
commit
5c9c414988
@ -18,6 +18,7 @@
|
||||
|
||||
#include <CreatePartitionDialog.h>
|
||||
|
||||
#include <PartitionSizeController.h>
|
||||
#include <PartitionInfo.h>
|
||||
#include <PMUtils.h>
|
||||
#include <ui_CreatePartitionDialog.h>
|
||||
@ -116,7 +117,8 @@ CreatePartitionDialog::createPartition()
|
||||
);
|
||||
}
|
||||
|
||||
PartitionSizeWidget::SectorRange range = m_ui->sizeSpinBox->sectorRange();
|
||||
qint64 first = m_partResizerWidgetPartition->firstSector();
|
||||
qint64 last = m_partResizerWidgetPartition->lastSector();
|
||||
|
||||
FileSystem::Type fsType = m_role.has( PartitionRole::Extended )
|
||||
? FileSystem::Extended
|
||||
@ -125,7 +127,7 @@ CreatePartitionDialog::createPartition()
|
||||
m_parent,
|
||||
*m_device,
|
||||
m_role,
|
||||
fsType, range.first, range.second );
|
||||
fsType, first, last );
|
||||
|
||||
PartitionInfo::setMountPoint( partition, m_ui->mountPointComboBox->currentText() );
|
||||
PartitionInfo::setFormat( partition, true );
|
||||
@ -145,10 +147,25 @@ CreatePartitionDialog::updateMountPointUi()
|
||||
m_ui->mountPointComboBox->setEnabled( enabled );
|
||||
}
|
||||
|
||||
void
|
||||
CreatePartitionDialog::initPartResizerWidget( Partition* partition )
|
||||
{
|
||||
PartitionSizeController* controller = new PartitionSizeController( this );
|
||||
m_partResizerWidgetPartition.reset( PMUtils::clonePartition( m_device, partition ) );
|
||||
|
||||
qint64 minFirstSector = partition->firstSector() - m_device->partitionTable()->freeSectorsBefore( *partition );
|
||||
qint64 maxLastSector = partition->lastSector() + m_device->partitionTable()->freeSectorsAfter( *partition );
|
||||
m_ui->partResizerWidget->init( *m_device, *m_partResizerWidgetPartition, minFirstSector, maxLastSector );
|
||||
|
||||
controller->init( m_device, m_partResizerWidgetPartition.data() );
|
||||
controller->setPartResizerWidget( m_ui->partResizerWidget );
|
||||
controller->setSpinBox( m_ui->sizeSpinBox );
|
||||
}
|
||||
|
||||
void
|
||||
CreatePartitionDialog::initFromFreeSpace( Partition* freeSpacePartition )
|
||||
{
|
||||
m_ui->sizeSpinBox->init( m_device, freeSpacePartition );
|
||||
initPartResizerWidget( freeSpacePartition );
|
||||
}
|
||||
|
||||
void
|
||||
@ -164,7 +181,7 @@ CreatePartitionDialog::initFromPartitionToCreate( Partition* partition )
|
||||
return;
|
||||
}
|
||||
|
||||
m_ui->sizeSpinBox->init( m_device, partition );
|
||||
initPartResizerWidget( partition );
|
||||
|
||||
// File System
|
||||
FileSystem::Type fsType = partition->fileSystem().type();
|
||||
|
@ -49,10 +49,11 @@ private:
|
||||
Device* m_device;
|
||||
PartitionNode* m_parent;
|
||||
PartitionRole m_role = PartitionRole( PartitionRole::None );
|
||||
QScopedPointer< Partition > m_partResizerWidgetPartition;
|
||||
|
||||
void initGptPartitionTypeUi();
|
||||
void initMbrPartitionTypeUi();
|
||||
void initSectorRange( Partition* );
|
||||
void initPartResizerWidget( Partition* );
|
||||
};
|
||||
|
||||
#endif /* CREATEPARTITIONDIALOG_H */
|
||||
|
@ -14,9 +14,25 @@
|
||||
<string>Create a Partition</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="PartResizerWidget" name="partResizerWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>59</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="partitionTypeLabel">
|
||||
<property name="text">
|
||||
<string>Partition &Type:</string>
|
||||
@ -26,7 +42,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="primaryRadioButton">
|
||||
@ -67,7 +83,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>F&ile System:</string>
|
||||
@ -77,27 +93,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="fsComboBox"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Si&ze:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>sizeSpinBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="PartitionSizeWidget" name="sizeSpinBox">
|
||||
<property name="suffix">
|
||||
<string> MB</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="5" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -113,7 +112,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="mountPointLabel">
|
||||
<property name="text">
|
||||
<string>&Mount Point:</string>
|
||||
@ -123,7 +122,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="QComboBox" name="mountPointComboBox">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
@ -163,7 +162,7 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -176,7 +175,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -189,6 +188,23 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Si&ze:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>sizeSpinBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="sizeSpinBox">
|
||||
<property name="suffix">
|
||||
<string> MB</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@ -205,15 +221,15 @@
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>PartitionSizeWidget</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header location="global">PartitionSizeWidget.h</header>
|
||||
<class>PartResizerWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">gui/partresizerwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>primaryRadioButton</tabstop>
|
||||
<tabstop>fsComboBox</tabstop>
|
||||
<tabstop>sizeSpinBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
Loading…
Reference in New Issue
Block a user