feat: new action for fit long image
This commit is contained in:
@ -58,6 +58,7 @@ void ActionManager::setupAction(MainWindow *mainWindow)
|
|||||||
CREATE_NEW_ACTION(mainWindow, actionHorizontalFlip);
|
CREATE_NEW_ACTION(mainWindow, actionHorizontalFlip);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionFitInView);
|
CREATE_NEW_ACTION(mainWindow, actionFitInView);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionFitByWidth);
|
CREATE_NEW_ACTION(mainWindow, actionFitByWidth);
|
||||||
|
CREATE_NEW_ACTION(mainWindow, actionFitLongImage);
|
||||||
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionCopyPixmap, edit-copy);
|
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionCopyPixmap, edit-copy);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionCopyFilePath);
|
CREATE_NEW_ACTION(mainWindow, actionCopyFilePath);
|
||||||
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionPaste, edit-paste);
|
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionPaste, edit-paste);
|
||||||
@ -101,6 +102,7 @@ void ActionManager::retranslateUi(MainWindow *mainWindow)
|
|||||||
actionHorizontalFlip->setText(QCoreApplication::translate("MainWindow", "Flip &Horizontally", nullptr));
|
actionHorizontalFlip->setText(QCoreApplication::translate("MainWindow", "Flip &Horizontally", nullptr));
|
||||||
actionFitInView->setText(QCoreApplication::translate("MainWindow", "Fit to view", nullptr));
|
actionFitInView->setText(QCoreApplication::translate("MainWindow", "Fit to view", nullptr));
|
||||||
actionFitByWidth->setText(QCoreApplication::translate("MainWindow", "Fit to width", nullptr));
|
actionFitByWidth->setText(QCoreApplication::translate("MainWindow", "Fit to width", nullptr));
|
||||||
|
actionFitLongImage->setText(QCoreApplication::translate("MainWindow", "Fit long image", nullptr));
|
||||||
actionCopyPixmap->setText(QCoreApplication::translate("MainWindow", "Copy P&ixmap", nullptr));
|
actionCopyPixmap->setText(QCoreApplication::translate("MainWindow", "Copy P&ixmap", nullptr));
|
||||||
actionCopyFilePath->setText(QCoreApplication::translate("MainWindow", "Copy &File Path", nullptr));
|
actionCopyFilePath->setText(QCoreApplication::translate("MainWindow", "Copy &File Path", nullptr));
|
||||||
actionPaste->setText(QCoreApplication::translate("MainWindow", "&Paste", nullptr));
|
actionPaste->setText(QCoreApplication::translate("MainWindow", "&Paste", nullptr));
|
||||||
|
@ -41,6 +41,7 @@ public:
|
|||||||
QAction *actionHorizontalFlip;
|
QAction *actionHorizontalFlip;
|
||||||
QAction *actionFitInView;
|
QAction *actionFitInView;
|
||||||
QAction *actionFitByWidth;
|
QAction *actionFitByWidth;
|
||||||
|
QAction *actionFitLongImage;
|
||||||
QAction *actionCopyPixmap;
|
QAction *actionCopyPixmap;
|
||||||
QAction *actionCopyFilePath;
|
QAction *actionCopyFilePath;
|
||||||
QAction *actionPaste;
|
QAction *actionPaste;
|
||||||
|
@ -282,19 +282,12 @@ bool GraphicsView::isLongImage() const
|
|||||||
|
|
||||||
void GraphicsView::fitLongImage()
|
void GraphicsView::fitLongImage()
|
||||||
{
|
{
|
||||||
// Determine image orientation based on current transform
|
|
||||||
QRectF transformedRect = transform().mapRect(sceneRect());
|
QRectF transformedRect = transform().mapRect(sceneRect());
|
||||||
qreal aspectRatio = transformedRect.width() / transformedRect.height();
|
|
||||||
bool isTallImage = aspectRatio < 0.4;
|
|
||||||
bool isWideImage = aspectRatio > 2.5;
|
|
||||||
|
|
||||||
// Use fitByOrientation with the migrated logic
|
if (transformedRect.width() < transformedRect.height()) {
|
||||||
if (isTallImage) {
|
fitByOrientation(Qt::Horizontal, true);
|
||||||
// Tall image (height >> width): fit by width
|
} else {
|
||||||
fitByOrientation(Qt::Horizontal, true); // scaleDownOnly = true
|
fitByOrientation(Qt::Vertical, true);
|
||||||
} else if (isWideImage) {
|
|
||||||
// Wide image (width >> height): fit by height
|
|
||||||
fitByOrientation(Qt::Vertical, true); // scaleDownOnly = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -737,6 +737,12 @@ void MainWindow::on_actionFitByWidth_triggered()
|
|||||||
m_graphicsView->fitByOrientation();
|
m_graphicsView->fitByOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionFitLongImage_triggered()
|
||||||
|
{
|
||||||
|
m_graphicsView->setLongImageMode(true);
|
||||||
|
m_graphicsView->fitLongImage();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionCopyPixmap_triggered()
|
void MainWindow::on_actionCopyPixmap_triggered()
|
||||||
{
|
{
|
||||||
QClipboard *cb = QApplication::clipboard();
|
QClipboard *cb = QApplication::clipboard();
|
||||||
|
@ -93,6 +93,7 @@ private slots:
|
|||||||
void on_actionHorizontalFlip_triggered();
|
void on_actionHorizontalFlip_triggered();
|
||||||
void on_actionFitInView_triggered();
|
void on_actionFitInView_triggered();
|
||||||
void on_actionFitByWidth_triggered();
|
void on_actionFitByWidth_triggered();
|
||||||
|
void on_actionFitLongImage_triggered();
|
||||||
void on_actionCopyPixmap_triggered();
|
void on_actionCopyPixmap_triggered();
|
||||||
void on_actionCopyFilePath_triggered();
|
void on_actionCopyFilePath_triggered();
|
||||||
void on_actionPaste_triggered();
|
void on_actionPaste_triggered();
|
||||||
|
Reference in New Issue
Block a user