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#ifndef QQUICKABSTRACTBUTTON_P_P_H
5#define QQUICKABSTRACTBUTTON_P_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuickTemplates2/private/qquickabstractbutton_p.h>
19#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
20#if QT_CONFIG(shortcut)
21# include <QtGui/qkeysequence.h>
22#endif
23
24#include <QtCore/qpointer.h>
25
26#include <QtQml/private/qqmlpropertyutils_p.h>
27
28QT_BEGIN_NAMESPACE
29
30class QQuickAction;
31class QQuickButtonGroup;
32
33class Q_QUICKTEMPLATES2_EXPORT QQuickAbstractButtonPrivate : public QQuickControlPrivate
34{
35public:
36 Q_DECLARE_PUBLIC(QQuickAbstractButton)
37
38 static QQuickAbstractButtonPrivate *get(QQuickAbstractButton *button)
39 {
40 return button->d_func();
41 }
42
43 QPointF centerPressPoint() const;
44 void setPressPoint(const QPointF &point);
45 void setMovePoint(const QPointF &point);
46
47 bool handlePress(const QPointF &point, ulong timestamp) override;
48 bool handleMove(const QPointF &point, ulong timestamp) override;
49 bool handleRelease(const QPointF &point, ulong timestamp) override;
50 void handleUngrab() override;
51
52 virtual bool acceptKeyClick(Qt::Key key) const;
53 virtual void accessiblePressAction();
54
55 bool isPressAndHoldConnected();
56 bool isDoubleClickConnected();
57 void startPressAndHold();
58 void stopPressAndHold();
59
60 void startRepeatDelay();
61 void startPressRepeat();
62 void stopPressRepeat();
63
64#if QT_CONFIG(shortcut)
65 void grabShortcut();
66 void ungrabShortcut();
67#endif
68
69 QQuickAbstractButton *findCheckedButton() const;
70 QList<QQuickAbstractButton *> findExclusiveButtons() const;
71
72 void actionTextChange();
73 void setText(const QString &text, QQml::PropertyUtils::State propertyState);
74 void init();
75
76 void updateEffectiveIcon();
77
78 void click();
79 void trigger(bool doubleClick = false);
80 void toggle(bool value);
81
82 void cancelIndicator();
83 void executeIndicator(bool complete = false);
84
85 void itemImplicitWidthChanged(QQuickItem *item) override;
86 void itemImplicitHeightChanged(QQuickItem *item) override;
87 void itemDestroyed(QQuickItem *item) override;
88
89 // copied from qabstractbutton.cpp
90 static const int AUTO_REPEAT_DELAY = 300;
91 static const int AUTO_REPEAT_INTERVAL = 100;
92
93 bool explicitText = false;
94 bool down = false;
95 bool explicitDown = false;
96 bool pressed = false;
97 bool keepPressed = false;
98 bool checked = false;
99 bool checkable = false;
100 bool autoExclusive = false;
101 bool autoRepeat = false;
102 bool wasHeld = false;
103 bool wasDoubleClick = false;
104 int holdTimer = 0;
105 int delayTimer = 0;
106 int repeatTimer = 0;
107 int repeatDelay = AUTO_REPEAT_DELAY;
108 int repeatInterval = AUTO_REPEAT_INTERVAL;
109 int animateTimer = 0;
110#if QT_CONFIG(shortcut)
111 int shortcutId = 0;
112 QKeySequence shortcut;
113#endif
114 qreal lastTouchReleaseTimestamp = 0;
115 QString text;
116 QQuickIcon icon;
117 QQuickIcon effectiveIcon;
118 QPointF pressPoint;
119 QPointF movePoint;
120 Qt::MouseButtons pressButtons = Qt::NoButton;
121 QQuickAbstractButton::Display display = QQuickAbstractButton::TextBesideIcon;
122 QQuickDeferredPointer<QQuickItem> indicator;
123 QQuickButtonGroup *group = nullptr;
124 QPointer<QQuickAction> action;
125};
126
127QT_END_NAMESPACE
128
129#endif // QQUICKABSTRACTBUTTON_P_P_H
130

source code of qtdeclarative/src/quicktemplates/qquickabstractbutton_p_p.h