Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix adjusting select geometry before 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 ;) 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 * 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