1/* This file is part of the KDE libraries
2 SPDX-FileCopyrightText: 1999 Steffen Hansen <hansen@kde.org>
3 SPDX-FileCopyrightText: 2005 Joseph Wenninger <jowenn@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef _KCOLORMIMEDATA_H
9#define _KCOLORMIMEDATA_H
10
11#include <kguiaddons_export.h>
12
13class QColor;
14class QDrag;
15class QMimeData;
16class QObject;
17
18/**
19 * Drag-and-drop and clipboard mimedata manipulation for QColor objects. The according MIME type
20 * is set to application/x-color.
21 *
22 * See the Qt drag'n'drop documentation.
23 */
24namespace KColorMimeData
25{
26/**
27 * Sets the color and text representation fields for the specified color in the mimedata object:
28 * application/x-color and text/plain types are set
29 */
30KGUIADDONS_EXPORT void populateMimeData(QMimeData *mimeData, const QColor &color);
31
32/**
33 * Returns true if the MIME data @p mimeData contains a color object.
34 * First checks for application/x-color and if that fails, for a text/plain entry, which
35 * represents a color in the format \#hexnumbers
36 */
37KGUIADDONS_EXPORT bool canDecode(const QMimeData *mimeData);
38
39/**
40 * Decodes the MIME data @p mimeData and returns the resulting color.
41 * First tries application/x-color and if that fails, a text/plain entry, which
42 * represents a color in the format \#hexnumbers. If this fails too,
43 * an invalid QColor object is returned, use QColor::isValid() to test it.
44 */
45KGUIADDONS_EXPORT QColor fromMimeData(const QMimeData *mimeData);
46
47/**
48 * Creates a color drag object. Either you have to start this drag or delete it
49 * The drag object's mime data has the application/x-color and text/plain type set and a pixmap
50 * filled with the specified color, which is going to be displayed next to the mouse cursor
51 */
52KGUIADDONS_EXPORT QDrag *createDrag(const QColor &color, QObject *dragsource);
53}
54
55#endif // _KCOLORMIMEDATA_H
56

source code of kguiaddons/src/colors/kcolormimedata.h