mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(video): fix scaling issues under HiDPI displays with desktop video
This commit fixes missing scaling factors with desktop video to allow desktop video under HiDPI scaling to work as intended. Also removes a few obsolete lines of scaling that that was required for older Qt versions.
This commit is contained in:
parent
79c249be55
commit
ef157ca8af
|
@ -438,7 +438,13 @@ QVector<VideoMode> CameraDevice::getScreenModes()
|
|||
QRect rect = s->geometry();
|
||||
QPoint p = rect.topLeft();
|
||||
|
||||
VideoMode mode(rect.width(), rect.height(), p.x(), p.y());
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
|
||||
qreal pixRatio = s->devicePixelRatio();
|
||||
#else
|
||||
qreal pixRatio = 1.0;
|
||||
#endif
|
||||
|
||||
VideoMode mode(rect.width() * pixRatio, rect.height() * pixRatio, p.x() * pixRatio, p.y() * pixRatio);
|
||||
result.push_back(mode);
|
||||
});
|
||||
|
||||
|
|
|
@ -53,9 +53,6 @@ ScreenshotGrabber::ScreenshotGrabber()
|
|||
pixRatio = QApplication::primaryScreen()->devicePixelRatio();
|
||||
#endif
|
||||
|
||||
// Scale window down by devicePixelRatio to show full screen region
|
||||
window->scale(1 / pixRatio, 1 / pixRatio);
|
||||
|
||||
setupScene();
|
||||
}
|
||||
|
||||
|
@ -131,6 +128,9 @@ void ScreenshotGrabber::acceptRegion()
|
|||
if (rect.width() < 1 || rect.height() < 1)
|
||||
return;
|
||||
|
||||
// Scale the accepted region from DIPs to actual pixels
|
||||
rect.setRect(rect.x() * pixRatio, rect.y() * pixRatio, rect.width() * pixRatio, rect.height() * pixRatio);
|
||||
|
||||
emit regionChosen(rect);
|
||||
qDebug() << "Screenshot accepted, chosen region" << rect;
|
||||
QPixmap pixmap = this->screenGrab.copy(rect);
|
||||
|
@ -152,10 +152,6 @@ void ScreenshotGrabber::setupScene()
|
|||
this->screenGrabDisplay = scene->addPixmap(this->screenGrab);
|
||||
this->helperTooltip = scene->addText(QString());
|
||||
|
||||
// Scale UI elements up by devicePixelRatio to compensate for window downscaling
|
||||
this->helperToolbox->setScale(pixRatio);
|
||||
this->helperTooltip->setScale(pixRatio);
|
||||
|
||||
scene->addItem(this->overlay);
|
||||
this->chooserRect = new ScreenGrabberChooserRectItem(scene);
|
||||
scene->addItem(this->helperToolbox);
|
||||
|
@ -203,9 +199,8 @@ void ScreenshotGrabber::adjustTooltipPosition()
|
|||
int x = qAbs(recGL.x()) + rec.x() + ((rec.width() - ttRect.width()) / 2);
|
||||
int y = qAbs(recGL.y()) + rec.y();
|
||||
|
||||
// Multiply by devicePixelRatio to get centered positions under scaling
|
||||
helperToolbox->setX(x * pixRatio);
|
||||
helperToolbox->setY(y * pixRatio);
|
||||
helperToolbox->setX(x);
|
||||
helperToolbox->setY(y);
|
||||
}
|
||||
|
||||
void ScreenshotGrabber::reject()
|
||||
|
|
Loading…
Reference in New Issue
Block a user