krita

kis_dlg_apply_profile.cc

00001 /*
00002  *  Copyright (c) 2004 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 
00019 #include <qcombobox.h>
00020 #include <klocale.h>
00021 #include <qbuttongroup.h>
00022 
00023 #include "kis_factory.h"
00024 #include "kis_colorspace_factory_registry.h"
00025 #include "kis_types.h"
00026 #include "kis_profile.h"
00027 #include "kis_colorspace.h"
00028 #include "kis_dlg_apply_profile.h"
00029 #include "kis_config.h"
00030 #include "kis_id.h"
00031 #include <kis_meta_registry.h>
00032 #include "kis_cmb_idlist.h"
00033 #include "squeezedcombobox.h"
00034 #include "wdgapplyprofile.h"
00035 
00036 // XXX: Hardcode RGBA name. This should be a constant, somewhere.
00037 KisDlgApplyProfile::KisDlgApplyProfile(QWidget *parent, const char *name)
00038     : super(parent, name, true, "", Ok | Cancel)
00039 {
00040 
00041     setCaption(i18n("Apply Image Profile to Clipboard Data"));
00042     m_page = new WdgApplyProfile(this);
00043 
00044     setMainWidget(m_page);
00045     resize(m_page->sizeHint());
00046 
00047     // XXX: This is BAD! (bsar)
00048     fillCmbProfiles(KisID("RGBA", ""));
00049     KisConfig cfg;
00050     m_page->grpRenderIntent->setButton(cfg.renderIntent());
00051 
00052 }
00053 
00054 KisDlgApplyProfile::~KisDlgApplyProfile()
00055 {
00056     delete m_page;
00057 }
00058 
00059 
00060 KisProfile *  KisDlgApplyProfile::profile() const
00061 {
00062     QString profileName;
00063 
00064     profileName = m_page->cmbProfile->currentText();
00065 
00066     return KisMetaRegistry::instance()->csRegistry()->getProfileByName(profileName);
00067 }
00068 
00069 int KisDlgApplyProfile::renderIntent() const
00070 {
00071     return m_page->grpRenderIntent->selectedId();
00072 }
00073 
00074 
00075 // XXX: Copy & paste from kis_custom_image_widget -- refactor to separate class
00076 void KisDlgApplyProfile::fillCmbProfiles(const KisID & s)
00077 {
00078     m_page->cmbProfile->clear();
00079 
00080     if (!KisMetaRegistry::instance()->csRegistry()->exists(s)) {
00081         return;
00082     }
00083 
00084     KisColorSpaceFactory * csf = KisMetaRegistry::instance()->csRegistry()->get(s);
00085     if (csf == 0) return;
00086 
00087     QValueVector<KisProfile *>  profileList = KisMetaRegistry::instance()->csRegistry()->profilesFor( csf );
00088         QValueVector<KisProfile *> ::iterator it;
00089         for ( it = profileList.begin(); it != profileList.end(); ++it ) {
00090             m_page->cmbProfile->insertItem((*it)->productName());
00091     }
00092     m_page->cmbProfile->setCurrentText(csf->defaultProfile());
00093 }
00094 
00095 #include "kis_dlg_apply_profile.moc"
00096 
KDE Home | KDE Accessibility Home | Description of Access Keys