diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-26 00:41:16 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-26 00:41:16 +0000 |
commit | 698569f8428ca088f764d704034a1330517b98c0 (patch) | |
tree | bf45be6946ebbbee9cce5a5bcf838f4c952d87e6 /chalk/ui/kis_dlg_adj_layer_props.cc | |
parent | 2785103a6bd4de55bd26d79e34d0fdd4b329a73a (diff) | |
download | koffice-698569f8428ca088f764d704034a1330517b98c0.tar.gz koffice-698569f8428ca088f764d704034a1330517b98c0.zip |
Finish rebranding of Krita as Chalk
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238363 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'chalk/ui/kis_dlg_adj_layer_props.cc')
-rw-r--r-- | chalk/ui/kis_dlg_adj_layer_props.cc | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/chalk/ui/kis_dlg_adj_layer_props.cc b/chalk/ui/kis_dlg_adj_layer_props.cc new file mode 100644 index 00000000..c955eba3 --- /dev/null +++ b/chalk/ui/kis_dlg_adj_layer_props.cc @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2006 Boudewijn Rempt <boud@valdyas.org> + * Copyright (c) 2007 Benjamin Schleimer <bensch128@yahoo.com> + * + * 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 <klocale.h> + +#include <tqgroupbox.h> +#include <tqlabel.h> +#include <tqlayout.h> + +#include <klineedit.h> +#include <klocale.h> + +#include "kis_filter_config_widget.h" +#include "kis_transaction.h" +#include "kis_filter.h" +#include "kis_filter_configuration.h" +#include "kis_filters_listview.h" +#include "kis_image.h" +#include "kis_previewwidget.h" +#include "kis_layer.h" +#include "kis_adjustment_layer.h" +#include "kis_paint_device.h" +#include "kis_paint_layer.h" +#include "kis_group_layer.h" +#include "kis_dlg_adj_layer_props.h" +#include "kis_filter.h" +#include "kis_filter_configuration.h" + +KisDlgAdjLayerProps::KisDlgAdjLayerProps(KisAdjustmentLayerSP layer, + const TQString & layerName, + const TQString & caption, + TQWidget *tqparent, + const char *name) + : KDialogBase(tqparent, name, true, "", Ok | Cancel) +{ + Q_ASSERT( layer ); + m_layer = layer; + + KisLayerSP next = layer->nextSibling(); + Q_ASSERT( next ); + + m_currentConfiguration = layer->filter(); + m_currentFilter = KisFilterRegistry::instance()->get(m_currentConfiguration->name()); + if (!m_currentFilter) { + kdWarning() << "No filter specified!\n"; + } + + KisPaintDeviceSP dev = 0; + + if( next ) + { + KisPaintLayer * pl = dynamic_cast<KisPaintLayer*>(next.data()); + if (pl) { + dev = pl->paintDevice(); + } + else { + KisGroupLayer * gl = dynamic_cast<KisGroupLayer*>(next.data()); + if (gl) { + dev = gl->projection(gl->extent()); + } + else { + KisAdjustmentLayer * al = dynamic_cast<KisAdjustmentLayer*>(next.data()); + if (al) { + dev = al->cachedPaintDevice(); + } + } + } + } else { + dev = new KisPaintDevice(m_layer->image()->colorSpace()); + } + setCaption(caption); + TQWidget * page = new TQWidget(this, "page widget"); + TQHBoxLayout * tqlayout = new TQHBoxLayout(page, 0, 6); + setMainWidget(page); + + m_preview = new KisPreviewWidget(page, "dlgadjustment.preview"); + m_preview->slotSetDevice( dev ); + + connect( m_preview, TQT_SIGNAL(updated()), this, TQT_SLOT(refreshPreview())); + tqlayout->addWidget(m_preview, 1, 1); + + TQVBoxLayout *v1 = new TQVBoxLayout( tqlayout ); + TQHBoxLayout *hl = new TQHBoxLayout( v1 ); + + TQLabel * lblName = new TQLabel(i18n("Layer name:"), page, "lblName"); + hl->addWidget(lblName, 0, 0); + + m_layerName = new KLineEdit(page, "m_layerName"); + m_layerName->setText(layerName); + m_layerName->tqsetSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::Fixed); + hl->addWidget(m_layerName, 0, 1); + connect( m_layerName, TQT_SIGNAL( textChanged ( const TQString & ) ), this, TQT_SLOT( slotNameChanged( const TQString & ) ) ); + + if ( m_currentFilter ) { + m_currentConfigWidget = m_currentFilter->createConfigurationWidget(page, dev); + if (m_currentConfigWidget) { + m_currentConfigWidget->setConfiguration( m_currentConfiguration ); + } + } + if ( m_currentFilter == 0 || m_currentConfigWidget == 0 ) { + TQLabel * labelNoConfigWidget = new TQLabel( i18n("No configuration options are available for this filter"), page ); + v1->addWidget( labelNoConfigWidget ); + } + else { + v1->addWidget( m_currentConfigWidget ); + connect(m_currentConfigWidget, TQT_SIGNAL(sigPleaseUpdatePreview()), this, TQT_SLOT(slotConfigChanged())); + } + + refreshPreview(); + enableButtonOK( !m_layerName->text().isEmpty() ); +} + +void KisDlgAdjLayerProps::slotNameChanged( const TQString & text ) +{ + enableButtonOK( !text.isEmpty() ); +} + +KisFilterConfiguration * KisDlgAdjLayerProps::filterConfiguration() const +{ + return m_currentFilter->configuration(m_currentConfigWidget); +} + +TQString KisDlgAdjLayerProps::layerName() const +{ + return m_layerName->text(); +} + +void KisDlgAdjLayerProps::slotConfigChanged() +{ + if(m_preview->getAutoUpdate()) + { + refreshPreview(); + } else { + m_preview->needUpdate(); + } +} + +void KisDlgAdjLayerProps::refreshPreview() +{ + if (!m_preview) { + kdDebug() << "no preview!\n"; + return; + } + + if (!m_currentFilter) { + return; + } + KisFilterConfiguration* config = m_currentFilter->configuration(m_currentConfigWidget); + + m_preview->runFilter(m_currentFilter, config); +} + +#include "kis_dlg_adj_layer_props.moc" |