QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskSwitchButton.cpp
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#include "QskSwitchButton.h"
7
8QSK_SUBCONTROL( QskSwitchButton, Groove )
9QSK_SUBCONTROL( QskSwitchButton, Handle )
10QSK_SUBCONTROL( QskSwitchButton, Icon )
11
12struct QskSwitchButton::PrivateData
13{
14 PrivateData( Qt::Orientation orientation )
15 : orientation( orientation )
16 {
17 }
18
19 bool inverted = false;
20 Qt::Orientation orientation;
21 IconMode iconMode = NoIcon;
22};
23
24QskSwitchButton::QskSwitchButton( QQuickItem* parent )
25 : QskSwitchButton( Qt::Horizontal, parent )
26{
27}
28
29QskSwitchButton::QskSwitchButton( Qt::Orientation orientation, QQuickItem* parent )
30 : QskAbstractButton( parent )
31 , m_data( new PrivateData( orientation ) )
32{
33 initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
34}
35
36QskSwitchButton::~QskSwitchButton()
37{
38}
39
40bool QskSwitchButton::isCheckable() const
41{
42 return true;
43}
44
45Qt::Orientation QskSwitchButton::orientation() const
46{
47 return m_data->orientation;
48}
49
50void QskSwitchButton::setOrientation( Qt::Orientation orientation )
51{
52 if( m_data->orientation != orientation )
53 {
54 m_data->orientation = orientation;
55
57 update();
58
59 Q_EMIT orientationChanged( orientation );
60 }
61}
62
63bool QskSwitchButton::isInverted() const
64{
65 return m_data->inverted;
66}
67
68void QskSwitchButton::setInverted( bool on )
69{
70 if( m_data->inverted != on )
71 {
72 m_data->inverted = on;
73
74 resetImplicitSize(); // in case the size hints depend on it
75 update();
76
77 Q_EMIT invertedChanged( on );
78 }
79}
80
81QskSwitchButton::IconMode QskSwitchButton::iconMode() const
82{
83 return m_data->iconMode;
84}
85
86void QskSwitchButton::setIconMode( IconMode iconMode )
87{
88 if( iconMode != m_data->iconMode )
89 {
90 m_data->iconMode = iconMode;
91 Q_EMIT iconModeChanged( m_data->iconMode );
92 }
93}
94
96{
97 return static_cast< QskAspect::Variation >( m_data->orientation );
98}
99
100#include "moc_QskSwitchButton.cpp"
Variation
Some sort of variation.
Definition QskAspect.h:82
void resetImplicitSize()
Definition QskItem.cpp:721
QskAspect::Variation effectiveVariation() const override