krita

kis_dlg_layer_properties.cc

00001 /*
00002  *  Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 #include <limits.h>
00019 #include <qlabel.h>
00020 #include <qlayout.h>
00021 #include <qgroupbox.h>
00022 #include <qslider.h>
00023 #include <qstring.h>
00024 #include <klineedit.h>
00025 #include <klocale.h>
00026 #include <kpushbutton.h>
00027 #include <knuminput.h>
00028 #include "kis_global.h"
00029 #include "squeezedcombobox.h"
00030 #include "wdglayerproperties.h"
00031 #include "kis_dlg_layer_properties.h"
00032 #include "kis_cmb_composite.h"
00033 #include "kis_cmb_idlist.h"
00034 #include "kis_profile.h"
00035 #include "kis_int_spinbox.h"
00036 #include "kis_colorspace.h"
00037 
00038 KisDlgLayerProperties::KisDlgLayerProperties(const QString& deviceName,
00039                      Q_INT32 opacity,
00040                      const KisCompositeOp& compositeOp,
00041                      const KisColorSpace * colorSpace,
00042                      QWidget *parent, const char *name, WFlags f)
00043     : super(parent, name, f, name, Ok | Cancel)
00044 {
00045     m_page = new WdgLayerProperties(this);
00046     m_page->layout()->setMargin(0);
00047 
00048     opacity = int((opacity * 100.0) / 255 + 0.5);
00049 
00050     setCaption(i18n("Layer Properties"));
00051     setMainWidget(m_page);
00052 
00053     m_page->editName->setText(deviceName);
00054     connect( m_page->editName, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotNameChanged( const QString & ) ) );
00055 
00056     m_page->cmbColorSpaces->setCurrent(colorSpace->id());
00057     m_page->cmbColorSpaces->setEnabled(false);
00058 
00059     QString profilename;
00060     if (KisProfile* profile = const_cast<KisColorSpace *>(colorSpace)->getProfile())
00061         profilename = profile->productName();
00062     m_page->cmbProfile->insertItem(profilename);
00063     m_page->cmbProfile->setEnabled(false);
00064 
00065     m_page->intOpacity->setRange(0, 100, 13);
00066     m_page->intOpacity->setValue(opacity);
00067 
00068     m_page->cmbComposite->setCompositeOpList(colorSpace->userVisiblecompositeOps());
00069     m_page->cmbComposite->setCurrentItem(compositeOp);
00070 
00071     slotNameChanged( m_page->editName->text() );
00072 }
00073 
00074 KisDlgLayerProperties::~KisDlgLayerProperties()
00075 {
00076 }
00077 
00078 void KisDlgLayerProperties::slotNameChanged( const QString &_text )
00079 {
00080     enableButtonOK( !_text.isEmpty() );
00081 }
00082 
00083 QString KisDlgLayerProperties::getName() const
00084 {
00085     return m_page->editName->text();
00086 }
00087 
00088 int KisDlgLayerProperties::getOpacity() const
00089 {
00090     Q_INT32 opacity = m_page->intOpacity->value();
00091 
00092     if (!opacity)
00093         return 0;
00094 
00095     opacity = int((opacity * 255.0) / 100 + 0.5);
00096     if(opacity>255)
00097         opacity=255;
00098     return opacity;
00099 }
00100 
00101 KisCompositeOp KisDlgLayerProperties::getCompositeOp() const
00102 {
00103     return m_page->cmbComposite->currentItem();
00104 }
00105 
00106 #include "kis_dlg_layer_properties.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys