krita
kis_dlg_new_layer.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <qgroupbox.h>
00022 #include <qlabel.h>
00023 #include <qlayout.h>
00024
00025 #include <klineedit.h>
00026 #include <klocale.h>
00027 #include <knuminput.h>
00028 #include <kpushbutton.h>
00029
00030 #include "kis_factory.h"
00031 #include "kis_global.h"
00032 #include "kis_cmb_composite.h"
00033 #include "kis_cmb_idlist.h"
00034 #include "squeezedcombobox.h"
00035 #include "kis_dlg_new_layer.h"
00036 #include <kis_meta_registry.h>
00037 #include "kis_colorspace_factory_registry.h"
00038 #include "kis_profile.h"
00039 #include "kis_colorspace.h"
00040 #include "wdglayerproperties.h"
00041 #include "kis_int_spinbox.h"
00042
00043 NewLayerDialog::NewLayerDialog(const KisID colorSpaceID,
00044 const QString & profilename,
00045 const QString & deviceName,
00046 QWidget *parent,
00047 const char *name)
00048 : super(parent, name, true, "", Ok | Cancel)
00049 {
00050 m_page = new WdgLayerProperties(this);
00051 m_page->layout()->setMargin(0);
00052
00053 setCaption(i18n("New Layer"));
00054
00055 setMainWidget(m_page);
00056
00057
00058 m_page->editName->setText(deviceName);
00059
00060
00061 m_page->intOpacity->setRange(0, 100, 13);
00062 m_page->intOpacity->setValue(100);
00063
00064
00065 m_page->cmbColorSpaces->setIDList(KisMetaRegistry::instance()->csRegistry()->listKeys());
00066 m_page->cmbColorSpaces->setCurrentText(colorSpaceID.id());
00067 connect(m_page->cmbColorSpaces, SIGNAL(activated(const KisID &)),
00068 this, SLOT(fillCmbProfiles(const KisID &)));
00069 connect(m_page->cmbColorSpaces, SIGNAL(activated(const KisID &)),
00070 this, SLOT(fillCmbComposite(const KisID &)));
00071
00072
00073 fillCmbProfiles(m_page->cmbColorSpaces->currentItem());
00074 m_page->cmbProfile->setCurrentText(profilename);
00075
00076
00077 fillCmbComposite(m_page->cmbColorSpaces->currentItem());
00078
00079
00080
00081
00082
00083
00084 }
00085
00086 void NewLayerDialog::setColorSpaceEnabled(bool enabled)
00087 {
00088 m_page->cmbProfile->setEnabled(enabled);
00089 m_page->cmbColorSpaces->setEnabled(enabled);
00090 }
00091
00092 void NewLayerDialog::fillCmbProfiles(const KisID & s)
00093 {
00094 m_page->cmbProfile->clear();
00095
00096 if (!KisMetaRegistry::instance()->csRegistry()->exists(s)) {
00097 return;
00098 }
00099
00100 KisColorSpaceFactory * csf = KisMetaRegistry::instance()->csRegistry()->get(s);
00101 if (csf == 0) return;
00102
00103 QValueVector<KisProfile *> profileList = KisMetaRegistry::instance()->csRegistry()->profilesFor( csf );
00104 QValueVector<KisProfile *> ::iterator it;
00105 for ( it = profileList.begin(); it != profileList.end(); ++it ) {
00106 m_page->cmbProfile->insertItem((*it)->productName());
00107 }
00108 m_page->cmbProfile->setCurrentText(csf->defaultProfile());
00109 }
00110
00111 void NewLayerDialog::fillCmbComposite(const KisID & s)
00112 {
00113 m_page->cmbComposite->clear();
00114
00115 if (!KisMetaRegistry::instance()->csRegistry()->exists(s)) {
00116 return;
00117 }
00118
00119 KisColorSpace * cs = KisMetaRegistry::instance()->csRegistry()->getColorSpace(s,"");
00120 if (cs) {
00121 m_page->cmbComposite->setCompositeOpList(cs->userVisiblecompositeOps());
00122 }
00123 }
00124
00125 int NewLayerDialog::opacity() const
00126 {
00127 Q_INT32 opacity = m_page->intOpacity->value();
00128
00129 if (!opacity)
00130 return 0;
00131
00132 opacity = int((opacity * 255.0) / 100 + 0.5);
00133 if(opacity>255)
00134 opacity=255;
00135 return opacity;
00136 }
00137
00138 KisCompositeOp NewLayerDialog::compositeOp() const
00139 {
00140 return m_page->cmbComposite->currentItem();
00141 }
00142
00143 KisID NewLayerDialog::colorSpaceID() const
00144 {
00145 return m_page->cmbColorSpaces->currentItem();
00146 }
00147
00148 QString NewLayerDialog::layerName() const
00149 {
00150 return m_page->editName->text();
00151 }
00152
00153 QString NewLayerDialog::profileName() const
00154 {
00155 return m_page->cmbProfile-> currentText();
00156 }
00157
00158 #include "kis_dlg_new_layer.moc"
00159
|