use QDoubleSpinBox instead of the integer version for free space before and
after and for capacity so that fractions are possible for these values svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1118931
This commit is contained in:
parent
c9a9402fbe
commit
8dcd4cd1de
8
TODO
8
TODO
|
@ -17,10 +17,16 @@ Bugs to fix for 1.1:
|
|||
|
||||
* make sure the default file system can indeed be created
|
||||
|
||||
* fs limits in sizedialog: create ext with >4GiB, set fs to fat16 --> it's
|
||||
* fs limits in sizedialog: create ext with >4GiB, set fs to fat16 --> it's
|
||||
correctly resized to 4096MiB. but if align is on, the right handle can
|
||||
still be moved to the next aligned sector
|
||||
|
||||
* changing free space before or after a partition in the size dialog base is
|
||||
broken when align is on
|
||||
|
||||
* Make sure progress dialog when scanning is hidden even if there are no devices
|
||||
to scan.
|
||||
|
||||
===============================================================================
|
||||
|
||||
For releases after 1.1:
|
||||
|
|
|
@ -70,14 +70,14 @@ qint64 SizeDialogBase::maximumLength() const
|
|||
return qMin(maximumLastSector() - minimumFirstSector() + 1, partition().maximumSectors());
|
||||
}
|
||||
|
||||
static int sectorsToDialogUnit(const Partition& p, qint64 v)
|
||||
static double sectorsToDialogUnit(const Partition& p, qint64 v)
|
||||
{
|
||||
return Capacity(v * p.sectorSize()).toInt(Capacity::preferredUnit());
|
||||
return Capacity(v * p.sectorSize()).toDouble(Capacity::preferredUnit());
|
||||
}
|
||||
|
||||
static qint64 dialogUnitToSectors(const Partition& p, int v)
|
||||
static qint64 dialogUnitToSectors(const Partition& p, double v)
|
||||
{
|
||||
return Capacity::unitFactor(Capacity::Byte, Capacity::preferredUnit()) * v / p.sectorSize();
|
||||
return v * Capacity::unitFactor(Capacity::Byte, Capacity::preferredUnit()) / p.sectorSize();
|
||||
}
|
||||
|
||||
void SizeDialogBase::setupDialog()
|
||||
|
@ -128,8 +128,7 @@ void SizeDialogBase::setupConstraints()
|
|||
detailsWidget().spinFirstSector().setRange(minimumFirstSector(), maximumLastSector());
|
||||
detailsWidget().spinLastSector().setRange(minimumFirstSector(), maximumLastSector());
|
||||
|
||||
detailsWidget().spinFirstSector().setSingleStep(PartitionAlignment::sectorAlignment(device()));
|
||||
detailsWidget().spinLastSector().setSingleStep(PartitionAlignment::sectorAlignment(device()));
|
||||
onAlignToggled(detailsWidget().checkAlign().isChecked());
|
||||
}
|
||||
|
||||
void SizeDialogBase::setupConnections()
|
||||
|
@ -137,9 +136,9 @@ void SizeDialogBase::setupConnections()
|
|||
connect(&dialogWidget().partResizerWidget(), SIGNAL(firstSectorChanged(qint64)), SLOT(onFirstSectorChanged(qint64)));
|
||||
connect(&dialogWidget().partResizerWidget(), SIGNAL(lastSectorChanged(qint64)), SLOT(onLastSectorChanged(qint64)));
|
||||
|
||||
connect(&dialogWidget().spinFreeBefore(), SIGNAL(valueChanged(int)), SLOT(onFreeSpaceBeforeChanged(int)));
|
||||
connect(&dialogWidget().spinFreeAfter(), SIGNAL(valueChanged(int)), SLOT(onFreeSpaceAfterChanged(int)));
|
||||
connect(&dialogWidget().spinCapacity(), SIGNAL(valueChanged(int)), SLOT(onCapacityChanged(int)));
|
||||
connect(&dialogWidget().spinFreeBefore(), SIGNAL(valueChanged(double)), SLOT(onFreeSpaceBeforeChanged(double)));
|
||||
connect(&dialogWidget().spinFreeAfter(), SIGNAL(valueChanged(double)), SLOT(onFreeSpaceAfterChanged(double)));
|
||||
connect(&dialogWidget().spinCapacity(), SIGNAL(valueChanged(double)), SLOT(onCapacityChanged(double)));
|
||||
|
||||
connect(&detailsWidget().spinFirstSector(), SIGNAL(valueChanged(double)), SLOT(onSpinFirstSectorChanged(double)));
|
||||
connect(&detailsWidget().spinLastSector(), SIGNAL(valueChanged(double)), SLOT(onSpinLastSectorChanged(double)));
|
||||
|
@ -167,8 +166,14 @@ void SizeDialogBase::onSpinLastSectorChanged(double newLast)
|
|||
void SizeDialogBase::onAlignToggled(bool align)
|
||||
{
|
||||
dialogWidget().partResizerWidget().setAlign(align);
|
||||
|
||||
detailsWidget().spinFirstSector().setSingleStep(align ? PartitionAlignment::sectorAlignment(device()) : 1);
|
||||
detailsWidget().spinLastSector().setSingleStep(align ? PartitionAlignment::sectorAlignment(device()) : 1);
|
||||
|
||||
const int freeStep = align ? sectorsToDialogUnit(partition(), PartitionAlignment::sectorAlignment(device())) : 1;
|
||||
|
||||
dialogWidget().spinFreeBefore().setSingleStep(freeStep);
|
||||
dialogWidget().spinFreeBefore().setSingleStep(freeStep);
|
||||
}
|
||||
|
||||
void SizeDialogBase::onFirstSectorChanged(qint64 newFirst)
|
||||
|
@ -206,26 +211,48 @@ void SizeDialogBase::updateLength(qint64 newLength)
|
|||
dialogWidget().spinCapacity().blockSignals(state);
|
||||
}
|
||||
|
||||
void SizeDialogBase::onCapacityChanged(int newCapacity)
|
||||
void SizeDialogBase::onCapacityChanged(double newCapacity)
|
||||
{
|
||||
const qint64 newLength = dialogUnitToSectors(partition(), newCapacity);
|
||||
dialogWidget().partResizerWidget().updateLength(newLength);
|
||||
}
|
||||
|
||||
void SizeDialogBase::onFreeSpaceBeforeChanged(int newBefore)
|
||||
void SizeDialogBase::onFreeSpaceBeforeChanged(double newBefore)
|
||||
{
|
||||
const qint64 newFirstSector = minimumFirstSector() + dialogUnitToSectors(partition(), newBefore);
|
||||
|
||||
if (!dialogWidget().partResizerWidget().movePartition(newFirstSector))
|
||||
dialogWidget().partResizerWidget().updateFirstSector(newFirstSector);
|
||||
{
|
||||
bool b = dialogWidget().partResizerWidget().updateFirstSector(newFirstSector);
|
||||
|
||||
if (!b)
|
||||
{
|
||||
const bool state = dialogWidget().spinFreeBefore().blockSignals(true);
|
||||
dialogWidget().spinFreeBefore().setValue(sectorsToDialogUnit(partition(), partition().firstSector() - minimumFirstSector()));
|
||||
dialogWidget().spinFreeBefore().blockSignals(state);
|
||||
}
|
||||
}
|
||||
|
||||
setDirty();
|
||||
}
|
||||
|
||||
void SizeDialogBase::onFreeSpaceAfterChanged(int newAfter)
|
||||
void SizeDialogBase::onFreeSpaceAfterChanged(double newAfter)
|
||||
{
|
||||
const qint64 newLastSector = maximumLastSector() - dialogUnitToSectors(partition(), newAfter);
|
||||
const qint64 newFirstSector = newLastSector - partition().length() + 1;
|
||||
|
||||
if (!dialogWidget().partResizerWidget().movePartition(newFirstSector))
|
||||
dialogWidget().partResizerWidget().updateLastSector(newLastSector);
|
||||
{
|
||||
bool b = dialogWidget().partResizerWidget().updateLastSector(newLastSector);
|
||||
|
||||
if (!b)
|
||||
{
|
||||
const bool state = dialogWidget().spinFreeAfter().blockSignals(true);
|
||||
dialogWidget().spinFreeAfter().setValue(sectorsToDialogUnit(partition(), maximumLastSector() - partition().lastSector()));
|
||||
dialogWidget().spinFreeAfter().blockSignals(state);
|
||||
}
|
||||
}
|
||||
|
||||
setDirty();
|
||||
}
|
||||
|
||||
|
|
|
@ -74,9 +74,9 @@ class SizeDialogBase : public KDialog
|
|||
void onFirstSectorChanged(qint64 newFirst);
|
||||
void onLastSectorChanged(qint64 newLast);
|
||||
|
||||
void onCapacityChanged(int newCapacity);
|
||||
void onFreeSpaceBeforeChanged(int newBefore);
|
||||
void onFreeSpaceAfterChanged(int newAfter);
|
||||
void onCapacityChanged(double newCapacity);
|
||||
void onFreeSpaceBeforeChanged(double newBefore);
|
||||
void onFreeSpaceAfterChanged(double newAfter);
|
||||
|
||||
void onSpinFirstSectorChanged(double newFirst);
|
||||
void onSpinLastSectorChanged(double newLast);
|
||||
|
|
|
@ -39,9 +39,9 @@ class SizeDialogWidget : public QWidget, public Ui::SizeDialogWidgetBase
|
|||
public:
|
||||
PartResizerWidget& partResizerWidget() { Q_ASSERT(m_PartResizerWidget); return *m_PartResizerWidget; }
|
||||
|
||||
QSpinBox& spinFreeBefore() { Q_ASSERT(m_SpinFreeBefore); return *m_SpinFreeBefore; }
|
||||
QSpinBox& spinFreeAfter() { Q_ASSERT(m_SpinFreeAfter); return *m_SpinFreeAfter; }
|
||||
QSpinBox& spinCapacity() { Q_ASSERT(m_SpinCapacity); return *m_SpinCapacity; }
|
||||
QDoubleSpinBox& spinFreeBefore() { Q_ASSERT(m_SpinFreeBefore); return *m_SpinFreeBefore; }
|
||||
QDoubleSpinBox& spinFreeAfter() { Q_ASSERT(m_SpinFreeAfter); return *m_SpinFreeAfter; }
|
||||
QDoubleSpinBox& spinCapacity() { Q_ASSERT(m_SpinCapacity); return *m_SpinCapacity; }
|
||||
|
||||
QLabel& labelMinSize() { Q_ASSERT(m_LabelMinSize); return *m_LabelMinSize; }
|
||||
QLabel& labelMaxSize() { Q_ASSERT(m_LabelMaxSize); return *m_LabelMaxSize; }
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1" colspan="2">
|
||||
<widget class="QSpinBox" name="m_SpinFreeBefore">
|
||||
<widget class="QDoubleSpinBox" name="m_SpinFreeBefore">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>3</horstretch>
|
||||
|
@ -224,10 +224,10 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
<double>999999999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -251,7 +251,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1" colspan="2">
|
||||
<widget class="QSpinBox" name="m_SpinCapacity">
|
||||
<widget class="QDoubleSpinBox" name="m_SpinCapacity">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>3</horstretch>
|
||||
|
@ -259,10 +259,10 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
<double>999999999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -286,7 +286,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1" colspan="2">
|
||||
<widget class="QSpinBox" name="m_SpinFreeAfter">
|
||||
<widget class="QDoubleSpinBox" name="m_SpinFreeAfter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>3</horstretch>
|
||||
|
@ -294,10 +294,10 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
<double>999999999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in New Issue