1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
/*
* Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <tqpixmap.h>
#include <tqwidget.h>
#include <kdebug.h>
#include <kinstance.h>
#include <kglobal.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <tdeparts/plugin.h>
#include <kservice.h>
#include <ktrader.h>
#include <tdeparts/componentfactory.h>
#include "kis_generic_registry.h"
#include "kis_types.h"
#include "kis_paintop_registry.h"
#include "kis_paintop.h"
#include "kis_id.h"
#include "kis_debug_areas.h"
#include "kis_colorspace.h"
KisPaintOpRegistry * KisPaintOpRegistry::m_singleton = 0;
KisPaintOpRegistry::KisPaintOpRegistry()
{
Q_ASSERT(KisPaintOpRegistry::m_singleton == 0);
KisPaintOpRegistry::m_singleton = this;
TDETrader::OfferList offers = TDETrader::self()->query(TQString::fromLatin1("Chalk/Paintop"),
TQString::fromLatin1("(Type == 'Service') and "
"([X-Chalk-Version] == 2)"));
TDETrader::OfferList::ConstIterator iter;
for(iter = offers.begin(); iter != offers.end(); ++iter)
{
KService::Ptr service = *iter;
int errCode = 0;
KParts::Plugin* plugin =
KParts::ComponentFactory::createInstanceFromService<KParts::Plugin> ( service, this, 0, TQStringList(), &errCode);
if ( plugin )
kdDebug(41006) << "found plugin " << service->property("Name").toString() << "\n";
else {
kdDebug(41006) << "found plugin " << service->property("Name").toString() << ", " << errCode << "\n";
if( errCode == KParts::ComponentFactory::ErrNoLibrary)
{
kdWarning(41006) << " Error loading plugin was : ErrNoLibrary " << KLibLoader::self()->lastErrorMessage() << endl;
}
}
}
}
KisPaintOpRegistry::~KisPaintOpRegistry()
{
}
KisPaintOpRegistry* KisPaintOpRegistry::instance()
{
if(KisPaintOpRegistry::m_singleton == 0)
{
KisPaintOpRegistry::m_singleton = new KisPaintOpRegistry();
TQ_CHECK_PTR(KisPaintOpRegistry::m_singleton);
}
return KisPaintOpRegistry::m_singleton;
}
KisPaintOp * KisPaintOpRegistry::paintOp(const KisID & id, const KisPaintOpSettings * settings, KisPainter * painter) const
{
if (painter == 0) {
kdWarning() << " KisPaintOpRegistry::paintOp painter is null";
return 0;
}
KisPaintOpFactorySP f = get(id);
if (f) {
return f->createOp(settings, painter);
}
else {
return 0;
}
}
KisPaintOp * KisPaintOpRegistry::paintOp(const TQString & id, const KisPaintOpSettings * settings, KisPainter * painter) const
{
return paintOp(KisID(id, ""), settings, painter);
}
KisPaintOpSettings * KisPaintOpRegistry::settings(const KisID& id, TQWidget * parent, const KisInputDevice& inputDevice) const
{
KisPaintOpFactory* f = get(id);
if (f)
return f->settings( parent, inputDevice );
return 0;
}
bool KisPaintOpRegistry::userVisible(const KisID & id, KisColorSpace* cs) const
{
KisPaintOpFactorySP f = get(id);
if (!f) {
kdDebug(DBG_AREA_REGISTRY) << "No paintop " << id.id() << "\n";
return false;
}
return f->userVisible(cs);
}
TQString KisPaintOpRegistry::pixmap(const KisID & id) const
{
KisPaintOpFactorySP f = get(id);
if (!f) {
kdDebug(DBG_AREA_REGISTRY) << "No paintop " << id.id() << "\n";
return "";
}
return f->pixmap();
}
#include "kis_paintop_registry.moc"
|