File indexing completed on 2024-05-12 16:02:07
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2007 C. Boemann <cbo@boemann.dk> 0003 SPDX-FileCopyrightText: 2007 Fredy Yanardi <fyanardi@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KOCOLORSETWIDGET_H_ 0009 #define KOCOLORSETWIDGET_H_ 0010 0011 #include <QWidgetAction> 0012 #include <QFrame> 0013 0014 #include <KisSwatch.h> 0015 #include <KoColorSet.h> 0016 0017 #include <KoColorDisplayRendererInterface.h> 0018 0019 #include "kritawidgets_export.h" 0020 0021 class KoColor; 0022 class KoColorPatch; 0023 0024 /** 0025 * @short A colormanaged widget for choosing a color from a colorset 0026 * 0027 * KoColorSetWidget is a widget for choosing a color (colormanaged via pigment). It shows a color 0028 * set plus optionally a checkbox to filter away bad matching colors. 0029 */ 0030 class KRITAWIDGETS_EXPORT KoColorSetWidget : public QFrame 0031 { 0032 0033 Q_OBJECT 0034 0035 public: 0036 0037 /** 0038 * Constructor for the widget, where color is initially blackpoint of sRGB 0039 * 0040 * @param parent parent QWidget 0041 */ 0042 explicit KoColorSetWidget(QWidget *parent=0); 0043 0044 /** 0045 * Destructor 0046 */ 0047 ~KoColorSetWidget() override; 0048 0049 /** 0050 * Sets the color set that this widget shows. 0051 * @param colorSet pointer to the color set 0052 */ 0053 void setColorSet(KoColorSetSP colorSet); 0054 0055 /** 0056 * @brief setDisplayRenderer 0057 * Set the display renderer of this object. 0058 * @param displayRenderer 0059 */ 0060 void setDisplayRenderer(const KoColorDisplayRendererInterface *displayRenderer); 0061 0062 /** 0063 * Gets the current color set 0064 * @returns current color set,, 0 if none set 0065 */ 0066 KoColorSetSP colorSet(); 0067 0068 protected: 0069 void resizeEvent(QResizeEvent *event) override; ///< reimplemented from QFrame 0070 0071 Q_SIGNALS: 0072 0073 /** 0074 * Emitted every time the color changes (by calling setColor() or 0075 * by user interaction. 0076 * @param color the new color 0077 * @param final if the value is final (ie not produced by the pointer moving over around) 0078 */ 0079 void colorChanged(const KoColor &color, bool final); 0080 0081 /** 0082 * Emitted every time the size of this widget changes because of new colorset with 0083 * different number of colors is loaded. This is useful for KoColorSetAction to update 0084 * correct size of the menu showing this widget. 0085 * @param size the new size 0086 */ 0087 void widgetSizeChanged(const QSize &size); 0088 0089 private Q_SLOTS: 0090 /** 0091 * @brief slotPatchTriggered 0092 * Triggered when a recent patch is triggered 0093 */ 0094 void slotPatchTriggered(KoColorPatch *); 0095 /** 0096 * @brief slotEntrySelected 0097 * Triggered when a color is choose from the palette view 0098 */ 0099 void slotColorSelectedByPalette(const KoColor &color); 0100 void slotPaletteChoosen(KoColorSetSP ); 0101 void slotNameListSelection(const KoColor &); 0102 0103 private: 0104 class KoColorSetWidgetPrivate; 0105 KoColorSetWidgetPrivate * const d; 0106 }; 0107 0108 #endif