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#include "qwidgetplatformcolordialog_p.h"
5#include "qwidgetplatformdialog_p.h"
6
7#include <QtWidgets/qcolordialog.h>
8
9QT_BEGIN_NAMESPACE
10
11QWidgetPlatformColorDialog::QWidgetPlatformColorDialog(QObject *parent)
12 : m_dialog(new QColorDialog)
13{
14 setParent(parent);
15
16 connect(sender: m_dialog.data(), signal: &QColorDialog::accepted, context: this, slot: &QPlatformDialogHelper::accept);
17 connect(sender: m_dialog.data(), signal: &QColorDialog::rejected, context: this, slot: &QPlatformDialogHelper::reject);
18 connect(sender: m_dialog.data(), signal: &QColorDialog::currentColorChanged, context: this, slot: &QPlatformColorDialogHelper::currentColorChanged);
19}
20
21QWidgetPlatformColorDialog::~QWidgetPlatformColorDialog()
22{
23}
24
25QColor QWidgetPlatformColorDialog::currentColor() const
26{
27 return m_dialog->currentColor();
28}
29
30void QWidgetPlatformColorDialog::setCurrentColor(const QColor &color)
31{
32 m_dialog->setCurrentColor(color);
33}
34
35void QWidgetPlatformColorDialog::exec()
36{
37 m_dialog->exec();
38}
39
40bool QWidgetPlatformColorDialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
41{
42 QSharedPointer<QColorDialogOptions> options = QPlatformColorDialogHelper::options();
43 m_dialog->setWindowTitle(options->windowTitle());
44 m_dialog->setOptions(static_cast<QColorDialog::ColorDialogOptions>(int(options->options())) | QColorDialog::DontUseNativeDialog);
45
46 return QWidgetPlatformDialog::show(dialog: m_dialog.data(), flags, modality, parent);
47}
48
49void QWidgetPlatformColorDialog::hide()
50{
51 m_dialog->hide();
52}
53
54QT_END_NAMESPACE
55
56#include "moc_qwidgetplatformcolordialog_p.cpp"
57

source code of qtdeclarative/src/labs/platform/widgets/qwidgetplatformcolordialog.cpp