1// Copyright (C) 2023 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 QQUICKMATERIALPLACEHOLDERTEXT_P_H
5#define QQUICKMATERIALPLACEHOLDERTEXT_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 <QtCore/private/qglobal_p.h>
19#include <QtGui/qcolor.h>
20#include <QtQuickControls2Impl/private/qquickplaceholdertext_p.h>
21
22#include <QtCore/qpointer.h>
23
24QT_BEGIN_NAMESPACE
25
26class QParallelAnimationGroup;
27
28class QQuickMaterialPlaceholderText : public QQuickPlaceholderText
29{
30 Q_OBJECT
31 Q_PROPERTY(bool filled READ isFilled WRITE setFilled NOTIFY filledChanged FINAL)
32 Q_PROPERTY(bool controlHasActiveFocus READ controlHasActiveFocus
33 WRITE setControlHasActiveFocus NOTIFY controlHasActiveFocusChanged FINAL)
34 Q_PROPERTY(bool controlHasText READ controlHasText WRITE setControlHasText NOTIFY controlHasTextChanged FINAL)
35 Q_PROPERTY(int largestHeight READ largestHeight NOTIFY largestHeightChanged FINAL)
36 Q_PROPERTY(qreal verticalPadding READ verticalPadding WRITE setVerticalPadding NOTIFY verticalPaddingChanged FINAL)
37 Q_PROPERTY(qreal controlImplicitBackgroundHeight READ controlImplicitBackgroundHeight
38 WRITE setControlImplicitBackgroundHeight NOTIFY controlImplicitBackgroundHeightChanged FINAL)
39 Q_PROPERTY(qreal controlHeight READ controlHeight WRITE setControlHeight FINAL)
40 QML_NAMED_ELEMENT(FloatingPlaceholderText)
41 QML_ADDED_IN_VERSION(6, 5)
42
43public:
44 explicit QQuickMaterialPlaceholderText(QQuickItem *parent = nullptr);
45
46 bool isFilled() const;
47 void setFilled(bool filled);
48
49 int largestHeight() const;
50
51 bool controlHasActiveFocus() const;
52 void setControlHasActiveFocus(bool controlHasActiveFocus);
53
54 bool controlHasText() const;
55 void setControlHasText(bool controlHasText);
56
57 qreal controlImplicitBackgroundHeight() const;
58 void setControlImplicitBackgroundHeight(qreal controlImplicitBackgroundHeight);
59
60 qreal controlHeight() const;
61 void setControlHeight(qreal controlHeight);
62
63 qreal verticalPadding() const;
64 void setVerticalPadding(qreal verticalPadding);
65
66signals:
67 void filledChanged();
68 void largestHeightChanged();
69 void controlHasActiveFocusChanged();
70 void controlHasTextChanged();
71 void controlImplicitBackgroundHeightChanged();
72 void verticalPaddingChanged();
73
74private slots:
75 void adjustTransformOrigin();
76
77private:
78 bool shouldFloat() const;
79 bool shouldAnimate() const;
80
81 void updateY();
82 qreal normalTargetY() const;
83 qreal floatingTargetY() const;
84
85 void controlGotActiveFocus();
86 void controlLostActiveFocus();
87
88 void maybeSetFocusAnimationProgress();
89
90 void componentComplete() override;
91
92 bool m_filled = false;
93 bool m_controlHasActiveFocus = false;
94 bool m_controlHasText = false;
95 int m_largestHeight = 0;
96 qreal m_verticalPadding = 0;
97 qreal m_controlImplicitBackgroundHeight = 0;
98 qreal m_controlHeight = 0;
99 QPointer<QParallelAnimationGroup> m_focusInAnimation;
100 QPointer<QParallelAnimationGroup> m_focusOutAnimation;
101};
102
103QT_END_NAMESPACE
104
105#endif // QQUICKMATERIALPLACEHOLDERTEXT_P_H
106

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qtdeclarative/src/quickcontrols/material/impl/qquickmaterialplaceholdertext_p.h