File indexing completed on 2024-05-12 16:01:30
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2009 Vera Lukman <shicmap@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #ifndef KIS_FAVORITE_RESOURCE_MANAGER_H 0008 #define KIS_FAVORITE_RESOURCE_MANAGER_H 0009 0010 #include <QObject> 0011 #include <kis_types.h> 0012 #include <QQueue> 0013 #include <QList> 0014 #include "KoResourceServer.h" 0015 #include <KisTag.h> 0016 #include "KisTagFilterResourceProxyModel.h" 0017 0018 #include <KoColor.h> 0019 #include <KoResource.h> 0020 0021 class QString; 0022 class KisPaintopBox; 0023 class KisPaintOpPreset; 0024 0025 class KisFavoriteResourceManager : public QObject, public KoResourceServerObserver<KisPaintOpPreset> 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 0031 KisFavoriteResourceManager(KisPaintopBox *paintopBox); 0032 ~KisFavoriteResourceManager() override; 0033 0034 void unsetResourceServer() override; 0035 0036 QList<QImage> favoritePresetImages(); 0037 QVector<QString> favoritePresetNamesList(); 0038 0039 void setCurrentTag(const KisTagSP tag); 0040 0041 int numFavoritePresets(); 0042 0043 void updateFavoritePresets(); 0044 0045 int recentColorsTotal(); 0046 const KoColor& recentColorAt(int pos); 0047 0048 // Reimplemented from KoResourceServerObserver 0049 void removingResource(QSharedPointer<KisPaintOpPreset> resource) override; 0050 void resourceAdded(QSharedPointer<KisPaintOpPreset> resource) override; 0051 void resourceChanged(QSharedPointer<KisPaintOpPreset> resource) override; 0052 0053 //BgColor; 0054 KoColor bgColor() const; 0055 0056 0057 Q_SIGNALS: 0058 0059 void sigSetFGColor(const KoColor& c); 0060 void sigSetBGColor(const KoColor& c); 0061 0062 void sigChangeFGColorSelector(const KoColor&); 0063 0064 void setSelectedColor(int); 0065 0066 void updatePalettes(); 0067 0068 void hidePalettes(); 0069 0070 public Q_SLOTS: 0071 0072 void slotChangeActivePaintop(int); 0073 0074 /*update the priority of a color in m_colorList, used only by m_popupPalette*/ 0075 void slotUpdateRecentColor(int); 0076 0077 /*add a color to m_colorList, used by KisCanvasResourceProvider*/ 0078 void slotAddRecentColor(const KoColor&); 0079 0080 void slotChangeFGColorSelector(KoColor c); 0081 0082 void slotSetBGColor(const KoColor c); 0083 0084 /** Clears the color history shown in the popup palette. */ 0085 void slotClearHistory(); 0086 0087 private Q_SLOTS: 0088 0089 void configChanged(); 0090 void presetsChanged(); 0091 0092 private: 0093 0094 void init(); 0095 0096 KisPaintopBox *m_paintopBox {nullptr}; 0097 0098 class ColorDataList; 0099 ColorDataList *m_colorList {nullptr}; 0100 0101 void saveFavoritePresets(); 0102 0103 KoColor m_bgColor; 0104 KisTagSP m_currentTag; 0105 0106 bool m_initialized {false}; 0107 0108 int m_maxPresets {0}; 0109 0110 KisTagModel* m_tagModel {nullptr}; 0111 KisTagFilterResourceProxyModel* m_resourcesProxyModel {nullptr}; 0112 KisResourceModel* m_resourceModel {nullptr}; 0113 0114 }; 0115 0116 #endif