File indexing completed on 2024-12-22 04:15:08
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 #ifndef PYQTPLUGINSETTINGS_H 0007 #define PYQTPLUGINSETTINGS_H 0008 0009 #include "kis_preference_set_registry.h" 0010 0011 namespace Ui 0012 { 0013 class ManagerPage; 0014 } 0015 0016 class QIcon; 0017 class PythonPluginManager; 0018 0019 class PyQtPluginSettings : public KisPreferenceSet 0020 { 0021 Q_OBJECT 0022 public: 0023 PyQtPluginSettings(PythonPluginManager *pluginManager, 0024 QWidget *parent = nullptr); 0025 ~PyQtPluginSettings() override; 0026 0027 QString id() override; 0028 QString name() override; 0029 QString header() override; 0030 QIcon icon() override; 0031 0032 public Q_SLOTS: 0033 void savePreferences() const override; 0034 void loadPreferences() override; 0035 void loadDefaultPreferences() override; 0036 0037 Q_SIGNALS: 0038 void settingsChanged() const; 0039 0040 private Q_SLOTS: 0041 0042 void updateManual(const QModelIndex &index); 0043 0044 private: 0045 PythonPluginManager *m_pluginManager; 0046 Ui::ManagerPage *m_page; 0047 0048 }; 0049 0050 0051 class PyQtPluginSettingsUpdateRepeater : public QObject 0052 { 0053 Q_OBJECT 0054 0055 Q_SIGNALS: 0056 void settingsUpdated(); 0057 0058 public Q_SLOTS: 0059 void updateSettings() { 0060 Q_EMIT settingsUpdated(); 0061 } 0062 }; 0063 0064 0065 class PyQtPluginSettingsFactory : public KisAbstractPreferenceSetFactory 0066 { 0067 public: 0068 PyQtPluginSettingsFactory(PythonPluginManager *engine) 0069 : m_pluginManager(engine) 0070 { 0071 } 0072 0073 KisPreferenceSet *createPreferenceSet() override 0074 { 0075 PyQtPluginSettings* ps = new PyQtPluginSettings(m_pluginManager); 0076 QObject::connect(ps, SIGNAL(settingsChanged()), &repeater, SLOT(updateSettings()), Qt::UniqueConnection); 0077 return ps; 0078 } 0079 QString id() const override 0080 { 0081 return "PyQtSettings"; 0082 } 0083 PyQtPluginSettingsUpdateRepeater repeater; 0084 PythonPluginManager *m_pluginManager; 0085 }; 0086 0087 0088 0089 0090 #endif // PYQTPLUGINSETTINGS_H