thickness -> extent

This commit is contained in:
Uwe Rathmann 2020-12-15 11:01:23 +01:00
parent 1527f46d51
commit 3004b8b74f
2 changed files with 18 additions and 23 deletions

View File

@ -8,11 +8,6 @@
QSK_SUBCONTROL( QskSeparator, Panel ) QSK_SUBCONTROL( QskSeparator, Panel )
static inline QskAspect::Aspect qskAspectThickness()
{
return QskSeparator::Panel | QskAspect::Metric | QskAspect::Size;
}
QskSeparator::QskSeparator( QQuickItem* parent ) QskSeparator::QskSeparator( QQuickItem* parent )
: QskSeparator( Qt::Horizontal, parent ) : QskSeparator( Qt::Horizontal, parent )
{ {
@ -55,36 +50,36 @@ Qt::Orientation QskSeparator::orientation() const
return m_orientation; return m_orientation;
} }
void QskSeparator::setThickness( qreal thickness ) void QskSeparator::setExtent( qreal extent )
{ {
thickness = qMax( thickness, 0.0 ); extent = qMax( extent, 0.0 );
const auto aspect = qskAspectThickness(); const auto aspect = Panel | QskAspect::Size;
if ( thickness != metric( aspect ) ) if ( extent != metric( aspect ) )
{ {
setMetric( aspect, thickness ); setMetric( aspect, extent );
resetImplicitSize(); resetImplicitSize();
update(); update();
Q_EMIT thicknessChanged( thickness ); Q_EMIT extentChanged( extent );
} }
} }
qreal QskSeparator::thickness() const qreal QskSeparator::extent() const
{ {
return metric( qskAspectThickness() ); return metric( Panel | QskAspect::Size );
} }
void QskSeparator::resetThickness() void QskSeparator::resetExtent()
{ {
if ( resetHint( qskAspectThickness() ) ) if ( resetMetric( Panel | QskAspect::Size ) )
{ {
resetImplicitSize(); resetImplicitSize();
update(); update();
Q_EMIT thicknessChanged( thickness() ); Q_EMIT extentChanged( extent() );
} }
} }
@ -94,7 +89,7 @@ QSizeF QskSeparator::contentsSizeHint(
if ( which != Qt::PreferredSize ) if ( which != Qt::PreferredSize )
return QSizeF(); return QSizeF();
const qreal m = thickness(); const qreal m = extent();
if ( m_orientation == Qt::Horizontal ) if ( m_orientation == Qt::Horizontal )
return QSizeF( -1, m ); return QSizeF( -1, m );

View File

@ -15,8 +15,8 @@ class QSK_EXPORT QskSeparator : public QskControl
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 thickness READ thickness Q_PROPERTY( qreal extent READ extent
WRITE setThickness RESET resetThickness NOTIFY thicknessChanged ) WRITE setExtent RESET resetExtent NOTIFY extentChanged )
using Inherited = QskControl; using Inherited = QskControl;
@ -31,15 +31,15 @@ class QSK_EXPORT QskSeparator : public QskControl
void setOrientation( Qt::Orientation ); void setOrientation( Qt::Orientation );
Qt::Orientation orientation() const; Qt::Orientation orientation() const;
void setThickness( qreal thickness ); void setExtent( qreal thickness );
void resetThickness(); void resetExtent();
qreal thickness() const; qreal extent() const;
QskAspect::Placement effectivePlacement() const override; QskAspect::Placement effectivePlacement() const override;
Q_SIGNALS: Q_SIGNALS:
void orientationChanged( Qt::Orientation ); void orientationChanged( Qt::Orientation );
void thicknessChanged( qreal ); void extentChanged( qreal );
protected: protected:
QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override; QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override;