From 004e83447b58265c83f7b91c23753d7ebff6357d Mon Sep 17 00:00:00 2001 From: Volker Lanz Date: Tue, 27 Apr 2010 11:21:16 +0000 Subject: [PATCH] turn off keyboard tracking for the spin boxes if align is on; this mostly alleviates the problems arising from overwriting the spin box values if the new value is illegal since we don't see values while they are being entered svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1119551 --- src/gui/sizedialogbase.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gui/sizedialogbase.cpp b/src/gui/sizedialogbase.cpp index 1ce9ece..fbcdca9 100644 --- a/src/gui/sizedialogbase.cpp +++ b/src/gui/sizedialogbase.cpp @@ -159,8 +159,8 @@ void SizeDialogBase::onSpinFreeBeforeChanged(double newBefore) if (success) setDirty(); else - // TODO: this is wrong, we cannot just revert the entry of invalid data here. instead, - // use the spin box's validator + // TODO: this is not the best solution: we should prevent the user from entering + // illegal values with a validator updateSpinFreeBefore(dialogUnitToSectors(partition(), oldBefore)); } @@ -252,7 +252,8 @@ void SizeDialogBase::onSpinFreeAfterChanged(double newAfter) if (success) setDirty(); else - // TODO: see above, this isn't the correct solution + // TODO: this is not the best solution: we should prevent the user from entering + // illegal values with a validator updateSpinFreeAfter(dialogUnitToSectors(partition(), oldAfter)); } @@ -261,8 +262,8 @@ void SizeDialogBase::onSpinFirstSectorChanged(double newFirst) if (newFirst >= minimumFirstSector() && dialogWidget().partResizerWidget().updateFirstSector(newFirst)) setDirty(); else - // TODO: this is not the correct solution - we cannot overwrite here if newFirst is - // invalid, we need to handle this in the spin box with the validator + // TODO: this is not the best solution: we should prevent the user from entering + // illegal values with a validator updateSpinFirstSector(partition().firstSector()); } @@ -271,7 +272,8 @@ void SizeDialogBase::onSpinLastSectorChanged(double newLast) if (newLast <= maximumLastSector() && dialogWidget().partResizerWidget().updateLastSector(newLast)) setDirty(); else - // TODO: see above + // TODO: this is not the best solution: we should prevent the user from entering + // illegal values with a validator updateSpinLastSector(partition().lastSector()); } @@ -303,6 +305,11 @@ void SizeDialogBase::onAlignToggled(bool align) dialogWidget().spinFreeBefore().setSingleStep(capacityStep); dialogWidget().spinFreeBefore().setSingleStep(capacityStep); dialogWidget().spinCapacity().setSingleStep(capacityStep); + + // if align is on, turn off keyboard tracking for all spin boxes to avoid the two clashing + foreach(QAbstractSpinBox* box, dialogWidget().findChildren() + + detailsWidget().findChildren()) + box->setKeyboardTracking(!align); } void SizeDialogBase::updateSpinFreeBefore(qint64 sectorsFreeBefore)