1// Copyright (C) 2022 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 QQUICKCOLORDIALOGIMPL_P_P_H
5#define QQUICKCOLORDIALOGIMPL_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 "qquickcolordialogimpl_p.h"
19#include "qquickabstractcolorpicker_p.h"
20#include "qquickcolorinputs_p.h"
21
22#include <QtQuickTemplates2/private/qquickdialog_p_p.h>
23#include <QtQuickTemplates2/private/qquickdialogbuttonbox_p.h>
24#include <QtQuickTemplates2/private/qquickabstractbutton_p.h>
25#include <QtQuickTemplates2/private/qquickslider_p.h>
26
27QT_BEGIN_NAMESPACE
28
29class QQuickEyeDropperEventFilter : public QObject
30{
31public:
32 enum class LeaveReason { Default, Cancel };
33 explicit QQuickEyeDropperEventFilter(std::function<void(QPoint, LeaveReason)> callOnLeave,
34 std::function<void(QPoint)> callOnUpdate)
35 : m_leave(callOnLeave), m_update(callOnUpdate)
36 {
37 }
38
39protected:
40 bool eventFilter(QObject *obj, QEvent *event) override;
41
42private:
43 std::function<void(QPoint, LeaveReason)> m_leave;
44 std::function<void(QPoint)> m_update;
45 QPoint m_lastPosition;
46};
47
48class QQuickColorDialogImplPrivate : public QQuickDialogPrivate
49{
50public:
51 Q_DECLARE_PUBLIC(QQuickColorDialogImpl);
52
53public:
54 explicit QQuickColorDialogImplPrivate();
55 ~QQuickColorDialogImplPrivate();
56
57 static QQuickColorDialogImplPrivate *get(QQuickColorDialogImpl *dialog)
58 {
59 return dialog->d_func();
60 }
61
62 QQuickColorDialogImplAttached *attachedOrWarn();
63
64 void handleClick(QQuickAbstractButton *button) override;
65
66 void eyeDropperEnter();
67 void eyeDropperLeave(const QPoint &pos, QQuickEyeDropperEventFilter::LeaveReason actionOnLeave);
68 void eyeDropperPointerMoved(const QPoint &pos);
69
70 void alphaSliderMoved();
71
72 QSharedPointer<QColorDialogOptions> options;
73 HSVA m_hsva;
74 std::unique_ptr<QQuickEyeDropperEventFilter> eyeDropperEventFilter;
75 QPointer<QQuickWindow> m_eyeDropperWindow;
76 QColor m_eyeDropperPreviousColor;
77 bool m_eyeDropperMode = false;
78 bool m_showAlpha = false;
79 bool m_hsl = false;
80};
81
82class QQuickColorDialogImplAttachedPrivate : public QObjectPrivate
83{
84public:
85 QPointer<QQuickDialogButtonBox> buttonBox;
86 QPointer<QQuickAbstractButton> eyeDropperButton;
87 QPointer<QQuickColorInputs> colorInputs;
88 QPointer<QQuickAbstractColorPicker> colorPicker;
89 QPointer<QQuickSlider> alphaSlider;
90
91 Q_DECLARE_PUBLIC(QQuickColorDialogImplAttached)
92};
93
94QT_END_NAMESPACE
95
96#endif // QQUICKCOLORDIALOGIMPL_P_P_H
97

source code of qtdeclarative/src/quickdialogs/quickdialogsquickimpl/qquickcolordialogimpl_p_p.h