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++
Don't move line origin if Alt is held at start
Carsten Hartenfels9c8d312a0957
diff --git a/plugins/tools/basictools/kis_tool_line.cc b/plugins/tools/basictools/kis_tool_line.ccindex a018cdf88a..cc4485b13b 100644--- a/plugins/tools/basictools/kis_tool_line.cc+++ b/plugins/tools/basictools/kis_tool_line.cc@@ -233,6 +233,7 @@ void KisToolLine::beginPrimaryAction(KoPointerEvent *event)m_originalStartPoint = m_startPoint;m_strokeIsRunning = true;+ m_altInitiallyHeld = event->modifiers().testFlag(Qt::AltModifier);showSize();}@@ -251,18 +252,36 @@ void KisToolLine::continuePrimaryAction(KoPointerEvent *event)CHECK_MODE_SANITY_OR_RETURN(KisTool::PAINT_MODE);if (!m_strokeIsRunning) return;+ // If the user was holding Alt at the start of the line, we don't want to+ // move the origin around because moving the origin of a zero-length line+ // is silly and this interferes with users coming from PS binding Alt to+ // the quick switch line tool.+ Qt::KeyboardModifiers effectiveModifiers = event->modifiers();+ if (m_altInitiallyHeld){+ if (effectiveModifiers.testFlag(Qt::AltModifier)) {+ // Remove the modifier if it was held at the beginning. The checks+ // in the subsequent code use equality instead of testing the flag,+ // so this retains the expected behavior without much rejigging.+ effectiveModifiers.setFlag(Qt::AltModifier, false);+ } else {+ // User lifted the Alt key, we'll let them re-press it from this+ // point on to move the origin after all.+ m_altInitiallyHeld = false;+ }+ }+// First ensure the old guideline is deletedupdateGuideline();QPointF pos = convertToPixelCoordAndSnap(event);- if (event->modifiers() == Qt::AltModifier) {+ if (effectiveModifiers == Qt::AltModifier) {QPointF trans = pos - m_endPoint;m_helper->translatePoints(trans);m_startPoint += trans;m_endPoint += trans;m_originalStartPoint += trans; // original start point is only original in terms of snapping to assistants- } else if (event->modifiers() == Qt::ShiftModifier) {+ } else if (effectiveModifiers == Qt::ShiftModifier) {pos = straightLine(pos);m_helper->addPoint(event, pos);} else {@@ -288,7 +307,7 @@ void KisToolLine::continuePrimaryAction(KoPointerEvent *event)}}- if(event->modifiers() == Qt::AltModifier) {+ if(effectiveModifiers == Qt::AltModifier) {KisCanvas2 *kisCanvas =dynamic_cast<KisCanvas2*>(canvas());KIS_ASSERT(kisCanvas);kisCanvas->viewManager()->showFloatingMessage(i18n("X: %1 px\nY: %2 px", QString::number(m_startPoint.x(), 'f',1)diff --git a/plugins/tools/basictools/kis_tool_line.h b/plugins/tools/basictools/kis_tool_line.hindex f96966e01e..7c07f820bf 100644--- a/plugins/tools/basictools/kis_tool_line.h+++ b/plugins/tools/basictools/kis_tool_line.h@@ -88,6 +88,7 @@ private:QPointF m_lastUpdatedPoint;bool m_strokeIsRunning {false};+ bool m_altInitiallyHeld {false};QCheckBox *m_chkUseSensors {nullptr};