Skip to content

armgit / krita

Public Imported from GitHub
0

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++

Remove option for touch-zoom/rotating around the first finger

Dmitry Kazakovbabae9bd8447
diff --git a/libs/ui/input/KisCanvasNavigationActionStrategyTouch.cpp b/libs/ui/input/KisCanvasNavigationActionStrategyTouch.cpp
index 9f04596612..fdc5f3f108 100644
--- a/libs/ui/input/KisCanvasNavigationActionStrategyTouch.cpp
+++ b/libs/ui/input/KisCanvasNavigationActionStrategyTouch.cpp
@@ -28,15 +28,20 @@ bool testIfPointPressed(const TouchPoint &point) {
return KisTouchShortcut::pressedOnlyTouchStates().testFlag(state);
}
-template <typename PointFunctor>
-QPointF calcAverageForEachPressedPoint(const QTouchEvent *tevent, PointFunctor pointFunctor)
+QPointF calculateBasePointFromEvent(const QTouchEvent *tevent)
{
QPointF result;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
auto points = tevent->touchPoints();
+ auto pointFunctor = [] (const auto &point) {
+ return point.pos();
+ };
#else
auto points = tevent->points();
+ auto pointFunctor = [] (const auto &point) {
+ return point.position();
+ };
#endif
auto [sum, count] =
@@ -60,52 +65,6 @@ QPointF calcAverageForEachPressedPoint(const QTouchEvent *tevent, PointFunctor p
return result;
}
-template <typename PointFunctor>
-QPointF calcForTheFirstPressedPoint(const QTouchEvent *tevent, PointFunctor pointFunctor)
-{
- QPointF result;
-
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- auto points = tevent->touchPoints();
-#else
- auto points = tevent->points();
-#endif
-
- auto it = std::find_if(points.begin(), points.end(), &testIfPointPressed);
- if (it != points.end()) {
- result = pointFunctor(*it);
- }
-
- return result;
-}
-
-QPointF calculateBasePointFromEvent(const QTouchEvent *tevent, bool aroundTheFirstFinger)
-{
- auto functor = [] (const auto &point) {
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- return point.pos();
-#else
- return point.position();
-#endif
- };
-
- if (aroundTheFirstFinger) {
- return calcForTheFirstPressedPoint(tevent, functor);
- } else {
- return calcAverageForEachPressedPoint(tevent, functor);
- }
-}
-
-bool effectiveTransformAroundTheFirstFinger(KisCanvasNavigationActionStrategy::Flags flags) {
- using Flag = KisCanvasNavigationActionStrategy::Flag;
-
- // for pan-mode we force the average calculation mode, for all
- // the rest the value from the config
- return !(flags & (Flag::ZoomEnabled | Flag::RotationEnabled))
- ? false
- : KisConfig(true).readEntry("touchGestureAroundTheFirstFinger", true);
-}
-
} // namespace
KisCanvasNavigationActionStrategyTouch::KisCanvasNavigationActionStrategyTouch(Flags flags,
@@ -113,10 +72,9 @@ KisCanvasNavigationActionStrategyTouch::KisCanvasNavigationActionStrategyTouch(F
KisCanvas2 *canvas)
: KisCanvasNavigationActionStrategy(flags)
, m_canvas(canvas)
- , m_transformAroundTheFirstFinger(effectiveTransformAroundTheFirstFinger(flags))
{
m_actionStillPoint = canvas->coordinatesConverter()->makeWidgetStillPoint(
- calculateBasePointFromEvent(startEvent, m_transformAroundTheFirstFinger));
+ calculateBasePointFromEvent(startEvent));
m_nonRoundedZoom = canvas->viewConverter()->zoom();
}
@@ -175,7 +133,7 @@ void KisCanvasNavigationActionStrategyTouch::inputEvent(QEvent* event)
bool needsSeparatePanAction = true;
if (flags().testFlag(PanEnabled)) {
- adjustedStillPoint.second = calculateBasePointFromEvent(tevent, m_transformAroundTheFirstFinger);
+ adjustedStillPoint.second = calculateBasePointFromEvent(tevent);
}
if (flags().testFlag(ZoomEnabled)) {
diff --git a/libs/ui/input/KisCanvasNavigationActionStrategyTouch.h b/libs/ui/input/KisCanvasNavigationActionStrategyTouch.h
index a139ebdb27..1efb0f27f9 100644
--- a/libs/ui/input/KisCanvasNavigationActionStrategyTouch.h
+++ b/libs/ui/input/KisCanvasNavigationActionStrategyTouch.h
@@ -33,8 +33,6 @@ private:
SnappedRotationData m_rotationData;
qreal m_lastDistance {0.0};
-
- const bool m_transformAroundTheFirstFinger = {false};
};
diff --git a/libs/ui/input/kis_zoom_action.cpp b/libs/ui/input/kis_zoom_action.cpp
index 865f70252d..3963e1b8e2 100644
--- a/libs/ui/input/kis_zoom_action.cpp
+++ b/libs/ui/input/kis_zoom_action.cpp
@@ -30,8 +30,6 @@ class KisZoomAction::Private
public:
Private(KisZoomAction *qq) : q(qq) {}
- QPointF centerPoint(QTouchEvent* event);
-
KisZoomAction *q {nullptr};
// Coverity requires sane defaults for all variables (CID 36380)
Shortcuts mode {ZoomModeShortcut};
@@ -44,25 +42,6 @@ public:
std::unique_ptr<KisCanvasNavigationActionStrategy> actionStrategy;
};
-QPointF KisZoomAction::Private::centerPoint(QTouchEvent* event)
-{
- QPointF result;
- int count = 0;
-
- Q_FOREACH (QTouchEvent::TouchPoint point, event->touchPoints()) {
- if (point.state() != Qt::TouchPointReleased) {
- result += point.pos();
- count++;
- }
- }
-
- if (count > 0) {
- return result / count;
- } else {
- return QPointF();
- }
-}
-
KisZoomAction::KisZoomAction()
: KisAbstractInputAction("Zoom Canvas")
, d(new Private(this))