Skip to content

Commit

Permalink
Added ability to rotate pinned imaged
Browse files Browse the repository at this point in the history
  • Loading branch information
borgmanJeremy committed Jun 30, 2022
1 parent de5241d commit a932171
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/tools/pin/pinwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,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 @@ -236,6 +252,26 @@ void PinWidget::showContextMenu(const QPoint& pos)
&saveToFileAction, &QAction::triggered, this, &PinWidget::saveToFile);
contextMenu.addAction(&saveToFileAction);

<<<<<<< Updated upstream
=======
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();
contextMenu.addAction(&closePinAction);

>>>>>>> Stashed changes
contextMenu.exec(mapToGlobal(pos));
}

Expand Down
9 changes: 9 additions & 0 deletions src/tools/pin/pinwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ class PinWidget : public QWidget
bool gestureEvent(QGestureEvent* event);
bool scrollEvent(QWheelEvent* e);
void pinchTriggered(QPinchGesture*);
<<<<<<< Updated upstream
=======

void rotateLeft();
void rotateRight();

void closePin();
>>>>>>> Stashed changes

QPixmap m_pixmap;
QVBoxLayout* m_layout;
Expand All @@ -44,6 +52,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 a932171

Please sign in to comment.