2017-07-21 16:21:34 +00:00
|
|
|
/******************************************************************************
|
2024-01-17 13:31:45 +00:00
|
|
|
* QSkinny - Copyright (C) The authors
|
2023-04-06 07:23:37 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2017-07-21 16:21:34 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "QskSeparator.h"
|
|
|
|
#include "QskAspect.h"
|
|
|
|
|
|
|
|
QSK_SUBCONTROL( QskSeparator, Panel )
|
|
|
|
|
2018-08-03 06:15:28 +00:00
|
|
|
QskSeparator::QskSeparator( QQuickItem* parent )
|
|
|
|
: QskSeparator( Qt::Horizontal, parent )
|
2017-07-21 16:21:34 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-08-03 06:15:28 +00:00
|
|
|
QskSeparator::QskSeparator( Qt::Orientation orientation, QQuickItem* parent )
|
|
|
|
: Inherited( parent )
|
|
|
|
, m_orientation( orientation )
|
2017-07-21 16:21:34 +00:00
|
|
|
{
|
|
|
|
if ( orientation == Qt::Horizontal )
|
2017-08-31 07:09:05 +00:00
|
|
|
initSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Fixed );
|
2017-07-21 16:21:34 +00:00
|
|
|
else
|
2017-08-31 07:09:05 +00:00
|
|
|
initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Minimum );
|
2017-07-21 16:21:34 +00: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;
|
|
|
|
}
|
|
|
|
|
2020-12-15 10:01:23 +00:00
|
|
|
void QskSeparator::setExtent( qreal extent )
|
2017-09-01 10:27:08 +00:00
|
|
|
{
|
2020-12-27 15:31:07 +00:00
|
|
|
if ( extent < 0.0 )
|
|
|
|
extent = 0.0;
|
2017-09-01 10:27:08 +00:00
|
|
|
|
2020-12-27 15:31:07 +00:00
|
|
|
if ( setMetric( Panel | QskAspect::Size, extent ) )
|
2020-12-15 10:01:23 +00:00
|
|
|
Q_EMIT extentChanged( extent );
|
2020-12-11 14:17:09 +00:00
|
|
|
}
|
|
|
|
|
2020-12-15 10:01:23 +00:00
|
|
|
void QskSeparator::resetExtent()
|
2020-12-11 14:17:09 +00:00
|
|
|
{
|
2020-12-15 10:01:23 +00:00
|
|
|
if ( resetMetric( Panel | QskAspect::Size ) )
|
|
|
|
Q_EMIT extentChanged( extent() );
|
2020-12-27 15:31:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
qreal QskSeparator::extent() const
|
|
|
|
{
|
|
|
|
return metric( Panel | QskAspect::Size );
|
2017-09-01 10:27:08 +00:00
|
|
|
}
|
|
|
|
|
2023-02-15 15:37:54 +00:00
|
|
|
QskAspect::Variation QskSeparator::effectiveVariation() const
|
2017-10-17 15:34:00 +00:00
|
|
|
{
|
2023-02-15 15:37:54 +00:00
|
|
|
return static_cast< QskAspect::Variation >( m_orientation );
|
2017-10-17 15:34:00 +00:00
|
|
|
}
|
|
|
|
|
2017-07-21 16:21:34 +00:00
|
|
|
#include "moc_QskSeparator.cpp"
|