Skip to content

Commit

Permalink
Fuzzy-compare zoom factors
Browse files Browse the repository at this point in the history
Standard operators don't work well for imprecise floating-point numbers.
For example, zooming out from an almost-minimum zoom factor, then
zooming in to the default zoom factor does not disable the zoomBase
(Normal Size) action.

Replacing '<' and '>' with fuzzy inequality works, because the code
above clamps zoomFactor into [minZoomFactor, maxZoomFactor].
  • Loading branch information
vedgy committed Sep 24, 2023
1 parent 814b3bf commit 2fbca0a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mainwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4356,9 +4356,9 @@ void MainWindow::adjustCurrentZoomFactor()
else if( cfg.preferences.zoomFactor > maxZoomFactor )
cfg.preferences.zoomFactor = maxZoomFactor;

zoomIn->setEnabled( cfg.preferences.zoomFactor < maxZoomFactor );
zoomOut->setEnabled( cfg.preferences.zoomFactor > minZoomFactor );
zoomBase->setEnabled( cfg.preferences.zoomFactor != 1.0 );
zoomIn->setEnabled( !qFuzzyCompare( cfg.preferences.zoomFactor, maxZoomFactor ) );
zoomOut->setEnabled( !qFuzzyCompare( cfg.preferences.zoomFactor, minZoomFactor ) );
zoomBase->setEnabled( !qFuzzyCompare( cfg.preferences.zoomFactor, 1.0 ) );
}

void MainWindow::scaleArticlesByCurrentZoomFactor()
Expand Down

0 comments on commit 2fbca0a

Please sign in to comment.