File indexing completed on 2024-05-12 15:59:07
0001 /* 0002 * SPDX-FileCopyrightText: 2017 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef LIBKIS_PALETTE_VIEW_H 0008 #define LIBKIS_PALETTE_VIEW_H 0009 0010 #include <QObject> 0011 #include <QScopedPointer> 0012 #include "kritalibkis_export.h" 0013 #include "libkis.h" 0014 #include "Palette.h" 0015 #include "ManagedColor.h" 0016 #include "KoColorSet.h" 0017 #include <kis_palette_view.h> 0018 #include <KisPaletteModel.h> 0019 0020 #include <Swatch.h> 0021 0022 class KisSwatch; 0023 0024 /** 0025 * @class PaletteView 0026 * @brief The PaletteView class is a wrapper around a MVC method for handling 0027 * palettes. This class shows a nice widget that can drag and drop, edit colors in a colorset 0028 * and will handle adding and removing entries if you'd like it to. 0029 */ 0030 0031 class KRITALIBKIS_EXPORT PaletteView : public QWidget 0032 { 0033 Q_OBJECT 0034 public: 0035 PaletteView(QWidget *parent = 0); 0036 ~PaletteView(); 0037 public Q_SLOTS: 0038 /** 0039 * @brief setPalette 0040 * Set a new palette. 0041 * @param palette 0042 */ 0043 void setPalette(Palette *palette); 0044 /** 0045 * @brief addEntryWithDialog 0046 * This gives a simple dialog for adding colors, with options like 0047 * adding name, id, and to which group the color should be added. 0048 * @param color the default color to add 0049 * @return whether it was successful. 0050 */ 0051 bool addEntryWithDialog(ManagedColor *color); 0052 /** 0053 * @brief addGroupWithDialog 0054 * gives a little dialog to ask for the desired groupname. 0055 * @return whether this was successful. 0056 */ 0057 bool addGroupWithDialog(); 0058 /** 0059 * @brief removeSelectedEntryWithDialog 0060 * removes the selected entry. If it is a group, it pop up a dialog 0061 * asking whether the colors should also be removed. 0062 * @return whether this was successful 0063 */ 0064 bool removeSelectedEntryWithDialog(); 0065 /** 0066 * @brief trySelectClosestColor 0067 * tries to select the closest color to the one given. 0068 * It does not force a change on the active color. 0069 * @param color the color to compare to. 0070 */ 0071 void trySelectClosestColor(ManagedColor *color); 0072 Q_SIGNALS: 0073 /** 0074 * @brief entrySelectedForeGround 0075 * fires when a swatch is selected with leftclick. 0076 * @param entry 0077 */ 0078 void entrySelectedForeGround(Swatch entry); 0079 /** 0080 * @brief entrySelectedBackGround 0081 * fires when a swatch is selected with rightclick. 0082 * @param entry 0083 */ 0084 void entrySelectedBackGround(Swatch entry); 0085 0086 private Q_SLOTS: 0087 0088 void fgSelected(KisSwatch swatch); 0089 void bgSelected(KisSwatch swatch); 0090 0091 private: 0092 0093 0094 0095 struct Private; 0096 const QScopedPointer<Private> d; 0097 }; 0098 0099 #endif // LIBKIS_PALETTE_VIEW_H