feat: basic image flip support
This commit is contained in:
		@ -23,6 +23,7 @@ void ActionManager::setupAction(MainWindow *mainWindow)
 | 
			
		||||
{
 | 
			
		||||
    CREATE_NEW_ACTION(mainWindow, actionZoomIn);
 | 
			
		||||
    CREATE_NEW_ACTION(mainWindow, actionZoomOut);
 | 
			
		||||
    CREATE_NEW_ACTION(mainWindow, actionHorizontalFlip);
 | 
			
		||||
    CREATE_NEW_ACTION(mainWindow, actionCopyPixmap);
 | 
			
		||||
    CREATE_NEW_ACTION(mainWindow, actionCopyFilePath);
 | 
			
		||||
    CREATE_NEW_ACTION(mainWindow, actionPaste);
 | 
			
		||||
@ -45,6 +46,7 @@ void ActionManager::retranslateUi(MainWindow *mainWindow)
 | 
			
		||||
 | 
			
		||||
    actionZoomIn->setText(QCoreApplication::translate("MainWindow", "Zoom in", nullptr));
 | 
			
		||||
    actionZoomOut->setText(QCoreApplication::translate("MainWindow", "Zoom out", nullptr));
 | 
			
		||||
    actionHorizontalFlip->setText(QCoreApplication::translate("MainWindow", "Horizontal flip", nullptr));
 | 
			
		||||
    actionCopyPixmap->setText(QCoreApplication::translate("MainWindow", "Copy P&ixmap", nullptr));
 | 
			
		||||
    actionCopyFilePath->setText(QCoreApplication::translate("MainWindow", "Copy &File Path", nullptr));
 | 
			
		||||
    actionPaste->setText(QCoreApplication::translate("MainWindow", "&Paste", nullptr));
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,7 @@ public:
 | 
			
		||||
public:
 | 
			
		||||
    QAction *actionZoomIn;
 | 
			
		||||
    QAction *actionZoomOut;
 | 
			
		||||
    QAction *actionHorizontalFlip;
 | 
			
		||||
    QAction *actionCopyPixmap;
 | 
			
		||||
    QAction *actionCopyFilePath;
 | 
			
		||||
    QAction *actionPaste;
 | 
			
		||||
 | 
			
		||||
@ -134,6 +134,17 @@ void GraphicsView::zoomView(qreal scaleFactor)
 | 
			
		||||
    emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), m_rotateAngle);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GraphicsView::flipView(bool horizontal)
 | 
			
		||||
{
 | 
			
		||||
    if (horizontal) {
 | 
			
		||||
        scale(-1, 1);
 | 
			
		||||
    } else {
 | 
			
		||||
        scale(1, -1);
 | 
			
		||||
    }
 | 
			
		||||
    // I guess we don't need to check if we need to trigger navigator view here
 | 
			
		||||
    // since fliping doesn't affact the image rectangle size.
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GraphicsView::resetScale()
 | 
			
		||||
{
 | 
			
		||||
    resetWithScaleAndRotate(1, m_rotateAngle);
 | 
			
		||||
 | 
			
		||||
@ -26,6 +26,7 @@ public:
 | 
			
		||||
 | 
			
		||||
    void resetTransform();
 | 
			
		||||
    void zoomView(qreal scaleFactor);
 | 
			
		||||
    void flipView(bool horizontal = true);
 | 
			
		||||
    void resetScale();
 | 
			
		||||
    void rotateView(qreal rotateAngel);
 | 
			
		||||
    void fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode = Qt::IgnoreAspectRatio);
 | 
			
		||||
 | 
			
		||||
@ -420,6 +420,10 @@ void MainWindow::contextMenuEvent(QContextMenuEvent *event)
 | 
			
		||||
        menu->addAction(paste);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    menu->addSeparator();
 | 
			
		||||
 | 
			
		||||
    menu->addAction(m_am->actionHorizontalFlip);
 | 
			
		||||
 | 
			
		||||
    menu->addSeparator();
 | 
			
		||||
    menu->addAction(stayOnTopMode);
 | 
			
		||||
    menu->addAction(protectedMode);
 | 
			
		||||
@ -554,6 +558,11 @@ void MainWindow::on_actionZoomOut_triggered()
 | 
			
		||||
    m_graphicsView->zoomView(0.8);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::on_actionHorizontalFlip_triggered()
 | 
			
		||||
{
 | 
			
		||||
    m_graphicsView->flipView();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::on_actionCopyPixmap_triggered()
 | 
			
		||||
{
 | 
			
		||||
    QClipboard *cb = QApplication::clipboard();
 | 
			
		||||
 | 
			
		||||
@ -65,6 +65,7 @@ protected:
 | 
			
		||||
private slots:
 | 
			
		||||
    void on_actionZoomIn_triggered();
 | 
			
		||||
    void on_actionZoomOut_triggered();
 | 
			
		||||
    void on_actionHorizontalFlip_triggered();
 | 
			
		||||
    void on_actionCopyPixmap_triggered();
 | 
			
		||||
    void on_actionCopyFilePath_triggered();
 | 
			
		||||
    void on_actionPaste_triggered();
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user