chalk

kis_dlg_apply_profile.cpp
1/*
2 * Copyright (c) 2004 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
19#include <tqcombobox.h>
20#include <tdelocale.h>
21#include <tqbuttongroup.h>
22
23#include "kis_factory.h"
24#include "kis_colorspace_factory_registry.h"
25#include "kis_types.h"
26#include "kis_profile.h"
27#include "kis_colorspace.h"
28#include "kis_dlg_apply_profile.h"
29#include "kis_config.h"
30#include "kis_id.h"
31#include <kis_meta_registry.h>
32#include "kis_cmb_idlist.h"
33#include "squeezedcombobox.h"
34#include "wdgapplyprofile.h"
35
36// XXX: Hardcode RGBA name. This should be a constant, somewhere.
37KisDlgApplyProfile::KisDlgApplyProfile(TQWidget *parent, const char *name)
38 : super(parent, name, true, "", Ok | Cancel)
39{
40
41 setCaption(i18n("Apply Image Profile to Clipboard Data"));
42 m_page = new WdgApplyProfile(this);
43
44 setMainWidget(m_page);
45 resize(m_page->sizeHint());
46
47 // XXX: This is BAD! (bsar)
48 fillCmbProfiles(KisID("RGBA", ""));
49 KisConfig cfg;
50 m_page->grpRenderIntent->setButton(cfg.renderIntent());
51
52}
53
54KisDlgApplyProfile::~KisDlgApplyProfile()
55{
56 delete m_page;
57}
58
59
60KisProfile * KisDlgApplyProfile::profile() const
61{
62 TQString profileName;
63
64 profileName = m_page->cmbProfile->currentText();
65
66 return KisMetaRegistry::instance()->csRegistry()->getProfileByName(profileName);
67}
68
69int KisDlgApplyProfile::renderIntent() const
70{
71 return m_page->grpRenderIntent->selectedId();
72}
73
74
75// XXX: Copy & paste from kis_custom_image_widget -- refactor to separate class
76void KisDlgApplyProfile::fillCmbProfiles(const KisID & s)
77{
78 m_page->cmbProfile->clear();
79
80 if (!KisMetaRegistry::instance()->csRegistry()->exists(s)) {
81 return;
82 }
83
84 KisColorSpaceFactory * csf = KisMetaRegistry::instance()->csRegistry()->get(s);
85 if (csf == 0) return;
86
87 TQValueVector<KisProfile *> profileList = KisMetaRegistry::instance()->csRegistry()->profilesFor( csf );
88 TQValueVector<KisProfile *> ::iterator it;
89 for ( it = profileList.begin(); it != profileList.end(); ++it ) {
90 m_page->cmbProfile->insertItem((*it)->productName());
91 }
92 m_page->cmbProfile->setCurrentText(csf->defaultProfile());
93}
94
95#include "kis_dlg_apply_profile.moc"
96
TQValueVector< KisProfile * > profilesFor(KisColorSpaceFactory *cs)
Return the vector of profiles for this colorspacefactory.
KisProfile * getProfileByName(const TQString &name)
Return the profile associated with the given product name, or 0.
_T get(const KisID &name) const
This function allow to get an object from its KisID.
Chalk has a large number of extensible resources.
Definition kis_id.h:57