diff options
Diffstat (limited to 'kivio/plugins/kiviotargettool')
-rw-r--r-- | kivio/plugins/kiviotargettool/Makefile.am | 21 | ||||
-rw-r--r-- | kivio/plugins/kiviotargettool/kiviotargettool.cpp | 113 | ||||
-rw-r--r-- | kivio/plugins/kiviotargettool/kiviotargettool.desktop | 49 | ||||
-rw-r--r-- | kivio/plugins/kiviotargettool/kiviotargettool.h | 62 | ||||
-rw-r--r-- | kivio/plugins/kiviotargettool/kiviotargettool.rc | 11 | ||||
-rw-r--r-- | kivio/plugins/kiviotargettool/kiviotargettoolfactory.cpp | 52 | ||||
-rw-r--r-- | kivio/plugins/kiviotargettool/kiviotargettoolfactory.h | 45 |
7 files changed, 353 insertions, 0 deletions
diff --git a/kivio/plugins/kiviotargettool/Makefile.am b/kivio/plugins/kiviotargettool/Makefile.am new file mode 100644 index 00000000..34f2b72a --- /dev/null +++ b/kivio/plugins/kiviotargettool/Makefile.am @@ -0,0 +1,21 @@ +INCLUDES = -I$(top_srcdir)/kivio/kiviopart/config \ + -I$(top_builddir)/kivio/kiviopart/config \ + -I$(top_srcdir)/kivio/kiviopart\ + -I$(top_srcdir)/kivio/kiviopart/kiviosdk\ + -I$(top_srcdir)/kivio/kiviopart/tools\ + $(KOFFICE_INCLUDES) $(KOTEXT_INCLUDES) $(all_includes) + +METASOURCES = AUTO + +kde_module_LTLIBRARIES = libkiviotargettool.la +libkiviotargettool_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +libkiviotargettool_la_LIBADD = $(LIB_KOTEXT) $(LIB_KOPAINTER) $(top_builddir)/kivio/kiviopart/libkiviocommon.la +libkiviotargettool_la_SOURCES = kiviotargettool.cpp kiviotargettoolfactory.cpp + +noinst_HEADERS = kiviotargettool.h kiviotargettoolfactory.h + +rc_DATA = kiviotargettool.rc +rcdir = $(kde_datadir)/kivio/kpartplugins + +desktop_DATA = kiviotargettool.desktop +desktopdir = $(kde_servicesdir) diff --git a/kivio/plugins/kiviotargettool/kiviotargettool.cpp b/kivio/plugins/kiviotargettool/kiviotargettool.cpp new file mode 100644 index 00000000..95958d2a --- /dev/null +++ b/kivio/plugins/kiviotargettool/kiviotargettool.cpp @@ -0,0 +1,113 @@ +/* This file is part of the KDE project + Copyright (C) 2004 Peter Simonsson <psn@linux.se>, + + 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 "kiviotargettool.h" + +#include <qcursor.h> + +#include <klocale.h> + +#include "kivio_stencil.h" +#include "kivio_view.h" +#include "kivio_canvas.h" +#include "kivio_page.h" +#include "kivio_doc.h" +#include "mousetoolaction.h" +#include "kivio_pluginmanager.h" +#include "kivio_command.h" + +namespace Kivio { + TargetTool::TargetTool(KivioView* parent) : MouseTool(parent, "Add Target Mouse Tool") + { + m_targetAction = new Kivio::MouseToolAction(i18n("Add Connector Target"), + "add_target", 0, actionCollection(), "addTargetTool"); + connect(m_targetAction, SIGNAL(toggled(bool)), this, SLOT(setActivated(bool))); + connect(m_targetAction, SIGNAL(doubleClicked()), this, SLOT(makePermanent())); + + m_permanent = false; + } + + TargetTool::~TargetTool() + { + } + + bool TargetTool::processEvent(QEvent* e) + { + if(e->type() == QEvent::MouseButtonPress) { + mousePress(static_cast<QMouseEvent*>(e)); + return true; + } else if(e->type() == QEvent::MouseMove) { + mouseMove(static_cast<QMouseEvent*>(e)); + return true; + } + + return false; + } + + void TargetTool::setActivated(bool a) + { + if(a) { + m_targetAction->setChecked(true); + emit activated(this); + } else if(m_targetAction->isChecked()) { + m_targetAction->setChecked(false); + m_permanent = false; + } + } + + void TargetTool::applyToolAction(KivioStencil* stencil, const KoPoint& pos) + { + KivioAddConnectorTargetCommand* command = new KivioAddConnectorTargetCommand(i18n("Add Connector Target"), view()->activePage(), stencil, pos); + command->execute(); + view()->doc()->addCommand(command); + } + + void TargetTool::mousePress(QMouseEvent* e) + { + KoPoint p = view()->canvasWidget()->mapFromScreen(e->pos()); + int colType; + KivioStencil* stencil = view()->canvasWidget()->activePage()->checkForStencil(&p, &colType, 0, false); + + if(stencil) { + applyToolAction(stencil, p); + + if(!m_permanent) { + view()->pluginManager()->activateDefaultTool(); + } + } + } + + void TargetTool::mouseMove(QMouseEvent* e) + { + KoPoint p = view()->canvasWidget()->mapFromScreen(e->pos()); + int colType; + + if(view()->canvasWidget()->activePage()->checkForStencil(&p, &colType, 0, false)) { + view()->canvasWidget()->setCursor(Qt::CrossCursor); + } else { + view()->canvasWidget()->setCursor(Qt::ForbiddenCursor); + } + } + + void TargetTool::makePermanent() + { + m_permanent = true; + } +} + +#include "kiviotargettool.moc" diff --git a/kivio/plugins/kiviotargettool/kiviotargettool.desktop b/kivio/plugins/kiviotargettool/kiviotargettool.desktop new file mode 100644 index 00000000..37c1a650 --- /dev/null +++ b/kivio/plugins/kiviotargettool/kiviotargettool.desktop @@ -0,0 +1,49 @@ +[Desktop Entry] +X-KDE-Library=libkiviotargettool +Name=Target Tool for Kivio +Name[bg]=Целеви инструмент за Kivio +Name[br]=Ostilh wenn evit Kivio +Name[ca]=Eina d'objectiu per a Kivio +Name[cy]=Erfyn Targed ar gyfer Kivio +Name[da]=Målværktøj for Kivio +Name[de]=Ziel-Werkzeug für Kivio +Name[el]=Εργαλείο προορισμού για το Kivio +Name[eo]=Celumilo por Kivio +Name[es]=Herramienta de objetivo para Kivio +Name[et]=Kivio sihtmärgi tööriist +Name[eu]=Kivio-ren helburu-tresna +Name[fa]=ابزار هدف برای Kivio +Name[fi]=Kivion kohdetyökalu +Name[fr]=Outil cible pour Kivio +Name[fy]=Targetark foar Kivio +Name[gl]=Ferramenta de Obxectivo para Kivio +Name[he]=כלי יעד של Kivio +Name[hr]=Alat cilja za Kivio +Name[hu]=Célkezelő eszköz a Kivióhoz +Name[it]=Strumento di destinazione per Kivio +Name[ja]=Kivio ターゲットツール +Name[km]=ឧបករណ៍គោលដៅសម្រាប់ Kivio +Name[lv]=Mērķa rīks priekš Kivio +Name[ms]=Alat Sasaran bagi Kivio +Name[nb]=Målverktøy for Kivio +Name[nds]=Teelwarktüüch för Kivio +Name[ne]=किभियोका लागि लक्ष्य उपकरण +Name[nl]=Targettool voor Kivio +Name[nn]=Målverktøy for Kivio +Name[pl]=Narzędzie wyboru elementu docelowego dla Kivio +Name[pt]=Ferramenta de Alvo para o Kivio +Name[pt_BR]=Ferramenta de Alvo para o Kivio +Name[ru]=Указатель Kivio +Name[se]=Kivio-ulbmilreaidu +Name[sk]=Cieľový nástroj pre Kivio +Name[sl]=Ciljno orodje za Kivio +Name[sr]=Циљни алат за Kivio +Name[sr@Latn]=Ciljni alat za Kivio +Name[sv]=Målverktyg för Kivio +Name[ta]=Kivio உரைக்கருவி +Name[tg]=Асбоби Алоқакунанда барои Kivio +Name[tr]=Kivio için Hedef Aracı +Name[uk]=Вказівник для Kivio +Name[zh_CN]=Kivio 目标工具 +Name[zh_TW]=Kivio 目標工具 +Type=Service diff --git a/kivio/plugins/kiviotargettool/kiviotargettool.h b/kivio/plugins/kiviotargettool/kiviotargettool.h new file mode 100644 index 00000000..5a1fb787 --- /dev/null +++ b/kivio/plugins/kiviotargettool/kiviotargettool.h @@ -0,0 +1,62 @@ +/* This file is part of the KDE project + Copyright (C) 2004 Peter Simonsson <psn@linux.se>, + + 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 KIVIOKIVIOTARGETTOOL_H +#define KIVIOKIVIOTARGETTOOL_H + +#include <KoPoint.h> + +#include "kivio_mousetool.h" + +class QMouseEvent; + +namespace Kivio { + class MouseToolAction; +} + +class KivioStencil; +class KivioView; + +namespace Kivio { + class TargetTool : public MouseTool + { + Q_OBJECT + public: + TargetTool(KivioView* parent); + ~TargetTool(); + + virtual bool processEvent(QEvent* e); + + public slots: + virtual void setActivated(bool); + virtual void applyToolAction(KivioStencil* stencil, const KoPoint& pos); + + protected slots: + void makePermanent(); + + protected: + void mousePress(QMouseEvent* e); + void mouseMove(QMouseEvent* e); + + private: + Kivio::MouseToolAction* m_targetAction; + bool m_permanent; + }; +} + +#endif diff --git a/kivio/plugins/kiviotargettool/kiviotargettool.rc b/kivio/plugins/kiviotargettool/kiviotargettool.rc new file mode 100644 index 00000000..2b47f973 --- /dev/null +++ b/kivio/plugins/kiviotargettool/kiviotargettool.rc @@ -0,0 +1,11 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" > +<kpartgui name="KivioTextTool" library="libkiviotargettool" version="1"> + <MenuBar> + <Menu name="Tools"> + <Action name="addTargetTool"/> + </Menu> + </MenuBar> + <ToolBar name="ToolsToolBar"> + <Action name="addTargetTool"/> + </ToolBar> +</kpartgui> diff --git a/kivio/plugins/kiviotargettool/kiviotargettoolfactory.cpp b/kivio/plugins/kiviotargettool/kiviotargettoolfactory.cpp new file mode 100644 index 00000000..b80e9734 --- /dev/null +++ b/kivio/plugins/kiviotargettool/kiviotargettoolfactory.cpp @@ -0,0 +1,52 @@ +/* This file is part of the KDE project + Copyright (C) 2004 Peter Simonsson <psn@linux.se>, + + 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 "kiviotargettoolfactory.h" + +#include "kiviotargettool.h" + +K_EXPORT_COMPONENT_FACTORY( libkiviotargettool, KivioTargetToolFactory ) + +KInstance* KivioTargetToolFactory::s_global = 0; + +KivioTargetToolFactory::KivioTargetToolFactory(QObject *parent, const char *name) + : KLibFactory(parent, name) +{ + s_global = new KInstance("kivio"); +} + +KivioTargetToolFactory::~KivioTargetToolFactory() +{ + delete s_global; +} + +QObject* KivioTargetToolFactory::createObject( QObject* parent, const char*, const char*, const QStringList& ) +{ + if ( !parent->inherits("KivioView") ) + return 0; + + QObject *obj = new Kivio::TargetTool(static_cast<KivioView*>(parent)); + return obj; +} + +KInstance* KivioTargetToolFactory::global() +{ + return s_global; +} + +#include "kiviotargettoolfactory.moc" diff --git a/kivio/plugins/kiviotargettool/kiviotargettoolfactory.h b/kivio/plugins/kiviotargettool/kiviotargettoolfactory.h new file mode 100644 index 00000000..abe028ea --- /dev/null +++ b/kivio/plugins/kiviotargettool/kiviotargettoolfactory.h @@ -0,0 +1,45 @@ +/* This file is part of the KDE project + Copyright (C) 2004 Peter Simonsson <psn@linux.se>, + + 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 KIVIOTARGETTOOLFACTORY_H +#define KIVIOTARGETTOOLFACTORY_H + +#include <qstringlist.h> +#include <qobject.h> + +#include <klibloader.h> + +class KInstance; + +class KivioTargetToolFactory : public KLibFactory +{ + Q_OBJECT + public: + KivioTargetToolFactory(QObject *parent = 0, const char *name = 0); + ~KivioTargetToolFactory(); + + virtual QObject* createObject( QObject* parent = 0, const char* name = 0, + const char* classname = "QObject", const QStringList &args = QStringList() ); + + static KInstance* global(); + + private: + static KInstance* s_global; +}; + +#endif |