File indexing completed on 2024-05-19 04:29:25
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Dmitry Kazakov <dimula73@gmail.com> 0003 * SPDX-FileCopyrightText: 2017 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com> 0004 * SPDX-FileCopyrightText: 2022 Halla Rempt <halla@valdyas.org> 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef __KIS_PALETTE_VIEW_H 0009 #define __KIS_PALETTE_VIEW_H 0010 0011 #include <QScopedPointer> 0012 #include <QTableView> 0013 #include <QPushButton> 0014 #include <QPixmap> 0015 #include <QIcon> 0016 0017 #include <KoColorSet.h> 0018 #include "kritawidgets_export.h" 0019 0020 #include <KisKineticScroller.h> 0021 0022 class KisPaletteModel; 0023 class QWheelEvent; 0024 class KoColorDisplayRendererInterface; 0025 0026 class KRITAWIDGETS_EXPORT KisPaletteView : public QTableView 0027 { 0028 Q_OBJECT 0029 private: 0030 static int MINIMUM_ROW_HEIGHT; 0031 public: 0032 explicit KisPaletteView(QWidget *parent = 0); 0033 ~KisPaletteView() override; 0034 0035 void setPaletteModel(KisPaletteModel *model); 0036 KisPaletteModel *paletteModel() const; 0037 0038 public: 0039 0040 /** 0041 * @brief setAllowModification 0042 * Set whether doubleclick calls up a modification window. This is to prevent users from editing 0043 * the palette when the palette is intended to be a list of items. 0044 */ 0045 void setAllowModification(bool allow); 0046 0047 void setDisplayRenderer(const KoColorDisplayRendererInterface *displayRenderer); 0048 0049 /** 0050 * @brief setCrossedKeyword 0051 * This allows you to set keywords that can cross out colors. 0052 * This is implemented to mark the lazybrush "transparent" color. 0053 * @param value 0054 */ 0055 void setCrossedKeyword(const QString &value); 0056 0057 void removeSelectedEntry(); 0058 0059 /** 0060 * @brief selectClosestColor 0061 * select a color that's closest to parameter color 0062 * @param color 0063 */ 0064 void selectClosestColor(const KoColor &color); 0065 0066 /** 0067 * @brief closestColor 0068 * determines closest swatch in the active palette and returns it's color as KoColor 0069 * @param color 0070 * @return KoColor 0071 */ 0072 const KoColor closestColor(const KoColor& color) const; 0073 0074 /** 0075 * add an entry with a dialog window. 0076 * @warning deprecated. 0077 * kept for compatibility with PaletteView in libkis 0078 */ 0079 bool addEntryWithDialog(KoColor color); 0080 0081 /** 0082 * remove entry with a dialog window.(Necessary for groups. 0083 * @warning deprecated. 0084 * kept for compatibility with PaletteView in libkis 0085 */ 0086 bool removeEntryWithDialog(QModelIndex index); 0087 0088 /** 0089 * add entry with a dialog window. 0090 * @warning deprecated. 0091 * kept for compatibility with PaletteView in libkis 0092 */ 0093 bool addGroupWithDialog(); 0094 0095 Q_SIGNALS: 0096 void sigIndexSelected(const QModelIndex &index); 0097 void sigColorSelected(const KoColor &); 0098 void sigPaletteUpdatedFromModel(); 0099 0100 public Q_SLOTS: 0101 /** 0102 * This tries to select the closest color in the palette. 0103 * This doesn't update the foreground color, just the visual selection. 0104 */ 0105 void slotFGColorChanged(const KoColor &); 0106 0107 void slotScrollerStateChanged(QScroller::State state){KisKineticScroller::updateCursor(this, state);} 0108 0109 private Q_SLOTS: 0110 void slotHorizontalHeaderResized(int, int, int newSize); 0111 void slotAdditionalGuiUpdate(); 0112 void slotCurrentSelectionChanged(const QModelIndex &newCurrent); 0113 0114 private: 0115 void resizeRows(int newSize); 0116 void saveModification(); 0117 0118 private: 0119 struct Private; 0120 const QScopedPointer<Private> d; 0121 }; 0122 0123 #endif /* __KIS_PALETTE_VIEW_H */