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
24QT_BEGIN_NAMESPACE
25
26class QQuickAction;
27class QQuickButtonGroup;
28
29class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickAbstractButtonPrivate : public QQuickControlPrivate
30{
31public:
32 Q_DECLARE_PUBLIC(QQuickAbstractButton)
33
34 static QQuickAbstractButtonPrivate *get(QQuickAbstractButton *button)
35 {
36 return button->d_func();
37 }
38
39 QPointF centerPressPoint() const;
40 void setPressPoint(const QPointF &point);
41 void setMovePoint(const QPointF &point);
42
43 bool handlePress(const QPointF &point, ulong timestamp) override;
44 bool handleMove(const QPointF &point, ulong timestamp) override;
45 bool handleRelease(const QPointF &point, ulong timestamp) override;
46 void handleUngrab() override;
47
48 virtual bool acceptKeyClick(Qt::Key key) const;
49
50 bool isPressAndHoldConnected();
51 bool isDoubleClickConnected();
52 void startPressAndHold();
53 void stopPressAndHold();
54
55 void startRepeatDelay();
56 void startPressRepeat();
57 void stopPressRepeat();
58
59#if QT_CONFIG(shortcut)
60 void grabShortcut();
61 void ungrabShortcut();
62#endif
63
64 QQuickAbstractButton *findCheckedButton() const;
65 QList<QQuickAbstractButton *> findExclusiveButtons() const;
66
67 void actionTextChange();
68 void setText(const QString &text, bool isExplicit);
69
70 void updateEffectiveIcon();
71
72 void click();
73 void trigger(bool doubleClick = false);
74 void toggle(bool value);
75
76 void cancelIndicator();
77 void executeIndicator(bool complete = false);
78
79 void itemImplicitWidthChanged(QQuickItem *item) override;
80 void itemImplicitHeightChanged(QQuickItem *item) override;
81 void itemDestroyed(QQuickItem *item) override;
82
83 // copied from qabstractbutton.cpp
84 static const int AUTO_REPEAT_DELAY = 300;
85 static const int AUTO_REPEAT_INTERVAL = 100;
86
87 bool explicitText = false;
88 bool down = false;
89 bool explicitDown = false;
90 bool pressed = false;
91 bool keepPressed = false;
92 bool checked = false;
93 bool checkable = false;
94 bool autoExclusive = false;
95 bool autoRepeat = false;
96 bool wasHeld = false;
97 bool wasDoubleClick = false;
98 int holdTimer = 0;
99 int delayTimer = 0;
100 int repeatTimer = 0;
101 int repeatDelay = AUTO_REPEAT_DELAY;
102 int repeatInterval = AUTO_REPEAT_INTERVAL;
103#if QT_CONFIG(shortcut)
104 int shortcutId = 0;
105 QKeySequence shortcut;
106#endif
107 qreal lastTouchReleaseTimestamp = 0;
108 QString text;
109 QQuickIcon icon;
110 QQuickIcon effectiveIcon;
111 QPointF pressPoint;
112 QPointF movePoint;
113 Qt::MouseButtons pressButtons = Qt::NoButton;
114 QQuickAbstractButton::Display display = QQuickAbstractButton::TextBesideIcon;
115 QQuickDeferredPointer<QQuickItem> indicator;
116 QQuickButtonGroup *group = nullptr;
117 QPointer<QQuickAction> action;
118};
119
120QT_END_NAMESPACE
121
122#endif // QQUICKABSTRACTBUTTON_P_P_H
123

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