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 "qquicktabbutton_p.h" |
5 | #include "qquickcontrol_p_p.h" |
6 | #include "qquickabstractbutton_p_p.h" |
7 | |
8 | #include <QtGui/qpa/qplatformtheme.h> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | /*! |
13 | \qmltype TabButton |
14 | \inherits AbstractButton |
15 | //! \instantiates QQuickTabButton |
16 | \inqmlmodule QtQuick.Controls |
17 | \since 5.7 |
18 | \ingroup qtquickcontrols-navigation |
19 | \brief Button with a look suitable for a TabBar. |
20 | |
21 | \image qtquickcontrols-tabbutton.png |
22 | |
23 | TabButton is used in conjunction with a \l TabBar. |
24 | |
25 | \snippet qtquickcontrols-tabbutton.qml 1 |
26 | |
27 | TabButton inherits its API from AbstractButton. For instance, you can set |
28 | \l {AbstractButton::text}{text}, and react to \l {AbstractButton::clicked}{clicks} |
29 | using the AbstractButton API. |
30 | |
31 | \sa TabBar, {Customizing TabButton}, {Button Controls}, {Navigation Controls} |
32 | */ |
33 | |
34 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTabButtonPrivate : public QQuickAbstractButtonPrivate |
35 | { |
36 | Q_DECLARE_PUBLIC(QQuickTabButton) |
37 | |
38 | public: |
39 | QPalette defaultPalette() const override { return QQuickTheme::palette(scope: QQuickTheme::TabBar); } |
40 | }; |
41 | |
42 | QQuickTabButton::QQuickTabButton(QQuickItem *parent) |
43 | : QQuickAbstractButton(*(new QQuickTabButtonPrivate), parent) |
44 | { |
45 | setCheckable(true); |
46 | setAutoExclusive(true); |
47 | } |
48 | |
49 | QFont QQuickTabButton::defaultFont() const |
50 | { |
51 | return QQuickTheme::font(scope: QQuickTheme::TabBar); |
52 | } |
53 | |
54 | #if QT_CONFIG(accessibility) |
55 | QAccessible::Role QQuickTabButton::accessibleRole() const |
56 | { |
57 | return QAccessible::PageTab; |
58 | } |
59 | #endif |
60 | |
61 | QT_END_NAMESPACE |
62 | |
63 | #include "moc_qquicktabbutton_p.cpp" |
64 |