Fix first media viewer open zoom.

This commit is contained in:
John Preston 2020-11-18 14:11:23 +03:00
parent 4a73bb7872
commit b2047c9558

View file

@ -965,9 +965,9 @@ void OverlayWidget::resizeContentByScreenSize() {
const auto availableWidth = width(); const auto availableWidth = width();
const auto availableHeight = height() - 2 * skipHeight; const auto availableHeight = height() - 2 * skipHeight;
const auto countZoomFor = [&](int outerw, int outerh) { const auto countZoomFor = [&](int outerw, int outerh) {
auto result = float64(outerw) / _w; auto result = float64(outerw) / _width;
if (_h * result > outerh) { if (_height * result > outerh) {
result = float64(outerh) / _h; result = float64(outerh) / _height;
} }
if (result >= 1.) { if (result >= 1.) {
result -= 1.; result -= 1.;
@ -976,7 +976,7 @@ void OverlayWidget::resizeContentByScreenSize() {
} }
return result; return result;
}; };
if (_w > 0 && _h > 0) { if (_width > 0 && _height > 0) {
_zoomToDefault = countZoomFor(availableWidth, availableHeight); _zoomToDefault = countZoomFor(availableWidth, availableHeight);
_zoomToScreen = countZoomFor(width(), height()); _zoomToScreen = countZoomFor(width(), height());
} else { } else {
@ -984,15 +984,15 @@ void OverlayWidget::resizeContentByScreenSize() {
} }
const auto usew = _fullScreenVideo ? width() : availableWidth; const auto usew = _fullScreenVideo ? width() : availableWidth;
const auto useh = _fullScreenVideo ? height() : availableHeight; const auto useh = _fullScreenVideo ? height() : availableHeight;
if ((_w > usew) || (_h > useh) || _fullScreenVideo) { if ((_width > usew) || (_height > useh) || _fullScreenVideo) {
const auto use = _fullScreenVideo ? _zoomToScreen : _zoomToDefault; const auto use = _fullScreenVideo ? _zoomToScreen : _zoomToDefault;
_zoom = kZoomToScreenLevel; _zoom = kZoomToScreenLevel;
if (use >= 0) { if (use >= 0) {
_w = qRound(_w * (use + 1)); _w = qRound(_width * (use + 1));
_h = qRound(_h * (use + 1)); _h = qRound(_height * (use + 1));
} else { } else {
_w = qRound(_w / (-use + 1)); _w = qRound(_width / (-use + 1));
_h = qRound(_h / (-use + 1)); _h = qRound(_height / (-use + 1));
} }
} else { } else {
_zoom = 0; _zoom = 0;