krita

kis_meta_registry.cc

00001 /*
00002  *  Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 #include <qstringlist.h>
00019 #include <qdir.h>
00020 #include <kstandarddirs.h>
00021 #include <kglobal.h>
00022 
00023 #include <config.h>
00024 #include LCMS_HEADER
00025 
00026 #include <kis_colorspace_factory_registry.h>
00027 #include <kis_math_toolbox.h>
00028 #include <kis_meta_registry.h>
00029 
00030 KisMetaRegistry * KisMetaRegistry::m_singleton = 0;
00031 
00032 KisMetaRegistry::KisMetaRegistry()
00033 {
00034     // Create the colorspaces and load the profiles
00035 
00036     KGlobal::instance()->dirs()->addResourceType("kis_profiles",
00037                                                      KStandardDirs::kde_default("data") + "krita/profiles/");
00038                           
00039     // Add those things here as well, since we are not yet using KisDoc's KisFactory instance (which inits these as well)
00040     KGlobal::instance()->dirs()->addResourceType("kis_profiles", KStandardDirs::kde_default("data") + "krita/profiles/");
00041     KGlobal::instance()->dirs()->addResourceDir("kis_profiles", "/usr/share/color/icc");
00042     KGlobal::instance()->dirs()->addResourceDir("kis_profiles", QDir::homeDirPath() + QString("/.icc/"));
00043     KGlobal::instance()->dirs()->addResourceDir("kis_profiles", QDir::homeDirPath() + QString("/.color/icc/"));
00044 
00045     QStringList profileFilenames;
00046     profileFilenames += KGlobal::instance()->dirs()->findAllResources("kis_profiles", "*.icm", true /* recursive */);
00047     profileFilenames += KGlobal::instance()->dirs()->findAllResources("kis_profiles", "*.ICM", true);
00048     profileFilenames += KGlobal::instance()->dirs()->findAllResources("kis_profiles", "*.ICC", true);
00049     profileFilenames += KGlobal::instance()->dirs()->findAllResources("kis_profiles", "*.icc", true);
00050     // Set lcms to return NUll/false etc from failing calls, rather than aborting the app.
00051     cmsErrorAction(LCMS_ERROR_SHOW);
00052 
00053     m_csRegistry = new KisColorSpaceFactoryRegistry(profileFilenames);
00054     m_mtRegistry = new KisMathToolboxFactoryRegistry();
00055 }
00056 
00057 KisMetaRegistry::~KisMetaRegistry()
00058 {
00059 }
00060 
00061 KisMetaRegistry * KisMetaRegistry::instance()
00062 {
00063     if ( KisMetaRegistry::m_singleton == 0 ) {
00064         KisMetaRegistry::m_singleton = new KisMetaRegistry();
00065     }
00066     return KisMetaRegistry::m_singleton;
00067 }
00068 
KDE Home | KDE Accessibility Home | Description of Access Keys