krita
kis_dlg_image_properties.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <qbuttongroup.h>
00019 #include <qpushbutton.h>
00020 #include <qradiobutton.h>
00021 #include <qgroupbox.h>
00022 #include <qlayout.h>
00023 #include <qlabel.h>
00024 #include <qspinbox.h>
00025 #include <qslider.h>
00026 #include <qtextedit.h>
00027 #include <qcheckbox.h>
00028
00029 #include <klocale.h>
00030 #include <kcolorcombo.h>
00031
00032 #include <KoUnitWidgets.h>
00033
00034 #include "kis_factory.h"
00035 #include "kis_meta_registry.h"
00036 #include "kis_colorspace_factory_registry.h"
00037 #include "kis_dlg_image_properties.h"
00038 #include "kis_profile.h"
00039 #include "kis_types.h"
00040 #include "kis_image.h"
00041 #include "kis_config.h"
00042 #include "kis_id.h"
00043 #include "kis_cmb_idlist.h"
00044 #include "squeezedcombobox.h"
00045 #include "wdgnewimage.h"
00046
00047 KisDlgImageProperties::KisDlgImageProperties(KisImageSP image, QWidget *parent, const char *name)
00048 : super(parent, name, true, "", Ok | Cancel)
00049 {
00050
00051 setCaption(i18n("Image Properties"));
00052 m_page = new WdgNewImage(this);
00053
00054 m_page->lblResolution->hide();
00055 m_page->doubleResolution->hide();
00056
00057
00058 m_image = image;
00059
00060 setMainWidget(m_page);
00061 resize(m_page->sizeHint());
00062
00063 m_page->txtName->setText(image->name());
00064 m_page->m_createButton->hide();
00065 KisConfig cfg;
00066
00067 m_page->intWidth->setValue(image->width());
00068 m_page->intHeight->setValue(image->height());
00069
00070 m_page->doubleResolution->setValue(image->xRes());
00071
00072
00073
00074 KisIDList colorSpaces = KisMetaRegistry::instance()->csRegistry()->listKeys();
00075 KisIDList::iterator i = colorSpaces.find(KisID("WET",""));
00076 if (i != colorSpaces.end()) {
00077 colorSpaces.remove(i);
00078 }
00079 m_page->cmbColorSpaces->setIDList(colorSpaces);
00080 m_page->cmbColorSpaces->setCurrent(image->colorSpace()->id());
00081
00082 fillCmbProfiles(image->colorSpace()->id());
00083
00084 if (image->getProfile()) {
00085 m_page->cmbProfile->setCurrentText(image->getProfile()->productName());
00086 }
00087 else {
00088 m_page->cmbProfile->setCurrentItem(0);
00089 }
00090
00091 m_page->sliderOpacity->setEnabled(false);
00092 m_page->opacityPanel->hide();
00093 m_page->lblOpacity->hide();
00094
00095 m_page->cmbColor->setEnabled(false);
00096 m_page->cmbColor->hide();
00097 m_page->lblColor->hide();
00098
00099 connect(m_page->cmbColorSpaces, SIGNAL(activated(const KisID &)),
00100 this, SLOT(fillCmbProfiles(const KisID &)));
00101
00102
00103 }
00104
00105 KisDlgImageProperties::~KisDlgImageProperties()
00106 {
00107 delete m_page;
00108 }
00109
00110 int KisDlgImageProperties::imageWidth()
00111 {
00112 return m_page->intWidth->value();
00113 }
00114
00115 int KisDlgImageProperties::imageHeight()
00116 {
00117 return m_page->intHeight->value();
00118 }
00119
00120 int KisDlgImageProperties::opacity()
00121 {
00122 return m_page->sliderOpacity->value();
00123 }
00124
00125 QString KisDlgImageProperties::imageName()
00126 {
00127 return m_page->txtName->text();
00128 }
00129
00130 double KisDlgImageProperties::resolution()
00131 {
00132 return m_page->doubleResolution->value();
00133 }
00134
00135 QString KisDlgImageProperties::description()
00136 {
00137 return m_page->txtDescription->text();
00138 }
00139
00140 KisColorSpace * KisDlgImageProperties::colorSpace()
00141 {
00142 return KisMetaRegistry::instance()->csRegistry()->getColorSpace(m_page->cmbColorSpaces->currentItem(), m_page->cmbProfile->currentText());
00143 }
00144
00145 KisProfile * KisDlgImageProperties::profile()
00146 {
00147 QValueVector<KisProfile *> profileList = KisMetaRegistry::instance()->csRegistry()->profilesFor( m_image->colorSpace()->id() );
00148 Q_UINT32 index = m_page->cmbProfile->currentItem();
00149
00150 if (index < profileList.count()) {
00151 return profileList.at(index);
00152 } else {
00153 return 0;
00154 }
00155 }
00156
00157
00158 void KisDlgImageProperties::fillCmbProfiles(const KisID & s)
00159 {
00160
00161 KisColorSpaceFactory * csf = KisMetaRegistry::instance()->csRegistry()->get(s);
00162 m_page->cmbProfile->clear();
00163 QValueVector<KisProfile *> profileList = KisMetaRegistry::instance()->csRegistry()->profilesFor( csf );
00164 QValueVector<KisProfile *> ::iterator it;
00165 for ( it = profileList.begin(); it != profileList.end(); ++it ) {
00166 m_page->cmbProfile->insertItem((*it)->productName());
00167 }
00168
00169
00170 }
00171
00172 #include "kis_dlg_image_properties.moc"
00173
|