QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskSeparator.cpp
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#include "QskSeparator.h"
7#include "QskAspect.h"
8
9QSK_SUBCONTROL( QskSeparator, Panel )
10
11QskSeparator::QskSeparator( QQuickItem* parent )
12 : QskSeparator( Qt::Horizontal, parent )
13{
14}
15
16QskSeparator::QskSeparator( Qt::Orientation orientation, QQuickItem* parent )
17 : Inherited( parent )
18 , m_orientation( orientation )
19{
20 if ( orientation == Qt::Horizontal )
21 initSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Fixed );
22 else
23 initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Minimum );
24}
25
29
30void QskSeparator::setOrientation( Qt::Orientation orientation )
31{
32 if ( orientation == m_orientation )
33 return;
34
35 m_orientation = orientation;
36
37#if 1
38 // swapping the size policy: guess this is what a user expects
39 setSizePolicy( sizePolicy( Qt::Vertical ), sizePolicy( Qt::Horizontal ) );
40#endif
41
43 update();
44
45 Q_EMIT orientationChanged( m_orientation );
46}
47
48Qt::Orientation QskSeparator::orientation() const
49{
50 return m_orientation;
51}
52
53void QskSeparator::setExtent( qreal extent )
54{
55 if ( extent < 0.0 )
56 extent = 0.0;
57
58 if ( setMetric( Panel | QskAspect::Size, extent ) )
59 Q_EMIT extentChanged( extent );
60}
61
62void QskSeparator::resetExtent()
63{
65 Q_EMIT extentChanged( extent() );
66}
67
68qreal QskSeparator::extent() const
69{
70 return metric( Panel | QskAspect::Size );
71}
72
74{
75 return static_cast< QskAspect::Variation >( m_orientation );
76}
77
78#include "moc_QskSeparator.cpp"
Variation
Some sort of variation.
Definition QskAspect.h:82
Base class of all controls.
Definition QskControl.h:23
void setSizePolicy(QskSizePolicy)
QskSizePolicy sizePolicy
Definition QskControl.h:43
void initSizePolicy(QskSizePolicy::Policy, QskSizePolicy::Policy)
void resetImplicitSize()
Definition QskItem.cpp:721
Separates a group of items from adjacent items.
static const QskAspect::Subcontrol Panel
void setOrientation(Qt::Orientation)
QskSeparator(QQuickItem *parent=nullptr)
~QskSeparator() override
void orientationChanged(Qt::Orientation)
Qt::Orientation orientation
Orientation of the separator - Qt::Horizontal (the default) or Qt::Vertical.
QskAspect::Variation effectiveVariation() const override
bool setMetric(QskAspect, qreal)
Sets a metric hint.
qreal metric(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a metric hint.
bool resetMetric(QskAspect)
Removes a metric hint from the local table.