1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
/*
* Copyright (c) 2000 Michael Koch <koch@kde.org>
* Copyright (c) 2000 Patrick Julien <freak@codepimps.org>
* Copyright (c) 2004 Boudewijn Remot <boud@valdyas.org>
* Copyright (c) 2006 Casper Boemann <cbr@boemann.dk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <tqgroupbox.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <klineedit.h>
#include <tdelocale.h>
#include <knuminput.h>
#include <kpushbutton.h>
#include "kis_factory.h"
#include "kis_global.h"
#include "kis_cmb_composite.h"
#include "kis_cmb_idlist.h"
#include "squeezedcombobox.h"
#include "kis_dlg_new_layer.h"
#include <kis_meta_registry.h>
#include "kis_colorspace_factory_registry.h"
#include "kis_profile.h"
#include "kis_colorspace.h"
#include "wdglayerproperties.h"
#include "kis_int_spinbox.h"
NewLayerDialog::NewLayerDialog(const KisID colorSpaceID,
const TQString & profilename,
const TQString & deviceName,
TQWidget *parent,
const char *name)
: super(parent, name, true, "", Ok | Cancel)
{
m_page = new WdgLayerProperties(this);
m_page->layout()->setMargin(0);
setCaption(i18n("New Layer"));
setMainWidget(m_page);
// Name
m_page->editName->setText(deviceName);
// Opacity
m_page->intOpacity->setRange(0, 100, 13);
m_page->intOpacity->setValue(100);
// ColorSpace
m_page->cmbColorSpaces->setIDList(KisMetaRegistry::instance()->csRegistry()->listKeys());
m_page->cmbColorSpaces->setCurrentText(colorSpaceID.id());
connect(m_page->cmbColorSpaces, TQT_SIGNAL(activated(const KisID &)),
this, TQT_SLOT(fillCmbProfiles(const KisID &)));
connect(m_page->cmbColorSpaces, TQT_SIGNAL(activated(const KisID &)),
this, TQT_SLOT(fillCmbComposite(const KisID &)));
// Init profiles
fillCmbProfiles(m_page->cmbColorSpaces->currentItem());
m_page->cmbProfile->setCurrentText(profilename);
// Init composite op
fillCmbComposite(m_page->cmbColorSpaces->currentItem());
/*
connect( m_page->editName, TQT_SIGNAL( textChanged ( const TQString & ) ), this, TQT_SLOT( slotNameChanged( const TQString & ) ) );
slotNameChanged( m_page->editName->text() );
*/
}
void NewLayerDialog::setColorSpaceEnabled(bool enabled)
{
m_page->cmbProfile->setEnabled(enabled);
m_page->cmbColorSpaces->setEnabled(enabled);
}
void NewLayerDialog::fillCmbProfiles(const KisID & s)
{
m_page->cmbProfile->clear();
if (!KisMetaRegistry::instance()->csRegistry()->exists(s)) {
return;
}
KisColorSpaceFactory * csf = KisMetaRegistry::instance()->csRegistry()->get(s);
if (csf == 0) return;
TQValueVector<KisProfile *> profileList = KisMetaRegistry::instance()->csRegistry()->profilesFor( csf );
TQValueVector<KisProfile *> ::iterator it;
for ( it = profileList.begin(); it != profileList.end(); ++it ) {
m_page->cmbProfile->insertItem((*it)->productName());
}
m_page->cmbProfile->setCurrentText(csf->defaultProfile());
}
void NewLayerDialog::fillCmbComposite(const KisID & s)
{
m_page->cmbComposite->clear();
if (!KisMetaRegistry::instance()->csRegistry()->exists(s)) {
return;
}
KisColorSpace * cs = KisMetaRegistry::instance()->csRegistry()->getColorSpace(s,"");
if (cs) {
m_page->cmbComposite->setCompositeOpList(cs->userVisiblecompositeOps());
}
}
int NewLayerDialog::opacity() const
{
TQ_INT32 opacity = m_page->intOpacity->value();
if (!opacity)
return 0;
opacity = int((opacity * 255.0) / 100 + 0.5);
if(opacity>255)
opacity=255;
return opacity;
}
KisCompositeOp NewLayerDialog::compositeOp() const
{
return m_page->cmbComposite->currentItem();
}
KisID NewLayerDialog::colorSpaceID() const
{
return m_page->cmbColorSpaces->currentItem();
}
TQString NewLayerDialog::layerName() const
{
return m_page->editName->text();
}
TQString NewLayerDialog::profileName() const
{
return m_page->cmbProfile-> currentText();
}
#include "kis_dlg_new_layer.moc"
|