chalk

kis_dlg_image_properties.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#include <tqbuttongroup.h>
19#include <tqpushbutton.h>
20#include <tqradiobutton.h>
21#include <tqgroupbox.h>
22#include <tqlayout.h>
23#include <tqlabel.h>
24#include <tqspinbox.h>
25#include <tqslider.h>
26#include <tqtextedit.h>
27#include <tqcheckbox.h>
28
29#include <tdelocale.h>
30#include <kcolorcombo.h>
31
32#include <KoUnitWidgets.h>
33
34#include "kis_factory.h"
35#include "kis_meta_registry.h"
36#include "kis_colorspace_factory_registry.h"
37#include "kis_dlg_image_properties.h"
38#include "kis_profile.h"
39#include "kis_types.h"
40#include "kis_image.h"
41#include "kis_config.h"
42#include "kis_id.h"
43#include "kis_cmb_idlist.h"
44#include "squeezedcombobox.h"
45#include "wdgnewimage.h"
46
47KisDlgImageProperties::KisDlgImageProperties(KisImageSP image, TQWidget *parent, const char *name)
48 : super(parent, name, true, "", Ok | Cancel)
49{
50
51 setCaption(i18n("Image Properties"));
52 m_page = new WdgNewImage(this);
53
54 m_page->lblResolution->hide();
55 m_page->doubleResolution->hide();
56
57
58 m_image = image;
59
60 setMainWidget(m_page);
61 resize(m_page->sizeHint());
62
63 m_page->txtName->setText(image->name());
64 m_page->m_createButton->hide();
65 KisConfig cfg;
66
67 m_page->intWidth->setValue(image->width());
68 m_page->intHeight->setValue(image->height());
69 m_page->txtDescription->setText(image->description());
70 m_page->doubleResolution->setValue(image->xRes()); // XXX: separate values for x & y?
71
72 //m_page->cmbColorSpaces->hide();
73 //m_page->lblColorSpaces->setText(image->colorSpace()->id().name());
74 KisIDList colorSpaces = KisMetaRegistry::instance()->csRegistry()->listKeys();
75 KisIDList::iterator i = colorSpaces.find(KisID("WET",""));
76 if (i != colorSpaces.end()) {
77 colorSpaces.remove(i);
78 }
79 m_page->cmbColorSpaces->setIDList(colorSpaces);
80 m_page->cmbColorSpaces->setCurrent(image->colorSpace()->id());
81
82 fillCmbProfiles(image->colorSpace()->id());
83
84 if (image->getProfile()) {
85 m_page->cmbProfile->setCurrentText(image->getProfile()->productName());
86 }
87 else {
88 m_page->cmbProfile->setCurrentItem(0);
89 }
90
91 m_page->sliderOpacity->setEnabled(false); // XXX re-enable when figured out a way to do this
92 m_page->opacityPanel->hide();
93 m_page->lblOpacity->hide();
94
95 m_page->cmbColor->setEnabled(false); // XXX re-enable when figured out a way to do this
96 m_page->cmbColor->hide();
97 m_page->lblColor->hide();
98
99 connect(m_page->cmbColorSpaces, TQ_SIGNAL(activated(const KisID &)),
100 this, TQ_SLOT(fillCmbProfiles(const KisID &)));
101
102
103}
104
105KisDlgImageProperties::~KisDlgImageProperties()
106{
107 delete m_page;
108}
109
110int KisDlgImageProperties::imageWidth()
111{
112 return m_page->intWidth->value();
113}
114
115int KisDlgImageProperties::imageHeight()
116{
117 return m_page->intHeight->value();
118}
119
120int KisDlgImageProperties::opacity()
121{
122 return m_page->sliderOpacity->value();
123}
124
125TQString KisDlgImageProperties::imageName()
126{
127 return m_page->txtName->text();
128}
129
130double KisDlgImageProperties::resolution()
131{
132 return m_page->doubleResolution->value();
133}
134
135TQString KisDlgImageProperties::description()
136{
137 return m_page->txtDescription->text();
138}
139
140KisColorSpace * KisDlgImageProperties::colorSpace()
141{
142 return KisMetaRegistry::instance()->csRegistry()->getColorSpace(m_page->cmbColorSpaces->currentItem(), m_page->cmbProfile->currentText());
143}
144
145KisProfile * KisDlgImageProperties::profile()
146{
147 TQValueVector<KisProfile *> profileList = KisMetaRegistry::instance()->csRegistry()->profilesFor( m_image->colorSpace()->id() );
148 TQ_UINT32 index = m_page->cmbProfile->currentItem();
149
150 if (index < profileList.count()) {
151 return profileList.at(index);
152 } else {
153 return 0;
154 }
155}
156
157// XXX: Copy & paste from kis_dlg_create_img -- refactor to separate class
158void KisDlgImageProperties::fillCmbProfiles(const KisID & s)
159{
160
161 KisColorSpaceFactory * csf = KisMetaRegistry::instance()->csRegistry()->get(s);
162 m_page->cmbProfile->clear();
163 TQValueVector<KisProfile *> profileList = KisMetaRegistry::instance()->csRegistry()->profilesFor( csf );
164 TQValueVector<KisProfile *> ::iterator it;
165 for ( it = profileList.begin(); it != profileList.end(); ++it ) {
166 m_page->cmbProfile->insertItem((*it)->productName());
167 }
168
169
170}
171
172#include "kis_dlg_image_properties.moc"
173
TQValueVector< KisProfile * > profilesFor(KisColorSpaceFactory *cs)
Return the vector of profiles for this colorspacefactory.
KisColorSpace * getColorSpace(const KisID &csID, const TQString &profileName)
Return the colorspace + profile as named, or NULL if impossible combination.
A colorspace is the definition of a certain color model in Chalk.
_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