[krita] /: FEATURE: Edit Seleciton action
Dmitry Kazakov
null at kde.org
Tue Sep 4 11:43:52 BST 2018
Git commit 0dbdd41a2068a11bc6d90c41154267abcb194675 by Dmitry Kazakov.
Committed on 04/09/2018 at 10:43.
Pushed by dkazakov into branch 'master'.
FEATURE: Edit Seleciton action
This action just activates the current selection mask
(even when it is hidden as a global selection mask) and
activates a corresponding transformation tool: either
shape manipulation tool or raster transform tool.
Ref T9486
CC:kimageshop at kde.org
M +2 -0 krita/krita4.xmlgui
M +12 -0 krita/kritamenu.action
M +47 -0 libs/ui/kis_selection_manager.cc
M +1 -0 libs/ui/kis_selection_manager.h
M +2 -0 libs/ui/tool/kis_selection_tool_helper.cpp
https://commits.kde.org/krita/0dbdd41a2068a11bc6d90c41154267abcb194675
diff --git a/krita/krita4.xmlgui b/krita/krita4.xmlgui
index 020d78ddb57..d050f120370 100644
--- a/krita/krita4.xmlgui
+++ b/krita/krita4.xmlgui
@@ -268,6 +268,8 @@ xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org
<Action name="deselect"/>
<Action name="reselect"/>
<Action name="invert_selection"/>
+ <Separator/>
+ <Action name="edit_selection"/>
<Action name="convert_to_vector_selection"/>
<Action name="convert_to_raster_selection"/>
<Action name="convert_shapes_to_vector_selection"/>
diff --git a/krita/kritamenu.action b/krita/kritamenu.action
index 3b2fce8b2ed..efc698bd37f 100644
--- a/krita/kritamenu.action
+++ b/krita/kritamenu.action
@@ -1259,6 +1259,18 @@
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
+ <Action name="edit_selection">
+ <icon></icon>
+ <text>Edit Selection</text>
+ <whatsThis></whatsThis>
+ <toolTip>Edit Selection</toolTip>
+ <iconText>Edit Selection</iconText>
+ <activationFlags>10000000000</activationFlags>
+ <activationConditions>100</activationConditions>
+ <shortcut></shortcut>
+ <isCheckable>false</isCheckable>
+ <statusTip></statusTip>
+ </Action>
<Action name="convert_shapes_to_vector_selection">
<icon></icon>
<text>Convert Shapes to &Vector Selection</text>
diff --git a/libs/ui/kis_selection_manager.cc b/libs/ui/kis_selection_manager.cc
index ab79dacfe5a..d7dc8747555 100644
--- a/libs/ui/kis_selection_manager.cc
+++ b/libs/ui/kis_selection_manager.cc
@@ -195,6 +195,9 @@ void KisSelectionManager::setup(KisActionManager* actionManager)
m_imageResizeToSelection = actionManager->createAction("resizeimagetoselection");
connect(m_imageResizeToSelection, SIGNAL(triggered()), this, SLOT(imageResizeToSelection()));
+ action = actionManager->createAction("edit_selection");
+ connect(action, SIGNAL(triggered()), SLOT(editSelection()));
+
action = actionManager->createAction("convert_to_vector_selection");
connect(action, SIGNAL(triggered()), SLOT(convertToVectorSelection()));
@@ -421,6 +424,50 @@ void KisSelectionManager::reselect()
factory.run(m_view);
}
+
+#include <KoToolManager.h>
+#include <KoInteractionTool.h>
+
+void KisSelectionManager::editSelection()
+{
+ KisSelectionSP selection = m_view->selection();
+ if (!selection) return;
+
+ KisAction *action = m_view->actionManager()->actionByName("show-global-selection-mask");
+ KIS_SAFE_ASSERT_RECOVER_RETURN(action);
+
+ if (!action->isChecked()) {
+ action->setChecked(true);
+ emit action->toggled(true);
+ emit action->triggered(true);
+ }
+
+ KisNodeSP node = selection->parentNode();
+ KIS_SAFE_ASSERT_RECOVER_RETURN(node);
+
+ m_view->nodeManager()->slotNonUiActivatedNode(node);
+
+ if (selection->hasShapeSelection()) {
+ KisShapeSelection *shapeSelection = dynamic_cast<KisShapeSelection*>(selection->shapeSelection());
+ KIS_SAFE_ASSERT_RECOVER_RETURN(shapeSelection);
+
+ KoToolManager::instance()->switchToolRequested(KoInteractionTool_ID);
+
+ QList<KoShape*> shapes = shapeSelection->shapes();
+
+ if (shapes.isEmpty()) {
+ KIS_SAFE_ASSERT_RECOVER_NOOP(0 && "no shapes");
+ return;
+ }
+
+ Q_FOREACH (KoShape *shape, shapes) {
+ m_view->canvasBase()->selectedShapesProxy()->selection()->select(shape);
+ }
+ } else {
+ KoToolManager::instance()->switchToolRequested("KisToolTransform");
+ }
+}
+
void KisSelectionManager::convertToVectorSelection()
{
KisSelectionToVectorActionFactory factory;
diff --git a/libs/ui/kis_selection_manager.h b/libs/ui/kis_selection_manager.h
index 3aaa4f45099..ea9024071d0 100644
--- a/libs/ui/kis_selection_manager.h
+++ b/libs/ui/kis_selection_manager.h
@@ -97,6 +97,7 @@ public Q_SLOTS:
void fillBackgroundColorOpacity();
void fillPatternOpacity();
void reselect();
+ void editSelection();
void convertToVectorSelection();
void convertToRasterSelection();
void convertShapesToVectorSelection();
diff --git a/libs/ui/tool/kis_selection_tool_helper.cpp b/libs/ui/tool/kis_selection_tool_helper.cpp
index 6133454f5ec..198fae9ac7b 100644
--- a/libs/ui/tool/kis_selection_tool_helper.cpp
+++ b/libs/ui/tool/kis_selection_tool_helper.cpp
@@ -309,6 +309,8 @@ QMenu* KisSelectionToolHelper::getSelectionContextMenu(KisCanvas2* canvas)
KisSelectionSP selection = canvas->viewManager()->selection();
if (selection && canvas->viewManager()->selectionEditable()) {
+ m_contextMenu->addAction(actionMan->actionByName("edit_selection"));
+
if (!selection->hasShapeSelection()) {
m_contextMenu->addAction(actionMan->actionByName("convert_to_vector_selection"));
} else {
More information about the kimageshop
mailing list