File indexing completed on 2024-04-21 14:56:35

0001 /*  This file is part of the KDE libraries
0002     SPDX-FileCopyrightText: 1999 Steffen Hansen <hansen@kde.org>
0003     SPDX-FileCopyrightText: 2005 Joseph Wenninger <jowenn@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef _KCOLORMIMEDATA_H
0009 #define _KCOLORMIMEDATA_H
0010 
0011 #include <kguiaddons_export.h>
0012 
0013 class QColor;
0014 class QDrag;
0015 class QMimeData;
0016 class QObject;
0017 
0018 /**
0019  * Drag-and-drop and clipboard mimedata manipulation for QColor objects. The according MIME type
0020  * is set to application/x-color.
0021  *
0022  * See the Qt drag'n'drop documentation.
0023  */
0024 namespace KColorMimeData
0025 {
0026 /**
0027  * Sets the color and text representation fields for the specified color in the mimedata object:
0028  * application/x-color and text/plain types are set
0029  */
0030 KGUIADDONS_EXPORT void populateMimeData(QMimeData *mimeData, const QColor &color);
0031 
0032 /**
0033  * Returns true if the MIME data @p mimeData contains a color object.
0034  * First checks for application/x-color and if that fails, for a text/plain entry, which
0035  * represents a color in the format \#hexnumbers
0036  */
0037 KGUIADDONS_EXPORT bool canDecode(const QMimeData *mimeData);
0038 
0039 /**
0040  * Decodes the MIME data @p mimeData and returns the resulting color.
0041  * First tries application/x-color and if that fails, a text/plain entry, which
0042  * represents a color in the format \#hexnumbers. If this fails too,
0043  * an invalid QColor object is returned, use QColor::isValid() to test it.
0044  */
0045 KGUIADDONS_EXPORT QColor fromMimeData(const QMimeData *mimeData);
0046 
0047 /**
0048  * Creates a color drag object. Either you have to start this drag or delete it
0049  * The drag object's mime data has the application/x-color and text/plain type set and a pixmap
0050  * filled with the specified color, which is going to be displayed next to the mouse cursor
0051  */
0052 KGUIADDONS_EXPORT QDrag *createDrag(const QColor &color, QObject *dragsource);
0053 }
0054 
0055 #endif // _KCOLORMIMEDATA_H