File indexing completed on 2024-05-12 15:58:12
0001 /* 0002 * SPDX-FileCopyrightText: 2004 Boudewijn Rempt (boud@valdyas.org) 0003 * SPDX-FileCopyrightText: 2004-2006 Cyrille Berger <cberger@cberger.net> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 #ifndef _KIS_CONFIG_WIDGET_H_ 0008 #define _KIS_CONFIG_WIDGET_H_ 0009 0010 #include <QWidget> 0011 #include <kritaimage_export.h> 0012 0013 #include "kis_signal_compressor.h" 0014 #include <kis_properties_configuration.h> 0015 0016 class KoCanvasResourcesInterface; 0017 using KoCanvasResourcesInterfaceSP = QSharedPointer<KoCanvasResourcesInterface>; 0018 0019 0020 class KisViewManager; 0021 0022 /** 0023 * Empty base class. Configurable resources like filters, paintops etc. 0024 * can build their own configuration widgets that inherit this class. 0025 * The configuration widget should emit sigConfigurationItemChanged 0026 * when it wants a preview updated; there is a timer that 0027 * waits a little time to see if there are more changes coming 0028 * and then emits sigConfigurationUpdated. 0029 */ 0030 class KRITAIMAGE_EXPORT KisConfigWidget : public QWidget 0031 { 0032 0033 Q_OBJECT 0034 0035 protected: 0036 0037 KisConfigWidget(QWidget * parent = 0, Qt::WindowFlags f = Qt::WindowFlags(), int delay = 200); 0038 0039 public: 0040 ~KisConfigWidget() override; 0041 0042 /** 0043 * @param config the configuration for this configuration widget. 0044 */ 0045 virtual void setConfiguration(const KisPropertiesConfigurationSP config) = 0; 0046 0047 /** 0048 * @return the configuration 0049 */ 0050 virtual KisPropertiesConfigurationSP configuration() const = 0; 0051 0052 /** 0053 * Sets the view object that can be used by the configuration 0054 * widget for richer functionality 0055 */ 0056 virtual void setView(KisViewManager *view); 0057 0058 virtual void setCanvasResourcesInterface(KoCanvasResourcesInterfaceSP canvasResourcesInterface); 0059 virtual KoCanvasResourcesInterfaceSP canvasResourcesInterface() const; 0060 0061 Q_SIGNALS: 0062 0063 /** 0064 * emitted whenever it makes sense to update the preview 0065 */ 0066 void sigConfigurationUpdated(); 0067 0068 /** 0069 * Subclasses should emit this signal whenever the preview should be 0070 * be recalculated. This kicks of a timer, so it's perfectly fine 0071 * to connect this to the changed signals of the widgets in your configuration 0072 * widget. 0073 */ 0074 void sigConfigurationItemChanged(); 0075 void sigSaveLockedConfig(KisPropertiesConfigurationSP p); 0076 void sigDropLockedConfig(KisPropertiesConfigurationSP p); 0077 0078 private Q_SLOTS: 0079 0080 void slotConfigChanged(); 0081 0082 private: 0083 KisSignalCompressor m_compressor; 0084 KoCanvasResourcesInterfaceSP m_canvasResourcesInterface; 0085 }; 0086 0087 0088 #endif