feat: add option to avoid reset transform when switching between images
It's not enabled for now so it's not available to end-users.
This commit is contained in:
parent
f96da17e78
commit
d4ded92734
|
@ -68,6 +68,7 @@ void ActionManager::setupAction(MainWindow *mainWindow)
|
||||||
CREATE_NEW_ACTION(mainWindow, actionPaste);
|
CREATE_NEW_ACTION(mainWindow, actionPaste);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionToggleStayOnTop);
|
CREATE_NEW_ACTION(mainWindow, actionToggleStayOnTop);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionToggleProtectMode);
|
CREATE_NEW_ACTION(mainWindow, actionToggleProtectMode);
|
||||||
|
CREATE_NEW_ACTION(mainWindow, actionToggleAvoidResetTransform);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionSettings);
|
CREATE_NEW_ACTION(mainWindow, actionSettings);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionHelp);
|
CREATE_NEW_ACTION(mainWindow, actionHelp);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionLocateInFileManager);
|
CREATE_NEW_ACTION(mainWindow, actionLocateInFileManager);
|
||||||
|
@ -104,6 +105,7 @@ void ActionManager::retranslateUi(MainWindow *mainWindow)
|
||||||
actionPaste->setText(QCoreApplication::translate("MainWindow", "&Paste", nullptr));
|
actionPaste->setText(QCoreApplication::translate("MainWindow", "&Paste", nullptr));
|
||||||
actionToggleStayOnTop->setText(QCoreApplication::translate("MainWindow", "Stay on top", nullptr));
|
actionToggleStayOnTop->setText(QCoreApplication::translate("MainWindow", "Stay on top", nullptr));
|
||||||
actionToggleProtectMode->setText(QCoreApplication::translate("MainWindow", "Protected mode", nullptr));
|
actionToggleProtectMode->setText(QCoreApplication::translate("MainWindow", "Protected mode", nullptr));
|
||||||
|
actionToggleAvoidResetTransform->setText("Avoid reset transform"); // TODO: what should it called?
|
||||||
actionSettings->setText(QCoreApplication::translate("MainWindow", "Configure...", nullptr));
|
actionSettings->setText(QCoreApplication::translate("MainWindow", "Configure...", nullptr));
|
||||||
actionHelp->setText(QCoreApplication::translate("MainWindow", "Help", nullptr));
|
actionHelp->setText(QCoreApplication::translate("MainWindow", "Help", nullptr));
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
QAction *actionPaste;
|
QAction *actionPaste;
|
||||||
QAction *actionToggleStayOnTop;
|
QAction *actionToggleStayOnTop;
|
||||||
QAction *actionToggleProtectMode;
|
QAction *actionToggleProtectMode;
|
||||||
|
QAction *actionToggleAvoidResetTransform;
|
||||||
QAction *actionSettings;
|
QAction *actionSettings;
|
||||||
QAction *actionHelp;
|
QAction *actionHelp;
|
||||||
QAction *actionLocateInFileManager;
|
QAction *actionLocateInFileManager;
|
||||||
|
|
|
@ -121,7 +121,9 @@ qreal GraphicsView::scaleFactor() const
|
||||||
|
|
||||||
void GraphicsView::resetTransform()
|
void GraphicsView::resetTransform()
|
||||||
{
|
{
|
||||||
QGraphicsView::resetTransform();
|
if (!m_avoidResetTransform) {
|
||||||
|
QGraphicsView::resetTransform();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsView::zoomView(qreal scaleFactor)
|
void GraphicsView::zoomView(qreal scaleFactor)
|
||||||
|
@ -197,6 +199,11 @@ void GraphicsView::fitByOrientation(Qt::Orientation ori, bool scaleDownOnly)
|
||||||
|
|
||||||
void GraphicsView::displayScene()
|
void GraphicsView::displayScene()
|
||||||
{
|
{
|
||||||
|
if (m_avoidResetTransform) {
|
||||||
|
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isSceneBiggerThanView()) {
|
if (isSceneBiggerThanView()) {
|
||||||
fitInView(sceneRect(), Qt::KeepAspectRatio);
|
fitInView(sceneRect(), Qt::KeepAspectRatio);
|
||||||
}
|
}
|
||||||
|
@ -219,6 +226,16 @@ void GraphicsView::setEnableAutoFitInView(bool enable)
|
||||||
m_enableFitInView = enable;
|
m_enableFitInView = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GraphicsView::avoidResetTransform() const
|
||||||
|
{
|
||||||
|
return m_avoidResetTransform;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicsView::setAvoidResetTransform(bool avoidReset)
|
||||||
|
{
|
||||||
|
m_avoidResetTransform = avoidReset;
|
||||||
|
}
|
||||||
|
|
||||||
inline double zeroOrOne(double number)
|
inline double zeroOrOne(double number)
|
||||||
{
|
{
|
||||||
return qFuzzyIsNull(number) ? 0 : (number > 0 ? 1 : -1);
|
return qFuzzyIsNull(number) ? 0 : (number > 0 ? 1 : -1);
|
||||||
|
|
|
@ -40,6 +40,9 @@ public:
|
||||||
bool isSceneBiggerThanView() const;
|
bool isSceneBiggerThanView() const;
|
||||||
void setEnableAutoFitInView(bool enable = true);
|
void setEnableAutoFitInView(bool enable = true);
|
||||||
|
|
||||||
|
bool avoidResetTransform() const;
|
||||||
|
void setAvoidResetTransform(bool avoidReset);
|
||||||
|
|
||||||
static QTransform resetScale(const QTransform & orig);
|
static QTransform resetScale(const QTransform & orig);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -70,6 +73,7 @@ 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_avoidResetTransform = false;
|
||||||
bool m_checkerboardEnabled = false;
|
bool m_checkerboardEnabled = false;
|
||||||
bool m_isLastCheckerboardColorInverted = false;
|
bool m_isLastCheckerboardColorInverted = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -453,6 +453,10 @@ void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
||||||
protectedMode->setCheckable(true);
|
protectedMode->setCheckable(true);
|
||||||
protectedMode->setChecked(m_protectedMode);
|
protectedMode->setChecked(m_protectedMode);
|
||||||
|
|
||||||
|
QAction * avoidResetTransform = m_am->actionToggleAvoidResetTransform;
|
||||||
|
avoidResetTransform->setCheckable(true);
|
||||||
|
avoidResetTransform->setChecked(m_graphicsView->avoidResetTransform());
|
||||||
|
|
||||||
QAction * toggleSettings = m_am->actionSettings;
|
QAction * toggleSettings = m_am->actionSettings;
|
||||||
QAction * helpAction = m_am->actionHelp;
|
QAction * helpAction = m_am->actionHelp;
|
||||||
QAction * propertiesAction = m_am->actionProperties;
|
QAction * propertiesAction = m_am->actionProperties;
|
||||||
|
@ -481,6 +485,9 @@ void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(stayOnTopMode);
|
menu->addAction(stayOnTopMode);
|
||||||
menu->addAction(protectedMode);
|
menu->addAction(protectedMode);
|
||||||
|
#if 0
|
||||||
|
menu->addAction(avoidResetTransform);
|
||||||
|
#endif // 0
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(toggleSettings);
|
menu->addAction(toggleSettings);
|
||||||
menu->addAction(helpAction);
|
menu->addAction(helpAction);
|
||||||
|
@ -545,6 +552,11 @@ void MainWindow::toggleStayOnTop()
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::toggleAvoidResetTransform()
|
||||||
|
{
|
||||||
|
m_graphicsView->setAvoidResetTransform(!m_graphicsView->avoidResetTransform());
|
||||||
|
}
|
||||||
|
|
||||||
bool MainWindow::stayOnTop() const
|
bool MainWindow::stayOnTop() const
|
||||||
{
|
{
|
||||||
return windowFlags().testFlag(Qt::WindowStaysOnTopHint);
|
return windowFlags().testFlag(Qt::WindowStaysOnTopHint);
|
||||||
|
@ -727,6 +739,11 @@ void MainWindow::on_actionToggleProtectMode_triggered()
|
||||||
toggleProtectedMode();
|
toggleProtectedMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionToggleAvoidResetTransform_triggered()
|
||||||
|
{
|
||||||
|
toggleAvoidResetTransform();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionSettings_triggered()
|
void MainWindow::on_actionSettings_triggered()
|
||||||
{
|
{
|
||||||
SettingsDialog * sd = new SettingsDialog(this);
|
SettingsDialog * sd = new SettingsDialog(this);
|
||||||
|
|
|
@ -63,6 +63,7 @@ protected slots:
|
||||||
void updateWidgetsPosition();
|
void updateWidgetsPosition();
|
||||||
void toggleProtectedMode();
|
void toggleProtectedMode();
|
||||||
void toggleStayOnTop();
|
void toggleStayOnTop();
|
||||||
|
void toggleAvoidResetTransform();
|
||||||
bool stayOnTop() const;
|
bool stayOnTop() const;
|
||||||
bool canPaste() const;
|
bool canPaste() const;
|
||||||
void quitAppAction(bool force = false);
|
void quitAppAction(bool force = false);
|
||||||
|
@ -93,6 +94,7 @@ private slots:
|
||||||
void on_actionPaste_triggered();
|
void on_actionPaste_triggered();
|
||||||
void on_actionToggleStayOnTop_triggered();
|
void on_actionToggleStayOnTop_triggered();
|
||||||
void on_actionToggleProtectMode_triggered();
|
void on_actionToggleProtectMode_triggered();
|
||||||
|
void on_actionToggleAvoidResetTransform_triggered();
|
||||||
void on_actionSettings_triggered();
|
void on_actionSettings_triggered();
|
||||||
void on_actionHelp_triggered();
|
void on_actionHelp_triggered();
|
||||||
void on_actionProperties_triggered();
|
void on_actionProperties_triggered();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user