kcms/screenedges: Slightly refactor monitor size calculation

It doesn't need width when it's going to be scaled with KeepAspectRatio
to some other rectangle anyway, so using constant 1.0 makes it clearer.
This commit is contained in:
ivan tkachenko 2023-10-16 21:29:17 +03:00
parent c5d692843f
commit 6c67b73b7d
No known key found for this signature in database
GPG key ID: AF72731B7C654CB3

View file

@ -39,16 +39,16 @@ public:
void updateScreenGraphics() void updateScreenGraphics()
{ {
int bottomElements = screenGraphics->elementSize("base").height() + screenGraphics->marginSize(KSvg::FrameSvg::BottomMargin); int bottomElements = screenGraphics->elementSize("base").height() + screenGraphics->marginSize(KSvg::FrameSvg::BottomMargin);
QRect bounds(QPoint(0, 0), QSize(q->size().width(), q->height() - bottomElements)); QRect bounds(QPoint(0, 0), QSize(q->width(), q->height() - bottomElements));
QSize monitorSize(q->size().width(), q->size().width() / ratio); QSizeF monitorSize(1.0, 1.0 / ratio);
monitorSize.scale(bounds.size(), Qt::KeepAspectRatio); monitorSize.scale(bounds.size(), Qt::KeepAspectRatio);
if (monitorSize.isEmpty()) { if (monitorSize.isEmpty()) {
return; return;
} }
monitorRect = QRect(QPoint(0, 0), monitorSize); monitorRect = QRect(QPoint(0, 0), monitorSize.toSize());
monitorRect.moveCenter(bounds.center()); monitorRect.moveCenter(bounds.center());
screenGraphics->resizeFrame(monitorRect.size()); screenGraphics->resizeFrame(monitorRect.size());