mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 09:51:06 +00:00
Fix magnify windows (#2746)
* Fixed issue with magnifier on windows where screen numbers were not monotonically increasing * clang format * fixed dos line endings * remove qt debug
This commit is contained in:
@@ -44,8 +44,11 @@ void MagnifierWidget::paintEvent(QPaintEvent*)
|
|||||||
|
|
||||||
void MagnifierWidget::drawMagnifierCircle(QPainter& painter)
|
void MagnifierWidget::drawMagnifierCircle(QPainter& painter)
|
||||||
{
|
{
|
||||||
int x = QCursor::pos().x() + m_magPixels;
|
auto relativeCursor = QCursor::pos();
|
||||||
int y = QCursor::pos().y() + m_magPixels;
|
auto translated = QWidget::mapFromGlobal(relativeCursor);
|
||||||
|
auto x = translated.x() + m_magPixels;
|
||||||
|
auto y = translated.y() + m_magPixels;
|
||||||
|
|
||||||
int magX = static_cast<int>(x * m_devicePixelRatio - m_magPixels);
|
int magX = static_cast<int>(x * m_devicePixelRatio - m_magPixels);
|
||||||
int magY = static_cast<int>(y * m_devicePixelRatio - m_magPixels);
|
int magY = static_cast<int>(y * m_devicePixelRatio - m_magPixels);
|
||||||
QRectF magniRect(magX, magY, m_pixels, m_pixels);
|
QRectF magniRect(magX, magY, m_pixels, m_pixels);
|
||||||
@@ -103,8 +106,11 @@ void MagnifierWidget::drawMagnifierCircle(QPainter& painter)
|
|||||||
// https://invent.kde.org/graphics/spectacle/-/blob/master/src/QuickEditor/QuickEditor.cpp#L841
|
// https://invent.kde.org/graphics/spectacle/-/blob/master/src/QuickEditor/QuickEditor.cpp#L841
|
||||||
void MagnifierWidget::drawMagnifier(QPainter& painter)
|
void MagnifierWidget::drawMagnifier(QPainter& painter)
|
||||||
{
|
{
|
||||||
int x = QCursor::pos().x();
|
auto relativeCursor = QCursor::pos();
|
||||||
int y = QCursor::pos().y();
|
auto translated = QWidget::mapFromGlobal(relativeCursor);
|
||||||
|
auto x = translated.x();
|
||||||
|
auto y = translated.y();
|
||||||
|
|
||||||
int magX = static_cast<int>(x * m_devicePixelRatio - m_magPixels);
|
int magX = static_cast<int>(x * m_devicePixelRatio - m_magPixels);
|
||||||
int offsetX = 0;
|
int offsetX = 0;
|
||||||
if (magX < 0) {
|
if (magX < 0) {
|
||||||
@@ -170,4 +176,4 @@ void MagnifierWidget::drawMagnifier(QPainter& painter)
|
|||||||
{ crossHairTop, crossHairRight, crossHairBottom, crossHairLeft }) {
|
{ crossHairTop, crossHairRight, crossHairBottom, crossHairLeft }) {
|
||||||
painter.fillRect(rect, m_color);
|
painter.fillRect(rect, m_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user