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

Fix constness in KisTouchShortcut

Dmitry Kazakov6cfe81cb52f0
diff --git a/libs/ui/input/kis_touch_shortcut.cpp b/libs/ui/input/kis_touch_shortcut.cpp
index b83bff58d9..1bd20fb4b2 100644
--- a/libs/ui/input/kis_touch_shortcut.cpp
+++ b/libs/ui/input/kis_touch_shortcut.cpp
@@ -92,7 +92,7 @@ bool KisTouchShortcut::isAvailable(KisInputActionGroupsMask mask) const
return KisAbstractShortcut::isAvailable(mask);
}
-bool KisTouchShortcut::matchTapType(QTouchEvent *event, Qt::TouchPointStates allowedStates)
+bool KisTouchShortcut::matchTapType(const QTouchEvent *event, Qt::TouchPointStates allowedStates)
{
return matchTouchPoint(event, allowedStates)
#ifndef Q_OS_MACOS
@@ -101,7 +101,7 @@ bool KisTouchShortcut::matchTapType(QTouchEvent *event, Qt::TouchPointStates all
;
}
-bool KisTouchShortcut::matchDragType(QTouchEvent *event, Qt::TouchPointStates allowedStates)
+bool KisTouchShortcut::matchDragType(const QTouchEvent *event, Qt::TouchPointStates allowedStates)
{
return touchDragDistance(event, allowedStates) > d->minDragThreshold &&
matchTouchPoint(event, allowedStates)
@@ -111,12 +111,13 @@ bool KisTouchShortcut::matchDragType(QTouchEvent *event, Qt::TouchPointStates al
;
}
-bool KisTouchShortcut::matchHoldType(QTouchEvent *event, Qt::TouchPointStates allowedStates)
+bool KisTouchShortcut::matchHoldType(const QTouchEvent *event, Qt::TouchPointStates allowedStates)
{
return isHoldType() && matchTouchPoint(event, allowedStates);
}
-int KisTouchShortcut::countTouchPoints(QTouchEvent *event, Qt::TouchPointStates allowedStates)
+// TODO: const
+int KisTouchShortcut::countTouchPoints(const QTouchEvent *event, Qt::TouchPointStates allowedStates)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
auto points = event->touchPoints();
@@ -135,7 +136,7 @@ int KisTouchShortcut::countTouchPoints(QTouchEvent *event, Qt::TouchPointStates
return count;
}
-qreal KisTouchShortcut::touchDragDistance(QTouchEvent *event, Qt::TouchPointStates allowedStates)
+qreal KisTouchShortcut::touchDragDistance(const QTouchEvent *event, Qt::TouchPointStates allowedStates)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
auto points = event->touchPoints();
@@ -156,7 +157,7 @@ qreal KisTouchShortcut::touchDragDistance(QTouchEvent *event, Qt::TouchPointStat
}));
}
-bool KisTouchShortcut::matchTouchPoint(QTouchEvent *event, Qt::TouchPointStates allowedStates)
+bool KisTouchShortcut::matchTouchPoint(const QTouchEvent *event, Qt::TouchPointStates allowedStates)
{
const int numStillActivePoints = countTouchPoints(event, allowedStates);
diff --git a/libs/ui/input/kis_touch_shortcut.h b/libs/ui/input/kis_touch_shortcut.h
index 04994e39e7..78fd76717e 100644
--- a/libs/ui/input/kis_touch_shortcut.h
+++ b/libs/ui/input/kis_touch_shortcut.h
@@ -35,10 +35,10 @@ class KRITAUI_EXPORT KisTouchShortcut : public KisAbstractShortcut
void setIsTouchPainting(bool value);
- bool matchTapType(QTouchEvent *event, Qt::TouchPointStates allowedStates);
- bool matchDragType(QTouchEvent *event, Qt::TouchPointStates allowedStates);
- bool matchHoldType(QTouchEvent *event, Qt::TouchPointStates allowedStates);
- bool matchTouchPoint(QTouchEvent *event, Qt::TouchPointStates allowedStates);
+ bool matchTapType(const QTouchEvent *event, Qt::TouchPointStates allowedStates);
+ bool matchDragType(const QTouchEvent *event, Qt::TouchPointStates allowedStates);
+ bool matchHoldType(const QTouchEvent *event, Qt::TouchPointStates allowedStates);
+ bool matchTouchPoint(const QTouchEvent *event, Qt::TouchPointStates allowedStates);
qreal minDragThreshold() const;
void setMinDragThreshold(qreal value);
@@ -51,9 +51,9 @@ class KRITAUI_EXPORT KisTouchShortcut : public KisAbstractShortcut
return Qt::TouchPointStationary | Qt::TouchPointPressed | Qt::TouchPointMoved;
}
- static int countTouchPoints(QTouchEvent *event, Qt::TouchPointStates allowedStates);
+ static int countTouchPoints(const QTouchEvent *event, Qt::TouchPointStates allowedStates);
- static qreal touchDragDistance(QTouchEvent *event, Qt::TouchPointStates allowedStates);
+ static qreal touchDragDistance(const QTouchEvent *event, Qt::TouchPointStates allowedStates);
private:
class Private;