From 6234e904fb195c60069fefb983178470faccada0 Mon Sep 17 00:00:00 2001 From: borgmanJeremy <46930769+borgmanJeremy@users.noreply.github.com> Date: Wed, 29 Jun 2022 20:17:33 -0500 Subject: [PATCH] Added ability to rotate pinned imaged --- src/tools/pin/pinwidget.cpp | 28 ++++++++++++++++++++++++++++ src/tools/pin/pinwidget.h | 4 ++++ 2 files changed, 32 insertions(+) diff --git a/src/tools/pin/pinwidget.cpp b/src/tools/pin/pinwidget.cpp index 160e900ae5..b173d4ff7f 100644 --- a/src/tools/pin/pinwidget.cpp +++ b/src/tools/pin/pinwidget.cpp @@ -173,6 +173,22 @@ bool PinWidget::gestureEvent(QGestureEvent* event) return true; } +void PinWidget::rotateLeft() +{ + m_sizeChanged = true; + + auto rotateTransform = QTransform().rotate(270); + m_pixmap = m_pixmap.transformed(rotateTransform); +} + +void PinWidget::rotateRight() +{ + m_sizeChanged = true; + + auto rotateTransform = QTransform().rotate(90); + m_pixmap = m_pixmap.transformed(rotateTransform); +} + bool PinWidget::event(QEvent* event) { if (event->type() == QEvent::Gesture) { @@ -240,6 +256,18 @@ void PinWidget::showContextMenu(const QPoint& pos) &saveToFileAction, &QAction::triggered, this, &PinWidget::saveToFile); contextMenu.addAction(&saveToFileAction); + contextMenu.addSeparator(); + + QAction rotateRightAction(tr("Rotate Right"), this); + connect( + &rotateRightAction, &QAction::triggered, this, &PinWidget::rotateRight); + contextMenu.addAction(&rotateRightAction); + + QAction rotateLeftAction(tr("Rotate Left"), this); + connect( + &rotateLeftAction, &QAction::triggered, this, &PinWidget::rotateLeft); + contextMenu.addAction(&rotateLeftAction); + QAction closePinAction(tr("Close"), this); connect(&closePinAction, &QAction::triggered, this, &PinWidget::closePin); contextMenu.addSeparator(); diff --git a/src/tools/pin/pinwidget.h b/src/tools/pin/pinwidget.h index 4a824a7a14..9bdff1fdea 100644 --- a/src/tools/pin/pinwidget.h +++ b/src/tools/pin/pinwidget.h @@ -35,6 +35,9 @@ class PinWidget : public QWidget void pinchTriggered(QPinchGesture*); void closePin(); + void rotateLeft(); + void rotateRight(); + QPixmap m_pixmap; QVBoxLayout* m_layout; QLabel* m_label; @@ -45,6 +48,7 @@ class PinWidget : public QWidget bool m_expanding{ false }; qreal m_scaleFactor{ 1 }; + unsigned int m_rotateFactor{ 0 }; qreal m_currentStepScaleFactor{ 1 }; bool m_sizeChanged{ false };