revert: remove auto long image mode
- remove auto long image mode. - there is no "auto" requirement for this. - user can utilize fit by height/width to achieve the same goal by manually click them. - some optimization code about graphic view are preserved.
This commit is contained in:
@@ -58,7 +58,6 @@ 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);
|
||||||
@@ -102,7 +101,6 @@ 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,7 +41,6 @@ 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;
|
||||||
|
|||||||
@@ -138,7 +138,6 @@ void GraphicsView::resetTransform()
|
|||||||
void GraphicsView::zoomView(qreal scaleFactor)
|
void GraphicsView::zoomView(qreal scaleFactor)
|
||||||
{
|
{
|
||||||
m_enableFitInView = false;
|
m_enableFitInView = false;
|
||||||
m_longImageMode = false;
|
|
||||||
scale(scaleFactor, scaleFactor);
|
scale(scaleFactor, scaleFactor);
|
||||||
applyTransformationModeByScaleFactor();
|
applyTransformationModeByScaleFactor();
|
||||||
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
||||||
@@ -280,31 +279,6 @@ void GraphicsView::fitByOrientation(Qt::Orientation ori, bool scaleDownOnly)
|
|||||||
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GraphicsView::isLongImage() const
|
|
||||||
{
|
|
||||||
// Get the transformed image size (considering rotation and other transforms)
|
|
||||||
QRectF transformedRect = transform().mapRect(sceneRect());
|
|
||||||
QSizeF imageSize = transformedRect.size();
|
|
||||||
|
|
||||||
if (imageSize.isEmpty()) return false;
|
|
||||||
|
|
||||||
qreal aspectRatio = imageSize.width() / imageSize.height();
|
|
||||||
|
|
||||||
// Check if aspect ratio exceeds 5:2 (wide) or 2:5 (tall)
|
|
||||||
return aspectRatio > 2.5 || aspectRatio < 0.4;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GraphicsView::fitLongImage()
|
|
||||||
{
|
|
||||||
QRectF transformedRect = transform().mapRect(sceneRect());
|
|
||||||
|
|
||||||
if (transformedRect.width() < transformedRect.height()) {
|
|
||||||
fitByOrientation(Qt::Horizontal, true);
|
|
||||||
} else {
|
|
||||||
fitByOrientation(Qt::Vertical, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GraphicsView::displayScene()
|
void GraphicsView::displayScene()
|
||||||
{
|
{
|
||||||
if (shouldAvoidTransform()) {
|
if (shouldAvoidTransform()) {
|
||||||
@@ -312,14 +286,6 @@ void GraphicsView::displayScene()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if should apply long image mode
|
|
||||||
if (Settings::instance()->autoLongImageMode() && isLongImage()) {
|
|
||||||
m_longImageMode = true;
|
|
||||||
m_firstUserMediaLoaded = true;
|
|
||||||
if (isSceneBiggerThanView()) fitLongImage();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSceneBiggerThanView()) {
|
if (isSceneBiggerThanView()) {
|
||||||
// Do fit-in-view
|
// Do fit-in-view
|
||||||
fitInView(sceneRect(), Qt::KeepAspectRatio);
|
fitInView(sceneRect(), Qt::KeepAspectRatio);
|
||||||
@@ -330,7 +296,6 @@ void GraphicsView::displayScene()
|
|||||||
emit navigatorViewRequired(false, transform());
|
emit navigatorViewRequired(false, transform());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_longImageMode = false;
|
|
||||||
m_enableFitInView = true;
|
m_enableFitInView = true;
|
||||||
m_firstUserMediaLoaded = true;
|
m_firstUserMediaLoaded = true;
|
||||||
}
|
}
|
||||||
@@ -350,11 +315,6 @@ void GraphicsView::setEnableAutoFitInView(bool enable)
|
|||||||
m_enableFitInView = enable;
|
m_enableFitInView = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsView::setLongImageMode(bool enable)
|
|
||||||
{
|
|
||||||
m_longImageMode = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GraphicsView::avoidResetTransform() const
|
bool GraphicsView::avoidResetTransform() const
|
||||||
{
|
{
|
||||||
return m_avoidResetTransform;
|
return m_avoidResetTransform;
|
||||||
@@ -427,12 +387,7 @@ void GraphicsView::wheelEvent(QWheelEvent *event)
|
|||||||
|
|
||||||
void GraphicsView::resizeEvent(QResizeEvent *event)
|
void GraphicsView::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
if (m_longImageMode) {
|
if (m_enableFitInView) {
|
||||||
// In long image mode, reapply long image logic on resize
|
|
||||||
// We directly apply the long image mode logic without rechecking
|
|
||||||
// if we should enter long image mode, as the mode is already active
|
|
||||||
fitLongImage();
|
|
||||||
} else if (m_enableFitInView) {
|
|
||||||
bool originalSizeSmallerThanWindow = isThingSmallerThanWindowWith(resetScale(transform()));
|
bool originalSizeSmallerThanWindow = isThingSmallerThanWindowWith(resetScale(transform()));
|
||||||
if (originalSizeSmallerThanWindow && scaleFactor() >= 1) {
|
if (originalSizeSmallerThanWindow && scaleFactor() >= 1) {
|
||||||
// no longer need to do fitInView()
|
// no longer need to do fitInView()
|
||||||
|
|||||||
@@ -39,17 +39,12 @@ public:
|
|||||||
void displayScene();
|
void displayScene();
|
||||||
bool isSceneBiggerThanView() const;
|
bool isSceneBiggerThanView() const;
|
||||||
void setEnableAutoFitInView(bool enable = true);
|
void setEnableAutoFitInView(bool enable = true);
|
||||||
void setLongImageMode(bool enable = true);
|
|
||||||
|
|
||||||
bool avoidResetTransform() const;
|
bool avoidResetTransform() const;
|
||||||
void setAvoidResetTransform(bool avoidReset);
|
void setAvoidResetTransform(bool avoidReset);
|
||||||
|
|
||||||
static QTransform resetScale(const QTransform & orig);
|
static QTransform resetScale(const QTransform & orig);
|
||||||
|
|
||||||
// Long image mode support
|
|
||||||
bool isLongImage() const;
|
|
||||||
void fitLongImage();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void navigatorViewRequired(bool required, QTransform transform);
|
void navigatorViewRequired(bool required, QTransform transform);
|
||||||
void viewportRectChanged();
|
void viewportRectChanged();
|
||||||
@@ -75,7 +70,6 @@ private:
|
|||||||
// ... or even more? e.g. "fit/snap width" things...
|
// ... or even more? e.g. "fit/snap width" things...
|
||||||
// Currently it's "no fit" when it's false and "fit when view is smaller" when it's true.
|
// Currently it's "no fit" when it's false and "fit when view is smaller" when it's true.
|
||||||
bool m_enableFitInView = false;
|
bool m_enableFitInView = false;
|
||||||
bool m_longImageMode = false;
|
|
||||||
bool m_avoidResetTransform = false;
|
bool m_avoidResetTransform = false;
|
||||||
bool m_checkerboardEnabled = false;
|
bool m_checkerboardEnabled = false;
|
||||||
bool m_useLightCheckerboard = false;
|
bool m_useLightCheckerboard = false;
|
||||||
|
|||||||
@@ -701,7 +701,6 @@ void MainWindow::on_actionActualSize_triggered()
|
|||||||
{
|
{
|
||||||
m_graphicsView->resetScale();
|
m_graphicsView->resetScale();
|
||||||
m_graphicsView->setEnableAutoFitInView(false);
|
m_graphicsView->setEnableAutoFitInView(false);
|
||||||
m_graphicsView->setLongImageMode(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionToggleMaximize_triggered()
|
void MainWindow::on_actionToggleMaximize_triggered()
|
||||||
@@ -730,7 +729,6 @@ void MainWindow::on_actionFitInView_triggered()
|
|||||||
{
|
{
|
||||||
m_graphicsView->fitInView(m_gv->sceneRect(), Qt::KeepAspectRatio);
|
m_graphicsView->fitInView(m_gv->sceneRect(), Qt::KeepAspectRatio);
|
||||||
m_graphicsView->setEnableAutoFitInView(m_graphicsView->scaleFactor() <= 1);
|
m_graphicsView->setEnableAutoFitInView(m_graphicsView->scaleFactor() <= 1);
|
||||||
m_graphicsView->setLongImageMode(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionFitByWidth_triggered()
|
void MainWindow::on_actionFitByWidth_triggered()
|
||||||
@@ -738,12 +736,6 @@ 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,7 +93,6 @@ 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();
|
||||||
|
|||||||
@@ -65,11 +65,6 @@ bool Settings::loopGallery() const
|
|||||||
return m_qsettings->value("loop_gallery", true).toBool();
|
return m_qsettings->value("loop_gallery", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::autoLongImageMode() const
|
|
||||||
{
|
|
||||||
return m_qsettings->value("auto_long_image_mode", true).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Settings::svgTiny12Only() const
|
bool Settings::svgTiny12Only() const
|
||||||
{
|
{
|
||||||
// Qt 6.7.0's SVG support is terrible caused by huge memory usage, see QTBUG-124287
|
// Qt 6.7.0's SVG support is terrible caused by huge memory usage, see QTBUG-124287
|
||||||
@@ -135,12 +130,6 @@ void Settings::setLoopGallery(bool on)
|
|||||||
m_qsettings->sync();
|
m_qsettings->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setAutoLongImageMode(bool on)
|
|
||||||
{
|
|
||||||
m_qsettings->setValue("auto_long_image_mode", on);
|
|
||||||
m_qsettings->sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Settings::setSvgTiny12Only(bool on)
|
void Settings::setSvgTiny12Only(bool on)
|
||||||
{
|
{
|
||||||
m_qsettings->setValue("svg_tiny12_only", on);
|
m_qsettings->setValue("svg_tiny12_only", on);
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ public:
|
|||||||
bool useBuiltInCloseAnimation() const;
|
bool useBuiltInCloseAnimation() const;
|
||||||
bool useLightCheckerboard() const;
|
bool useLightCheckerboard() const;
|
||||||
bool loopGallery() const;
|
bool loopGallery() const;
|
||||||
bool autoLongImageMode() const;
|
|
||||||
bool svgTiny12Only() const;
|
bool svgTiny12Only() const;
|
||||||
DoubleClickBehavior doubleClickBehavior() const;
|
DoubleClickBehavior doubleClickBehavior() const;
|
||||||
MouseWheelBehavior mouseWheelBehavior() const;
|
MouseWheelBehavior mouseWheelBehavior() const;
|
||||||
@@ -49,7 +48,6 @@ public:
|
|||||||
void setUseBuiltInCloseAnimation(bool on);
|
void setUseBuiltInCloseAnimation(bool on);
|
||||||
void setUseLightCheckerboard(bool light);
|
void setUseLightCheckerboard(bool light);
|
||||||
void setLoopGallery(bool on);
|
void setLoopGallery(bool on);
|
||||||
void setAutoLongImageMode(bool on);
|
|
||||||
void setSvgTiny12Only(bool on);
|
void setSvgTiny12Only(bool on);
|
||||||
void setDoubleClickBehavior(DoubleClickBehavior dcb);
|
void setDoubleClickBehavior(DoubleClickBehavior dcb);
|
||||||
void setMouseWheelBehavior(MouseWheelBehavior mwb);
|
void setMouseWheelBehavior(MouseWheelBehavior mwb);
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ SettingsDialog::SettingsDialog(QWidget *parent)
|
|||||||
, m_useBuiltInCloseAnimation(new QCheckBox)
|
, m_useBuiltInCloseAnimation(new QCheckBox)
|
||||||
, m_useLightCheckerboard(new QCheckBox)
|
, m_useLightCheckerboard(new QCheckBox)
|
||||||
, m_loopGallery(new QCheckBox)
|
, m_loopGallery(new QCheckBox)
|
||||||
, m_autoLongImageMode(new QCheckBox)
|
|
||||||
, m_svgTiny12Only(new QCheckBox)
|
, m_svgTiny12Only(new QCheckBox)
|
||||||
, m_doubleClickBehavior(new QComboBox)
|
, m_doubleClickBehavior(new QComboBox)
|
||||||
, m_mouseWheelBehavior(new QComboBox)
|
, m_mouseWheelBehavior(new QComboBox)
|
||||||
@@ -125,7 +124,6 @@ SettingsDialog::SettingsDialog(QWidget *parent)
|
|||||||
settingsForm->addRow(tr("Use built-in close window animation"), m_useBuiltInCloseAnimation);
|
settingsForm->addRow(tr("Use built-in close window animation"), m_useBuiltInCloseAnimation);
|
||||||
settingsForm->addRow(tr("Use light-color checkerboard"), m_useLightCheckerboard);
|
settingsForm->addRow(tr("Use light-color checkerboard"), m_useLightCheckerboard);
|
||||||
settingsForm->addRow(tr("Loop the loaded gallery"), m_loopGallery);
|
settingsForm->addRow(tr("Loop the loaded gallery"), m_loopGallery);
|
||||||
settingsForm->addRow(tr("Auto long image mode"), m_autoLongImageMode);
|
|
||||||
settingsForm->addRow(tr("Limit SVG support to SVG Tiny 1.2"), m_svgTiny12Only);
|
settingsForm->addRow(tr("Limit SVG support to SVG Tiny 1.2"), m_svgTiny12Only);
|
||||||
settingsForm->addRow(tr("Double-click behavior"), m_doubleClickBehavior);
|
settingsForm->addRow(tr("Double-click behavior"), m_doubleClickBehavior);
|
||||||
settingsForm->addRow(tr("Mouse wheel behavior"), m_mouseWheelBehavior);
|
settingsForm->addRow(tr("Mouse wheel behavior"), m_mouseWheelBehavior);
|
||||||
@@ -136,7 +134,6 @@ SettingsDialog::SettingsDialog(QWidget *parent)
|
|||||||
m_useBuiltInCloseAnimation->setChecked(Settings::instance()->useBuiltInCloseAnimation());
|
m_useBuiltInCloseAnimation->setChecked(Settings::instance()->useBuiltInCloseAnimation());
|
||||||
m_useLightCheckerboard->setChecked(Settings::instance()->useLightCheckerboard());
|
m_useLightCheckerboard->setChecked(Settings::instance()->useLightCheckerboard());
|
||||||
m_loopGallery->setChecked(Settings::instance()->loopGallery());
|
m_loopGallery->setChecked(Settings::instance()->loopGallery());
|
||||||
m_autoLongImageMode->setChecked(Settings::instance()->autoLongImageMode());
|
|
||||||
m_svgTiny12Only->setChecked(Settings::instance()->svgTiny12Only());
|
m_svgTiny12Only->setChecked(Settings::instance()->svgTiny12Only());
|
||||||
m_doubleClickBehavior->setModel(new QStringListModel(dcbDropDown));
|
m_doubleClickBehavior->setModel(new QStringListModel(dcbDropDown));
|
||||||
Settings::DoubleClickBehavior dcb = Settings::instance()->doubleClickBehavior();
|
Settings::DoubleClickBehavior dcb = Settings::instance()->doubleClickBehavior();
|
||||||
@@ -180,10 +177,6 @@ SettingsDialog::SettingsDialog(QWidget *parent)
|
|||||||
Settings::instance()->setLoopGallery(state == Qt::Checked);
|
Settings::instance()->setLoopGallery(state == Qt::Checked);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_autoLongImageMode, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){
|
|
||||||
Settings::instance()->setAutoLongImageMode(state == Qt::Checked);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(m_svgTiny12Only, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){
|
connect(m_svgTiny12Only, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){
|
||||||
Settings::instance()->setSvgTiny12Only(state == Qt::Checked);
|
Settings::instance()->setSvgTiny12Only(state == Qt::Checked);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ private:
|
|||||||
QCheckBox * m_useBuiltInCloseAnimation = nullptr;
|
QCheckBox * m_useBuiltInCloseAnimation = nullptr;
|
||||||
QCheckBox * m_useLightCheckerboard = nullptr;
|
QCheckBox * m_useLightCheckerboard = nullptr;
|
||||||
QCheckBox * m_loopGallery = nullptr;
|
QCheckBox * m_loopGallery = nullptr;
|
||||||
QCheckBox * m_autoLongImageMode = nullptr;
|
|
||||||
QCheckBox * m_svgTiny12Only = nullptr;
|
QCheckBox * m_svgTiny12Only = nullptr;
|
||||||
QComboBox * m_doubleClickBehavior = nullptr;
|
QComboBox * m_doubleClickBehavior = nullptr;
|
||||||
QComboBox * m_mouseWheelBehavior = nullptr;
|
QComboBox * m_mouseWheelBehavior = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user