#932 AppFwk : Improved double slider

This commit is contained in:
Magne Sjaastad 2016-10-25 13:10:24 +02:00
parent 442fb04a97
commit c09e22c1df
2 changed files with 11 additions and 9 deletions

View File

@ -74,7 +74,7 @@ public:
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
virtual void fixup(QString& stringValue) const virtual void fixup(QString& stringValue) const override
{ {
double doubleValue = stringValue.toDouble(); double doubleValue = stringValue.toDouble();
doubleValue = qBound(bottom(), doubleValue, top()); doubleValue = qBound(bottom(), doubleValue, top());
@ -116,15 +116,18 @@ void PdmUiDoubleSliderEditor::configureAndUpdateUi(const QString& uiConfigName)
uiObject->editorAttribute(field()->fieldHandle(), uiConfigName, &m_attributes); uiObject->editorAttribute(field()->fieldHandle(), uiConfigName, &m_attributes);
} }
m_slider->setMaximum(m_attributes.m_sliderResolution); QString textValue = field()->uiValue().toString();
m_slider->blockSignals(true);
m_slider->setMaximum(m_attributes.m_sliderTickCount);
m_slider->blockSignals(false);
PdmDoubleValidator* pdmValidator = new PdmDoubleValidator(m_attributes.m_minimum, m_attributes.m_maximum, m_attributes.m_decimals, this); PdmDoubleValidator* pdmValidator = new PdmDoubleValidator(m_attributes.m_minimum, m_attributes.m_maximum, m_attributes.m_decimals, this);
m_lineEdit->setValidator(pdmValidator);
QString textValue = field()->uiValue().toString();
pdmValidator->fixup(textValue); pdmValidator->fixup(textValue);
m_lineEdit->setValidator(pdmValidator);
m_lineEdit->setText(textValue); m_lineEdit->setText(textValue);
updateSliderPosition(); updateSliderPosition();
} }
@ -144,7 +147,6 @@ QWidget* PdmUiDoubleSliderEditor::createEditorWidget(QWidget * parent)
connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished())); connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
m_slider = new QSlider(Qt::Horizontal, containerWidget); m_slider = new QSlider(Qt::Horizontal, containerWidget);
layout->addWidget(m_lineEdit); layout->addWidget(m_lineEdit);
layout->addWidget(m_slider); layout->addWidget(m_slider);

View File

@ -62,14 +62,14 @@ public:
m_minimum = 0; m_minimum = 0;
m_maximum = 10; m_maximum = 10;
m_decimals = 6; m_decimals = 6;
m_sliderResolution = 2000; m_sliderTickCount = 2000;
} }
public: public:
double m_minimum; double m_minimum;
double m_maximum; double m_maximum;
int m_decimals; int m_decimals;
int m_sliderResolution; int m_sliderTickCount;
}; };