Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Text: Add shift + click selection in addition to drag selection.
Wolthera van Hövell tot Westerflierda7e8ca75994
diff --git a/plugins/tools/svgtexttool/SvgSelectTextStrategy.cpp b/plugins/tools/svgtexttool/SvgSelectTextStrategy.cppindex 007cea3347..8c2bb3209c 100644--- a/plugins/tools/svgtexttool/SvgSelectTextStrategy.cpp+++ b/plugins/tools/svgtexttool/SvgSelectTextStrategy.cpp@@ -7,20 +7,22 @@#include "SvgTextCursor.h"#include <QDebug>-SvgSelectTextStrategy::SvgSelectTextStrategy(KoToolBase *tool, SvgTextCursor *cursor, const QPointF &clicked)+SvgSelectTextStrategy::SvgSelectTextStrategy(KoToolBase *tool, SvgTextCursor *cursor, const QPointF &clicked, Qt::KeyboardModifiers modifiers): KoInteractionStrategy(tool), m_cursor(cursor), m_dragStart(clicked){m_dragEnd = m_dragStart;- m_cursor->setPosToPoint(m_dragStart, true);+ m_cursor->setPosToPoint(m_dragStart, !(modifiers & Qt::ShiftModifier));}void SvgSelectTextStrategy::handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers){Q_UNUSED(modifiers)m_dragEnd = mouseLocation;- m_cursor->setPosToPoint(m_dragStart, true);+ if (!(modifiers & Qt::ShiftModifier)) {+ m_cursor->setPosToPoint(m_dragStart, true);+ }m_cursor->setPosToPoint(m_dragEnd, false);}@@ -37,6 +39,9 @@ void SvgSelectTextStrategy::cancelInteraction()void SvgSelectTextStrategy::finishInteraction(Qt::KeyboardModifiers modifiers){Q_UNUSED(modifiers)- m_cursor->setPosToPoint(m_dragStart, true);+ if (!(modifiers & Qt::ShiftModifier)) {+ m_cursor->setPosToPoint(m_dragStart, true);+ }m_cursor->setPosToPoint(m_dragEnd, false);+}diff --git a/plugins/tools/svgtexttool/SvgSelectTextStrategy.h b/plugins/tools/svgtexttool/SvgSelectTextStrategy.hindex ad246b1548..45f42a9244 100644--- a/plugins/tools/svgtexttool/SvgSelectTextStrategy.h+++ b/plugins/tools/svgtexttool/SvgSelectTextStrategy.h@@ -14,7 +14,7 @@ class SvgTextCursor;class SvgSelectTextStrategy : public KoInteractionStrategy{public:- SvgSelectTextStrategy(KoToolBase *tool, SvgTextCursor *cursor, const QPointF &clicked);+ SvgSelectTextStrategy(KoToolBase *tool, SvgTextCursor *cursor, const QPointF &clicked, Qt::KeyboardModifiers modifiers);~SvgSelectTextStrategy() override = default;void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override;diff --git a/plugins/tools/svgtexttool/SvgTextTool.cpp b/plugins/tools/svgtexttool/SvgTextTool.cppindex e70ffca855..f433113df4 100644--- a/plugins/tools/svgtexttool/SvgTextTool.cpp+++ b/plugins/tools/svgtexttool/SvgTextTool.cpp@@ -829,7 +829,7 @@ void SvgTextTool::mousePressEvent(KoPointerEvent *event)canvas()->shapeManager()->selection()->select(hoveredShape);m_hoveredShapeHighlightRect = QPainterPath();}- m_interactionStrategy.reset(new SvgSelectTextStrategy(this, &m_textCursor, event->point));+ m_interactionStrategy.reset(new SvgSelectTextStrategy(this, &m_textCursor, event->point, event->modifiers()));m_dragging = DragMode::Select;event->accept();} else if (hoveredFlowShape) {@@ -839,7 +839,7 @@ void SvgTextTool::mousePressEvent(KoPointerEvent *event)event->accept();} else if (crossLayerPossible) {if (KisToolUtils::selectShapeCrossLayer(canvas(), event->point, KoSvgTextShape_SHAPEID)) {- m_interactionStrategy.reset(new SvgSelectTextStrategy(this, &m_textCursor, event->point));+ m_interactionStrategy.reset(new SvgSelectTextStrategy(this, &m_textCursor, event->point, event->modifiers()));m_dragging = DragMode::Select;m_hoveredShapeHighlightRect = QPainterPath();} else {