File indexing completed on 2024-05-19 04:29:28
0001 /* 0002 * SPDX-FileCopyrightText: 2018 Michael Zhou <simeirxh@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KISPALETTECOMBOBOX_H 0008 #define KISPALETTECOMBOBOX_H 0009 0010 #include "kritawidgets_export.h" 0011 0012 #include <QComboBox> 0013 #include <QPointer> 0014 #include <QScopedPointer> 0015 #include <QPixmap> 0016 #include <QPair> 0017 #include <QHash> 0018 #include <KisSqueezedComboBox.h> 0019 #include <KisPaletteModel.h> 0020 #include <KisSwatchGroup.h> 0021 0022 class KisPaletteView; 0023 0024 /** 0025 * @brief The KisPaletteComboBox class 0026 * A combobox used with KisPaletteView 0027 * 0028 */ 0029 class KRITAWIDGETS_EXPORT KisPaletteComboBox : public KisSqueezedComboBox 0030 { 0031 Q_OBJECT 0032 private: 0033 0034 typedef QPair<int, int> SwatchPosType; // first is column #, second is row # 0035 typedef QHash<SwatchPosType, int> PosIdxMapType; 0036 0037 public: 0038 explicit KisPaletteComboBox(QWidget *parent = 0); 0039 ~KisPaletteComboBox(); 0040 0041 Q_SIGNALS: 0042 void sigColorSelected(const KoColor &); 0043 0044 public: 0045 void setCompanionView(KisPaletteView *); 0046 0047 private Q_SLOTS: 0048 0049 void setPaletteModel(const KisPaletteModel *); 0050 void slotPaletteChanged(); 0051 void slotSwatchSelected(const QModelIndex &index); 0052 void slotIndexUpdated(int); 0053 0054 private: 0055 0056 QPixmap createColorSquare(const KisSwatch &swatch) const; 0057 static bool swatchInfoLess(const KisSwatchGroup::SwatchInfo &, const KisSwatchGroup::SwatchInfo &); 0058 0059 private: 0060 QPointer<const KisPaletteModel> m_model; 0061 QPointer<KisPaletteView> m_view; 0062 QHash<QString, PosIdxMapType> m_groupMapMap; 0063 QVector<KisSwatch> m_idxSwatchMap; 0064 }; 0065 0066 #endif // KISPALETTECOMBOBOX_H