@@ -666,17 +666,18 @@ void CaptureWidget::paintEvent(QPaintEvent* paintEvent)
666666 painter.setPen (uicolor);
667667 painter.setBrush (QBrush (uicolor));
668668
669- auto topLeft = mapToGlobal (m_context.selection .topLeft ());
669+ const auto scale{ m_context.screenshot .devicePixelRatio () };
670+ auto topLeft = mapToGlobal (m_context.selection .topLeft () / scale);
670671 topLeft.rx () -= topLeft.x () % m_gridSize;
671672 topLeft.ry () -= topLeft.y () % m_gridSize;
672673 topLeft = mapFromGlobal (topLeft);
673674
674- const auto scale{ m_context.screenshot .devicePixelRatio () };
675- const auto step{ m_gridSize * scale };
675+ const auto step{ m_gridSize / scale };
676676 const auto radius{ 1 * scale };
677677
678- for (int y = topLeft.y (); y < m_context.selection .bottom (); y += step) {
679- for (int x = topLeft.x (); x < m_context.selection .right ();
678+ for (int y = topLeft.y (); y < m_context.selection .bottom () / scale;
679+ y += step) {
680+ for (int x = topLeft.x (); x < m_context.selection .right () / scale;
680681 x += step) {
681682 painter.drawEllipse (x, y, radius, radius);
682683 }
@@ -1812,10 +1813,8 @@ QPoint CaptureWidget::snapToGrid(const QPoint& point) const
18121813
18131814 const auto scale{ m_context.screenshot .devicePixelRatio () };
18141815
1815- snapPoint.setX ((qRound (snapPoint.x () / double (m_gridSize)) * m_gridSize) *
1816- scale);
1817- snapPoint.setY ((qRound (snapPoint.y () / double (m_gridSize)) * m_gridSize) *
1818- scale);
1816+ snapPoint.setX ((qRound (snapPoint.x () / double (m_gridSize)) * m_gridSize));
1817+ snapPoint.setY ((qRound (snapPoint.y () / double (m_gridSize)) * m_gridSize));
18191818
18201819 return mapFromGlobal (snapPoint);
18211820}
0 commit comments