Add trackpad pinch-to-zoom gesture to the comic viewer#530
Open
codeKonami wants to merge 2 commits intoYACReader:developfrom
Open
Add trackpad pinch-to-zoom gesture to the comic viewer#530codeKonami wants to merge 2 commits intoYACReader:developfrom
codeKonami wants to merge 2 commits intoYACReader:developfrom
Conversation
Enables the macOS (and any Qt-supported) trackpad pinch gesture to zoom the current page continuously within the existing [30%, 500%] bounds. The gesture is anchored on the cursor position captured at GestureStarted so the point under the cursor stays stationary during scaling. A compact translucent HUD in the bottom-right corner shows the live zoom percentage while the gesture is active so it does not obscure the reading surface; the existing centered notification is still used for keyboard zoom shortcuts. A new "Zoom mode" checkbox is added to Preferences > General, below "Mouse mode", to enable or disable the gesture. It defaults to enabled. Relates to YACReader#435
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to #435.
What this adds
Native trackpad pinch-to-zoom in the comic viewer:
Cmd +/Cmd -) driven by the trackpad pinch gesture.Cmd +/Cmd -zoom.How it works
Viewernow grabsQt::PinchGesturein its constructor and overridesevent()to dispatchQEvent::Gestureto a newgestureEvent(QGestureEvent *).Qt::GestureStarted, then onQt::GestureUpdatedappliesbaselineZoom * pinch->totalScaleFactor()clamped to[30, 500], resizes the content, and adjusts the horizontal/vertical scroll bars to keep the anchor stationary.QLabelchild of the viewer, rendered as Qt rich text to keep the "%" text reliably white over the translucent background regardless of palette cascade. It shows onGestureStartedand hides onGestureFinished/GestureCanceled.PINCH_TO_ZOOM_ENABLEDin the existingQSettingsfile, exposed viaConfiguration::getPinchToZoomEnabled()/setPinchToZoomEnabled(), and checked on each gesture event so toggling in Preferences takes effect immediately.Cross-platform
No
#ifdef Q_OS_MACOSis needed.QPinchGestureis handled natively by Qt on macOS (trackpad) and Windows (touch), and is a no-op on platforms that do not deliver pinch events, so the feature is additive and does not regress existing behavior on Linux or on systems without a touch surface.Tested
Cmd +/Cmd -shortcuts and their HUD still work, two-finger scroll and the magnifying glass still work, the Zoom mode checkbox enables/disables the gesture at runtime.clang-formatpasses on the modified files.Both Qt 5 and Qt 6 code paths should compile (
QPinchGestureandQGestureEventare available in both), though I have only been able to test Qt 6 locally.