[graphics/krita] /: Fix ambiguous "break path" shortcut in Shape Edit Tool
Dmitry Kazakov
null at kde.org
Fri Dec 13 14:25:36 GMT 2024
Git commit 228b8fbf9b9d2a34f331d179bdbdf1094742539b by Dmitry Kazakov.
Committed on 13/12/2024 at 14:25.
Pushed by dkazakov into branch 'master'.
Fix ambiguous "break path" shortcut in Shape Edit Tool
Now the default shortcut for this action is Ctrl+B (and the
status test shows it correctly)
Please note that there is a theoretical conflict with a global
shortcut Ctrl+B that opens color balance filter, though it does
never happen in real life, because "Break path at selection"
shortcut activates **only** when shape editing too is activated
(it is a non-global tool-level shortcut).
BUG:429503
CC:kimageshop at kde.org
M +10 -0 krita/data/actions/PathTool.action
M +29 -10 libs/flake/tools/KoPathTool.cpp
M +2 -0 libs/flake/tools/KoPathTool.h
M +2 -0 libs/flake/tools/KoPathToolFactory.cpp
https://invent.kde.org/graphics/krita/-/commit/228b8fbf9b9d2a34f331d179bdbdf1094742539b
diff --git a/krita/data/actions/PathTool.action b/krita/data/actions/PathTool.action
index 436f10c1991..5348b8ca050 100644
--- a/krita/data/actions/PathTool.action
+++ b/krita/data/actions/PathTool.action
@@ -52,6 +52,16 @@
<isCheckable>false</isCheckable>
<text>Break at point</text>
</Action>
+ <Action name="path-break-selection">
+ <iconText>Break at selection</iconText>
+ <shortcut>Ctrl+B</shortcut>
+ <toolTip>Break at selection</toolTip>
+ <icon>path-break-point</icon>
+ <whatsThis></whatsThis>
+ <statusTip></statusTip>
+ <isCheckable>false</isCheckable>
+ <text>Break at selection</text>
+ </Action>
<Action name="pathpoint-line">
<iconText>Make line point</iconText>
<shortcut></shortcut>
diff --git a/libs/flake/tools/KoPathTool.cpp b/libs/flake/tools/KoPathTool.cpp
index 30ce728c64f..00fb7b5eb5c 100644
--- a/libs/flake/tools/KoPathTool.cpp
+++ b/libs/flake/tools/KoPathTool.cpp
@@ -98,6 +98,8 @@ KoPathTool::KoPathTool(KoCanvasBase *canvas)
m_actionRemovePoint = action("pathpoint-remove");
m_actionBreakPoint = action("path-break-point");
m_actionBreakSegment = action("path-break-segment");
+ m_actionBreakSelection = action("path-break-selection");
+ KIS_ASSERT(m_actionBreakSelection);
m_actionJoinSegment = action("pathpoint-join");
m_actionMergePoints = action("pathpoint-merge");
m_actionConvertToPath = action("convert-to-path");
@@ -412,6 +414,20 @@ void KoPathTool::breakAtPoint()
}
}
+void KoPathTool::breakAtSelection()
+{
+ Q_D(KoToolBase);
+
+ if (m_pointSelection.objectCount() == 1 && m_pointSelection.size() == 2) {
+ QList<KoPathPointData> segments(m_pointSelection.selectedSegmentsData());
+ if (segments.size() == 1) {
+ d->canvas->addCommand(new KoPathSegmentBreakCommand(segments.at(0)));
+ }
+ } else if (m_pointSelection.hasSelection()) {
+ d->canvas->addCommand(new KoPathBreakAtPointCommand(m_pointSelection.selectedPointsData()));
+ }
+}
+
void KoPathTool::breakAtSegment()
{
Q_D(KoToolBase);
@@ -694,10 +710,16 @@ void KoPathTool::mouseMoveEvent(KoPointerEvent *event)
uint selectedPointCount = m_pointSelection.size();
if (selectedPointCount == 0)
Q_EMIT statusTextChanged(QString());
- else if (selectedPointCount == 1)
- Q_EMIT statusTextChanged(i18n("Press B to break path at selected point."));
- else
- Q_EMIT statusTextChanged(i18n("Press B to break path at selected segments."));
+ else {
+ if (!m_actionBreakSelection->shortcut().isEmpty()) {
+ if (selectedPointCount == 1)
+ Q_EMIT statusTextChanged(i18nc("%1 is a shortcut to be pressed", "Press %1 to break path at selected point.", m_actionBreakSelection->shortcut().toString()));
+ else
+ Q_EMIT statusTextChanged(i18nc("%1 is a shortcut to be pressed", "Press %1 to break path at selected segments.", m_actionBreakSelection->shortcut().toString()));
+ } else {
+ Q_EMIT statusTextChanged(QString());
+ }
+ }
}
}
@@ -751,12 +773,6 @@ void KoPathTool::keyPressEvent(QKeyEvent *event)
// }
// break;
#endif
- case Qt::Key_B:
- if (m_pointSelection.size() == 1)
- breakAtPoint();
- else if (m_pointSelection.size() >= 2)
- breakAtSegment();
- break;
default:
event->ignore();
return;
@@ -884,6 +900,7 @@ void KoPathTool::activate(const QSet<KoShape*> &shapes)
connect(m_actionRemovePoint, SIGNAL(triggered()), this, SLOT(removePoints()), Qt::UniqueConnection);
connect(m_actionBreakPoint, SIGNAL(triggered()), this, SLOT(breakAtPoint()), Qt::UniqueConnection);
connect(m_actionBreakSegment, SIGNAL(triggered()), this, SLOT(breakAtSegment()), Qt::UniqueConnection);
+ connect(m_actionBreakSelection, SIGNAL(triggered()), this, SLOT(breakAtSelection()), Qt::UniqueConnection);
connect(m_actionJoinSegment, SIGNAL(triggered()), this, SLOT(joinPoints()), Qt::UniqueConnection);
connect(m_actionMergePoints, SIGNAL(triggered()), this, SLOT(mergePoints()), Qt::UniqueConnection);
connect(m_actionConvertToPath, SIGNAL(triggered()), this, SLOT(convertToPath()), Qt::UniqueConnection);
@@ -1043,6 +1060,7 @@ void KoPathTool::updateActions()
m_actionCurveSegment->setEnabled(canConvertSegmentToCurve);
m_actionBreakSegment->setEnabled(canSplitAtSegment);
+ m_actionBreakSelection->setEnabled(canSplitAtSegment | canBreakAtPoint);
KoSelection *selection = canvas()->selectedShapesProxy()->selection();
bool haveConvertibleShapes = false;
@@ -1080,6 +1098,7 @@ void KoPathTool::deactivate()
disconnect(m_actionRemovePoint, 0, this, 0);
disconnect(m_actionBreakPoint, 0, this, 0);
disconnect(m_actionBreakSegment, 0, this, 0);
+ disconnect(m_actionBreakSelection, 0, this, 0);
disconnect(m_actionJoinSegment, 0, this, 0);
disconnect(m_actionMergePoints, 0, this, 0);
disconnect(m_actionConvertToPath, 0, this, 0);
diff --git a/libs/flake/tools/KoPathTool.h b/libs/flake/tools/KoPathTool.h
index af240b93b46..50c4c5b0f35 100644
--- a/libs/flake/tools/KoPathTool.h
+++ b/libs/flake/tools/KoPathTool.h
@@ -96,6 +96,7 @@ private Q_SLOTS:
void mergePoints();
void breakAtPoint();
void breakAtSegment();
+ void breakAtSelection();
void pointSelectionChanged();
void updateActions();
void pointToLine();
@@ -133,6 +134,7 @@ private:
QAction *m_actionRemovePoint;
QAction *m_actionBreakPoint;
QAction *m_actionBreakSegment;
+ QAction *m_actionBreakSelection;
QAction *m_actionJoinSegment;
QAction *m_actionMergePoints;
QAction *m_actionConvertToPath;
diff --git a/libs/flake/tools/KoPathToolFactory.cpp b/libs/flake/tools/KoPathToolFactory.cpp
index e8bb429fca4..ff7b82ce3d0 100644
--- a/libs/flake/tools/KoPathToolFactory.cpp
+++ b/libs/flake/tools/KoPathToolFactory.cpp
@@ -44,8 +44,10 @@ QList<QAction *> KoPathToolFactory::createActionsImpl()
actions << actionRegistry->makeQAction("pathsegment-curve", this);
actions << actionRegistry->makeQAction("pathpoint-insert", this);
actions << actionRegistry->makeQAction("pathpoint-remove", this);
+ actions << actionRegistry->makeQAction("path-break-at-selection", this);
actions << actionRegistry->makeQAction("path-break-point", this);
actions << actionRegistry->makeQAction("path-break-segment", this);
+ actions << actionRegistry->makeQAction("path-break-selection", this);
actions << actionRegistry->makeQAction("pathpoint-join", this);
actions << actionRegistry->makeQAction("pathpoint-merge", this);
actions << actionRegistry->makeQAction("convert-to-path", this);
More information about the kimageshop
mailing list