diff --git a/TODO b/TODO
index ca8fd1e..eb322ca 100644
--- a/TODO
+++ b/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:
diff --git a/src/gui/sizedialogbase.cpp b/src/gui/sizedialogbase.cpp
index 81b6e7c..f4d8431 100644
--- a/src/gui/sizedialogbase.cpp
+++ b/src/gui/sizedialogbase.cpp
@@ -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();
}
diff --git a/src/gui/sizedialogbase.h b/src/gui/sizedialogbase.h
index 313cbad..dcdd54c 100644
--- a/src/gui/sizedialogbase.h
+++ b/src/gui/sizedialogbase.h
@@ -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);
diff --git a/src/gui/sizedialogwidget.h b/src/gui/sizedialogwidget.h
index e9a94da..5796e6b 100644
--- a/src/gui/sizedialogwidget.h
+++ b/src/gui/sizedialogwidget.h
@@ -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; }
diff --git a/src/gui/sizedialogwidgetbase.ui b/src/gui/sizedialogwidgetbase.ui
index dc7754d..ce301c2 100644
--- a/src/gui/sizedialogwidgetbase.ui
+++ b/src/gui/sizedialogwidgetbase.ui
@@ -216,7 +216,7 @@
-
-
+
3
@@ -224,10 +224,10 @@
- 0
+ 0.000000000000000
- 999999999
+ 999999999.000000000000000
@@ -251,7 +251,7 @@
-
-
+
3
@@ -259,10 +259,10 @@
- 0
+ 0.000000000000000
- 999999999
+ 999999999.000000000000000
@@ -286,7 +286,7 @@
-
-
+
3
@@ -294,10 +294,10 @@
- 0
+ 0.000000000000000
- 999999999
+ 999999999.000000000000000