Skip to content

Fix aspect ratio in selection widget when pressing CTRL - #4651

Merged
borgmanJeremy merged 2 commits into
flameshot-org:masterfrom
ElTh0r0:aspect_ratio
Jul 31, 2026
Merged

Fix aspect ratio in selection widget when pressing CTRL#4651
borgmanJeremy merged 2 commits into
flameshot-org:masterfrom
ElTh0r0:aspect_ratio

Conversation

@ElTh0r0

@ElTh0r0 ElTh0r0 commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Another approach to fix aspect ratio in selection widget when pressing CTRL (fix for #3436).

This PR gets the aspect ratio only once when the left mouse button is pressed. Before, the aspect ratio was permanently calculated while the mouse was moved, but QWidget:geometry only returns a QRect with integer precision, so we constantly lost aspect ratio precision while the mouse was moved.

There is another old PR #3439, which was never finalized. It may be closed if this one is merged.

@mmahmoudian

Copy link
Copy Markdown
Member

Nice fix. Also great to catch the division by zero. I initially didn't think about that.

As a general comment and not specific to this PR, I was puzzled why even changing the variable name and prepend m_. I think in general we need some more commenting in the codebase to explain some of these naming conventions.

@ElTh0r0

ElTh0r0 commented Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the review!

As a general comment and not specific to this PR, I was puzzled why even changing the variable name and prepend m_. I think in general we need some more commenting in the codebase to explain some of these naming conventions.

I moved the aspect ratio from a local function variable to a class member variable. The m_ prefix is a common naming convention in C++ projects and most / all (?) Flameshot classes are using this convention, so I added the prefix too, even if this rule is not written anywhere.
I am open for a separate discussion about this topic!

@andrewanswer

Copy link
Copy Markdown

ElTh0r0 Thank you for this patch, waiting for releasing that!

@ElTh0r0

ElTh0r0 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Hi @borgmanJeremy
once you have time, please review if this fix can be merged 😊

@borgmanJeremy

Copy link
Copy Markdown
Collaborator

Thanks for the ping! Lost track of this one.

@borgmanJeremy
borgmanJeremy merged commit f55a3bd into flameshot-org:master Jul 31, 2026
16 checks passed
@ElTh0r0
ElTh0r0 deleted the aspect_ratio branch August 1, 2026 08:44
@mmahmoudian mmahmoudian added this to the v15 milestone Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants