1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#include "qquicktoolseparator_p.h"
38
39#include "qquickcontrol_p_p.h"
40
41QT_BEGIN_NAMESPACE
42
43/*!
44 \qmltype ToolSeparator
45 \inherits Control
46//! \instantiates QQuickToolSeparator
47 \inqmlmodule QtQuick.Controls
48 \since 5.8
49 \ingroup qtquickcontrols2-separators
50 \brief Separates a group of items in a toolbar from adjacent items.
51
52 ToolSeparator is used to visually distinguish between groups of items in a
53 toolbar by separating them with a line. It can be used in horizontal or
54 vertical toolbars by setting the \l orientation property to \c Qt.Vertical
55 or \c Qt.Horizontal, respectively.
56
57 \image qtquickcontrols2-toolseparator.png
58
59 \snippet qtquickcontrols2-toolseparator.qml 1
60
61 \sa {Customizing ToolSeparator}, {Separator Controls}
62*/
63
64class QQuickToolSeparatorPrivate : public QQuickControlPrivate
65{
66 Q_DECLARE_PUBLIC(QQuickToolSeparator)
67
68public:
69 Qt::Orientation orientation = Qt::Vertical;
70};
71
72QQuickToolSeparator::QQuickToolSeparator(QQuickItem *parent)
73 : QQuickControl(*(new QQuickToolSeparatorPrivate), parent)
74{
75}
76
77/*!
78 \qmlproperty enumeration QtQuick.Controls::ToolSeparator::orientation
79
80 This property holds the orientation of the tool separator.
81
82 Possible values:
83 \value Qt.Horizontal A horizontal separator is used in a vertical toolbar.
84 \value Qt.Vertical A vertical separator is used in a horizontal toolbar. (default)
85*/
86Qt::Orientation QQuickToolSeparator::orientation() const
87{
88 Q_D(const QQuickToolSeparator);
89 return d->orientation;
90}
91
92void QQuickToolSeparator::setOrientation(Qt::Orientation orientation)
93{
94 Q_D(QQuickToolSeparator);
95 if (d->orientation == orientation)
96 return;
97
98 d->orientation = orientation;
99 emit orientationChanged();
100}
101
102/*!
103 \readonly
104 \qmlproperty bool QtQuick.Controls::ToolSeparator::horizontal
105
106 This property holds whether \l orientation is equal to \c Qt.Horizontal.
107
108 It is useful for \l {Customizing ToolSeparator}{customizing ToolSeparator}.
109
110 \sa orientation, vertical
111*/
112bool QQuickToolSeparator::isHorizontal() const
113{
114 Q_D(const QQuickToolSeparator);
115 return d->orientation == Qt::Horizontal;
116}
117
118/*!
119 \readonly
120 \qmlproperty bool QtQuick.Controls::ToolSeparator::vertical
121
122 This property holds whether \l orientation is equal to \c Qt.Vertical.
123
124 It is useful for \l {Customizing ToolSeparator}{customizing ToolSeparator}.
125
126 \sa orientation, horizontal
127*/
128bool QQuickToolSeparator::isVertical() const
129{
130 Q_D(const QQuickToolSeparator);
131 return d->orientation == Qt::Vertical;
132}
133
134QFont QQuickToolSeparator::defaultFont() const
135{
136 return QQuickTheme::font(scope: QQuickTheme::ToolBar);
137}
138
139QPalette QQuickToolSeparator::defaultPalette() const
140{
141 return QQuickTheme::palette(scope: QQuickTheme::ToolBar);
142}
143
144#if QT_CONFIG(accessibility)
145QAccessible::Role QQuickToolSeparator::accessibleRole() const
146{
147 return QAccessible::Separator;
148}
149#endif
150
151QT_END_NAMESPACE
152

source code of qtquickcontrols2/src/quicktemplates2/qquicktoolseparator.cpp