mirror of
https://github.com/fergalmoran/flameshot.git
synced 2026-03-26 18:10:02 +00:00
screengrabber: fix devicePixelRatio detection (#277)
This commit is contained in:
@@ -85,7 +85,9 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool &ok) {
|
||||
geometry.width(),
|
||||
geometry.height())
|
||||
);
|
||||
p.setDevicePixelRatio(QApplication::desktop()->devicePixelRatio());
|
||||
auto screenNumber = QApplication::desktop()->screenNumber();
|
||||
QScreen *screen = QApplication::screens()[screenNumber];
|
||||
p.setDevicePixelRatio(screen->devicePixelRatio());
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@@ -453,7 +453,7 @@ void CaptureWidget::mouseReleaseEvent(QMouseEvent *e) {
|
||||
newGeometry.setBottom(top);
|
||||
}
|
||||
m_selection->setGeometry(newGeometry);
|
||||
m_context.selection = newGeometry;
|
||||
m_context.selection = extendedRect(&newGeometry);
|
||||
updateSizeIndicator();
|
||||
m_buttonHandler->updatePosition(newGeometry);
|
||||
m_buttonHandler->show();
|
||||
@@ -850,11 +850,14 @@ void CaptureWidget::redo() {
|
||||
QRect CaptureWidget::extendedSelection() const {
|
||||
if (!m_selection->isVisible())
|
||||
return QRect();
|
||||
auto devicePixelRatio = m_context.screenshot.devicePixelRatio();
|
||||
|
||||
QRect const &r = m_selection->geometry();
|
||||
return QRect(r.left() * devicePixelRatio,
|
||||
r.top() * devicePixelRatio,
|
||||
r.width() * devicePixelRatio,
|
||||
r.height() * devicePixelRatio);
|
||||
QRect r = m_selection->geometry();
|
||||
return extendedRect(&r);
|
||||
}
|
||||
|
||||
QRect CaptureWidget::extendedRect(QRect *r) const {
|
||||
auto devicePixelRatio = m_context.screenshot.devicePixelRatio();
|
||||
return QRect(r->left() * devicePixelRatio,
|
||||
r->top() * devicePixelRatio,
|
||||
r->width() * devicePixelRatio,
|
||||
r->height() * devicePixelRatio);
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ private:
|
||||
void makeChild(QWidget *w);
|
||||
|
||||
QRect extendedSelection() const;
|
||||
QRect extendedRect(QRect *r) const;
|
||||
|
||||
QUndoStack m_undoStack;
|
||||
QPointer<CaptureButton> m_sizeIndButton;
|
||||
|
||||
Reference in New Issue
Block a user