Skip to content

qt: add qr reading from file to ScanQRTextEdit and SendTab #9782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025

Conversation

f321x
Copy link
Member

@f321x f321x commented May 2, 2025

There was no ability to read qr codes contained in image files. This is confusing in some contexts, as on_file_input() of ScanQRTextEdit will read the whole content of the file (instead of looking for qr codes).
The revealer plugin for example generates png files containing qr codes and uses the ScanQRTextEdit to get user input, for the user it would seem logical to click on 'Read from file' to load the generated file, however this will result in the wrong data getting loaded. Having the option to explicitly load a QR from file makes this clear.
Besides that it seems useful, considering reading QR from screenshots doesn't work on wayland.

@accumulator
Copy link
Member

Nothing wrong with the code per se, but it doesn't find a QR code in my testing (screenshot saved as png from spectacle, which itself detects a QR code)

@f321x
Copy link
Member Author

f321x commented May 2, 2025

That's weird, works fine for me with the following screenshots:

Screenshot_20250502_161712
Screenshot_20250502_093128

Can you share a png that doesn't work?

@accumulator
Copy link
Member

Screenshot_20250502_160807

@accumulator
Copy link
Member

That's weird, works fine for me with the following screenshots:

Yeah, your screenshots work fine here too

@f321x f321x force-pushed the fix_qr_input_from_file branch from f04a60a to f00f62e Compare May 5, 2025 14:45
@f321x
Copy link
Member Author

f321x commented May 5, 2025

The zbar library we use here for detecting the qr codes doesn't seem to like dense qr codes that are a large portion of the image. So i added a function _reduce_qr_code_density() to create a new image of which the original image is only a smaller part (it pads the image with white space), so it can attempt the scan multiple times with the qr code being different proportions of the image. This seems to make it more reliable, also with your screenshot.

@f321x f321x force-pushed the fix_qr_input_from_file branch from f00f62e to 0a789e3 Compare May 6, 2025 11:37
There was no ability to read qr codes contained in image files. This
could lead to confusion in some contexts, as `on_file_input()` of
ScanQRTextEdit will read the whole content of the file (instead of
looking for qr codes). The revealer plugin for example generates png
files containing qr codes and uses the `ScanQRTextEdit` to get user
input, for the user it would seem logical to click on 'Read from file'
to load the generated file, however this will result in the wrong data
being loaded. Having the option to explicitly load a QR from file makes
this clear. Also it seems useful, especially considering reading QR from
screenshots doesn't work on wayland.
@f321x f321x force-pushed the fix_qr_input_from_file branch from 0a789e3 to 63c224c Compare May 6, 2025 11:39
@accumulator accumulator merged commit 05e3950 into spesmilo:master May 9, 2025
14 checks passed
@f321x f321x deleted the fix_qr_input_from_file branch May 9, 2025 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants