diff --git a/libs/basicflakes/CMakeLists.txt b/libs/basicflakes/CMakeLists.txt index edf42265a1..4ef11cea1f 100644 --- a/libs/basicflakes/CMakeLists.txt +++ b/libs/basicflakes/CMakeLists.txt @@ -1,38 +1,36 @@ -add_subdirectory(plugin) - include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/tools ${CMAKE_CURRENT_SOURCE_DIR}/plugin ) set(kritabasicflakes_LIB_SRCS tools/KoCreatePathTool.cpp tools/KoPencilTool.cpp ) ki18n_wrap_ui( kritabasicflakes_LIB_SRCS ) add_library(kritabasicflakes SHARED ${kritabasicflakes_LIB_SRCS}) generate_export_header(kritabasicflakes) target_include_directories(kritabasicflakes PUBLIC $ $ ) target_link_libraries(kritabasicflakes PUBLIC kritaui kritawidgets kritaflake kritapigment ) set_target_properties(kritabasicflakes PROPERTIES VERSION ${GENERIC_KRITA_LIB_VERSION} SOVERSION ${GENERIC_KRITA_LIB_SOVERSION} ) install(TARGETS kritabasicflakes ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/libs/basicflakes/plugin/CMakeLists.txt b/libs/basicflakes/plugin/CMakeLists.txt deleted file mode 100644 index 181df785a2..0000000000 --- a/libs/basicflakes/plugin/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -project( basicflakesplugin ) - -########### Basickritaflakes plugin library ############### - -set ( basicflakesplugin_SRCS - Plugin.cpp - KoCreatePathToolFactory.cpp - KoPencilToolFactory.cpp -) - -ki18n_wrap_ui(basicflakesplugin_SRCS -) - -add_library(krita_tool_basicflakes MODULE ${basicflakesplugin_SRCS}) -target_link_libraries(krita_tool_basicflakes kritaflake kritabasicflakes) -install(TARGETS krita_tool_basicflakes DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) diff --git a/libs/basicflakes/plugin/KoCreatePathToolFactory.cpp b/libs/basicflakes/plugin/KoCreatePathToolFactory.cpp deleted file mode 100644 index e9b9f8e11d..0000000000 --- a/libs/basicflakes/plugin/KoCreatePathToolFactory.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* This file is part of the KDE project - * - * Copyright (C) 2006 Thorsten Zachmann - * - * 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 "KoCreatePathToolFactory.h" -#include "KoCreatePathTool.h" - -#include -#include - -KoCreatePathToolFactory::KoCreatePathToolFactory() - : KoToolFactoryBase(KoCreatePathTool_ID) -{ - setToolTip(i18n("Draw path")); - setSection(mainToolType()); - setPriority(4); - setIconName(koIconNameCStr("createpath")); - setActivationShapeId("flake/edit"); -} - -KoCreatePathToolFactory::~KoCreatePathToolFactory() -{ -} - -KoToolBase* KoCreatePathToolFactory::createTool(KoCanvasBase *canvas) -{ - return new KoCreatePathTool(canvas); -} diff --git a/libs/basicflakes/plugin/KoCreatePathToolFactory.h b/libs/basicflakes/plugin/KoCreatePathToolFactory.h deleted file mode 100644 index 0de423789c..0000000000 --- a/libs/basicflakes/plugin/KoCreatePathToolFactory.h +++ /dev/null @@ -1,37 +0,0 @@ -/* This file is part of the KDE project - * - * Copyright (C) 2006 Thorsten Zachmann - * - * 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 KOCREATEPATHTOOLFACTORY_H -#define KOCREATEPATHTOOLFACTORY_H - -#include "KoToolFactoryBase.h" - -/// The factory for the KoCreatePathTool -class KoCreatePathToolFactory : public KoToolFactoryBase -{ -public: - /// Constructor - KoCreatePathToolFactory(); - /// Destructor - ~KoCreatePathToolFactory() override; - - KoToolBase* createTool(KoCanvasBase *canvas) override; -}; -#endif diff --git a/libs/basicflakes/plugin/KoPencilToolFactory.cpp b/libs/basicflakes/plugin/KoPencilToolFactory.cpp deleted file mode 100644 index 059c0f21ec..0000000000 --- a/libs/basicflakes/plugin/KoPencilToolFactory.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* This file is part of the KDE project - * Copyright (C) 2007 Jan Hambrecht - * - * 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 "KoPencilToolFactory.h" -#include "KoPencilTool.h" - -#include -#include - -KoPencilToolFactory::KoPencilToolFactory() - : KoToolFactoryBase("KoPencilTool") -{ - setToolTip(i18n("Freehand path")); - setSection("karbon, krita"); - setIconName(koIconNameCStr("draw-freehand")); - setPriority(3); - setActivationShapeId("flake/edit"); -} - -KoPencilToolFactory::~KoPencilToolFactory() -{ -} - -KoToolBase * KoPencilToolFactory::createTool(KoCanvasBase *canvas) -{ - return new KoPencilTool(canvas); -} - diff --git a/libs/basicflakes/plugin/KoPencilToolFactory.h b/libs/basicflakes/plugin/KoPencilToolFactory.h deleted file mode 100644 index 6f7416c0be..0000000000 --- a/libs/basicflakes/plugin/KoPencilToolFactory.h +++ /dev/null @@ -1,34 +0,0 @@ -/* This file is part of the KDE project - * Copyright (C) 2007 Jan Hambrecht - * - * 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 _KOPENCILTOOLFACTORY_H_ -#define _KOPENCILTOOLFACTORY_H_ - -#include - -class KoPencilToolFactory : public KoToolFactoryBase -{ -public: - KoPencilToolFactory(); - ~KoPencilToolFactory() override; - - KoToolBase * createTool(KoCanvasBase *canvas) override; -}; - -#endif // _KOPENCILTOOLFACTORY_H_ diff --git a/libs/basicflakes/plugin/Plugin.cpp b/libs/basicflakes/plugin/Plugin.cpp deleted file mode 100644 index f1663caa5e..0000000000 --- a/libs/basicflakes/plugin/Plugin.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* This file is part of the KDE project - * Copyright (C) 2007 Thomas Zander - * Copyright (C) 2012 C. Boemann - * - * 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 "Plugin.h" - -#include -#include -#include - -#include - -K_PLUGIN_FACTORY_WITH_JSON(PluginFactory, "krita_tool_basicflakes.json", registerPlugin();) - -Plugin::Plugin(QObject * parent, const QVariantList &) - : QObject(parent) -{ - KoToolRegistry::instance()->add(new KoCreatePathToolFactory()); - KoToolRegistry::instance()->add(new KoPencilToolFactory()); -} - -#include diff --git a/libs/basicflakes/plugin/Plugin.h b/libs/basicflakes/plugin/Plugin.h deleted file mode 100644 index c38223f7dc..0000000000 --- a/libs/basicflakes/plugin/Plugin.h +++ /dev/null @@ -1,33 +0,0 @@ -/* This file is part of the KDE project - * Copyright (C) 2007 Thomas Zander - * - * 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 PLUGIN_H -#define PLUGIN_H - -#include -#include - -class Plugin : public QObject -{ - Q_OBJECT - -public: - Plugin(QObject * parent, const QVariantList &); - ~Plugin() override {} -}; -#endif diff --git a/libs/basicflakes/plugin/krita_tool_basicflakes.json b/libs/basicflakes/plugin/krita_tool_basicflakes.json deleted file mode 100644 index 4e370f1059..0000000000 --- a/libs/basicflakes/plugin/krita_tool_basicflakes.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Id": "Basic Flake Shapes", - "Type": "Service", - "X-Flake-MinVersion": "28", - "X-Flake-PluginVersion": "28", - "X-KDE-Library": "calligra_tool_basicflakes", - "X-KDE-PluginInfo-Name": "basicflakesplugin", - "X-KDE-ServiceTypes": [ - "Calligra/Tool" - ] -} diff --git a/libs/flake/CMakeLists.txt b/libs/flake/CMakeLists.txt index a3b3ec6bb0..1926026a53 100644 --- a/libs/flake/CMakeLists.txt +++ b/libs/flake/CMakeLists.txt @@ -1,252 +1,249 @@ project(kritaflake) include_directories( ${CMAKE_SOURCE_DIR}/libs/flake/commands ${CMAKE_SOURCE_DIR}/libs/flake/tools ${CMAKE_SOURCE_DIR}/libs/flake/svg ${CMAKE_SOURCE_DIR}/libs/flake/text ${CMAKE_BINARY_DIR}/libs/flake ) add_subdirectory(styles) add_subdirectory(tests) add_subdirectory(resources/tests) set(kritaflake_SRCS KoGradientHelper.cpp KoFlake.cpp KoCanvasBase.cpp KoResourceManager_p.cpp KoDerivedResourceConverter.cpp KoResourceUpdateMediator.cpp KoCanvasResourceProvider.cpp KoDocumentResourceManager.cpp KoCanvasObserverBase.cpp KoCanvasSupervisor.cpp KoDockFactoryBase.cpp KoDockRegistry.cpp KoDataCenterBase.cpp KoInsets.cpp KoPathShape.cpp KoPathPoint.cpp KoPathSegment.cpp KoSelection.cpp KoSelectedShapesProxy.cpp KoSelectedShapesProxySimple.cpp KoShape.cpp KoShapeAnchor.cpp KoShapeControllerBase.cpp KoShapeApplicationData.cpp KoShapeContainer.cpp KoShapeContainerModel.cpp KoShapeGroup.cpp KoShapeManager.cpp KoShapePaintingContext.cpp KoFrameShape.cpp KoMarker.cpp KoMarkerCollection.cpp KoToolBase.cpp KoCanvasController.cpp KoCanvasControllerWidget.cpp KoCanvasControllerWidgetViewport_p.cpp KoShapeRegistry.cpp KoDeferredShapeFactoryBase.cpp KoToolFactoryBase.cpp KoPathShapeFactory.cpp KoShapeFactoryBase.cpp KoShapeUserData.cpp KoParameterShape.cpp KoPointerEvent.cpp KoShapeController.cpp KoToolSelection.cpp KoShapeLayer.cpp KoPostscriptPaintDevice.cpp KoInputDevice.cpp KoToolManager_p.cpp KoToolManager.cpp KoToolRegistry.cpp KoToolProxy.cpp KoShapeSavingContext.cpp KoShapeLoadingContext.cpp KoLoadingShapeUpdater.cpp KoPathShapeLoader.cpp KoShapeStrokeModel.cpp KoShapeStroke.cpp KoShapeBackground.cpp KoColorBackground.cpp KoGradientBackground.cpp KoOdfGradientBackground.cpp KoHatchBackground.cpp KoPatternBackground.cpp KoVectorPatternBackground.cpp KoShapeFillWrapper.cpp KoShapeFillResourceConnector.cpp KoShapeConfigWidgetBase.cpp KoDrag.cpp KoSvgPaste.cpp KoDragOdfSaveHelper.cpp KoShapeOdfSaveHelper.cpp KoConnectionPoint.cpp KoConnectionShape.cpp KoConnectionShapeLoadingUpdater.cpp KoConnectionShapeFactory.cpp KoConnectionShapeConfigWidget.cpp KoSnapGuide.cpp KoSnapProxy.cpp KoSnapStrategy.cpp KoSnapData.cpp KoShapeShadow.cpp KoSharedLoadingData.cpp KoSharedSavingData.cpp KoViewConverter.cpp KoInputDeviceHandler.cpp KoInputDeviceHandlerEvent.cpp KoInputDeviceHandlerRegistry.cpp KoImageData.cpp KoImageData_p.cpp KoImageCollection.cpp KoOdfWorkaround.cpp KoFilterEffect.cpp KoFilterEffectStack.cpp KoFilterEffectFactoryBase.cpp KoFilterEffectRegistry.cpp KoFilterEffectConfigWidgetBase.cpp KoFilterEffectRenderContext.cpp KoFilterEffectLoadingContext.cpp KoTextShapeDataBase.cpp KoTosContainer.cpp KoTosContainerModel.cpp KoClipPath.cpp KoClipMask.cpp KoClipMaskPainter.cpp KoCurveFit.cpp KisGamutMaskViewConverter.cpp commands/KoShapeGroupCommand.cpp commands/KoShapeAlignCommand.cpp commands/KoShapeBackgroundCommand.cpp commands/KoShapeCreateCommand.cpp commands/KoShapeDeleteCommand.cpp commands/KoShapeDistributeCommand.cpp commands/KoShapeLockCommand.cpp commands/KoShapeMoveCommand.cpp commands/KoShapeResizeCommand.cpp commands/KoShapeShearCommand.cpp commands/KoShapeSizeCommand.cpp commands/KoShapeStrokeCommand.cpp commands/KoShapeUngroupCommand.cpp commands/KoShapeReorderCommand.cpp commands/KoShapeKeepAspectRatioCommand.cpp commands/KoPathBaseCommand.cpp commands/KoPathPointMoveCommand.cpp commands/KoPathControlPointMoveCommand.cpp commands/KoPathPointTypeCommand.cpp commands/KoPathPointRemoveCommand.cpp commands/KoPathPointInsertCommand.cpp commands/KoPathSegmentBreakCommand.cpp commands/KoPathBreakAtPointCommand.cpp commands/KoPathSegmentTypeCommand.cpp commands/KoPathCombineCommand.cpp commands/KoSubpathRemoveCommand.cpp commands/KoSubpathJoinCommand.cpp commands/KoParameterHandleMoveCommand.cpp commands/KoParameterToPathCommand.cpp commands/KoShapeTransformCommand.cpp commands/KoPathFillRuleCommand.cpp commands/KoConnectionShapeTypeCommand.cpp commands/KoShapeShadowCommand.cpp commands/KoPathReverseCommand.cpp commands/KoShapeRenameCommand.cpp commands/KoShapeRunAroundCommand.cpp commands/KoPathPointMergeCommand.cpp commands/KoShapeTransparencyCommand.cpp commands/KoShapeClipCommand.cpp commands/KoShapeUnclipCommand.cpp commands/KoPathShapeMarkerCommand.cpp commands/KoShapeConnectionChangeCommand.cpp commands/KoMultiPathPointMergeCommand.cpp commands/KoMultiPathPointJoinCommand.cpp commands/KoKeepShapesSelectedCommand.cpp commands/KoPathMergeUtils.cpp html/HtmlSavingContext.cpp html/HtmlWriter.cpp - tools/KoCreateShapeStrategy.cpp tools/KoPathToolFactory.cpp tools/KoPathTool.cpp tools/KoPathToolSelection.cpp tools/KoPathToolHandle.cpp tools/PathToolOptionWidget.cpp tools/KoPathPointRubberSelectStrategy.cpp tools/KoPathPointMoveStrategy.cpp tools/KoPathConnectionPointStrategy.cpp tools/KoPathControlPointMoveStrategy.cpp tools/KoParameterChangeStrategy.cpp tools/KoZoomTool.cpp tools/KoZoomToolFactory.cpp tools/KoZoomToolWidget.cpp tools/KoZoomStrategy.cpp tools/KoInteractionTool.cpp tools/KoInteractionStrategy.cpp tools/KoInteractionStrategyFactory.cpp - tools/KoCreateShapesTool.cpp - tools/KoCreateShapesToolFactory.cpp tools/KoShapeRubberSelectStrategy.cpp tools/KoPathSegmentChangeStrategy.cpp svg/KoShapePainter.cpp svg/SvgUtil.cpp svg/SvgGraphicContext.cpp svg/SvgSavingContext.cpp svg/SvgWriter.cpp svg/SvgStyleWriter.cpp svg/SvgShape.cpp svg/SvgParser.cpp svg/SvgStyleParser.cpp svg/SvgGradientHelper.cpp svg/SvgFilterHelper.cpp svg/SvgCssHelper.cpp svg/SvgClipPathHelper.cpp svg/SvgLoadingContext.cpp svg/SvgShapeFactory.cpp svg/parsers/SvgTransformParser.cpp text/KoSvgText.cpp text/KoSvgTextProperties.cpp text/KoSvgTextChunkShape.cpp text/KoSvgTextShape.cpp text/KoSvgTextShapeMarkupConverter.cpp resources/KoSvgSymbolCollectionResource.cpp resources/KoGamutMask.cpp FlakeDebug.cpp tests/MockShapes.cpp ) ki18n_wrap_ui(kritaflake_SRCS tools/PathToolOptionWidgetBase.ui KoConnectionShapeConfigWidget.ui tools/KoZoomToolWidget.ui ) add_library(kritaflake SHARED ${kritaflake_SRCS}) generate_export_header(kritaflake BASE_NAME kritaflake) target_include_directories(kritaflake PUBLIC $ $ $ $ ) target_link_libraries(kritaflake kritapigment kritawidgetutils kritaodf kritacommand KF5::WidgetsAddons Qt5::Svg) set_target_properties(kritaflake PROPERTIES VERSION ${GENERIC_KRITA_LIB_VERSION} SOVERSION ${GENERIC_KRITA_LIB_SOVERSION} ) install(TARGETS kritaflake ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/libs/flake/KoToolManager.cpp b/libs/flake/KoToolManager.cpp index 66a04bc0c9..637bb080a5 100644 --- a/libs/flake/KoToolManager.cpp +++ b/libs/flake/KoToolManager.cpp @@ -1,975 +1,952 @@ /* This file is part of the KDE project * * Copyright (c) 2005-2010 Boudewijn Rempt * Copyright (C) 2006-2008 Thomas Zander * Copyright (C) 2006 Thorsten Zachmann * Copyright (C) 2008 Jan Hambrecht * * 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. */ // flake #include "KoToolManager.h" #include "KoToolManager_p.h" #include "KoToolRegistry.h" #include "KoToolProxy.h" #include "KoToolProxy_p.h" #include "KoSelection.h" #include "KoCanvasController.h" #include "KoCanvasControllerWidget.h" #include "KoShape.h" #include "KoShapeLayer.h" #include "KoShapeRegistry.h" #include "KoShapeManager.h" #include "KoSelectedShapesProxy.h" #include "KoCanvasBase.h" #include "KoInputDeviceHandlerRegistry.h" #include "KoInputDeviceHandlerEvent.h" #include "KoPointerEvent.h" -#include "tools/KoCreateShapesTool.h" #include "tools/KoZoomTool.h" #include "kis_action_registry.h" #include "KoToolFactoryBase.h" #include "kis_assert.h" #include // Qt + kde #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include Q_GLOBAL_STATIC(KoToolManager, s_instance) class CanvasData { public: CanvasData(KoCanvasController *cc, const KoInputDevice &id) : activeTool(0), canvas(cc), inputDevice(id), dummyToolWidget(0), dummyToolLabel(0) { } ~CanvasData() { // the dummy tool widget does not necessarily have a parent and we create it, so we delete it. delete dummyToolWidget; } void activateToolActions() { toolActions.clear(); disabledGlobalActions.clear(); KActionCollection *windowActionCollection = canvas->actionCollection(); if (!windowActionCollection) { qWarning() << "We haven't got an action collection"; return; } QStringList globalActions; QMap shortcutMap; //qDebug() << "................... activating tool" << activeToolId; Q_FOREACH(QAction *action, windowActionCollection->actions()) { //qDebug() << "Action" << action->objectName() << "shortcuts" << action->shortcuts(); if (action->property("tool_action").isValid()) { QStringList tools = action->property("tool_action").toStringList(); //qDebug() << "\tassociated with" << tools; if (tools.contains(activeToolId)) { //qDebug() << "\t\tenabling"; action->setEnabled(true); toolActions << action->objectName(); } else { action->setDisabled(true); } } else { globalActions << action->objectName(); } Q_FOREACH(QKeySequence keySequence, action->shortcuts()) { // After loading a custom shortcut profile, shortcuts can be defined as an empty string, which is not an empty shortcut if (keySequence.toString() != "") { if (shortcutMap.contains(keySequence)) { shortcutMap[keySequence].append(action->objectName()); } else { shortcutMap[keySequence] = QStringList() << action->objectName(); } } } } // Make sure the tool's actions override the global actions that aren't associated with the tool. Q_FOREACH(const QKeySequence &k, shortcutMap.keys()) { if (shortcutMap[k].size() > 1) { QStringList actions = shortcutMap[k]; //qDebug() << k << actions; bool toolActionFound = false; Q_FOREACH(const QString &action, actions) { if (toolActions.contains(action)) { toolActionFound = true; } } Q_FOREACH(const QString &action, actions) { if (toolActionFound && globalActions.contains(action)) { //qDebug() << "\tdisabling global action" << action; windowActionCollection->action(action)->setEnabled(false); disabledGlobalActions << action; } } //qDebug() << k << shortcutMap[k]; } } windowActionCollection->readSettings(); // The shortcuts might have been configured in the meantime. } void deactivateToolActions() { if (!activeTool) return; //qDebug() << "............... deactivating previous tool because activating" << activeToolId; KActionCollection *windowActionCollection = canvas->actionCollection(); Q_FOREACH(const QString &action, toolActions) { //qDebug() << "disabling" << action; windowActionCollection->action(action)->setDisabled(true); } Q_FOREACH(const QString &action, disabledGlobalActions) { //qDebug() << "enabling" << action; windowActionCollection->action(action)->setEnabled(true); } } KoToolBase *activeTool; // active Tool QString activeToolId; // the id of the active Tool QString activationShapeId; // the shape-type (KoShape::shapeId()) the activeTool 'belongs' to. QHash allTools; // all the tools that are created for this canvas. QStack stack; // stack of temporary tools KoCanvasController *const canvas; const KoInputDevice inputDevice; QWidget *dummyToolWidget; // the widget shown in the toolDocker. QLabel *dummyToolLabel; QStringList toolActions; QStringList disabledGlobalActions; }; // ******** KoToolManager ********** KoToolManager::KoToolManager() : QObject(), d(new Private(this)) { connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*,QWidget*)), this, SLOT(movedFocus(QWidget*,QWidget*))); } KoToolManager::~KoToolManager() { delete d; } QList KoToolManager::toolActionList() const { QList answer; answer.reserve(d->tools.count()); Q_FOREACH (ToolHelper *tool, d->tools) { - if (tool->id() == KoCreateShapesTool_ID) - continue; // don't show this one. answer.append(tool->toolAction()); } return answer; } void KoToolManager::requestToolActivation(KoCanvasController * controller) { if (d->canvasses.contains(controller)) { QString activeToolId = d->canvasses.value(controller).first()->activeToolId; Q_FOREACH (ToolHelper * th, d->tools) { if (th->id() == activeToolId) { d->toolActivated(th); break; } } } } KoInputDevice KoToolManager::currentInputDevice() const { return d->inputDevice; } void KoToolManager::registerToolActions(KActionCollection *ac, KoCanvasController *controller) { Q_ASSERT(controller); Q_ASSERT(ac); d->setup(); if (!d->canvasses.contains(controller)) { return; } // Actions used to switch tools via shortcuts Q_FOREACH (ToolHelper * th, d->tools) { if (ac->action(th->id())) { continue; } ShortcutToolAction* action = th->createShortcutToolAction(ac); ac->addCategorizedAction(th->id(), action, "tool-shortcuts"); } } void KoToolManager::addController(KoCanvasController *controller) { Q_ASSERT(controller); if (d->canvasses.contains(controller)) return; d->setup(); d->attachCanvas(controller); connect(controller->proxyObject, SIGNAL(destroyed(QObject*)), this, SLOT(attemptCanvasControllerRemoval(QObject*))); connect(controller->proxyObject, SIGNAL(canvasRemoved(KoCanvasController*)), this, SLOT(detachCanvas(KoCanvasController*))); connect(controller->proxyObject, SIGNAL(canvasSet(KoCanvasController*)), this, SLOT(attachCanvas(KoCanvasController*))); } void KoToolManager::removeCanvasController(KoCanvasController *controller) { Q_ASSERT(controller); disconnect(controller->proxyObject, SIGNAL(canvasRemoved(KoCanvasController*)), this, SLOT(detachCanvas(KoCanvasController*))); disconnect(controller->proxyObject, SIGNAL(canvasSet(KoCanvasController*)), this, SLOT(attachCanvas(KoCanvasController*))); d->detachCanvas(controller); } void KoToolManager::attemptCanvasControllerRemoval(QObject* controller) { KoCanvasControllerProxyObject* controllerActual = qobject_cast(controller); if (controllerActual) { removeCanvasController(controllerActual->canvasController()); } } void KoToolManager::switchToolRequested(const QString & id) { Q_ASSERT(d->canvasData); if (!d->canvasData) return; while (!d->canvasData->stack.isEmpty()) // switching means to flush the stack d->canvasData->stack.pop(); d->switchTool(id, false); } void KoToolManager::switchInputDeviceRequested(const KoInputDevice &id) { if (!d->canvasData) return; d->switchInputDevice(id); } void KoToolManager::switchToolTemporaryRequested(const QString &id) { d->switchTool(id, true); } void KoToolManager::switchBackRequested() { if (!d->canvasData) return; if (d->canvasData->stack.isEmpty()) { // default to changing to the interactionTool d->switchTool(KoInteractionTool_ID, false); return; } d->switchTool(d->canvasData->stack.pop(), false); } -KoCreateShapesTool * KoToolManager::shapeCreatorTool(KoCanvasBase *canvas) const -{ - Q_ASSERT(canvas); - Q_FOREACH (KoCanvasController *controller, d->canvasses.keys()) { - if (controller->canvas() == canvas) { - KoCreateShapesTool *createTool = dynamic_cast - (d->canvasData->allTools.value(KoCreateShapesTool_ID)); - Q_ASSERT(createTool /* ID changed? */); - return createTool; - } - } - Q_ASSERT(0); // this should not happen - return 0; -} - KoToolBase *KoToolManager::toolById(KoCanvasBase *canvas, const QString &id) const { Q_ASSERT(canvas); Q_FOREACH (KoCanvasController *controller, d->canvasses.keys()) { if (controller->canvas() == canvas) return d->canvasData->allTools.value(id); } return 0; } KoCanvasController *KoToolManager::activeCanvasController() const { if (! d->canvasData) return 0; return d->canvasData->canvas; } QString KoToolManager::preferredToolForSelection(const QList &shapes) { QSet shapeTypes; Q_FOREACH (KoShape *shape, shapes) { shapeTypes << shape->shapeId(); } //KritaUtils::makeContainerUnique(types); QString toolType = KoInteractionTool_ID; int prio = INT_MAX; Q_FOREACH (ToolHelper *helper, d->tools) { - if (helper->id() == KoCreateShapesTool_ID) continue; if (helper->priority() >= prio) continue; bool toolWillWork = false; foreach (const QString &type, shapeTypes) { if (helper->activationShapeId().split(',').contains(type)) { toolWillWork = true; break; } } if (toolWillWork) { toolType = helper->id(); prio = helper->priority(); } } return toolType; } QPair KoToolManager::createTools(KoCanvasController *controller, ToolHelper *tool) { // XXX: maybe this method should go into the private class? QHash origHash; if (d->canvasses.contains(controller)) { origHash = d->canvasses.value(controller).first()->allTools; } if (origHash.contains(tool->id())) { return QPair(tool->id(), origHash.value(tool->id())); } debugFlake << "Creating tool" << tool->id() << ". Activated on:" << tool->activationShapeId() << ", prio:" << tool->priority(); KoToolBase *tl = tool->createTool(controller->canvas()); if (tl) { d->uniqueToolIds.insert(tl, tool->uniqueId()); tl->setObjectName(tool->id()); } KoZoomTool *zoomTool = dynamic_cast(tl); if (zoomTool) { zoomTool->setCanvasController(controller); } return QPair(tool->id(), tl); } void KoToolManager::initializeCurrentToolForCanvas() { d->postSwitchTool(false); } KoToolManager* KoToolManager::instance() { return s_instance; } QString KoToolManager::activeToolId() const { if (!d->canvasData) return QString(); return d->canvasData->activeToolId; } KoToolManager::Private *KoToolManager::priv() { return d; } /**** KoToolManager::Private ****/ KoToolManager::Private::Private(KoToolManager *qq) : q(qq), canvasData(0), layerExplicitlyDisabled(false) { } KoToolManager::Private::~Private() { qDeleteAll(tools); } // helper method. CanvasData *KoToolManager::Private::createCanvasData(KoCanvasController *controller, const KoInputDevice &device) { QHash toolsHash; Q_FOREACH (ToolHelper *tool, tools) { QPair toolPair = q->createTools(controller, tool); if (toolPair.second) { // only if a real tool was created toolsHash.insert(toolPair.first, toolPair.second); } } - KoCreateShapesTool *createShapesTool = dynamic_cast(toolsHash.value(KoCreateShapesTool_ID)); - KIS_ASSERT(createShapesTool); - QString id = KoShapeRegistry::instance()->keys()[0]; - createShapesTool->setShapeId(id); CanvasData *cd = new CanvasData(controller, device); cd->allTools = toolsHash; return cd; } void KoToolManager::Private::setup() { if (tools.size() > 0) return; KoShapeRegistry::instance(); KoToolRegistry *registry = KoToolRegistry::instance(); Q_FOREACH (const QString & id, registry->keys()) { ToolHelper *t = new ToolHelper(registry->value(id)); tools.append(t); } // connect to all tools so we can hear their button-clicks Q_FOREACH (ToolHelper *tool, tools) connect(tool, SIGNAL(toolActivated(ToolHelper*)), q, SLOT(toolActivated(ToolHelper*))); // load pluggable input devices KoInputDeviceHandlerRegistry::instance(); } void KoToolManager::Private::connectActiveTool() { if (canvasData->activeTool) { connect(canvasData->activeTool, SIGNAL(cursorChanged(QCursor)), q, SLOT(updateCursor(QCursor))); connect(canvasData->activeTool, SIGNAL(activateTool(QString)), q, SLOT(switchToolRequested(QString))); connect(canvasData->activeTool, SIGNAL(activateTemporary(QString)), q, SLOT(switchToolTemporaryRequested(QString))); connect(canvasData->activeTool, SIGNAL(done()), q, SLOT(switchBackRequested())); connect(canvasData->activeTool, SIGNAL(statusTextChanged(QString)), q, SIGNAL(changedStatusText(QString))); } // we expect the tool to emit a cursor on activation. updateCursor(Qt::ForbiddenCursor); } void KoToolManager::Private::disconnectActiveTool() { if (canvasData->activeTool) { canvasData->deactivateToolActions(); // repaint the decorations before we deactivate the tool as it might deleted // data needed for the repaint emit q->aboutToChangeTool(canvasData->canvas); canvasData->activeTool->deactivate(); disconnect(canvasData->activeTool, SIGNAL(cursorChanged(QCursor)), q, SLOT(updateCursor(QCursor))); disconnect(canvasData->activeTool, SIGNAL(activateTool(QString)), q, SLOT(switchToolRequested(QString))); disconnect(canvasData->activeTool, SIGNAL(activateTemporary(QString)), q, SLOT(switchToolTemporaryRequested(QString))); disconnect(canvasData->activeTool, SIGNAL(done()), q, SLOT(switchBackRequested())); disconnect(canvasData->activeTool, SIGNAL(statusTextChanged(QString)), q, SIGNAL(changedStatusText(QString))); } // emit a empty status text to clear status text from last active tool emit q->changedStatusText(QString()); } void KoToolManager::Private::switchTool(KoToolBase *tool, bool temporary) { Q_ASSERT(tool); if (canvasData == 0) return; if (canvasData->activeTool == tool && tool->toolId() != KoInteractionTool_ID) return; disconnectActiveTool(); canvasData->activeTool = tool; connectActiveTool(); postSwitchTool(temporary); } void KoToolManager::Private::switchTool(const QString &id, bool temporary) { Q_ASSERT(canvasData); if (!canvasData) return; if (canvasData->activeTool && temporary) canvasData->stack.push(canvasData->activeToolId); canvasData->activeToolId = id; KoToolBase *tool = canvasData->allTools.value(id); if (! tool) { return; } Q_FOREACH (ToolHelper *th, tools) { if (th->id() == id) { canvasData->activationShapeId = th->activationShapeId(); break; } } switchTool(tool, temporary); } void KoToolManager::Private::postSwitchTool(bool temporary) { #ifndef NDEBUG int canvasCount = 1; Q_FOREACH (QList list, canvasses) { bool first = true; Q_FOREACH (CanvasData *data, list) { if (first) { debugFlake << "Canvas" << canvasCount++; } debugFlake << " +- Tool:" << data->activeToolId << (data == canvasData ? " *" : ""); first = false; } } #endif Q_ASSERT(canvasData); if (!canvasData) return; KoToolBase::ToolActivation toolActivation; if (temporary) toolActivation = KoToolBase::TemporaryActivation; else toolActivation = KoToolBase::DefaultActivation; QSet shapesToOperateOn; if (canvasData->activeTool && canvasData->activeTool->canvas() && canvasData->activeTool->canvas()->shapeManager()) { KoSelection *selection = canvasData->activeTool->canvas()->shapeManager()->selection(); Q_ASSERT(selection); shapesToOperateOn = QSet::fromList(selection->selectedEditableShapesAndDelegates()); } if (canvasData->canvas->canvas()) { // Caller of postSwitchTool expect this to be called to update the selected tool updateToolForProxy(); canvasData->activeTool->activate(toolActivation, shapesToOperateOn); KoCanvasBase *canvas = canvasData->canvas->canvas(); canvas->updateInputMethodInfo(); } else { canvasData->activeTool->activate(toolActivation, shapesToOperateOn); } QList > optionWidgetList = canvasData->activeTool->optionWidgets(); if (optionWidgetList.empty()) { // no option widget. QWidget *toolWidget; QString title; Q_FOREACH (ToolHelper *tool, tools) { if (tool->id() == canvasData->activeTool->toolId()) { title = tool->toolTip(); break; } } toolWidget = canvasData->dummyToolWidget; if (toolWidget == 0) { toolWidget = new QWidget(); toolWidget->setObjectName("DummyToolWidget"); QVBoxLayout *layout = new QVBoxLayout(toolWidget); layout->setMargin(3); canvasData->dummyToolLabel = new QLabel(toolWidget); layout->addWidget(canvasData->dummyToolLabel); layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding)); toolWidget->setLayout(layout); canvasData->dummyToolWidget = toolWidget; } canvasData->dummyToolLabel->setText(i18n("Active tool: %1", title)); optionWidgetList.append(toolWidget); } // Activate the actions for the currently active tool canvasData->activateToolActions(); emit q->changedTool(canvasData->canvas, uniqueToolIds.value(canvasData->activeTool)); emit q->toolOptionWidgetsChanged(canvasData->canvas, optionWidgetList); } void KoToolManager::Private::switchCanvasData(CanvasData *cd) { Q_ASSERT(cd); KoCanvasBase *oldCanvas = 0; KoInputDevice oldInputDevice; if (canvasData) { oldCanvas = canvasData->canvas->canvas(); oldInputDevice = canvasData->inputDevice; if (canvasData->activeTool) { disconnectActiveTool(); } KoToolProxy *proxy = proxies.value(oldCanvas); Q_ASSERT(proxy); proxy->setActiveTool(0); } canvasData = cd; inputDevice = canvasData->inputDevice; if (canvasData->activeTool) { connectActiveTool(); postSwitchTool(false); } if (oldInputDevice != canvasData->inputDevice) { emit q->inputDeviceChanged(canvasData->inputDevice); } if (oldCanvas != canvasData->canvas->canvas()) { emit q->changedCanvas(canvasData->canvas->canvas()); } } void KoToolManager::Private::toolActivated(ToolHelper *tool) { Q_ASSERT(tool); Q_ASSERT(canvasData); if (!canvasData) return; KoToolBase *t = canvasData->allTools.value(tool->id()); Q_ASSERT(t); canvasData->activeToolId = tool->id(); canvasData->activationShapeId = tool->activationShapeId(); switchTool(t, false); } void KoToolManager::Private::detachCanvas(KoCanvasController *controller) { Q_ASSERT(controller); // check if we are removing the active canvas controller if (canvasData && canvasData->canvas == controller) { KoCanvasController *newCanvas = 0; // try to find another canvas controller beside the one we are removing Q_FOREACH (KoCanvasController* canvas, canvasses.keys()) { if (canvas != controller) { // yay found one newCanvas = canvas; break; } } if (newCanvas) { switchCanvasData(canvasses.value(newCanvas).first()); } else { emit q->toolOptionWidgetsChanged(controller, QList >()); // as a last resort just set a blank one canvasData = 0; } } KoToolProxy *proxy = proxies.value(controller->canvas()); if (proxy) proxy->setActiveTool(0); QList tools; Q_FOREACH (CanvasData *canvasData, canvasses.value(controller)) { Q_FOREACH (KoToolBase *tool, canvasData->allTools) { if (! tools.contains(tool)) { tools.append(tool); } } delete canvasData; } Q_FOREACH (KoToolBase *tool, tools) { uniqueToolIds.remove(tool); delete tool; } canvasses.remove(controller); emit q->changedCanvas(canvasData ? canvasData->canvas->canvas() : 0); } void KoToolManager::Private::attachCanvas(KoCanvasController *controller) { Q_ASSERT(controller); CanvasData *cd = createCanvasData(controller, KoInputDevice::mouse()); // switch to new canvas as the active one. switchCanvasData(cd); inputDevice = cd->inputDevice; QList canvasses_; canvasses_.append(cd); canvasses[controller] = canvasses_; KoToolProxy *tp = proxies[controller->canvas()]; if (tp) tp->priv()->setCanvasController(controller); if (cd->activeTool == 0) { // no active tool, so we activate the highest priority main tool int highestPriority = INT_MAX; ToolHelper * helper = 0; Q_FOREACH (ToolHelper * th, tools) { if (th->section() == KoToolFactoryBase::mainToolType()) { if (th->priority() < highestPriority) { highestPriority = qMin(highestPriority, th->priority()); helper = th; } } } if (helper) toolActivated(helper); } Connector *connector = new Connector(controller->canvas()->shapeManager()); connect(connector, SIGNAL(selectionChanged(QList)), q, SLOT(selectionChanged(QList))); connect(controller->canvas()->selectedShapesProxy(), SIGNAL(currentLayerChanged(const KoShapeLayer*)), q, SLOT(currentLayerChanged(const KoShapeLayer*))); emit q->changedCanvas(canvasData ? canvasData->canvas->canvas() : 0); } void KoToolManager::Private::movedFocus(QWidget *from, QWidget *to) { Q_UNUSED(from); // no canvas anyway or no focus set anyway? if (!canvasData || to == 0) { return; } // Check if this app is about QWidget-based KoCanvasControllerWidget canvasses // XXX: Focus handling for non-qwidget based canvases! KoCanvasControllerWidget *canvasControllerWidget = dynamic_cast(canvasData->canvas); if (!canvasControllerWidget) { return; } // canvasWidget is set as focusproxy for KoCanvasControllerWidget, // so all focus checks are to be done against canvasWidget objects // focus returned to current canvas? if (to == canvasData->canvas->canvas()->canvasWidget()) { // nothing to do return; } // if the 'to' is one of our canvasWidgets, then switch. // for code simplicity the current canvas will be checked again, // but would have been caught already in the lines above, so no issue KoCanvasController *newCanvas = 0; Q_FOREACH (KoCanvasController* canvas, canvasses.keys()) { if (canvas->canvas()->canvasWidget() == to) { newCanvas = canvas; break; } } // none of our canvasWidgets got focus? if (newCanvas == 0) { return; } // switch to canvasdata matching inputdevice used last with this app instance Q_FOREACH (CanvasData *data, canvasses.value(newCanvas)) { if (data->inputDevice == inputDevice) { switchCanvasData(data); return; } } // if no such inputDevice for this canvas, then simply fallback to first one switchCanvasData(canvasses.value(newCanvas).first()); } void KoToolManager::Private::updateCursor(const QCursor &cursor) { Q_ASSERT(canvasData); Q_ASSERT(canvasData->canvas); Q_ASSERT(canvasData->canvas->canvas()); canvasData->canvas->canvas()->setCursor(cursor); } void KoToolManager::Private::selectionChanged(const QList &shapes) { QList types; Q_FOREACH (KoShape *shape, shapes) { QSet delegates = shape->toolDelegates(); if (delegates.isEmpty()) { // no delegates, just the orig shape delegates << shape; } foreach (KoShape *shape2, delegates) { Q_ASSERT(shape2); if (! types.contains(shape2->shapeId())) { types.append(shape2->shapeId()); } } } // check if there is still a shape selected the active tool can work on // there needs to be at least one shape for a tool without an activationShapeId // to work // if not change the current tool to the default tool const QStringList activationShapeIds = canvasData->activationShapeId.split(','); if (!(canvasData->activationShapeId.isNull() && shapes.size() > 0) && !activationShapeIds.contains("flake/always") && !activationShapeIds.contains("flake/edit")) { bool currentToolWorks = false; foreach (const QString &type, types) { if (activationShapeIds.contains(type)) { currentToolWorks = true; break; } } if (!currentToolWorks) { switchTool(KoInteractionTool_ID, false); } } emit q->toolCodesSelected(types); } void KoToolManager::Private::currentLayerChanged(const KoShapeLayer *layer) { emit q->currentLayerChanged(canvasData->canvas, layer); layerExplicitlyDisabled = layer && !layer->isShapeEditable(); updateToolForProxy(); debugFlake << "Layer changed to" << layer << "explicitly disabled:" << layerExplicitlyDisabled; } void KoToolManager::Private::updateToolForProxy() { KoToolProxy *proxy = proxies.value(canvasData->canvas->canvas()); if(!proxy) return; bool canUseTool = !layerExplicitlyDisabled || canvasData->activationShapeId.endsWith(QLatin1String("/always")); proxy->setActiveTool(canUseTool ? canvasData->activeTool : 0); } void KoToolManager::Private::switchInputDevice(const KoInputDevice &device) { Q_ASSERT(canvasData); if (!canvasData) return; if (inputDevice == device) return; if (inputDevice.isMouse() && device.isMouse()) return; if (device.isMouse() && !inputDevice.isMouse()) { // we never switch back to mouse from a tablet input device, so the user can use the // mouse to edit the settings for a tool activated by a tablet. See bugs // https://bugs.kde.org/show_bug.cgi?id=283130 and https://bugs.kde.org/show_bug.cgi?id=285501. // We do continue to switch between tablet devices, thought. return; } QList items = canvasses[canvasData->canvas]; // search for a canvasdata object for the current input device Q_FOREACH (CanvasData *cd, items) { if (cd->inputDevice == device) { switchCanvasData(cd); if (!canvasData->activeTool) { switchTool(KoInteractionTool_ID, false); } return; } } // still here? That means we need to create a new CanvasData instance with the current InputDevice. CanvasData *cd = createCanvasData(canvasData->canvas, device); // switch to new canvas as the active one. QString oldTool = canvasData->activeToolId; items.append(cd); canvasses[cd->canvas] = items; switchCanvasData(cd); q->switchToolRequested(oldTool); } void KoToolManager::Private::registerToolProxy(KoToolProxy *proxy, KoCanvasBase *canvas) { proxies.insert(canvas, proxy); Q_FOREACH (KoCanvasController *controller, canvasses.keys()) { if (controller->canvas() == canvas) { proxy->priv()->setCanvasController(controller); break; } } } //have to include this because of Q_PRIVATE_SLOT #include "moc_KoToolManager.cpp" diff --git a/libs/flake/KoToolManager.h b/libs/flake/KoToolManager.h index 77dbe4edd1..5504755171 100644 --- a/libs/flake/KoToolManager.h +++ b/libs/flake/KoToolManager.h @@ -1,335 +1,326 @@ /* This file is part of the KDE project * Copyright (c) 2005-2006 Boudewijn Rempt * Copyright (C) 2006, 2008 Thomas Zander * Copyright (C) 2006 Thorsten Zachmann * * 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 KO_TOOL_MANAGER #define KO_TOOL_MANAGER #include "KoInputDevice.h" #include "kritaflake_export.h" #include #include class KoCanvasController; class KoShapeControllerBase; class KoToolFactoryBase; class KoCanvasBase; class KoToolBase; class KoCreateShapesTool; class KActionCollection; class KoShape; class KoInputDeviceHandlerEvent; class KoShapeLayer; class ToolHelper; class QKeySequence; class QCursor; /** * This class serves as a QAction-like control object for activation of a tool. * * It allows to implement a custom UI to control the activation of tools. * See KoToolBox & KoModeBox in the kowidgets library. * * KoToolAction objects are indirectly owned by the KoToolManager singleton * and live until the end of its lifetime. */ class KRITAFLAKE_EXPORT KoToolAction : public QObject { Q_OBJECT public: // toolHelper takes over ownership, and those live till the end of KoToolManager. explicit KoToolAction(ToolHelper *toolHelper); ~KoToolAction() override; public: QString id() const; ///< The id of the tool QString iconText() const; ///< The icontext of the tool QString toolTip() const; ///< The tooltip of the tool QString iconName() const; ///< The icon name of the tool QKeySequence shortcut() const; ///< The shortcut to activate the tool QString section() const; ///< The section the tool wants to be in. int priority() const; ///< Lower number (higher priority) means coming first in the section. int buttonGroupId() const; ///< A unique ID for this tool as passed by changedTool(), >= 0 QString visibilityCode() const; ///< This tool should become visible when we emit this string in toolCodesSelected() public Q_SLOTS: void trigger(); ///< Request the activation of the tool Q_SIGNALS: void changed(); ///< Emitted when a property changes (shortcut ATM) private: friend class ToolHelper; class Private; Private *const d; }; /** * This class manages the activation and deactivation of tools for * each input device. * * Managing the active tool and switching tool based on various variables. * * The state of the toolbox will be the same for all views in the process so practically * you can say we have one toolbox per application instance (process). Implementation * does not allow one widget to be in more then one view, so we just make sure the toolbox * is hidden in not-in-focus views. * * The ToolManager is a singleton and will manage all views in all applications that * are loaded in this process. This means you will have to register and unregister your view. * When creating your new view you should use a KoCanvasController() and register that * with the ToolManager like this: @code MyGuiWidget::MyGuiWidget() { m_canvasController = new KoCanvasController(this); m_canvasController->setCanvas(m_canvas); KoToolManager::instance()->addControllers(m_canvasController)); } MyGuiWidget::~MyGuiWidget() { KoToolManager::instance()->removeCanvasController(m_canvasController); } @endcode * * For a new view that extends KoView all you need to do is implement KoView::createToolBox() * * KoToolManager also keeps track of the current tool based on a complex set of conditions and heuristics: - there is one active tool per KoCanvasController (and there is one KoCanvasController per view, because this is a class with scrollbars and a zoomlevel and so on) - for every pointing device (determined by the unique id of tablet, or 0 for mice -- you may have more than one mouse attached, but Qt cannot distinguish between them, there is an associated tool. - depending on things like tablet leave/enter proximity, incoming mouse or tablet events and a little timer (that gets stopped when we know what is what), the active pointing device is determined, and the active tool is set accordingly. Nota bene: if you use KoToolManager and register your canvases with it you no longer have to manually implement methods to route mouse, tablet, key or wheel events to the active tool. In fact, it's no longer interesting to you which tool is active; you can safely route the paint event through KoToolProxy::paint(). (The reason the input events are handled completely by the toolmanager and the paint events not is that, generally speaking, it's okay if the tools get the input events first, but you want to paint your shapes or other canvas stuff first and only then paint the tool stuff.) */ class KRITAFLAKE_EXPORT KoToolManager : public QObject { Q_OBJECT public: KoToolManager(); /// Return the toolmanager singleton static KoToolManager* instance(); ~KoToolManager() override; /** * Register actions for switching to tools at the actionCollection parameter. * The actions will have the text / shortcut as stated by the toolFactory. * If the application calls this in their KoView extending class they will have all the benefits * from allowing this in the menus and to allow the use to configure the shortcuts used. * @param ac the actionCollection that will be the parent of the actions. * @param controller tools registered with this controller will have all their actions added as well. */ void registerToolActions(KActionCollection *ac, KoCanvasController *controller); /** * Register a new canvas controller * @param controller the view controller that this toolmanager will manage the tools for */ void addController(KoCanvasController *controller); /** * Remove a set of controllers * When the controller is no longer used it should be removed so all tools can be * deleted and stop eating memory. * @param controller the controller that is removed */ void removeCanvasController(KoCanvasController *controller); /** * Attempt to remove a controller. * This is automatically called when a controller's proxy object is deleted, and * it ensures that the controller is, in fact, removed, even if the creator forgot * to do so. * @param controller the proxy object of the controller to be removed */ Q_SLOT void attemptCanvasControllerRemoval(QObject *controller); /// @return the active canvas controller KoCanvasController *activeCanvasController() const; - /** - * Return the tool that is able to create shapes for this param canvas. - * This is typically used by the KoShapeSelector to set which shape to create next. - * @param canvas the canvas that is a child of a previously registered controller - * who's tool you want. - * @see addController() - */ - KoCreateShapesTool *shapeCreatorTool(KoCanvasBase *canvas) const; - /** * Returns the tool for the given tool id. The tool may be 0 * @param canvas the canvas that is a child of a previously registered controller * who's tool you want. * @param id the tool identifier * @see addController() */ KoToolBase *toolById(KoCanvasBase *canvas, const QString &id) const; /// @return the currently active pointing device KoInputDevice currentInputDevice() const; /** * For the list of shapes find out which tool is the highest priority tool that can handle it. * @returns the toolId for the shapes. * @param shapes a list of shapes, a selection for example, that is used to look for the tool. */ QString preferredToolForSelection(const QList &shapes); /** * Returns the list of toolActions for the current tools. * @returns lists of toolActions for the current tools. */ QList toolActionList() const; /// Request tool activation for the given canvas controller void requestToolActivation(KoCanvasController *controller); /// Returns the toolId of the currently active tool QString activeToolId() const; void initializeCurrentToolForCanvas(); class Private; /** * \internal return the private object for the toolmanager. */ KoToolManager::Private *priv(); public Q_SLOTS: /** * Request switching tool * @param id the id of the tool */ void switchToolRequested(const QString &id); /** * Request change input device * @param id the id of the input device */ void switchInputDeviceRequested(const KoInputDevice &id); /** * Request for temporary switching the tools. * This switch can be later reverted with switchBackRequested(). * @param id the id of the tool * * @see switchBackRequested() */ void switchToolTemporaryRequested(const QString &id); /** * Switches back to the original tool after the temporary switch * has been done. It the user changed the tool manually on the way, * then it switches to the interaction tool */ void switchBackRequested(); Q_SIGNALS: /** * Emitted when a new tool is going to override the current tool * @param canvas the currently active canvas. */ void aboutToChangeTool(KoCanvasController *canvas); /** * Emitted when a new tool was selected or became active. * @param canvas the currently active canvas. * @param uniqueToolId a random but unique code for the new tool. */ void changedTool(KoCanvasController *canvas, int uniqueToolId); /** * Emitted after the selection changed to state which unique shape-types are now * in the selection. * @param types a list of string that are the shape types of the selected objects. */ void toolCodesSelected(const QList &types); /** * Emitted after the current layer changed either its properties or to a new layer. * @param canvas the currently active canvas. * @param layer the layer that is selected. */ void currentLayerChanged(const KoCanvasController *canvas, const KoShapeLayer *layer); /** * Every time a new input device gets used by a tool, this event is emitted. * @param device the new input device that the user picked up. */ void inputDeviceChanged(const KoInputDevice &device); /** * Emitted whenever the active canvas changed. * @param canvas the new activated canvas (might be 0) */ void changedCanvas(const KoCanvasBase *canvas); /** * Emitted whenever the active tool changes the status text. * @param statusText the new status text */ void changedStatusText(const QString &statusText); /** * emitted whenever a new tool is dynamically added for the given canvas */ void addedTool(KoToolAction *toolAction, KoCanvasController *canvas); /** * Emit the new tool option widgets to be used with this canvas. */ void toolOptionWidgetsChanged(KoCanvasController *controller, const QList > &widgets); private: KoToolManager(const KoToolManager&); KoToolManager operator=(const KoToolManager&); Q_PRIVATE_SLOT(d, void toolActivated(ToolHelper *tool)) Q_PRIVATE_SLOT(d, void detachCanvas(KoCanvasController *controller)) Q_PRIVATE_SLOT(d, void attachCanvas(KoCanvasController *controller)) Q_PRIVATE_SLOT(d, void movedFocus(QWidget *from, QWidget *to)) Q_PRIVATE_SLOT(d, void updateCursor(const QCursor &cursor)) Q_PRIVATE_SLOT(d, void selectionChanged(const QList &shapes)) Q_PRIVATE_SLOT(d, void currentLayerChanged(const KoShapeLayer *layer)) QPair createTools(KoCanvasController *controller, ToolHelper *tool); Private *const d; }; #endif diff --git a/libs/flake/KoToolRegistry.cpp b/libs/flake/KoToolRegistry.cpp index 2e7b2bcb1e..f893b339be 100644 --- a/libs/flake/KoToolRegistry.cpp +++ b/libs/flake/KoToolRegistry.cpp @@ -1,79 +1,76 @@ /* This file is part of the KDE project * Copyright (C) 2006-2007 Thomas Zander * Copyright (c) 2004 Boudewijn Rempt * * 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 "KoToolRegistry.h" #include #include #include -#include "tools/KoCreateShapesToolFactory.h" -#include "tools/KoCreateShapesTool.h" #include "tools/KoPathToolFactory.h" #include "tools/KoZoomTool.h" #include "tools/KoZoomToolFactory.h" #include "KoToolManager.h" #include #include Q_GLOBAL_STATIC(KoToolRegistry, s_instance) KoToolRegistry::KoToolRegistry() : d(0) { } void KoToolRegistry::init() { KoPluginLoader::PluginsConfig config; config.group = "calligra"; config.whiteList = "ToolPlugins"; config.blacklist = "ToolPluginsDisabled"; KoPluginLoader::instance()->load(QString::fromLatin1("Calligra/Tool"), QString::fromLatin1("[X-Flake-PluginVersion] == 28"), config); // register generic tools - add(new KoCreateShapesToolFactory()); add(new KoPathToolFactory()); add(new KoZoomToolFactory()); KConfigGroup cfg = KSharedConfig::openConfig()->group("calligra"); QStringList toolsBlacklist = cfg.readEntry("ToolsBlacklist", QStringList()); foreach (const QString& toolID, toolsBlacklist) { delete value(toolID); remove(toolID); } } KoToolRegistry::~KoToolRegistry() { qDeleteAll(doubleEntries()); qDeleteAll(values()); } KoToolRegistry* KoToolRegistry::instance() { if (!s_instance.exists()) { s_instance->init(); } return s_instance; } diff --git a/libs/flake/tools/KoCreateShapeStrategy.cpp b/libs/flake/tools/KoCreateShapeStrategy.cpp deleted file mode 100644 index 83fbc4424e..0000000000 --- a/libs/flake/tools/KoCreateShapeStrategy.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* This file is part of the KDE project - * Copyright (C) 2006 Thomas Zander - * Copyright (C) 2006 Thorsten Zachmann - * - * 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 "KoCreateShapeStrategy.h" -#include "KoShapeRubberSelectStrategy_p.h" -#include "KoCreateShapesTool.h" -#include "KoShape.h" -#include "KoShapeRegistry.h" -#include "KoShapeManager.h" -#include "KoCanvasBase.h" -#include "KoSelection.h" -#include "KoShapeFactoryBase.h" -#include "KoShapeController.h" -#include "KoViewConverter.h" - -#include - -#include - -KoCreateShapeStrategy::KoCreateShapeStrategy(KoCreateShapesTool *tool, const QPointF &clicked) - : KoShapeRubberSelectStrategy(tool, clicked, tool->canvas()->snapToGrid()) -{ - KoCreateShapesTool *parent = static_cast(d_ptr->tool); - KoShapeFactoryBase *factory = KoShapeRegistry::instance()->value(parent->shapeId()); - if (factory) { - const KoProperties *props = parent->shapeProperties(); - KoShape *shape; - if (props) { - shape = factory->createShape(props); - } else { - shape = factory->createDefaultShape(); - } - - m_outline = shape->outline(); - m_outlineBoundingRect = m_outline.boundingRect(); - delete shape; - } -} - -KUndo2Command* KoCreateShapeStrategy::createCommand() -{ - Q_D(KoShapeRubberSelectStrategy); - KoCreateShapesTool *parent = static_cast(d_ptr->tool); - KoShapeFactoryBase *factory = KoShapeRegistry::instance()->value(parent->shapeId()); - if (! factory) { - warnFlake << "Application requested a shape that is not registered" << parent->shapeId(); - return 0; - } - - const KoProperties *props = parent->shapeProperties(); - KoShape *shape; - if (props) - shape = factory->createShape(props, parent->canvas()->shapeController()->resourceManager()); - else - shape = factory->createDefaultShape(parent->canvas()->shapeController()->resourceManager()); - if (shape->shapeId().isEmpty()) - shape->setShapeId(factory->id()); - QRectF rect = d->selectedRect(); - shape->setPosition(rect.topLeft()); - QSizeF newSize = rect.size(); - // if the user has dragged when creating the shape, - // resize the shape to the dragged size - if (newSize.width() > 1.0 && newSize.height() > 1.0) - shape->setSize(newSize); - - KUndo2Command * cmd = parent->canvas()->shapeController()->addShape(shape, 0); - if (cmd) { - KoSelection *selection = parent->canvas()->shapeManager()->selection(); - selection->deselectAll(); - selection->select(shape); - } - return cmd; -} - -void KoCreateShapeStrategy::finishInteraction(Qt::KeyboardModifiers modifiers) -{ - Q_UNUSED(modifiers); - Q_D(KoShapeRubberSelectStrategy); - d->tool->canvas()->updateCanvas(d->selectedRect()); -} - -void KoCreateShapeStrategy::paint(QPainter &painter, const KoViewConverter &converter) -{ - Q_D(KoShapeRubberSelectStrategy); - if (m_outline.isEmpty()) - KoShapeRubberSelectStrategy::paint(painter, converter); - else { - painter.save(); - painter.setRenderHint(QPainter::Antialiasing, false); - - QColor selectColor(Qt::blue); // TODO make configurable - selectColor.setAlphaF(0.5); - QBrush sb(selectColor, Qt::SolidPattern); - painter.setPen(QPen(sb, 0)); - painter.setBrush(sb); - QRectF paintRect = converter.documentToView(d->selectedRect()); - - qreal xscale = paintRect.width() / m_outlineBoundingRect.width(); - qreal yscale = paintRect.height() / m_outlineBoundingRect.height(); - QTransform matrix; - matrix.translate(-m_outlineBoundingRect.left(), -m_outlineBoundingRect.top()); - matrix.scale(xscale, yscale); - painter.translate(paintRect.left(), paintRect.top()); - - painter.setTransform(matrix, true); - painter.drawPath(m_outline); - painter.restore(); - } -} - -void KoCreateShapeStrategy::handleMouseMove(const QPointF &point, Qt::KeyboardModifiers modifiers) -{ - Q_D(KoShapeRubberSelectStrategy); - KoShapeRubberSelectStrategy::handleMouseMove(point, modifiers); - if (! m_outline.isEmpty()) - d->tool->canvas()->updateCanvas(d->selectedRect()); -} diff --git a/libs/flake/tools/KoCreateShapeStrategy.h b/libs/flake/tools/KoCreateShapeStrategy.h deleted file mode 100644 index f6971d16ae..0000000000 --- a/libs/flake/tools/KoCreateShapeStrategy.h +++ /dev/null @@ -1,57 +0,0 @@ -/* This file is part of the KDE project - * Copyright (C) 2006 Thomas Zander - * Copyright (C) 2006 Thorsten Zachmann - * - * 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 KOCREATESHAPESTRATEGY_H -#define KOCREATESHAPESTRATEGY_H - -#include "KoShapeRubberSelectStrategy.h" - -#include -#include - -class KoCreateShapesTool; - -/** - * A strategy for the KoCreateShapesTool. - */ -class KoCreateShapeStrategy : public KoShapeRubberSelectStrategy -{ -public: - /** - * Constructor that starts to create a new shape. - * @param tool the parent tool which controls this strategy - * @param clicked the initial point that the user depressed (in pt). - */ - KoCreateShapeStrategy(KoCreateShapesTool *tool, const QPointF &clicked); - ~KoCreateShapeStrategy() override {} - - void finishInteraction(Qt::KeyboardModifiers modifiers) override; - KUndo2Command* createCommand() override; - void paint(QPainter &painter, const KoViewConverter &converter) override; - void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override; - -private: - QPainterPath m_outline; - QRectF m_outlineBoundingRect; - Q_DECLARE_PRIVATE(KoShapeRubberSelectStrategy) -}; - -#endif - diff --git a/libs/flake/tools/KoCreateShapesTool.cpp b/libs/flake/tools/KoCreateShapesTool.cpp deleted file mode 100644 index 5f811f1eae..0000000000 --- a/libs/flake/tools/KoCreateShapesTool.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* This file is part of the KDE project - * - * Copyright (C) 2006-2007 Thomas Zander - * Copyright (C) 2006 Thorsten Zachmann - * - * 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 "KoCreateShapesTool.h" -#include "KoInteractionTool_p.h" -#include "KoPointerEvent.h" -#include "KoInteractionStrategy.h" -#include "KoCreateShapeStrategy.h" - -#include -#include - -class KoCreateShapesToolPrivate : public KoInteractionToolPrivate -{ -public: - KoCreateShapesToolPrivate(KoToolBase *qq, KoCanvasBase *canvas) - : KoInteractionToolPrivate(qq, canvas), - newShapeProperties(0) - { - } - - QString shapeId; - const KoProperties *newShapeProperties; -}; - -KoCreateShapesTool::KoCreateShapesTool(KoCanvasBase *canvas) - : KoInteractionTool(*(new KoCreateShapesToolPrivate(this, canvas))) -{ -} - -KoCreateShapesTool::~KoCreateShapesTool() -{ -} - -void KoCreateShapesTool::paint(QPainter &painter, const KoViewConverter &converter) -{ - if (currentStrategy()) - currentStrategy()->paint(painter, converter); -} - -void KoCreateShapesTool::mouseReleaseEvent(KoPointerEvent *event) -{ - KoInteractionTool::mouseReleaseEvent(event); - emit KoToolBase::done(); -} - -void KoCreateShapesTool::activate(ToolActivation, const QSet &) -{ - useCursor(Qt::ArrowCursor); -} - -void KoCreateShapesTool::setShapeId(const QString &id) -{ - Q_D(KoCreateShapesTool); - d->shapeId = id; -} - -QString KoCreateShapesTool::shapeId() const -{ - Q_D(const KoCreateShapesTool); - return d->shapeId; -} - -void KoCreateShapesTool::setShapeProperties(const KoProperties *properties) -{ - Q_D(KoCreateShapesTool); - d->newShapeProperties = properties; -} - -const KoProperties * KoCreateShapesTool::shapeProperties() -{ - Q_D(KoCreateShapesTool); - return d->newShapeProperties; -} - -KoInteractionStrategy *KoCreateShapesTool::createStrategy(KoPointerEvent *event) -{ - return new KoCreateShapeStrategy(this, event->point); -} - diff --git a/libs/flake/tools/KoCreateShapesTool.h b/libs/flake/tools/KoCreateShapesTool.h deleted file mode 100644 index 89fd409b57..0000000000 --- a/libs/flake/tools/KoCreateShapesTool.h +++ /dev/null @@ -1,87 +0,0 @@ -/* This file is part of the KDE project - * - * Copyright (C) 2006-2007 Thomas Zander - * Copyright (C) 2006 Thorsten Zachmann - * - * 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 KOCREATESHAPESTOOL_H -#define KOCREATESHAPESTOOL_H - -#include "KoInteractionTool.h" - -#include "kritaflake_export.h" - -#include - -class KoCanvasBase; -class KoProperties; -class KoCreateShapesToolPrivate; - -#define KoCreateShapesTool_ID "CreateShapesTool" - -/** - * A tool to create shapes with. - */ -class KRITAFLAKE_EXPORT KoCreateShapesTool : public KoInteractionTool -{ -public: - /** - * Create a new tool; typically not called by applications, only by the KoToolManager - * @param canvas the canvas this tool works for. - */ - explicit KoCreateShapesTool(KoCanvasBase *canvas); - /// destructor - ~KoCreateShapesTool() override; - void mouseReleaseEvent(KoPointerEvent *event) override; - void activate(ToolActivation toolActivation, const QSet &shapes) override; - - void paint(QPainter &painter, const KoViewConverter &converter) override; - - /** - * Each shape-type has an Id; as found in KoShapeFactoryBase::id().id(), to choose which - * shape this controller should actually create; set the id before the user starts to - * create the new shape. - * @param id the SHAPEID of the to be generated shape - */ - void setShapeId(const QString &id); - /** - * return the shape Id that is to be created. - * @return the shape Id that is to be created. - */ - QString shapeId() const; - - /** - * Set the shape properties that the create controller will use for the next shape it will - * create. The tool does not take ownership of the object. - * @param properties the properties or 0 if the default shape should be created. - */ - void setShapeProperties(const KoProperties *properties); - /** - * return the properties to be used for creating the next shape - * @return the properties to be used for creating the next shape - */ - const KoProperties *shapeProperties(); - -protected: - KoInteractionStrategy *createStrategy(KoPointerEvent *event) override; - -private: - Q_DECLARE_PRIVATE(KoCreateShapesTool) -}; - -#endif diff --git a/libs/flake/tools/KoCreateShapesToolFactory.cpp b/libs/flake/tools/KoCreateShapesToolFactory.cpp deleted file mode 100644 index c2a2aec4eb..0000000000 --- a/libs/flake/tools/KoCreateShapesToolFactory.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* This file is part of the KDE project - * - * Copyright (C) 2006 Thomas Zander - * - * 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 "KoCreateShapesToolFactory.h" -#include "KoCreateShapesTool.h" - -#include - -KoCreateShapesToolFactory::KoCreateShapesToolFactory() - : KoToolFactoryBase(KoCreateShapesTool_ID) -{ - setToolTip(i18n("Create object")); - setSection(mainToolType()); - setPriority(3); -} - -KoCreateShapesToolFactory::~KoCreateShapesToolFactory() -{ -} - -KoToolBase* KoCreateShapesToolFactory::createTool(KoCanvasBase *canvas) -{ - return new KoCreateShapesTool(canvas); -} diff --git a/libs/flake/tools/KoCreateShapesToolFactory.h b/libs/flake/tools/KoCreateShapesToolFactory.h deleted file mode 100644 index 51ab3cea93..0000000000 --- a/libs/flake/tools/KoCreateShapesToolFactory.h +++ /dev/null @@ -1,37 +0,0 @@ -/* This file is part of the KDE project - * - * Copyright (C) 2006 Thomas Zander - * - * 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 KOCREATESHAPESTOOLFACTORY_H -#define KOCREATESHAPESTOOLFACTORY_H - -#include "KoToolFactoryBase.h" - -/// The factory for the KoCreateShapesTool -class KoCreateShapesToolFactory : public KoToolFactoryBase -{ -public: - /// Constructor - KoCreateShapesToolFactory(); - /// Destructor - ~KoCreateShapesToolFactory() override; - - KoToolBase* createTool(KoCanvasBase *canvas) override; -}; -#endif