Fix translate feature and add a source/target language picker - #1
Open
giangnam0201 wants to merge 4 commits into
Open
Fix translate feature and add a source/target language picker#1giangnam0201 wants to merge 4 commits into
giangnam0201 wants to merge 4 commits into
Conversation
added 4 commits
August 29, 2026 22:47
The translate gesture could never arm in PdfGpuView: its Ctrl/Alt marquee branch sat below the SelectText, link-activation, Pan and every annotation tool branch, all of which return unconditionally. With the Select tool active -- a headline 2.4 feature -- the selection was simply never started. The branch now runs first in mousePressEvent. The two view backends also disagreed on the modifier (ContinuousView used Ctrl, PdfGpuView used Alt, and Alt+drag is frequently swallowed by the Windows window manager). Both now accept Ctrl or Alt. On the network side the Google request had no transfer timeout, so a stalled connection emitted neither finished() nor failed() and the UI sat on "Translating..." forever. Both requests now time out at 15s, Google is retried as a GET when the POST comes back empty (some proxies drop the body and return an empty 200), a missing Qt TLS backend is reported explicitly instead of as an opaque reply error, and every attempt logs its HTTP status, Qt error and byte count. Failures surface in the translation popup rather than a 4-second status flash. Translator::translate is now language-parameterised over a 21-language table, and the cache key hashes both languages so en->vi and fr->vi no longer collide. LanguagePickerPopup asks "from X into Y" at the cursor after each selection, defaulting to English -> Vietnamese, with a swap button and an "always use this pair" opt-out persisted via QSettings. Adds a Windows CI workflow so the portable build can be produced without a local Qt/MSVC toolchain.
windeployqt leaves msvcp140/vcruntime140 out by default, so the zip only ran on machines with the VC++ redistributable already installed. The shipped portable build carries them locally; match that.
windeployqt --compiler-runtime silently copied nothing on the runner, so the package still depended on the VC++ redistributable being installed.
Adds tesseract to the vcpkg set so FELIXPDF_ENABLE_OCR turns on, fails the configure step if CMake falls back to the OCR stub, and checks the packaged folder for the exe, Qt network/TLS, PDFium, the CRT, the tesseract runtime and the bundled tessdata languages before uploading.
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.
The problem
Translation never ran. Three independent causes, each enough on its own:
1. The selection gesture could never arm (
PdfGpuView). The Ctrl/Alt marquee branch sat below theViewTool::SelectTextbranch, link activation, Pan, and every annotation tool — all of whichreturnunconditionally. With the Select tool active, a headline 2.4 feature,mousePressEventreturned long before reaching it. The branch now runs first in the handler, guarded bym_hasImage.2. The two backends disagreed on the modifier.
ContinuousViewused Ctrl,PdfGpuViewused Alt — and Alt+LeftDrag is frequently swallowed by the Windows window manager. Both now accept Ctrl or Alt.3. The request had no timeout. A stalled connection emitted neither
finished()norfailed(), so the UI sat on "Translating…" forever with nothing to show — the "it just does nothing" symptom. Both the Google and Gemini requests now usesetTransferTimeout(15s), and both replyconnects got athisreceiver context.Making failures legible
The old path could fail in total silence, which is what made this hard to diagnose:
http=, the Qt error enum and string, and the byte count.The language picker
Translator::translate()is now parameterised over a 21-language table, andmakeCacheKey()hashes both languages — previouslyen→viandfr→vicollided in the cache and returned each other's results.LanguagePickerPopupopens at the cursor after a selection and asks from X into Y, defaulting to English → Vietnamese, with a swap button and an "always use this pair" opt-out. Choices persist viaQSettings(translate/srcLang,translate/dstLang,translate/rememberLangs). The result popup shows the pair it used. UI copy that hardcoded "to Vietnamese" or "Alt+Drag" was updated to match what the code now does.CI
The last three commits add a Windows build workflow (Qt 6.8.1/MSVC 2022, vcpkg for OpenSSL/QPDF/ZLIB/Tesseract, vendored PDFium) producing a portable zip artifact. It also fails the build if CMake silently falls back to the OCR stub, and verifies the package contains the exe, Qt network/TLS, PDFium, the CRT, the tesseract runtime and all 10 bundled tessdata languages before uploading.
These are separate commits and easy to drop if the workflow isn't something you want to maintain — the fix itself is the first commit alone.
Testing
Built via the workflow above and tested on Windows 10 x64 against the produced portable package. The CI build matches the shipped portable in scope, including OCR and the same 10 tessdata languages.
🤖 Generated with Claude Code
https://claude.ai/code/session_01GBDMRRnXFtfN8AG3fQCWSY