chalk

kis_meta_registry.cpp
1/*
2 * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program 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
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18#include <tqstringlist.h>
19#include <tqdir.h>
20#include <kstandarddirs.h>
21#include <tdeglobal.h>
22
23#include <config.h>
24#include LCMS_HEADER
25
26#include <kis_colorspace_factory_registry.h>
27#include <kis_math_toolbox.h>
28#include <kis_meta_registry.h>
29
30KisMetaRegistry * KisMetaRegistry::m_singleton = 0;
31
32KisMetaRegistry::KisMetaRegistry()
33{
34 // Create the colorspaces and load the profiles
35
36 TDEGlobal::instance()->dirs()->addResourceType("kis_profiles",
37 TDEStandardDirs::kde_default("data") + "chalk/profiles/");
38
39 // Add those things here as well, since we are not yet using KisDoc's KisFactory instance (which inits these as well)
40 TDEGlobal::instance()->dirs()->addResourceType("kis_profiles", TDEStandardDirs::kde_default("data") + "chalk/profiles/");
41 TDEGlobal::instance()->dirs()->addResourceDir("kis_profiles", "/usr/share/color/icc");
42 TDEGlobal::instance()->dirs()->addResourceDir("kis_profiles", TQDir::homeDirPath() + TQString("/.icc/"));
43 TDEGlobal::instance()->dirs()->addResourceDir("kis_profiles", TQDir::homeDirPath() + TQString("/.color/icc/"));
44
45 TQStringList profileFilenames;
46 profileFilenames += TDEGlobal::instance()->dirs()->findAllResources("kis_profiles", "*.icm", true /* recursive */);
47 profileFilenames += TDEGlobal::instance()->dirs()->findAllResources("kis_profiles", "*.ICM", true);
48 profileFilenames += TDEGlobal::instance()->dirs()->findAllResources("kis_profiles", "*.ICC", true);
49 profileFilenames += TDEGlobal::instance()->dirs()->findAllResources("kis_profiles", "*.icc", true);
50 // Set lcms to return NUll/false etc from failing calls, rather than aborting the app.
51 cmsErrorAction(LCMS_ERROR_SHOW);
52
53 m_csRegistry = new KisColorSpaceFactoryRegistry(profileFilenames);
54 m_mtRegistry = new KisMathToolboxFactoryRegistry();
55}
56
57KisMetaRegistry::~KisMetaRegistry()
58{
59}
60
61KisMetaRegistry * KisMetaRegistry::instance()
62{
63 if ( KisMetaRegistry::m_singleton == 0 ) {
64 KisMetaRegistry::m_singleton = new KisMetaRegistry();
65 }
66 return KisMetaRegistry::m_singleton;
67}
68
A single singleton that provides access to several registries.