diff options
Diffstat (limited to 'karbon/plugins/imagetool')
-rw-r--r-- | karbon/plugins/imagetool/Makefile.am | 14 | ||||
-rw-r--r-- | karbon/plugins/imagetool/imagetoolplugin.cc | 56 | ||||
-rw-r--r-- | karbon/plugins/imagetool/imagetoolplugin.h | 39 | ||||
-rw-r--r-- | karbon/plugins/imagetool/imagetoolplugin.rc | 3 | ||||
-rw-r--r-- | karbon/plugins/imagetool/karbonimagetool.desktop | 48 | ||||
-rw-r--r-- | karbon/plugins/imagetool/vimagetool.cc | 132 | ||||
-rw-r--r-- | karbon/plugins/imagetool/vimagetool.h | 70 |
7 files changed, 362 insertions, 0 deletions
diff --git a/karbon/plugins/imagetool/Makefile.am b/karbon/plugins/imagetool/Makefile.am new file mode 100644 index 00000000..491c0f86 --- /dev/null +++ b/karbon/plugins/imagetool/Makefile.am @@ -0,0 +1,14 @@ +kde_services_DATA = karbonimagetool.desktop + +INCLUDES = $(KOFFICE_INCLUDES) -I$(top_srcdir)/karbon -I$(top_srcdir)/karbon/core $(all_includes) + +kde_module_LTLIBRARIES = karbon_imagetoolplugin.la + +karbon_imagetoolplugin_la_SOURCES = imagetoolplugin.cc vimagetool.cc +karbon_imagetoolplugin_la_LIBADD = $(LIB_KPARTS) $(LIB_KOFFICEUI) \ + ../../libkarboncommon.la + +karbon_imagetoolplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) + +METASOURCES = AUTO + diff --git a/karbon/plugins/imagetool/imagetoolplugin.cc b/karbon/plugins/imagetool/imagetoolplugin.cc new file mode 100644 index 00000000..cd9c7c2f --- /dev/null +++ b/karbon/plugins/imagetool/imagetoolplugin.cc @@ -0,0 +1,56 @@ +/* This file is part of the KDE project + Copyright (C) 2002, The Karbon Developers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + +*/ + +#include <kgenericfactory.h> + +#include "karbon_factory.h" +#include "karbon_tool_factory.h" +#include "karbon_tool_registry.h" + +#include "vimagetool.h" + +#include "imagetoolplugin.h" + +typedef KGenericFactory<ImageToolPlugin> ImageToolPluginFactory; +K_EXPORT_COMPONENT_FACTORY( karbon_imagetoolplugin, ImageToolPluginFactory( "karbonimagetoolplugin" ) ) + +ImageToolPlugin::ImageToolPlugin(QObject *parent, const char *name, const QStringList &) : KParts::Plugin(parent, name) +{ + setInstance(ImageToolPluginFactory::instance()); + + kdDebug() << "VImageToolPlugin. Class: " + << className() + << ", Parent: " + << parent -> className() + << "\n"; + + if ( parent->inherits("KarbonFactory") ) + { + KarbonToolRegistry* r = KarbonToolRegistry::instance(); + r->add(new KarbonToolFactory<VImageTool>()); + } +} + +ImageToolPlugin::~ImageToolPlugin() +{ +} + +#include "imagetoolplugin.moc" + diff --git a/karbon/plugins/imagetool/imagetoolplugin.h b/karbon/plugins/imagetool/imagetoolplugin.h new file mode 100644 index 00000000..6f7e6547 --- /dev/null +++ b/karbon/plugins/imagetool/imagetoolplugin.h @@ -0,0 +1,39 @@ +/* This file is part of the KDE project + Copyright (C) 2002, The Karbon Developers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + +*/ + +#ifndef __IMAGETOOLPLUGIN_H__ +#define __IMAGETOOLPLUGIN_H__ + +#include <qstring.h> + +#include <kparts/plugin.h> + +/** + */ +class ImageToolPlugin : public KParts::Plugin +{ + Q_OBJECT +public: + ImageToolPlugin(QObject *parent, const char *name, const QStringList &); + virtual ~ImageToolPlugin(); +}; + +#endif + diff --git a/karbon/plugins/imagetool/imagetoolplugin.rc b/karbon/plugins/imagetool/imagetoolplugin.rc new file mode 100644 index 00000000..2defe12d --- /dev/null +++ b/karbon/plugins/imagetool/imagetoolplugin.rc @@ -0,0 +1,3 @@ +<!DOCTYPE kpartgui> +<kpartplugin name="imagetoolplugin" library="karbon_imagetoolplugin"> +</kpartplugin> diff --git a/karbon/plugins/imagetool/karbonimagetool.desktop b/karbon/plugins/imagetool/karbonimagetool.desktop new file mode 100644 index 00000000..1294482e --- /dev/null +++ b/karbon/plugins/imagetool/karbonimagetool.desktop @@ -0,0 +1,48 @@ +[Desktop Entry] +Name=Image Tool +Name[bg]=Инструмент за изображения +Name[br]=Ostilh skeudenn +Name[ca]=Eina d'imatge +Name[cy]=Erfyn Delwedd +Name[da]=Billedværktøj +Name[de]=Bild-Werkzeug +Name[el]=Εργαλείο εικόνας +Name[eo]=Bildprilaborilo +Name[es]=Herramienta de imagen +Name[et]=Pilditööriist +Name[fa]=ابزار تصویر +Name[fi]=Kuvatyökalu +Name[fr]=Outil d'images +Name[fy]=Ofbyldingsark +Name[ga]=Uirlis Íomhá +Name[gl]=Ferramenta de Imaxes +Name[he]=כלי תמונהב +Name[hr]=Alat za slike +Name[hu]=Képkezelő +Name[is]=Myndatól +Name[it]=Strumento per immagini +Name[ja]=画像ツール +Name[km]=ឧបករណ៍រូបភាព +Name[lv]=Attēlu rīks +Name[nb]=Bildeverktøy +Name[nds]=Bild-Warktüüch +Name[ne]=छवि उपकरण +Name[nl]=Afbeeldingsgereedschap +Name[pl]=Narzędzie do obrazków +Name[pt]=Ferramenta de Imagens +Name[pt_BR]=Ferramenta de Imagens +Name[ru]=Изображение +Name[se]=Govvareaidu +Name[sk]=Nástroj obrázok +Name[sl]=Slikarsko orodje +Name[sr]=Алат за слике +Name[sr@Latn]=Alat za slike +Name[sv]=Bildverktyg +Name[uk]=Засіб для зображень +Name[uz]=Rasm vositasi +Name[uz@cyrillic]=Расм воситаси +Name[zh_CN]=图像工具 +Name[zh_TW]=圖片工具 +ServiceTypes=Karbon/CoreModule +Type=Service +X-KDE-Library=karbon_imagetoolplugin diff --git a/karbon/plugins/imagetool/vimagetool.cc b/karbon/plugins/imagetool/vimagetool.cc new file mode 100644 index 00000000..6511fa4d --- /dev/null +++ b/karbon/plugins/imagetool/vimagetool.cc @@ -0,0 +1,132 @@ +/* This file is part of the KDE project + Copyright (C) 2002, The Karbon Developers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + +*/ + +#include <qcursor.h> +#include <klocale.h> +#include <kfiledialog.h> +#include <kdebug.h> + +#include "vimagetool.h" +#include <karbon_part.h> +#include <karbon_view.h> +#include <core/vimage.h> +#include <core/vselection.h> +#include <core/vcursor.h> + +VImageTool::VImageTool( KarbonView *view ) : VTool( view, "tool_image_plugin" ) +{ + registerTool( this ); + m_cursor = new QCursor( VCursor::createCursor( VCursor::CrossHair ) ); +} + +VImageTool::~VImageTool() +{ + delete m_cursor; +} + +QString +VImageTool::contextHelp() +{ + QString s = i18n( "<qt><b>Image tool:</b><br>" ); + return s; +} + +void +VImageTool::activate() +{ + view()->setCursor( *m_cursor ); + VTool::activate(); +} + +QString +VImageTool::statusText() +{ + return i18n( "Image Tool" ); +} + +void +VImageTool::deactivate() +{ +} + +void +VImageTool::mouseButtonRelease() +{ + QString fname = KFileDialog::getOpenFileName( QString::null, "*.jpg *.gif *.png", view(), i18n( "Choose Image to Add" ) ); + if( !fname.isEmpty() ) + { + VImage *image = new VImage( 0L, fname ); + VInsertImageCmd *cmd = new VInsertImageCmd( &view()->part()->document(), i18n( "Insert Image" ), image, first() ); + + view()->part()->addCommand( cmd, true ); + } +} + +VImageTool::VInsertImageCmd::VInsertImageCmd( VDocument* doc, const QString& name, VImage *image, KoPoint pos ) + : VCommand( doc, name, "frame_image" ), m_image( image ), m_pos( pos ) +{ +} + +void +VImageTool::VInsertImageCmd::execute() +{ + if( !m_image ) + return; + + if( m_image->state() == VObject::deleted ) + m_image->setState( VObject::normal ); + else + { + m_image->setState( VObject::normal ); + m_image->transform( QWMatrix().translate( m_pos.x(), m_pos.y() ) ); + document()->append( m_image ); + document()->selection()->clear(); + document()->selection()->append( m_image ); + } + + setSuccess( true ); +} + +void +VImageTool::VInsertImageCmd::unexecute() +{ + if( !m_image ) + return; + + document()->selection()->take( *m_image ); + m_image->setState( VObject::deleted ); + + setSuccess( false ); +} + +void +VImageTool::setup( KActionCollection *collection ) +{ + m_action = static_cast<KRadioAction *>(collection -> action( name() ) ); + + if( m_action == 0 ) + { + m_action = new KRadioAction( i18n( "Image Tool" ), "14_image", Qt::SHIFT+Qt::Key_H, this, SLOT( activate() ), collection, name() ); + m_action->setToolTip( i18n( "Image" ) ); + m_action->setExclusiveGroup( "misc" ); + //m_ownAction = true; + } +} + diff --git a/karbon/plugins/imagetool/vimagetool.h b/karbon/plugins/imagetool/vimagetool.h new file mode 100644 index 00000000..c9ac7f44 --- /dev/null +++ b/karbon/plugins/imagetool/vimagetool.h @@ -0,0 +1,70 @@ +/* This file is part of the KDE project + Copyright (C) 2002, The Karbon Developers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + +*/ + +#ifndef __VIMAGETOOL_H__ +#define __VIMAGETOOL_H__ + +#include <qstring.h> + +#include "vtool.h" +#include <commands/vcommand.h> + +class KarbonView; +class VImage; +class QCursor; + +class VImageTool : public VTool +{ +public: + VImageTool( KarbonView *view ); + ~VImageTool(); + + virtual void activate(); + virtual void deactivate(); + + virtual void setup( KActionCollection *collection ); + virtual QString uiname() { return i18n( "Image Tool" ); } + virtual QString contextHelp(); + virtual QString statusText(); + +protected: + class VInsertImageCmd : public VCommand + { + public: + VInsertImageCmd( VDocument* doc, const QString& name, VImage *image, KoPoint pos ); + virtual ~VInsertImageCmd() {} + + virtual void execute(); + virtual void unexecute(); + virtual bool changesSelection() const { return true; } + + protected: + VImage *m_image; + KoPoint m_pos; + }; + + virtual void mouseButtonRelease(); + +private: + QCursor* m_cursor; +}; + +#endif + |