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 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | QWidgetPlatformColorDialog::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 | |
21 | QWidgetPlatformColorDialog::~QWidgetPlatformColorDialog() |
22 | { |
23 | } |
24 | |
25 | QColor QWidgetPlatformColorDialog::currentColor() const |
26 | { |
27 | return m_dialog->currentColor(); |
28 | } |
29 | |
30 | void QWidgetPlatformColorDialog::setCurrentColor(const QColor &color) |
31 | { |
32 | m_dialog->setCurrentColor(color); |
33 | } |
34 | |
35 | void QWidgetPlatformColorDialog::exec() |
36 | { |
37 | m_dialog->exec(); |
38 | } |
39 | |
40 | bool 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 | |
49 | void QWidgetPlatformColorDialog::hide() |
50 | { |
51 | m_dialog->hide(); |
52 | } |
53 | |
54 | QT_END_NAMESPACE |
55 | |
56 | #include "moc_qwidgetplatformcolordialog_p.cpp" |
57 | |