Changeset View
Changeset View
Standalone View
Standalone View
libs/widgets/KisPaletteComboBox.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (c) 2018 Michael Zhou <simeirxh@gmail.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU General Public License as published by | ||||
6 | * the Free Software Foundation; either version 2 of the License, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU General Public License | ||||
15 | * along with this program; if not, write to the Free Software | ||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
17 | */ | ||||
18 | | ||||
19 | #ifndef KISPALETTECOMBOBOX_H | ||||
20 | #define KISPALETTECOMBOBOX_H | ||||
21 | | ||||
22 | #include "kritawidgets_export.h" | ||||
23 | | ||||
24 | #include <QComboBox> | ||||
25 | #include <QPointer> | ||||
26 | #include <QScopedPointer> | ||||
27 | #include <QPixmap> | ||||
28 | #include <QPair> | ||||
29 | #include <QHash> | ||||
30 | | ||||
31 | #include <KisPaletteModel.h> | ||||
32 | | ||||
33 | class KisPaletteView; | ||||
34 | | ||||
35 | /** | ||||
36 | * @brief The KisPaletteComboBox class | ||||
37 | * A combobox used with KisPaletteView | ||||
38 | * | ||||
39 | */ | ||||
40 | class KRITAWIDGETS_EXPORT KisPaletteComboBox : public QComboBox | ||||
41 | { | ||||
42 | Q_OBJECT | ||||
43 | private /* typedef */: | ||||
44 | typedef KisSwatchGroup::SwatchInfo SwatchInfoType; | ||||
45 | typedef QPair<int, int> SwatchPosType; // first is column #, second is row # | ||||
46 | typedef QHash<SwatchPosType, int> PosIdxMapType; | ||||
47 | | ||||
48 | public: | ||||
49 | explicit KisPaletteComboBox(QWidget *parent = Q_NULLPTR); | ||||
50 | ~KisPaletteComboBox(); | ||||
51 | | ||||
52 | Q_SIGNALS: | ||||
53 | void sigColorSelected(const KoColor &); | ||||
54 | | ||||
55 | public /* methods */: | ||||
56 | void setCompanionView(KisPaletteView *); | ||||
57 | | ||||
58 | private Q_SLOTS: | ||||
59 | void setPaletteModel(const KisPaletteModel *); | ||||
60 | void slotPaletteChanged(); | ||||
61 | void slotSwatchSelected(const QModelIndex &index); | ||||
62 | void slotIndexUpdated(int); | ||||
63 | | ||||
64 | private /* methods */: | ||||
65 | QPixmap createColorSquare(const KisSwatch &swatch) const; | ||||
66 | static bool swatchInfoLess(const SwatchInfoType &, const SwatchInfoType &); | ||||
67 | | ||||
68 | private /* member variables */: | ||||
69 | QPointer<const KisPaletteModel> m_model; | ||||
70 | QPointer<KisPaletteView> m_view; | ||||
71 | QHash<QString, PosIdxMapType> m_groupMapMap; | ||||
72 | QVector<KisSwatch> m_idxSwatchMap; | ||||
73 | }; | ||||
74 | | ||||
75 | #endif // KISPALETTECOMBOBOX_H |