File indexing completed on 2024-12-22 04:10:06
0001 /* 0002 * SPDX-FileCopyrightText: 2008 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "generator/kis_generator_registry.h" 0008 0009 #include <math.h> 0010 0011 #include <QString> 0012 #include <QApplication> 0013 0014 #include <klocalizedstring.h> 0015 0016 #include <KoPluginLoader.h> 0017 0018 #include "filter/kis_filter_configuration.h" 0019 #include "kis_debug.h" 0020 #include "kis_types.h" 0021 #include "kis_paint_device.h" 0022 #include "generator/kis_generator.h" 0023 0024 KisGeneratorRegistry::KisGeneratorRegistry(QObject *parent) 0025 : QObject(parent) 0026 { 0027 } 0028 0029 KisGeneratorRegistry::~KisGeneratorRegistry() 0030 { 0031 Q_FOREACH (KisGeneratorSP generator, values()) { 0032 remove(generator->id()); 0033 generator.clear(); 0034 } 0035 dbgRegistry << "deleting KisGeneratorRegistry"; 0036 } 0037 0038 KisGeneratorRegistry* KisGeneratorRegistry::instance() 0039 { 0040 KisGeneratorRegistry *reg = qApp->findChild<KisGeneratorRegistry *>(QString()); 0041 if (!reg) { 0042 dbgRegistry << "initializing KisGeneratorRegistry"; 0043 reg = new KisGeneratorRegistry(qApp); 0044 KoPluginLoader::instance()->load("Krita/Generator", "Type == 'Service' and ([X-Krita-Version] == 28)"); 0045 } 0046 return reg; 0047 } 0048 0049 void KisGeneratorRegistry::add(KisGeneratorSP item) 0050 { 0051 dbgPlugins << "adding " << item->name(); 0052 add(item->id(), item); 0053 } 0054 0055 void KisGeneratorRegistry::add(const QString &id, KisGeneratorSP item) 0056 { 0057 dbgPlugins << "adding " << item->name() << " with id " << id; 0058 KoGenericRegistry<KisGeneratorSP>::add(id, item); 0059 emit(generatorAdded(id)); 0060 } 0061