From 64ebd79b4a5df495481facedd2a18a0e7216cf28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferenc=20G=C3=A9czi?= Date: Sat, 23 Nov 2024 00:00:00 +0000 Subject: [PATCH] [qt][linux] Handle touchpad rotation gesture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ferenc Géczi --- qt/draw_widget.cpp | 12 ++++++++++++ qt/draw_widget.hpp | 3 +++ qt/qt_common/map_widget.hpp | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index 98f23dc2dd..239d8c1a81 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -253,6 +253,12 @@ bool DrawWidget::event(QEvent * event) m_framework.Scale(exp(factor), m2::PointD(L2D(pos.x()), L2D(pos.y())), false); return true; } + if (qNativeGestureEvent->gestureType() == Qt::RotateNativeGesture) + { + m_currentRotation += qNativeGestureEvent->value(); + m_framework.Rotate(m_currentRotation, false); + return true; + } } // Everything else return QOpenGLWidget::event(event); @@ -775,6 +781,12 @@ void DrawWidget::SetRuler(bool enabled) m_ruler.SetActive(enabled); } +void DrawWidget::OnViewportChanged(ScreenBase const & screen) +{ + MapWidget::OnViewportChanged(screen); + m_currentRotation = static_cast(screen.GetAngle()); +} + // static void DrawWidget::RefreshDrawingRules() { diff --git a/qt/draw_widget.hpp b/qt/draw_widget.hpp index 335611cd4c..9382c832d6 100644 --- a/qt/draw_widget.hpp +++ b/qt/draw_widget.hpp @@ -87,6 +87,8 @@ protected: void keyPressEvent(QKeyEvent * e) override; void keyReleaseEvent(QKeyEvent * e) override; + void OnViewportChanged(ScreenBase const & screen) override; + private: void SubmitFakeLocationPoint(m2::PointD const & pt); void SubmitRulerPoint(m2::PointD const & pt); @@ -124,5 +126,6 @@ private: std::unique_ptr m_screenshoter; Ruler m_ruler; RoutingTurnsVisualizer m_turnsVisualizer; + qreal m_currentRotation = 0.0; }; } // namespace qt diff --git a/qt/qt_common/map_widget.hpp b/qt/qt_common/map_widget.hpp index 304a51aea0..5149fe4523 100644 --- a/qt/qt_common/map_widget.hpp +++ b/qt/qt_common/map_widget.hpp @@ -82,7 +82,7 @@ protected: void Build(); void ShowInfoPopup(QMouseEvent * e, m2::PointD const & pt); - void OnViewportChanged(ScreenBase const & screen); + virtual void OnViewportChanged(ScreenBase const & screen); // QOpenGLWidget overrides: void initializeGL() override; -- 2.45.3