Disable OK button in resize dialog per default, enabling it if something's

modified.

svn path=/trunk/playground/sysadmin/partitionmanager/; revision=868381
This commit is contained in:
Volker Lanz 2008-10-06 08:01:28 +00:00
parent d1de6bce91
commit f2e2bbdfe3
4 changed files with 18 additions and 0 deletions

View File

@ -58,6 +58,17 @@ ResizeDialog::~ResizeDialog()
saveDialogSize(kcg);
}
void ResizeDialog::setupDialog()
{
SizeDialogBase::setupDialog();
enableButtonOk(false);
}
void ResizeDialog::setDirty()
{
enableButtonOk(isModified());
}
/** @return true if the user modified anything */
bool ResizeDialog::isModified() const
{

View File

@ -51,6 +51,8 @@ class ResizeDialog : public SizeDialogBase
virtual bool canGrow() const;
virtual bool canShrink() const;
virtual bool canMove() const;
virtual void setupDialog();
virtual void setDirty();
protected:
qint64 originalFirstSector() const { return m_OriginalFirstSector; }

View File

@ -125,6 +125,7 @@ void SizeDialogBase::onSectorsBeforeChanged(qint64 newBefore)
dialogWidget().spinFreeBefore().disconnect(this);
dialogWidget().spinFreeBefore().setValue(sectorsToDialogUnit(partition(), preferredUnit(), newBefore));
connect(&dialogWidget().spinFreeBefore(), SIGNAL(valueChanged(int)), SLOT(onFreeSpaceBeforeChanged(int)));
setDirty();
}
void SizeDialogBase::onSectorsAfterChanged(qint64 newAfter)
@ -132,6 +133,7 @@ void SizeDialogBase::onSectorsAfterChanged(qint64 newAfter)
dialogWidget().spinFreeAfter().disconnect(this);
dialogWidget().spinFreeAfter().setValue(sectorsToDialogUnit(partition(), preferredUnit(), newAfter));
connect(&dialogWidget().spinFreeAfter(), SIGNAL(valueChanged(int)), SLOT(onFreeSpaceAfterChanged(int)));
setDirty();
}
void SizeDialogBase::onLengthChanged(qint64 newLength)
@ -160,6 +162,7 @@ void SizeDialogBase::onFreeSpaceBeforeChanged(int newBefore)
}
dialogWidget().partResizerWidget().updateSectors(newSectorsBefore, newSectorsAfter);
setDirty();
}
void SizeDialogBase::onFreeSpaceAfterChanged(int newAfter)
@ -175,6 +178,7 @@ void SizeDialogBase::onFreeSpaceAfterChanged(int newAfter)
}
dialogWidget().partResizerWidget().updateSectors(newSectorsBefore, newSectorsAfter);
setDirty();
}
const PartitionTable& SizeDialogBase::partitionTable() const

View File

@ -65,6 +65,7 @@ class SizeDialogBase : public KDialog
virtual qint64 maxSectors() const;
virtual qint64 freeSectorsBefore() const { return m_FreeSectorsBefore; }
virtual qint64 freeSectorsAfter() const { return m_FreeSectorsAfter; }
virtual void setDirty() {}
static int sectorsToDialogUnit(const Partition& p, Capacity::Unit u, qint64 v);
static qint64 dialogUnitToSectors(const Partition& p, Capacity::Unit u, int v);