Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix adjusting selection geometry when exporting from gui
The docs for `setTopLeft()` say "Set the top-left corner of the rectangle to the given position. May change the size, but will never change the bottom-right corner of the rectangle." For some reason on windows when calling `setTopLeft()` here when the widget is at an offset it is moving the top left of the rect but not keeping the size the same. I believe all we want to do here is move the rect, so this commit changes this adjustment to definitively do that. There are various instances of `move()`, `moveTo()` and `moveTopLeft()` in the codebase, and only one other if `setTopLeft()`. I picked `moveTopLeft()` because it makes the diff smaller ;) This error has the following implications 1) causing the pin widget to shift a little from where the selection was 2) causing the reported geometry to not match the pixmap size, which didn't have much effect unless you wanted to use the geometry later (for example for allowing editing pins). I guess the pin widget got its size from the pixmap or something and that's why it wasn't huge? You can reproduce this like so: * have a windows machine with two monitors * change the display settings so monitor one is to the right of monitor two (which causes monitor two to have a negative offset) * pin a selection and watch the pinned window shift a bit from where the selection was; or * observe this modified geometry somehow, like this patch which changes the size measurement painted on the selection widget to include the modified geometry alongside the original one: diff --git c/src/widgets/capture/capturewidget.cpp w/src/widgets/capture/capturewidget.cpp index 49ebff9720a0..16c7d04dbed6 100644 --- c/src/widgets/capture/capturewidget.cpp +++ w/src/widgets/capture/capturewidget.cpp @@ -551,11 +633,18 @@ void CaptureWidget::paintEvent(QPaintEvent* paintEvent) QRect xybox; QFontMetrics fm = painter.fontMetrics(); - QString xy = QString("%1x%2+%3+%4") + QRect final_geometry(m_context.selection); + final_geometry.setTopLeft(final_geometry.topLeft() + m_context.widgetOffset); + QString xy = QString("%1x%2+%3+%4\n%5x%6+%7+%8") .arg(static_cast<int>(selection.width() * scale)) .arg(static_cast<int>(selection.height() * scale)) .arg(static_cast<int>(selection.left() * scale)) - .arg(static_cast<int>(selection.top() * scale)); + .arg(static_cast<int>(selection.top() * scale)) + .arg(static_cast<int>(final_geometry.width() * scale)) + .arg(static_cast<int>(final_geometry.height() * scale)) + .arg(static_cast<int>(final_geometry.left() * scale)) + .arg(static_cast<int>(final_geometry.top() * scale)) + ; xybox = fm.boundingRect(xy); // the small numbers here are just margins so the text doesn't https://doc.qt.io/qt-6/qrect.html#setTopLeft
- Loading branch information
4676b6b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally you find this bug, but I submit a fix PR 2 days ago.
4676b6b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you beat me!
I found that I couldn't reproduce any user visible effects with the release build from the website. In my reproductions steps above, where I talk about the pin widget shifting a bit, that only happened on my branch where I was refactoring stuff. I thought it might also be the cause of flameshot-org#3022 but there is a lot discussed in that issue I and don't want to get involved in macOS arcana.
Anyway, if there is some user facing issue that line causes and you can explain to the maintainers on the PR how they can reproduce that I'm sure that would get them to have a look at it sooner.
4676b6b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我对于通过这些提交并不是否热衷,我是snipaste的用户,但我需要的一个功能,这个软件一直未能提供非微软商店的购买途径,而我工作的场所不允许使用微软商店。所以我决定自己实现它,相比全部重写一个截图工具,显然修改现有的成熟软件能更加迅速达成我的目标。于是我选择了flameshot作为修改对象。现在我的目标已经达成60%,用鼠标滚轮快速框选窗口和子窗口元素。其余的可以慢慢完成。我的目标是我自己可以用,对于是否合并到主干则持可有可无的态度。
以下内容是机器翻译。The following content is machine translated.
I'm not enthusiastic about going through these submissions, I'm a snipaste user, but there's a feature I need, and the software has not been able to offer non-Microsoft store purchases, and the Microsoft store isn't allowed where I work. So I decided to implement it myself. Compared with completely rewriting a screenshot tool, it is obvious that modifying the existing mature software can achieve my goal more quickly. So I chose flameshot as the modification object. Now I have achieved 60% of my goal, using the mouse wheel to quickly select window and sub-window elements. The rest can be done slowly. My goal is that I can use it myself, and I have a dispensable attitude towards merging it into the trunk.