Skip to content

Commit

Permalink
Added ability to rotate pinned imaged (#2737)
Browse files Browse the repository at this point in the history
  • Loading branch information
borgmanJeremy authored Jul 10, 2022
1 parent e681834 commit 8f3bf19
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/tools/pin/pinwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions src/tools/pin/pinwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 };

Expand Down

0 comments on commit 8f3bf19

Please sign in to comment.