1 /* This file is part of the KDE project 2 * Copyright (C) Boudewijn Rempt <boud@valdyas.org>, (C) 2008 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library 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 GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef KIS_PAINTOP_OPTION_H 21 #define KIS_PAINTOP_OPTION_H 22 23 #include <kis_types.h> 24 #include <kritaui_export.h> 25 #include <kis_properties_configuration.h> 26 #include <brushengine/kis_locked_properties_proxy.h> 27 #include <KisPaintopPropertiesBase.h> 28 29 class QWidget; 30 class QString; 31 class KisPaintopLodLimitations; 32 33 34 /** 35 * Base interface for paintop options. A paintop option 36 * can be enabled/disabled, has a configuration page 37 * (for example, a curve), a user-visible name and can 38 * be serialized and deserialized into KisPaintOpPresets 39 * 40 * Because KisPaintOpOption classes create a QWidget in 41 * their constructor (the configuration page) you CANNOT 42 * create those objects in a KisPaintOp. KisPaintOps are 43 * created in non-gui threads. 44 * 45 * Options are disabled by default. 46 */ 47 class KRITAUI_EXPORT KisPaintOpOption : public QObject 48 { 49 Q_OBJECT 50 public: 51 52 enum PaintopCategory { 53 GENERAL, 54 COLOR, 55 TEXTURE, 56 FILTER, 57 MASKING_BRUSH 58 }; 59 60 KisPaintOpOption(KisPaintOpOption::PaintopCategory category, bool checked); 61 ~KisPaintOpOption() override; 62 63 KisPaintOpOption::PaintopCategory category() const; 64 virtual bool isCheckable() const; 65 66 virtual bool isChecked() const; 67 virtual void setChecked(bool checked); 68 69 void setLocked(bool value); 70 bool isLocked() const; 71 72 /** 73 * Reimplement this to use the image in the option widget 74 */ 75 virtual void setImage(KisImageWSP image); 76 77 virtual void setNode(KisNodeWSP node); 78 79 void startReadOptionSetting(const KisPropertiesConfigurationSP setting); 80 void startWriteOptionSetting(KisPropertiesConfigurationSP setting) const; 81 82 QWidget *configurationPage() const; 83 84 virtual void lodLimitations(KisPaintopLodLimitations *l) const; 85 86 protected: 87 88 void setConfigurationPage(QWidget *page); 89 90 protected: 91 /** 92 * Re-implement this to save the configuration to the paint configuration. 93 */ writeOptionSetting(KisPropertiesConfigurationSP setting)94 virtual void writeOptionSetting(KisPropertiesConfigurationSP setting) const { 95 Q_UNUSED(setting); 96 } 97 98 /** 99 * Re-implement this to set the widgets with the values in @p setting. 100 */ readOptionSetting(const KisPropertiesConfigurationSP setting)101 virtual void readOptionSetting(const KisPropertiesConfigurationSP setting) { 102 Q_UNUSED(setting); 103 } 104 105 protected Q_SLOTS: 106 void emitSettingChanged(); 107 void emitCheckedChanged(); 108 109 Q_SIGNALS: 110 111 /** 112 * emit this whenever a setting has changed. It will update the preview 113 */ 114 void sigSettingChanged(); 115 116 /** 117 * emit this whenever a checked state of the option has changed. It as always 118 * emitted *before* sigSettingChanged() 119 */ 120 void sigCheckedChanged(bool value); 121 122 protected: 123 124 bool m_checkable; 125 bool m_locked; 126 127 private: 128 129 struct Private; 130 Private* const m_d; 131 }; 132 133 #endif 134