Permalink
Browse files

ENH: Terminology selector reset name and color button states

Reset name and color buttons in the terminology selector were always enabled. This change makes them enabled only if the current name or color are not the generated ones, respectively. This is useful to indicate when it is possible to reset these properties.

Re https://issues.slicer.org/view.php?id=4658

git-svn-id: http://svn.slicer.org/Slicer4/trunk@27575 3bd1e089-480b-0410-8dfb-8563597acbee
  • Loading branch information...
cpinter
cpinter committed Nov 28, 2018
1 parent dbc9fe7 commit bf22f21aa2180c0ff647247c2f63cd91248ef0b3
Showing with 16 additions and 0 deletions.
  1. +16 −0 Modules/Loadable/Terminologies/Widgets/qSlicerTerminologyNavigatorWidget.cxx
@@ -379,6 +379,9 @@ void qSlicerTerminologyNavigatorWidgetPrivate::setNameFromCurrentTerminology()
// Set to auto-generated
this->NameAutoGenerated = true;
// Disable reset name button
this->pushButton_ResetName->setEnabled(false);
this->lineEdit_Name->blockSignals(true); // The callback function is to save the user's manual name entry
this->lineEdit_Name->setText(name);
this->lineEdit_Name->blockSignals(false);
@@ -424,6 +427,9 @@ void qSlicerTerminologyNavigatorWidgetPrivate::setRecommendedColorFromCurrentTer
// Set to auto-generated
this->ColorAutoGenerated = true;
// Disable reset color button
this->pushButton_ResetColor->setEnabled(false);
this->ColorPickerButton_RecommendedRGB->blockSignals(true); // The callback function is to save the user's custom color selection
this->ColorPickerButton_RecommendedRGB->setColor(QColor(r,g,b));
this->ColorPickerButton_RecommendedRGB->blockSignals(false);
@@ -572,6 +578,7 @@ void qSlicerTerminologyNavigatorWidget::setTerminologyInfo(TerminologyInfoBundle
{
qWarning() << Q_FUNC_INFO << ": Failed to set terminology entry from given terminology info bundle";
}
bool noneType = (d->CurrentTypeObject->GetCodeValue() == NULL);
// Set name
if (terminologyInfo.Name.isEmpty())
@@ -586,6 +593,7 @@ void qSlicerTerminologyNavigatorWidget::setTerminologyInfo(TerminologyInfoBundle
d->lineEdit_Name->blockSignals(false);
d->NameAutoGenerated = terminologyInfo.NameAutoGenerated;
d->pushButton_ResetName->setEnabled(!d->NameAutoGenerated && !noneType);
}
// Store generated color. It is used when the selected terminology contains no recommended color
@@ -607,6 +615,7 @@ void qSlicerTerminologyNavigatorWidget::setTerminologyInfo(TerminologyInfoBundle
d->ColorPickerButton_RecommendedRGB->blockSignals(false);
d->ColorAutoGenerated = terminologyInfo.ColorAutoGenerated;
d->pushButton_ResetColor->setEnabled(!d->ColorAutoGenerated && !noneType);
}
}
@@ -1457,6 +1466,7 @@ bool qSlicerTerminologyNavigatorWidget::setCurrentType(vtkSlicerTerminologyType*
// Reset current type modifier
d->resetCurrentTypeModifier();
// Null type means None selection
if (!type)
{
d->resetCurrentType();
@@ -1692,6 +1702,9 @@ void qSlicerTerminologyNavigatorWidget::onNameChanged(QString name)
// Set as manual
d->NameAutoGenerated = false;
// Enable reset name button
d->pushButton_ResetName->setEnabled(true);
}
//-----------------------------------------------------------------------------
@@ -1709,6 +1722,9 @@ void qSlicerTerminologyNavigatorWidget::onColorChanged(QColor color)
// Set as manual
d->ColorAutoGenerated = false;
// Enable reset color button
d->pushButton_ResetColor->setEnabled(true);
}
//-----------------------------------------------------------------------------

0 comments on commit bf22f21

Please sign in to comment.