2017-07-21 18:21:34 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "QskSeparator.h"
|
|
|
|
#include "QskAspect.h"
|
|
|
|
|
|
|
|
QSK_SUBCONTROL( QskSeparator, Panel )
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
QskSeparator::QskSeparator( QQuickItem* parent )
|
|
|
|
: QskSeparator( Qt::Horizontal, parent )
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
QskSeparator::QskSeparator( Qt::Orientation orientation, QQuickItem* parent )
|
|
|
|
: Inherited( parent )
|
|
|
|
, m_orientation( orientation )
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
|
|
|
if ( orientation == Qt::Horizontal )
|
2017-08-31 09:09:05 +02:00
|
|
|
initSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Fixed );
|
2017-07-21 18:21:34 +02:00
|
|
|
else
|
2017-08-31 09:09:05 +02:00
|
|
|
initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Minimum );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QskSeparator::~QskSeparator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void QskSeparator::setOrientation( Qt::Orientation orientation )
|
|
|
|
{
|
|
|
|
if ( orientation == m_orientation )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_orientation = orientation;
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
// swapping the size policy: guess this is what a user expects
|
|
|
|
setSizePolicy( sizePolicy( Qt::Vertical ), sizePolicy( Qt::Horizontal ) );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
resetImplicitSize();
|
|
|
|
update();
|
|
|
|
|
|
|
|
Q_EMIT orientationChanged( m_orientation );
|
|
|
|
}
|
|
|
|
|
|
|
|
Qt::Orientation QskSeparator::orientation() const
|
|
|
|
{
|
|
|
|
return m_orientation;
|
|
|
|
}
|
|
|
|
|
2017-09-01 12:27:08 +02:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
QSizeF QskSeparator::contentsSizeHint() const
|
|
|
|
{
|
2017-09-01 12:27:08 +02:00
|
|
|
const qreal m = thickness();
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
if ( m_orientation == Qt::Horizontal )
|
|
|
|
return QSizeF( -1, m );
|
|
|
|
else
|
|
|
|
return QSizeF( m, -1 );
|
|
|
|
}
|
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
QskAspect::Placement QskSeparator::effectivePlacement() const
|
|
|
|
{
|
2019-04-17 16:33:17 +02:00
|
|
|
return static_cast< QskAspect::Placement >( m_orientation );
|
2017-10-17 17:34:00 +02:00
|
|
|
}
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
#include "moc_QskSeparator.cpp"
|