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 QQUICKLABSPLATFORMCOLORDIALOG_P_H
5#define QQUICKLABSPLATFORMCOLORDIALOG_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 "qquicklabsplatformdialog_p.h"
19#include <QtGui/qcolor.h>
20#include <QtQml/qqml.h>
21
22QT_BEGIN_NAMESPACE
23
24class QQuickLabsPlatformColorDialog : public QQuickLabsPlatformDialog
25{
26 Q_OBJECT
27 QML_NAMED_ELEMENT(ColorDialog)
28 QML_EXTENDED_NAMESPACE(QColorDialogOptions)
29 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
30 Q_PROPERTY(QColor currentColor READ currentColor WRITE setCurrentColor NOTIFY currentColorChanged FINAL)
31 Q_PROPERTY(QColorDialogOptions::ColorDialogOptions options READ options WRITE setOptions NOTIFY optionsChanged FINAL)
32
33public:
34 explicit QQuickLabsPlatformColorDialog(QObject *parent = nullptr);
35
36 QColor color() const;
37 void setColor(const QColor &color);
38
39 QColor currentColor() const;
40 void setCurrentColor(const QColor &color);
41
42 QColorDialogOptions::ColorDialogOptions options() const;
43 void setOptions(QColorDialogOptions::ColorDialogOptions options);
44
45Q_SIGNALS:
46 void colorChanged();
47 void currentColorChanged();
48 void optionsChanged();
49
50protected:
51 bool useNativeDialog() const override;
52 void onCreate(QPlatformDialogHelper *dialog) override;
53 void onShow(QPlatformDialogHelper *dialog) override;
54 void accept() override;
55
56private:
57 QColor m_color;
58 QColor m_currentColor; // TODO: QColorDialogOptions::initialColor
59 QSharedPointer<QColorDialogOptions> m_options;
60};
61
62QT_END_NAMESPACE
63
64QML_DECLARE_TYPE(QQuickLabsPlatformColorDialog)
65
66#endif // QQUICKLABSPLATFORMCOLORDIALOG_P_H
67

source code of qtdeclarative/src/labs/platform/qquicklabsplatformcolordialog_p.h