1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qquicktoolseparator_p.h"
5
6#include "qquickcontrol_p_p.h"
7
8QT_BEGIN_NAMESPACE
9
10/*!
11 \qmltype ToolSeparator
12 \inherits Control
13//! \instantiates QQuickToolSeparator
14 \inqmlmodule QtQuick.Controls
15 \since 5.8
16 \ingroup qtquickcontrols-separators
17 \brief Separates a group of items in a toolbar from adjacent items.
18
19 ToolSeparator is used to visually distinguish between groups of items in a
20 toolbar by separating them with a line. It can be used in horizontal or
21 vertical toolbars by setting the \l orientation property to \c Qt.Vertical
22 or \c Qt.Horizontal, respectively.
23
24 \image qtquickcontrols-toolseparator.png
25
26 \snippet qtquickcontrols-toolseparator.qml 1
27
28 \sa {Customizing ToolSeparator}, {Separator Controls}
29*/
30
31class QQuickToolSeparatorPrivate : public QQuickControlPrivate
32{
33 Q_DECLARE_PUBLIC(QQuickToolSeparator)
34
35public:
36 QPalette defaultPalette() const override { return QQuickTheme::palette(scope: QQuickTheme::ToolBar); }
37
38 Qt::Orientation orientation = Qt::Vertical;
39};
40
41QQuickToolSeparator::QQuickToolSeparator(QQuickItem *parent)
42 : QQuickControl(*(new QQuickToolSeparatorPrivate), parent)
43{
44}
45
46/*!
47 \qmlproperty enumeration QtQuick.Controls::ToolSeparator::orientation
48
49 This property holds the orientation of the tool separator.
50
51 Possible values:
52 \value Qt.Horizontal A horizontal separator is used in a vertical toolbar.
53 \value Qt.Vertical A vertical separator is used in a horizontal toolbar. (default)
54*/
55Qt::Orientation QQuickToolSeparator::orientation() const
56{
57 Q_D(const QQuickToolSeparator);
58 return d->orientation;
59}
60
61void QQuickToolSeparator::setOrientation(Qt::Orientation orientation)
62{
63 Q_D(QQuickToolSeparator);
64 if (d->orientation == orientation)
65 return;
66
67 d->orientation = orientation;
68 emit orientationChanged();
69}
70
71/*!
72 \readonly
73 \qmlproperty bool QtQuick.Controls::ToolSeparator::horizontal
74
75 This property holds whether \l orientation is equal to \c Qt.Horizontal.
76
77 It is useful for \l {Customizing ToolSeparator}{customizing ToolSeparator}.
78
79 \sa orientation, vertical
80*/
81bool QQuickToolSeparator::isHorizontal() const
82{
83 Q_D(const QQuickToolSeparator);
84 return d->orientation == Qt::Horizontal;
85}
86
87/*!
88 \readonly
89 \qmlproperty bool QtQuick.Controls::ToolSeparator::vertical
90
91 This property holds whether \l orientation is equal to \c Qt.Vertical.
92
93 It is useful for \l {Customizing ToolSeparator}{customizing ToolSeparator}.
94
95 \sa orientation, horizontal
96*/
97bool QQuickToolSeparator::isVertical() const
98{
99 Q_D(const QQuickToolSeparator);
100 return d->orientation == Qt::Vertical;
101}
102
103QFont QQuickToolSeparator::defaultFont() const
104{
105 return QQuickTheme::font(scope: QQuickTheme::ToolBar);
106}
107
108#if QT_CONFIG(accessibility)
109QAccessible::Role QQuickToolSeparator::accessibleRole() const
110{
111 return QAccessible::Separator;
112}
113#endif
114
115QT_END_NAMESPACE
116
117#include "moc_qquicktoolseparator_p.cpp"
118

source code of qtdeclarative/src/quicktemplates/qquicktoolseparator.cpp