1
0

feat: update action manager

- add and delete some actions in action manager.
- rename "fit to view" to "fit to screen".
- update main window right click menu and toolbar.
- use special state update slot in action manager instead of function located in main window.
This commit is contained in:
2026-07-12 21:00:11 +08:00
parent 369a17ed7d
commit dbf8c09368
8 changed files with 388 additions and 324 deletions

View File

@@ -140,7 +140,7 @@ void GraphicsView::resetTransform()
void GraphicsView::zoomView(qreal scaleFactor)
{
m_enableFitInView = false;
m_enableFitToScreen = false;
scale(scaleFactor, scaleFactor);
applyTransformationModeByScaleFactor();
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
@@ -223,6 +223,8 @@ void GraphicsView::fitByOrientation(Qt::Orientation ori, bool scaleDownOnly)
// Position the image correctly based on orientation with rotation consideration
QRectF originalScene = sceneRect();
QTransform currentTransform = transform();
// TODO: May be optimized by matrix arithmetic operation?
if (ori == Qt::Horizontal) {
// For horizontal fit (fit by width), position at top (for tall images)
@@ -276,7 +278,7 @@ void GraphicsView::fitByOrientation(Qt::Orientation ori, bool scaleDownOnly)
centerOn(sceneLeftCenter);
}
m_enableFitInView = false;
m_enableFitToScreen = false;
applyTransformationModeByScaleFactor();
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
@@ -299,7 +301,7 @@ void GraphicsView::displayScene()
emit navigatorViewRequired(false, transform());
}
m_enableFitInView = true;
m_enableFitToScreen = true;
m_firstUserMediaLoaded = true;
}
@@ -313,9 +315,9 @@ bool GraphicsView::isSceneBiggerThanView() const
}
// Automately do fit in view when viewport(window) smaller than image original size.
void GraphicsView::setEnableAutoFitInView(bool enable)
void GraphicsView::setEnableAutoFitToScreen(bool enable)
{
m_enableFitInView = enable;
m_enableFitToScreen = enable;
}
bool GraphicsView::avoidResetTransform() const
@@ -328,6 +330,15 @@ void GraphicsView::setAvoidResetTransform(bool avoidReset)
m_avoidResetTransform = avoidReset;
}
bool GraphicsView::checkerboard() const {
return m_checkerboardEnabled;
}
void GraphicsView::toggleCheckerboard(bool invertCheckerboardColor)
{
setCheckerboardEnabled(!m_checkerboardEnabled, invertCheckerboardColor);
}
inline double zeroOrOne(double number)
{
return qFuzzyIsNull(number) ? 0 : (number > 0 ? 1 : -1);
@@ -342,11 +353,6 @@ QTransform GraphicsView::resetScale(const QTransform & orig)
orig.dx(), orig.dy());
}
void GraphicsView::toggleCheckerboard(bool invertCheckerboardColor)
{
setCheckerboardEnabled(!m_checkerboardEnabled, invertCheckerboardColor);
}
void GraphicsView::updateStyle(Qt::ColorScheme colorScheme) {
// YYC MARK:
// If we are using Windows 10 and lower system or Qt which do not support "Windows 11"
@@ -423,11 +429,11 @@ void GraphicsView::wheelEvent(QWheelEvent *event)
void GraphicsView::resizeEvent(QResizeEvent *event)
{
if (m_enableFitInView) {
if (m_enableFitToScreen) {
bool originalSizeSmallerThanWindow = isThingSmallerThanWindowWith(resetScale(transform()));
if (originalSizeSmallerThanWindow && scaleFactor() >= 1) {
// no longer need to do fitInView()
// but we leave the m_enableFitInView value unchanged in case
// but we leave the m_enableToScreen value unchanged in case
// user resize down the window again.
} else if (originalSizeSmallerThanWindow && scaleFactor() < 1) {
resetScale();