using QskSeparator::Panel | QskAspect::Size for the thickness of a
separator
This commit is contained in:
parent
16585a708d
commit
d6902f144c
|
@ -50,9 +50,29 @@ Qt::Orientation QskSeparator::orientation() const
|
||||||
return m_orientation;
|
return m_orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskSeparator::setThickness( qreal thickness )
|
||||||
|
{
|
||||||
|
thickness = qMax( thickness, 0.0 );
|
||||||
|
|
||||||
|
if ( thickness != metric( QskSeparator::Panel | QskAspect::Size ) )
|
||||||
|
{
|
||||||
|
setMetric( QskSeparator::Panel | QskAspect::Size, thickness );
|
||||||
|
|
||||||
|
resetImplicitSize();
|
||||||
|
update();
|
||||||
|
|
||||||
|
Q_EMIT thicknessChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal QskSeparator::thickness() const
|
||||||
|
{
|
||||||
|
return metric( QskSeparator::Panel | QskAspect::Size );
|
||||||
|
}
|
||||||
|
|
||||||
QSizeF QskSeparator::contentsSizeHint() const
|
QSizeF QskSeparator::contentsSizeHint() const
|
||||||
{
|
{
|
||||||
const qreal m = metric( Panel );
|
const qreal m = thickness();
|
||||||
|
|
||||||
if ( m_orientation == Qt::Horizontal )
|
if ( m_orientation == Qt::Horizontal )
|
||||||
return QSizeF( -1, m );
|
return QSizeF( -1, m );
|
||||||
|
|
|
@ -16,6 +16,9 @@ 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
|
||||||
|
WRITE setThickness NOTIFY thicknessChanged )
|
||||||
|
|
||||||
using Inherited = QskControl;
|
using Inherited = QskControl;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -23,15 +26,20 @@ public:
|
||||||
|
|
||||||
QskSeparator( QQuickItem* parent = nullptr );
|
QskSeparator( QQuickItem* parent = nullptr );
|
||||||
QskSeparator( Qt::Orientation, QQuickItem* parent = nullptr );
|
QskSeparator( Qt::Orientation, QQuickItem* parent = nullptr );
|
||||||
|
|
||||||
virtual ~QskSeparator();
|
virtual ~QskSeparator();
|
||||||
|
|
||||||
void setOrientation( Qt::Orientation );
|
void setOrientation( Qt::Orientation );
|
||||||
Qt::Orientation orientation() const;
|
Qt::Orientation orientation() const;
|
||||||
|
|
||||||
|
void setThickness( qreal thickness );
|
||||||
|
qreal thickness() const;
|
||||||
|
|
||||||
virtual QSizeF contentsSizeHint() const override;
|
virtual QSizeF contentsSizeHint() const override;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void orientationChanged( Qt::Orientation );
|
void orientationChanged( Qt::Orientation );
|
||||||
|
void thicknessChanged() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Qt::Orientation m_orientation;
|
Qt::Orientation m_orientation;
|
||||||
|
|
|
@ -51,7 +51,7 @@ QSGNode* QskSeparatorSkinlet::updateSubNode(
|
||||||
QRectF QskSeparatorSkinlet::panelRect( const QskSeparator* separator ) const
|
QRectF QskSeparatorSkinlet::panelRect( const QskSeparator* separator ) const
|
||||||
{
|
{
|
||||||
const QRectF cr = separator->contentsRect();
|
const QRectF cr = separator->contentsRect();
|
||||||
const qreal m = separator->metric( QskSeparator::Panel );
|
const qreal m = separator->metric( QskSeparator::Panel | QskAspect::Size );
|
||||||
|
|
||||||
QRectF r;
|
QRectF r;
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,7 @@ void QskMaterialSkin::initSeparatorHints()
|
||||||
|
|
||||||
const ColorPalette& pal = m_data->palette;
|
const ColorPalette& pal = m_data->palette;
|
||||||
|
|
||||||
setMetric( Q::Panel, 4 );
|
setMetric( Q::Panel | Size, 4 );
|
||||||
setColor( Q::Panel, pal.baseColor );
|
setColor( Q::Panel, pal.baseColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ void QskSquiekSkin::initSeparatorHints()
|
||||||
|
|
||||||
const ColorPalette& pal = m_data->palette;
|
const ColorPalette& pal = m_data->palette;
|
||||||
|
|
||||||
setMetric( Q::Panel, 4 );
|
setMetric( Q::Panel | Size, 4 );
|
||||||
setColor( Q::Panel | TopCorners, pal.lighter150 );
|
setColor( Q::Panel | TopCorners, pal.lighter150 );
|
||||||
setColor( Q::Panel | BottomCorners, pal.lighter125 );
|
setColor( Q::Panel | BottomCorners, pal.lighter125 );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue