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     QStringList profileFilenames;
00040     profileFilenames += KGlobal::instance()->dirs()->findAllResources("kis_profiles", "*.icm");
00041     profileFilenames += KGlobal::instance()->dirs()->findAllResources("kis_profiles", "*.ICM");
00042     profileFilenames += KGlobal::instance()->dirs()->findAllResources("kis_profiles", "*.ICC");
00043     profileFilenames += KGlobal::instance()->dirs()->findAllResources("kis_profiles", "*.icc");
00044 
00045     QDir d("/usr/share/color/icc/", "*.icc;*.ICC;*.icm;*.ICM");
00046 
00047     QStringList filenames = d.entryList();
00048 
00049     for (QStringList::iterator it = filenames.begin(); it != filenames.end(); ++it) {
00050         profileFilenames += d.absFilePath(*it);
00051     }
00052 
00053     d.setPath(QDir::homeDirPath() + "/.color/icc/");
00054     filenames = d.entryList();
00055 
00056     for (QStringList::iterator it = filenames.begin(); it != filenames.end(); ++it) {
00057         profileFilenames += d.absFilePath(*it);
00058     }
00059 
00060     // Set lcms to return NUll/false etc from failing calls, rather than aborting the app.
00061     cmsErrorAction(LCMS_ERROR_SHOW);
00062 
00063     m_csRegistry = new KisColorSpaceFactoryRegistry(profileFilenames);
00064     m_mtRegistry = new KisMathToolboxFactoryRegistry();
00065 }
00066 
00067 KisMetaRegistry::~KisMetaRegistry()
00068 {
00069 }
00070 
00071 KisMetaRegistry * KisMetaRegistry::instance()
00072 {
00073     if ( KisMetaRegistry::m_singleton == 0 ) {
00074         KisMetaRegistry::m_singleton = new KisMetaRegistry();
00075     }
00076     return KisMetaRegistry::m_singleton;
00077 }
00078 
KDE Home | KDE Accessibility Home | Description of Access Keys