extent property fixed

This commit is contained in:
Uwe Rathmann 2020-12-17 08:52:30 +01:00
parent 1f2617fe86
commit 72dfde05a1
4 changed files with 31 additions and 12 deletions

View File

@ -188,25 +188,39 @@ QskGradient QskProgressBar::barGradient() const
return gradientHint( QskProgressBar::Bar ); return gradientHint( QskProgressBar::Bar );
} }
void QskProgressBar::setThickness( qreal thickness ) void QskProgressBar::setExtent( qreal extent )
{ {
// effectiveSubcontrol( QskProgressBar::Groove ) ??? extent = qMax( extent, 0.0 );
const auto aspect = QskProgressBar::Groove | QskAspect::Size;
if ( thickness != metric( aspect ) ) const auto aspect = effectiveSubcontrol( Groove ) | QskAspect::Size;
if ( extent != metric( aspect ) )
{ {
setMetric( aspect, thickness ); setMetric( aspect, extent );
resetImplicitSize(); resetImplicitSize();
update(); update();
Q_EMIT extentChanged( extent );
} }
} }
qreal QskProgressBar::thickness() const qreal QskProgressBar::extent() const
{ {
return metric( Groove | QskAspect::Size ); return metric( Groove | QskAspect::Size );
} }
void QskProgressBar::resetExtent()
{
if ( resetMetric( Groove | QskAspect::Size ) )
{
resetImplicitSize();
update();
Q_EMIT extentChanged( extent() );
}
}
void QskProgressBar::setOrigin( qreal origin ) void QskProgressBar::setOrigin( qreal origin )
{ {
if ( isComponentComplete() ) if ( isComponentComplete() )
@ -272,9 +286,9 @@ QSizeF QskProgressBar::contentsSizeHint( Qt::SizeHint which, const QSizeF& ) con
return QSizeF(); return QSizeF();
if ( orientation() == Qt::Horizontal ) if ( orientation() == Qt::Horizontal )
return QSizeF( -1, thickness() ); return QSizeF( -1, extent() );
else else
return QSizeF( thickness(), -1 ); return QSizeF( extent(), -1 );
} }
void QskProgressBar::componentComplete() void QskProgressBar::componentComplete()

View File

@ -17,6 +17,9 @@ class QSK_EXPORT QskProgressBar : public QskBoundedControl
Q_PROPERTY( Qt::Orientation orientation READ orientation Q_PROPERTY( Qt::Orientation orientation READ orientation
WRITE setOrientation NOTIFY orientationChanged ) WRITE setOrientation NOTIFY orientationChanged )
Q_PROPERTY( qreal extent READ extent
WRITE setExtent RESET resetExtent NOTIFY extentChanged )
Q_PROPERTY( bool indeterminate READ isIndeterminate Q_PROPERTY( bool indeterminate READ isIndeterminate
WRITE setIndeterminate NOTIFY indeterminateChanged ) WRITE setIndeterminate NOTIFY indeterminateChanged )
@ -52,8 +55,9 @@ class QSK_EXPORT QskProgressBar : public QskBoundedControl
void resetBarGradient(); void resetBarGradient();
QskGradient barGradient() const; QskGradient barGradient() const;
void setThickness( qreal ); void setExtent( qreal );
qreal thickness() const; void resetExtent();
qreal extent() const;
void resetOrigin(); void resetOrigin();
qreal origin() const; qreal origin() const;
@ -69,6 +73,7 @@ class QSK_EXPORT QskProgressBar : public QskBoundedControl
Q_SIGNALS: Q_SIGNALS:
void orientationChanged( Qt::Orientation ); void orientationChanged( Qt::Orientation );
void extentChanged( qreal );
void indeterminateChanged( bool ); void indeterminateChanged( bool );
void valueChanged( qreal ); void valueChanged( qreal );
void originChanged( qreal ); void originChanged( qreal );

View File

@ -54,7 +54,7 @@ void QskSeparator::setExtent( qreal extent )
{ {
extent = qMax( extent, 0.0 ); extent = qMax( extent, 0.0 );
const auto aspect = Panel | QskAspect::Size; const auto aspect = effectiveSubcontrol( Panel ) | QskAspect::Size;
if ( extent != metric( aspect ) ) if ( extent != metric( aspect ) )
{ {

View File

@ -31,7 +31,7 @@ class QSK_EXPORT QskSeparator : public QskControl
void setOrientation( Qt::Orientation ); void setOrientation( Qt::Orientation );
Qt::Orientation orientation() const; Qt::Orientation orientation() const;
void setExtent( qreal thickness ); void setExtent( qreal );
void resetExtent(); void resetExtent();
qreal extent() const; qreal extent() const;