Added ability to rotate pinned imaged (#2737)

This commit is contained in:
borgmanJeremy
2022-07-10 13:57:04 -05:00
committed by GitHub
parent e68183451e
commit 8f3bf194c4
2 changed files with 32 additions and 0 deletions

View File

@@ -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();

View File

@@ -35,6 +35,9 @@ private:
void pinchTriggered(QPinchGesture*);
void closePin();
void rotateLeft();
void rotateRight();
QPixmap m_pixmap;
QVBoxLayout* m_layout;
QLabel* m_label;
@@ -45,6 +48,7 @@ private:
bool m_expanding{ false };
qreal m_scaleFactor{ 1 };
unsigned int m_rotateFactor{ 0 };
qreal m_currentStepScaleFactor{ 1 };
bool m_sizeChanged{ false };