Index: libs/ui/CMakeLists.txt =================================================================== --- libs/ui/CMakeLists.txt +++ libs/ui/CMakeLists.txt @@ -294,6 +294,7 @@ operations/kis_filter_selection_operation.cpp actions/kis_selection_action_factories.cpp actions/KisPasteActionFactory.cpp + actions/KisTransformToolActivationCommand.cpp input/kis_touch_shortcut.cpp kis_document_undo_store.cpp kis_gui_context_command.cpp Index: libs/ui/KisViewManager.h =================================================================== --- libs/ui/KisViewManager.h +++ libs/ui/KisViewManager.h @@ -212,6 +212,8 @@ void slotViewAdded(KisView *view); void slotViewRemoved(KisView *view); + + void slotActivateTransformTool(); Q_SIGNALS: Index: libs/ui/KisViewManager.cpp =================================================================== --- libs/ui/KisViewManager.cpp +++ libs/ui/KisViewManager.cpp @@ -1390,3 +1390,17 @@ KisConfig cfg(true); d->showPixelGrid->setChecked(cfg.pixelGridEnabled() && cfg.useOpenGL()); } + +void KisViewManager::slotActivateTransformTool() +{ + if(KoToolManager::instance()->activeToolId() == "KisToolTransform") { + KoToolBase* tool = KoToolManager::instance()->toolById(canvasBase(), "KisToolTransform"); + + QSet dummy; + // Start a new stroke + tool->deactivate(); + tool->activate(KoToolBase::DefaultActivation, dummy); + } + + KoToolManager::instance()->switchToolRequested("KisToolTransform"); +} Index: libs/ui/actions/KisPasteActionFactory.cpp =================================================================== --- libs/ui/actions/KisPasteActionFactory.cpp +++ libs/ui/actions/KisPasteActionFactory.cpp @@ -18,6 +18,9 @@ #include "KisPasteActionFactory.h" +#include + +#include "kis_config.h" #include "kis_image.h" #include "KisViewManager.h" #include "kis_tool_proxy.h" @@ -28,7 +31,10 @@ #include "kis_shape_layer.h" #include "kis_import_catcher.h" #include "kis_clipboard.h" +#include "kis_selection.h" +#include "commands/kis_selection_commands.h" #include "commands/kis_image_layer_add_command.h" +#include "KisTransformToolActivationCommand.h" #include "kis_processing_applicator.h" #include @@ -237,6 +243,15 @@ KUndo2Command *cmd = new KisImageLayerAddCommand(image, newLayer, parentNode, aboveNode); KisProcessingApplicator *ap = beginAction(view, cmd->text()); ap->applyCommand(cmd, KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::NORMAL); + + if (KisConfig(true).activateTransformToolAfterPaste()) { + KUndo2Command *deselectCmd = new KisDeselectActiveSelectionCommand(view->selection(), image); + ap->applyCommand(deselectCmd, KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::NORMAL); + + KUndo2Command *transformToolCmd = new KisTransformToolActivationCommand(view); + ap->applyCommand(transformToolCmd, KisStrokeJobData::BARRIER, KisStrokeJobData::NORMAL); + } + endAction(ap, KisOperationConfiguration(id()).toXML()); } else { // XXX: "Add saving of XML data for Paste of shapes" Index: libs/ui/actions/KisTransformToolActivationCommand.h =================================================================== --- /dev/null +++ libs/ui/actions/KisTransformToolActivationCommand.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018 Sven Langkamp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KISTRANSFORMTOOLACTIVATIONCOMMAND_H +#define KISTRANSFORMTOOLACTIVATIONCOMMAND_H + +#include +#include +#include +#include "KisViewManager.h" + +class KRITAUI_EXPORT KisTransformToolActivationCommand : public QObject, public KUndo2Command +{ + Q_OBJECT +public: + KisTransformToolActivationCommand(KisViewManager* view, KUndo2Command * parent = 0); + ~KisTransformToolActivationCommand() override; + + void redo() override; + void undo() override; + + +Q_SIGNALS: + void requestTransformTool(); + + +private: + bool m_firstRedo; + KisViewManager* m_view; +}; + +#endif // KISTRANSFORMTOOLACTIVATIONCOMMAND_H Index: libs/ui/actions/KisTransformToolActivationCommand.cpp =================================================================== --- /dev/null +++ libs/ui/actions/KisTransformToolActivationCommand.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018 Sven Langkamp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "KisTransformToolActivationCommand.h" + +#include + +#include +#include +#include "canvas/kis_canvas2.h" + +KisTransformToolActivationCommand::KisTransformToolActivationCommand(KisViewManager* view, KUndo2Command * parent) + : KUndo2Command(kundo2_i18n("Activate transform tool"), parent), m_firstRedo(true), m_view(view) +{ + connect(this, SIGNAL(requestTransformTool()), m_view, SLOT(slotActivateTransformTool())); +} + +KisTransformToolActivationCommand::~KisTransformToolActivationCommand() +{ +} + +void KisTransformToolActivationCommand::redo() +{ + if(m_firstRedo) + { + m_firstRedo = false; + emit requestTransformTool(); + } +} + +void KisTransformToolActivationCommand::undo() +{ + +} + +#include "KisTransformToolActivationCommand.moc" Index: libs/ui/dialogs/kis_dlg_preferences.cc =================================================================== --- libs/ui/dialogs/kis_dlg_preferences.cc +++ libs/ui/dialogs/kis_dlg_preferences.cc @@ -153,6 +153,7 @@ m_radioToolOptionsInDocker->setChecked(cfg.toolOptionsInDocker()); m_chkSwitchSelectionCtrlAlt->setChecked(cfg.switchSelectionCtrlAlt()); chkEnableTouch->setChecked(!cfg.disableTouchOnCanvas()); + chkEnableTranformToolAfterPaste->setChecked(cfg.activateTransformToolAfterPaste()); m_cmbKineticScrollingGesture->addItem(i18n("Disabled")); m_cmbKineticScrollingGesture->addItem(i18n("On Touch Drag")); @@ -241,6 +242,7 @@ m_chkKineticScrollingScrollbar->setChecked(cfg.kineticScrollingScrollbar(true)); m_chkSwitchSelectionCtrlAlt->setChecked(cfg.switchSelectionCtrlAlt(true)); chkEnableTouch->setChecked(!cfg.disableTouchOnCanvas(true)); + chkEnableTranformToolAfterPaste->setChecked(cfg.activateTransformToolAfterPaste(true)); m_chkConvertOnImport->setChecked(cfg.convertToImageColorspaceOnImport(true)); KoColor cursorColor(KoColorSpaceRegistry::instance()->rgb8()); @@ -1304,6 +1306,7 @@ cfg.setKineticScrollingScrollbar(dialog->m_general->kineticScrollingScrollbar()); cfg.setSwitchSelectionCtrlAlt(dialog->m_general->switchSelectionCtrlAlt()); cfg.setDisableTouchOnCanvas(!dialog->m_general->chkEnableTouch->isChecked()); + cfg.setActivateTransformToolAfterPaste(dialog->m_general->chkEnableTranformToolAfterPaste->isChecked()); cfg.setConvertToImageColorspaceOnImport(dialog->m_general->convertToImageColorspaceOnImport()); cfg.setUndoStackLimit(dialog->m_general->undoStackSize()); cfg.setFavoritePresets(dialog->m_general->favoritePresets()); Index: libs/ui/forms/wdggeneralsettings.ui =================================================================== --- libs/ui/forms/wdggeneralsettings.ui +++ libs/ui/forms/wdggeneralsettings.ui @@ -26,7 +26,7 @@ - 0 + 2 @@ -424,6 +424,13 @@ + + + Activate transform tool after pasting + + + + Kinetic Scrolling (needs restart) @@ -804,6 +811,16 @@ toggled(bool) m_autosaveSpinBox setEnabled(bool) + + + 20 + 20 + + + 20 + 20 + + Index: libs/ui/kis_config.h =================================================================== --- libs/ui/kis_config.h +++ libs/ui/kis_config.h @@ -568,6 +568,10 @@ bool autoSmoothBezierCurves(bool defaultValue = false) const; void setAutoSmoothBezierCurves(bool value); + + bool activateTransformToolAfterPaste(bool defaultValue = false) const; + void setActivateTransformToolAfterPaste(bool value); + template void writeEntry(const QString& name, const T& value) { Index: libs/ui/kis_config.cc =================================================================== --- libs/ui/kis_config.cc +++ libs/ui/kis_config.cc @@ -1975,6 +1975,16 @@ m_cfg.writeEntry("autoSmoothBezierCurves", value); } +bool KisConfig::activateTransformToolAfterPaste(bool defaultValue) const +{ + return defaultValue ? false : m_cfg.readEntry("activateTransformToolAfterPaste", false); +} + +void KisConfig::setActivateTransformToolAfterPaste(bool value) +{ + m_cfg.writeEntry("activateTransformToolAfterPaste", value); +} + #include #include