Skip to content

Commit

Permalink
libappfw|SliderWidget: Use defined precision in edit popup
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 1, 2014
1 parent 6cc8d9e commit de244c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions doomsday/libappfw/include/de/widgets/sliderwidget.h
Expand Up @@ -56,6 +56,7 @@ class LIBAPPFW_PUBLIC SliderWidget : public GuiWidget

Ranged range() const;
ddouble value() const;
int precision() const;
ddouble displayFactor() const;

// Events.
Expand Down
12 changes: 10 additions & 2 deletions doomsday/libappfw/src/widgets/sliderwidget.cpp
Expand Up @@ -44,7 +44,8 @@ class ValuePopup : public PopupWidget
connect(_edit, SIGNAL(enterPressed(QString)), this, SLOT(close()));
_edit->rule().setInput(Rule::Width, slider.style().rules().rule("slider.editor"));

_edit->setText(QString::number(slider.value() * slider.displayFactor(), 'g', 4));
_edit->setText(QString::number(slider.value() * slider.displayFactor(), 'f',
slider.precision()));
}

LineEditWidget &editor() const
Expand Down Expand Up @@ -462,7 +463,9 @@ SliderWidget::SliderWidget(String const &name)

// Default size.
rule().setInput(Rule::Width, style().rules().rule("slider.width"))
.setInput(Rule::Height, font().height() + margins().height());
.setInput(Rule::Height, OperatorRule::maximum(
style().fonts().font("default").height(),
font().height()) + margins().height());
}

void SliderWidget::setRange(Rangei const &intRange, int step)
Expand Down Expand Up @@ -529,6 +532,11 @@ ddouble SliderWidget::value() const
return d->value;
}

int SliderWidget::precision() const
{
return d->precision;
}

ddouble SliderWidget::displayFactor() const
{
return d->displayFactor;
Expand Down

0 comments on commit de244c6

Please sign in to comment.