6#include "QskProgressIndicator.h"
8#include "QskIntervalF.h"
9#include "QskFunctions.h"
10#include "QskAnimator.h"
22 : m_indicator( indicator )
24 setAutoRepeat(
true );
27 setWindow( indicator->window() );
30 void advance( qreal value )
override
32 if ( m_indicator->setPositionHint( QskProgressIndicator::Fill, value ) )
33 m_indicator->update();
41class QskProgressIndicator::PrivateData
46 if ( !isIndeterminate )
54 if ( indicator->window() && indicator->isVisible() )
56 if ( animator ==
nullptr )
57 animator =
new PositionAnimator( indicator );
68 PositionAnimator* animator =
nullptr;
73 bool hasOrigin =
false;
74 bool isIndeterminate =
false;
77QskProgressIndicator::QskProgressIndicator( qreal min, qreal max, QQuickItem* parent )
79 , m_data( new PrivateData )
81 m_data->value = minimum();
83 connect(
this, &QskBoundedControl::boundariesChanged,
84 this, &QskProgressIndicator::adjustValue );
87QskProgressIndicator::QskProgressIndicator( QQuickItem* parent )
92QskProgressIndicator::QskProgressIndicator(
const QskIntervalF& boundaries, QQuickItem* parent )
97QskProgressIndicator::~QskProgressIndicator()
99 delete m_data->animator;
102bool QskProgressIndicator::isIndeterminate()
const
104 return m_data->isIndeterminate;
107void QskProgressIndicator::setIndeterminate(
bool on )
109 if ( on == m_data->isIndeterminate )
112 m_data->isIndeterminate = on;
113 m_data->updateIndeterminateAnimator(
this );
116 Q_EMIT indeterminateChanged( on );
119void QskProgressIndicator::setFillGradient(
const QskGradient& gradient )
124void QskProgressIndicator::resetFillGradient()
129QskGradient QskProgressIndicator::fillGradient()
const
134void QskProgressIndicator::setExtent( qreal extent )
140 Q_EMIT extentChanged( extent );
143void QskProgressIndicator::resetExtent()
146 Q_EMIT extentChanged( extent() );
149qreal QskProgressIndicator::extent()
const
153 return qMax( grooveSize, fillSize );
156void QskProgressIndicator::setOrigin( qreal origin )
158 if ( isComponentComplete() )
159 origin = boundedValue( origin );
161 if( !m_data->hasOrigin || !qskFuzzyCompare( m_data->origin, origin ) )
163 m_data->hasOrigin =
true;
164 m_data->origin = origin;
167 Q_EMIT originChanged( origin );
171void QskProgressIndicator::resetOrigin()
173 if ( m_data->hasOrigin )
175 m_data->hasOrigin =
false;
178 Q_EMIT originChanged( origin() );
182qreal QskProgressIndicator::origin()
const
184 if ( m_data->hasOrigin )
186 return boundedValue( m_data->origin );
192void QskProgressIndicator::setValue( qreal value )
194 if ( isComponentComplete() )
195 value = boundedValue( value );
197 setValueInternal( value );
200qreal QskProgressIndicator::value()
const
202 return m_data->value;
205void QskProgressIndicator::setValueAsRatio( qreal ratio )
207 ratio = qBound( 0.0, ratio, 1.0 );
208 setValue( minimum() + ratio * boundaryLength() );
211qreal QskProgressIndicator::valueAsRatio()
const
213 return valueAsRatio( m_data->value );
216void QskProgressIndicator::componentComplete()
218 Inherited::componentComplete();
222void QskProgressIndicator::adjustValue()
224 if ( isComponentComplete() )
225 setValueInternal( boundedValue( m_data->value ) );
228void QskProgressIndicator::setValueInternal( qreal value )
230 if ( !qskFuzzyCompare( value, m_data->value ) )
232 m_data->value = value;
233 Q_EMIT valueChanged( value );
239void QskProgressIndicator::itemChange( QQuickItem::ItemChange change,
240 const QQuickItem::ItemChangeData& value )
242 switch(
static_cast< int >( change ) )
244 case QQuickItem::ItemVisibleHasChanged:
245 case QQuickItem::ItemSceneChange:
247 m_data->updateIndeterminateAnimator(
this );
255#include "moc_QskProgressIndicator.cpp"
void itemChange(ItemChange, const ItemChangeData &) override
bool resetColor(QskAspect)
Removes a color hint from the local table.
QskGradient gradientHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a color hint as gradient.
bool setGradientHint(QskAspect, const QskGradient &)
Sets a gradient as color hint.
bool setMetric(QskAspect, qreal)
Sets a metric hint.
qreal metric(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a metric hint.
bool resetMetric(QskAspect)
Removes a metric hint from the local table.