File indexing completed on 2024-05-12 16:02:07

0001 /**
0002  * SPDX-FileCopyrightText: 2006 C. Boemann (cbo@boemann.dk)
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 #ifndef KOCOLORPATCH_H
0007 #define KOCOLORPATCH_H
0008 
0009 #include <QFrame>
0010 
0011 #include <KoColor.h>
0012 #include "kritawidgets_export.h"
0013 #include <KoColorDisplayRendererInterface.h>
0014 
0015 /**
0016  *  The small widget showing the selected color
0017  */
0018 class KRITAWIDGETS_EXPORT KoColorPatch : public QFrame
0019 {
0020   Q_OBJECT
0021 public:
0022     explicit KoColorPatch( QWidget *parent );
0023     ~KoColorPatch() override;
0024 
0025     /**
0026      * Set the color of this color patch
0027      * @param c the new color
0028      */
0029     void setColor( const KoColor &c );
0030 
0031     /**
0032      * @brief setDisplayRenderer
0033      * Set the display renderer of this object.
0034      * @param displayRenderer
0035      */
0036     void setDisplayRenderer(const KoColorDisplayRendererInterface *displayRenderer);
0037 
0038     /**
0039      * @brief getColorFromDisplayRenderer
0040      * Get QColor from the display renderers
0041      * @param c
0042      */
0043     QColor getColorFromDisplayRenderer(KoColor c);
0044 
0045     /**
0046      * @return current color shown by this patch
0047      */
0048     KoColor color() const;
0049 
0050 protected:
0051     void mousePressEvent(QMouseEvent *e ) override; ///< reimplemented from QFrame
0052     void paintEvent(QPaintEvent *e) override; ///< reimplemented from QFrame
0053     QSize sizeHint() const override; ///< reimplemented from QFrame
0054 
0055 Q_SIGNALS:
0056 
0057     /**
0058      * Emitted when the mouse is released.
0059      * @param widget a pointer to this widget
0060      */
0061     void triggered(KoColorPatch *widget);
0062 
0063 private:
0064   KoColor m_color;
0065   const KoColorDisplayRendererInterface *m_displayRenderer;
0066 };
0067 
0068 #endif