diff options
author | Miguel Gómez <magomez@igalia.com> | 2011-01-14 15:35:32 +0100 |
---|---|---|
committer | Holger Schröder <holger.schroeder.ext@basyskom.de> | 2011-01-25 15:30:19 +0100 |
commit | 1873b3982f1b5d18ad89824069a859bb65d8534a (patch) | |
tree | b951fd6f8c13b8e3e7c36b34e2e9b876b3ba7b06 | |
parent | 7f5c59625365cd4d353380b10289e59dce604c45 (diff) |
Fixes: NB#217955 - Seek bar slider flickers when video starts playback
RevBy: Joaquim Rocha
Details:
Add minLabelFixedWidth and maxLabelFixedWidth style properties to MSliderView
so the minimum and maximum labels can be assigned a fixed width.
-rw-r--r-- | src/views/msliderview.cpp | 17 | ||||
-rw-r--r-- | src/views/msliderview_p.h | 2 | ||||
-rw-r--r-- | src/views/style/msliderstyle.h | 10 |
3 files changed, 28 insertions, 1 deletions
diff --git a/src/views/msliderview.cpp b/src/views/msliderview.cpp index 40e96b0b..a4608ff1 100644 --- a/src/views/msliderview.cpp +++ b/src/views/msliderview.cpp @@ -246,6 +246,7 @@ MSliderIndicator::MSliderIndicator(bool isMinMax, QGraphicsItem *parent) : MWidget(parent), label(0), image(0), + fixedWidth(0), layout(0) { layout = new QGraphicsAnchorLayout; @@ -264,6 +265,7 @@ MSliderIndicator::MSliderIndicator(bool isMinMax, QGraphicsItem *parent) : image->setObjectName("MSliderImage"); layout->addAnchor(layout, Qt::AnchorVerticalCenter, label, Qt::AnchorVerticalCenter); + layout->addAnchor(layout, Qt::AnchorHorizontalCenter, label, Qt::AnchorHorizontalCenter); layout->addAnchor(layout, Qt::AnchorVerticalCenter, image, Qt::AnchorVerticalCenter); label->resize(0, 0); @@ -400,13 +402,23 @@ QSizeF MSliderIndicator::sizeHint(Qt::SizeHint which, const QSizeF &constraint) } if (label && !label->text().isEmpty()) { - width = qMax(width, label->sizeHint(Qt::PreferredSize).width()); + if (fixedWidth) { + width = fixedWidth; + } else { + width = qMax(width, label->sizeHint(Qt::PreferredSize).width()); + } height = qMax(height, label->sizeHint(Qt::PreferredSize).height()); } return QSizeF(width, height); } +void MSliderIndicator::setLabelFixedWidth(const qreal width) +{ + fixedWidth = width; + updateGeometry(); +} + MSliderHandleIndicator::MSliderHandleIndicator(QGraphicsItem* parent) : MWidget(parent), arrowPos(0), @@ -1682,6 +1694,9 @@ void MSliderView::applyStyle() d->horizontalPolicy->setSpacing(style()->grooveMargin()); d->verticalPolicy->setSpacing(style()->grooveMargin()); + d->minIndicator->setLabelFixedWidth(style()->minLabelFixedWidth()); + d->maxIndicator->setLabelFixedWidth(style()->maxLabelFixedWidth()); + d->updateOrientation(); //only to reposition slider handle diff --git a/src/views/msliderview_p.h b/src/views/msliderview_p.h index a2a890ce..32f87880 100644 --- a/src/views/msliderview_p.h +++ b/src/views/msliderview_p.h @@ -108,6 +108,7 @@ public: void setLabelStyleName(const QString &stylename); void setText(const QString &text); void setImage(const QString &id); + void setLabelFixedWidth(const qreal width); bool isEmpty() const; @@ -118,6 +119,7 @@ private: MLabel *label; MImageWidget *image; QString imageName; + qreal fixedWidth; QGraphicsAnchorLayout *layout; diff --git a/src/views/style/msliderstyle.h b/src/views/style/msliderstyle.h index 58ec49c4..ed8d647e 100644 --- a/src/views/style/msliderstyle.h +++ b/src/views/style/msliderstyle.h @@ -176,6 +176,16 @@ class M_VIEWS_EXPORT MSliderStyle : public MWidgetStyle \brief Style name of the indicator label */ M_STYLE_ATTRIBUTE(QString, indicatorStyleName, IndicatorStyleName) + /*! + \property MSlider::minLabelFixedWidth + \brief Fixed width of the minimum label of the slider, if not empty + */ + M_STYLE_ATTRIBUTE(qreal, minLabelFixedWidth, MinLabelFixedWidth) + /*! + \property MSlider::maxLabelFixedWidth + \brief Fixed width of the maximum label of the slider, if not empty + */ + M_STYLE_ATTRIBUTE(qreal, maxLabelFixedWidth, MaxLabelFixedWidth) }; class M_VIEWS_EXPORT MSliderStyleContainer : public MWidgetStyleContainer |