summaryrefslogtreecommitdiffstats
path: root/kview/modules/effects
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit47d455dd55be855e4cc691c32f687f723d9247ee (patch)
tree52e236aaa2576bdb3840ebede26619692fed6d7d /kview/modules/effects
downloadtdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz
tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kview/modules/effects')
-rw-r--r--kview/modules/effects/Makefile.am15
-rw-r--r--kview/modules/effects/kvieweffects.cpp244
-rw-r--r--kview/modules/effects/kvieweffects.desktop119
-rw-r--r--kview/modules/effects/kvieweffects.h46
-rw-r--r--kview/modules/effects/kvieweffects.rc10
5 files changed, 434 insertions, 0 deletions
diff --git a/kview/modules/effects/Makefile.am b/kview/modules/effects/Makefile.am
new file mode 100644
index 00000000..64205856
--- /dev/null
+++ b/kview/modules/effects/Makefile.am
@@ -0,0 +1,15 @@
+INCLUDES = -I$(top_srcdir)/kview $(all_includes)
+
+kde_module_LTLIBRARIES = kview_effectsplugin.la
+
+kview_effectsplugin_la_SOURCES = kvieweffects.cpp
+kview_effectsplugin_la_LIBADD = $(LIB_KFILE) $(LIB_KPARTS) -lkdeprint
+kview_effectsplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+
+plugdir = $(kde_datadir)/kview/kpartplugins
+plug_DATA = kvieweffects.desktop kvieweffects.rc
+
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/kvieweffectsplugin.pot
diff --git a/kview/modules/effects/kvieweffects.cpp b/kview/modules/effects/kvieweffects.cpp
new file mode 100644
index 00000000..9295c876
--- /dev/null
+++ b/kview/modules/effects/kvieweffects.cpp
@@ -0,0 +1,244 @@
+/* This file is in the public domain */
+
+// $Id$
+
+#include "kvieweffects.h"
+
+#include <qobjectlist.h>
+
+#include <kaction.h>
+#include <klocale.h>
+#include <kgenericfactory.h>
+#include <kdebug.h>
+#include <kimageviewer/viewer.h>
+#include <kimageviewer/canvas.h>
+#include <kdialogbase.h>
+#include <knuminput.h>
+#include <kiconeffect.h>
+#include <qvbox.h>
+#include <kcolorbutton.h>
+#include <kimageeffect.h>
+#include <qlabel.h>
+#include <assert.h>
+
+typedef KGenericFactory<KViewEffects> KViewEffectsFactory;
+K_EXPORT_COMPONENT_FACTORY( kview_effectsplugin, KViewEffectsFactory( "kvieweffectsplugin" ) )
+
+KViewEffects::KViewEffects( QObject* parent, const char* name, const QStringList & )
+ : Plugin( parent, name )
+ , m_gamma( 0.5 ), m_lastgamma( -1.0 )
+ , m_opacity( 50 ), m_lastopacity( -1 )
+ , m_intensity( 50 ), m_lastintensity( -1 )
+ , m_color( white )
+ , m_image( 0 )
+{
+ QObjectList * viewerList = parent->queryList( 0, "KImageViewer Part", false, false );
+ m_pViewer = static_cast<KImageViewer::Viewer *>( viewerList->getFirst() );
+ delete viewerList;
+ if( m_pViewer )
+ {
+ KAction * gammaaction = new KAction( i18n( "&Gamma Correction..." ), 0, 0,
+ this, SLOT( gamma() ),
+ actionCollection(), "plugin_effects_gamma" );
+ KAction * blendaction = new KAction( i18n( "&Blend Color..." ), 0, 0,
+ this, SLOT( blend() ),
+ actionCollection(), "plugin_effects_blend" );
+ KAction * intensityaction = new KAction( i18n( "Change &Intensity (Brightness)..." ), 0, 0,
+ this, SLOT( intensity() ),
+ actionCollection(), "plugin_effects_intensity" );
+ gammaaction->setEnabled( m_pViewer->canvas()->image() != 0 );
+ blendaction->setEnabled( m_pViewer->canvas()->image() != 0 );
+ intensityaction->setEnabled( m_pViewer->canvas()->image() != 0 );
+ connect( m_pViewer->widget(), SIGNAL( hasImage( bool ) ), gammaaction, SLOT( setEnabled( bool ) ) );
+ connect( m_pViewer->widget(), SIGNAL( hasImage( bool ) ), blendaction, SLOT( setEnabled( bool ) ) );
+ connect( m_pViewer->widget(), SIGNAL( hasImage( bool ) ), intensityaction, SLOT( setEnabled( bool ) ) );
+ }
+ else
+ kdWarning( 4630 ) << "no KImageViewer interface found - the effects plugin won't work" << endl;
+}
+
+KViewEffects::~KViewEffects()
+{
+ // no need to delete m_image here since it will always be NULL at this
+ // point.
+ assert( m_image == 0 );
+}
+
+void KViewEffects::intensity()
+{
+ KDialogBase dlg( m_pViewer->widget(), "Intensity Dialog", true /*modal*/, i18n( "Change Intensity" ), KDialogBase::Ok | KDialogBase::Try | KDialogBase::Cancel );
+ connect( &dlg, SIGNAL( tryClicked() ), this, SLOT( applyIntensity() ) );
+
+ QVBox * vbox = new QVBox( &dlg );
+ vbox->setSpacing( KDialog::spacingHint() );
+ dlg.setMainWidget( vbox );
+ KIntNumInput * percent = new KIntNumInput( vbox, "Intensity Input" );
+ percent->setRange( 0, 100, 1, true );
+ percent->setValue( m_intensity );
+ percent->setLabel( i18n( "&Intensity:" ) );
+ percent->setSuffix( QString::fromAscii( "%" ) );
+ connect( percent, SIGNAL( valueChanged( int ) ), this, SLOT( setIntensity( int ) ) );
+
+ int result = dlg.exec();
+ if( result == QDialog::Accepted )
+ {
+ applyIntensity();
+ m_pViewer->setModified( true );
+ }
+ else
+ if( m_image )
+ m_pViewer->canvas()->setImage( *m_image );
+ m_lastintensity = -1;
+ delete m_image;
+ m_image = 0;
+}
+
+void KViewEffects::setIntensity( int intensity )
+{
+ m_intensity = intensity;
+}
+
+void KViewEffects::applyIntensity()
+{
+ kdDebug( 4630 ) << k_funcinfo << endl;
+ if( m_intensity == m_lastintensity )
+ return; // nothing to do
+
+ QImage * work = workImage();
+ if( work )
+ {
+ KImageEffect::intensity( *work, m_intensity * 0.01 );
+ m_pViewer->canvas()->setImage( *work );
+ delete work;
+ m_lastintensity = m_intensity;
+ }
+}
+
+void KViewEffects::blend()
+{
+ KDialogBase dlg( m_pViewer->widget(), "Blend Color Dialog", true /*modal*/, i18n( "Blend Color" ), KDialogBase::Ok | KDialogBase::Try | KDialogBase::Cancel );
+ connect( &dlg, SIGNAL( tryClicked() ), this, SLOT( applyBlend() ) );
+
+ QVBox * vbox = new QVBox( &dlg );
+ vbox->setSpacing( KDialog::spacingHint() );
+ dlg.setMainWidget( vbox );
+ KIntNumInput * opacity = new KIntNumInput( vbox, "Opacity Input" );
+ opacity->setRange( 0, 100, 1, true );
+ opacity->setValue( m_opacity );
+ opacity->setLabel( i18n( "O&pacity:" ) );
+ opacity->setSuffix( QString::fromAscii( "%" ) );
+ connect( opacity, SIGNAL( valueChanged( int ) ), this, SLOT( setOpacity( int ) ) );
+ QLabel * label = new QLabel( i18n( "Blend c&olor:" ), vbox );
+ KColorButton * color = new KColorButton( m_color, vbox, "Color Input Button" );
+ label->setBuddy( color );
+ connect( color, SIGNAL( changed( const QColor & ) ), this, SLOT( setColor( const QColor & ) ) );
+
+ int result = dlg.exec();
+ if( result == QDialog::Accepted )
+ {
+ applyBlend();
+ m_pViewer->setModified( true );
+ }
+ else
+ if( m_image )
+ m_pViewer->canvas()->setImage( *m_image );
+ m_lastopacity = -1;
+ delete m_image;
+ m_image = 0;
+}
+
+void KViewEffects::setOpacity( int opacity )
+{
+ m_opacity = opacity;
+}
+
+void KViewEffects::setColor( const QColor & color )
+{
+ m_color = color;
+}
+
+void KViewEffects::applyBlend()
+{
+ if( m_opacity == m_lastopacity )
+ return; // nothing to do
+
+ QImage * work = workImage();
+ if( work )
+ {
+ KImageEffect::blend( m_color, *work, m_opacity * 0.01 );
+ m_pViewer->canvas()->setImage( *work );
+ delete work;
+ m_lastopacity = m_opacity;
+ }
+}
+
+void KViewEffects::gamma()
+{
+ KDialogBase dlg( m_pViewer->widget(), "Gamma Correction Dialog", true /*modal*/, i18n( "Gamma Correction" ), KDialogBase::Ok | KDialogBase::Try | KDialogBase::Cancel );
+ connect( &dlg, SIGNAL( tryClicked() ), this, SLOT( applyGammaCorrection() ) );
+
+ // create dialog
+ KDoubleNumInput * gammavalue = new KDoubleNumInput( 0.0, 1.0, 0.5, 0.01, 4, &dlg, "Gamma value input" );
+ gammavalue->setRange( 0.0, 1.0, 0.01, true );
+ connect( gammavalue, SIGNAL( valueChanged( double ) ), this, SLOT( setGammaValue( double ) ) );
+ gammavalue->setLabel( i18n( "Gamma value:" ) );
+ dlg.setMainWidget( gammavalue );
+
+ int result = dlg.exec();
+ if( result == QDialog::Accepted )
+ {
+ // apply gamma correction
+ applyGammaCorrection();
+ m_pViewer->setModified( true );
+ }
+ else
+ {
+ if( m_image )
+ m_pViewer->canvas()->setImage( *m_image );
+ }
+ m_lastgamma = -1;
+ delete m_image;
+ m_image = 0;
+}
+
+void KViewEffects::setGammaValue( double gamma )
+{
+ m_gamma = gamma;
+ kdDebug( 4630 ) << "m_gamma = " << m_gamma << endl;
+ // TODO: show effect on the fly if requested
+}
+
+void KViewEffects::applyGammaCorrection()
+{
+ if( m_gamma == m_lastgamma )
+ return; // nothing to do
+
+ QImage * corrected = workImage();
+ if( corrected )
+ {
+ KIconEffect::toGamma( *corrected, m_gamma );
+ m_pViewer->canvas()->setImage( *corrected );
+ delete corrected;
+ m_lastgamma = m_gamma;
+ }
+}
+
+inline QImage * KViewEffects::workImage()
+{
+ if( ! m_image )
+ {
+ const QImage * canvasimage = m_pViewer->canvas()->image();
+ if( canvasimage )
+ m_image = new QImage( *canvasimage );
+ }
+ if( m_image )
+ {
+ QImage * changed = new QImage( *m_image );
+ changed->detach();
+ return changed;
+ }
+ return 0;
+}
+
+// vim:sw=4:ts=4:cindent
+#include "kvieweffects.moc"
diff --git a/kview/modules/effects/kvieweffects.desktop b/kview/modules/effects/kvieweffects.desktop
new file mode 100644
index 00000000..1f13781d
--- /dev/null
+++ b/kview/modules/effects/kvieweffects.desktop
@@ -0,0 +1,119 @@
+[Desktop Entry]
+Icon=effects
+Type=Service
+ServiceTypes=KPluginInfo
+
+X-KDE-PluginInfo-Author=Matthias Kretz
+X-KDE-PluginInfo-Email=kretz@kde.org
+X-KDE-PluginInfo-Name=kvieweffects
+X-KDE-PluginInfo-Version=0.1
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=false
+
+Name=Effects
+Name[ar]=مؤثرات
+Name[bg]=Ефекти
+Name[bs]=Efekti
+Name[ca]=Efectes
+Name[cs]=Efekty
+Name[cy]=Effeithiau
+Name[da]=Effekter
+Name[de]=Effekte
+Name[el]=Εφέ
+Name[eo]=Efektoj
+Name[es]=Efectos
+Name[et]=Efektid
+Name[eu]=Efectuak
+Name[fa]=اثرها
+Name[fi]=Tehosteet
+Name[fr]=Effets
+Name[ga]=Maisíochtaí
+Name[gl]=Efectos
+Name[he]=אפקטים
+Name[hi]=प्रभाव
+Name[hu]=Effektusok
+Name[is]=Brellur
+Name[it]=Effetti
+Name[ja]=効果
+Name[kk]=Эффекттері
+Name[km]=បែបផែន
+Name[lt]=Efektai
+Name[ms]=Kesan
+Name[nb]=Effekter
+Name[nds]=Effekten
+Name[ne]=असर
+Name[nl]=Effecten
+Name[nn]=Effektar
+Name[pa]=ਪ੍ਰਭਾਵ
+Name[pl]=Efekty
+Name[pt]=Efeitos
+Name[pt_BR]=Efeitos
+Name[ro]=Efecte
+Name[ru]=Эффекты
+Name[sk]=Efekty
+Name[sl]=Učinki
+Name[sr]=Ефекти
+Name[sr@Latn]=Efekti
+Name[sv]=Effekter
+Name[ta]=விளைவுகள்
+Name[tg]=Воситаҳо
+Name[tr]=Efektler
+Name[uk]=Ефекти
+Name[uz]=Effektlar
+Name[uz@cyrillic]=Эффектлар
+Name[wa]=Efets
+Name[zh_CN]=特效
+Name[zh_HK]=效果
+Name[zh_TW]=特效
+Comment=Provides some image effects
+Comment[ar]=يقدم بعض مؤثرات الصور
+Comment[bg]=Визуални ефекти при зареждане на изображенията
+Comment[bs]=Pruža neke efekte za slike
+Comment[ca]=Proporciona alguns efectes d'imatges
+Comment[cs]=Poskytuje několik efektů pro obrázky
+Comment[cy]=Darparu rhai effeithiau delwedd
+Comment[da]=Sørger for nogle billedeffekter
+Comment[de]=Stellt einige Bildverarbeitungseffekte zur Verfügung
+Comment[el]=Παρέχει μερικά εφέ εικόνας
+Comment[eo]=Provizas kelkajn bildefektojn
+Comment[es]=Proporciona alguno efectos para imágenes
+Comment[et]=Mõned pildiefektid
+Comment[eu]=Irudi efektu batzuk eskuratzen ditu
+Comment[fa]=برخی اثرهای تصویر را فراهم می‌کند
+Comment[fi]=Tarjoaa joitain kuvatehosteita
+Comment[fr]=Fournit des effets sur les images
+Comment[gl]=Proporciona algúns efectos para as imaxes
+Comment[he]=מספק מספר אפקטים עבור תמונות
+Comment[hi]=छवि में प्रभाव उत्पन्न करता है
+Comment[hu]=Képeffektusok használata
+Comment[is]=Býður uppá ýmsar myndbrellur
+Comment[it]=Fornisce alcuni effetti per le immagini
+Comment[ja]=画像効果を提供します
+Comment[kk]=Кескіндердің кейбір эффектерін іске асыру
+Comment[km]=ផ្ដល់​នូវ​បែបផែន​រូបភាព​មួយ​ចំនួន
+Comment[lt]=Prideda kai kuriuos paveikslėlių efektus
+Comment[ms]=Menyediakan beberapa kesan imej
+Comment[nb]=Utfører noen effekter på bilder
+Comment[nds]=Stellt en poor Bildeffekten praat
+Comment[ne]=केही छवि असर प्रदान गर्दछ
+Comment[nl]=Biedt enkele effecten om afbeeldingen te bewerken
+Comment[nn]=Utfører nokre effektar på bilete
+Comment[pl]=Dodaje kilka efektów do obrazków
+Comment[pt]=Fornece alguns efeitos de imagem
+Comment[pt_BR]=Fornece alguns efeitos de imagem
+Comment[ro]=Oferă unele efecte pentru imagini
+Comment[ru]=Некоторые эффекты обработки изображений
+Comment[sk]=Poskytuje niektoré efekty pre obrázky
+Comment[sl]=Prinaša nekaj učinkov za slike
+Comment[sr]=Пружа неке сликовне ефекте
+Comment[sr@Latn]=Pruža neke slikovne efekte
+Comment[sv]=Tillhandahåller vissa bildeffekter
+Comment[ta]=சில பிம்ப விளைவுகளை தருகிறது
+Comment[tg]=Якчанд воситаҳои коркарди тасвирот
+Comment[tr]=Resim efektleri oluşturur
+Comment[uk]=Надає деякі ефекти зображень
+Comment[uz]=Rasm effektlari
+Comment[uz@cyrillic]=Расм эффектлари
+Comment[zh_CN]=提供某些图像特效
+Comment[zh_HK]=提供一些圖像效果
+Comment[zh_TW]=提供影像特效
diff --git a/kview/modules/effects/kvieweffects.h b/kview/modules/effects/kvieweffects.h
new file mode 100644
index 00000000..0bf92a8e
--- /dev/null
+++ b/kview/modules/effects/kvieweffects.h
@@ -0,0 +1,46 @@
+/* This file is in the public domain */
+
+// $Id$
+
+#ifndef KVIEWEFFECTS_H
+#define KVIEWEFFECTS_H
+
+#include <kparts/plugin.h>
+#include <qcolor.h>
+
+namespace KImageViewer { class Viewer; }
+
+class KViewEffects : public KParts::Plugin
+{
+ Q_OBJECT
+public:
+ KViewEffects( QObject* parent, const char* name, const QStringList & );
+ virtual ~KViewEffects();
+
+private slots:
+ void intensity();
+ void setIntensity( int );
+ void applyIntensity();
+
+ void blend();
+ void setOpacity( int );
+ void setColor( const QColor & );
+ void applyBlend();
+
+ void gamma();
+ void setGammaValue( double );
+ void applyGammaCorrection();
+
+private:
+ QImage * workImage();
+
+ KImageViewer::Viewer * m_pViewer;
+ double m_gamma, m_lastgamma;
+ int m_opacity, m_lastopacity;
+ int m_intensity, m_lastintensity;
+ QColor m_color;
+ QImage * m_image;
+};
+
+// vim:sw=4:ts=4:cindent
+#endif // KVIEWEFFECTS_H
diff --git a/kview/modules/effects/kvieweffects.rc b/kview/modules/effects/kvieweffects.rc
new file mode 100644
index 00000000..d0c4eda6
--- /dev/null
+++ b/kview/modules/effects/kvieweffects.rc
@@ -0,0 +1,10 @@
+<!DOCTYPE kpartgui>
+<kpartplugin name="kvieweffects" library="kview_effectsplugin" version="2">
+ <MenuBar>
+ <Menu name="effects"><Text>Effe&amp;cts</Text>
+ <Action name="plugin_effects_gamma"/>
+ <Action name="plugin_effects_blend"/>
+ <Action name="plugin_effects_intensity"/>
+ </Menu>
+ </MenuBar>
+</kpartplugin>