File indexing completed on 2024-05-12 16:02:03
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 0021 class KisPaletteView; 0022 0023 /** 0024 * @brief The KisPaletteComboBox class 0025 * A combobox used with KisPaletteView 0026 * 0027 */ 0028 class KRITAWIDGETS_EXPORT KisPaletteComboBox : public KisSqueezedComboBox 0029 { 0030 Q_OBJECT 0031 private /* typedef */: 0032 typedef KisSwatchGroup::SwatchInfo SwatchInfoType; 0033 typedef QPair<int, int> SwatchPosType; // first is column #, second is row # 0034 typedef QHash<SwatchPosType, int> PosIdxMapType; 0035 0036 public: 0037 explicit KisPaletteComboBox(QWidget *parent = 0); 0038 ~KisPaletteComboBox(); 0039 0040 Q_SIGNALS: 0041 void sigColorSelected(const KoColor &); 0042 0043 public /* methods */: 0044 void setCompanionView(KisPaletteView *); 0045 0046 private Q_SLOTS: 0047 void setPaletteModel(const KisPaletteModel *); 0048 void slotPaletteChanged(); 0049 void slotSwatchSelected(const QModelIndex &index); 0050 void slotIndexUpdated(int); 0051 0052 private /* methods */: 0053 QPixmap createColorSquare(const KisSwatch &swatch) const; 0054 static bool swatchInfoLess(const SwatchInfoType &, const SwatchInfoType &); 0055 0056 private /* member variables */: 0057 QPointer<const KisPaletteModel> m_model; 0058 QPointer<KisPaletteView> m_view; 0059 QHash<QString, PosIdxMapType> m_groupMapMap; 0060 QVector<KisSwatch> m_idxSwatchMap; 0061 }; 0062 0063 #endif // KISPALETTECOMBOBOX_H