Fix small photo display in wide enough chat.

Fixes #28004.
This commit is contained in:
John Preston 2024-06-03 14:14:42 +04:00
parent f817504d67
commit eafc01e02b
2 changed files with 8 additions and 3 deletions

View File

@ -163,6 +163,9 @@ QSize ExtendedPreview::countCurrentSize(int newWidth) {
_parent->textualMaxWidth());
newWidth = qMin(qMax(newWidth, maxWithCaption), thumbMaxWidth);
}
if (newWidth >= maxWidth()) {
newHeight = qMin(newHeight, minHeight());
}
return { newWidth, newHeight };
}

View File

@ -218,7 +218,6 @@ QSize Photo::countCurrentSize(int newWidth) {
maxWidth());
newWidth = qMax(pix.width(), minWidth);
auto newHeight = qMax(pix.height(), st::minPhotoSize);
auto imageHeight = newHeight;
if (_parent->hasBubble()) {
auto captionMaxWidth = _parent->textualMaxWidth();
const auto botTop = _parent->Get<FakeBotAboutTop>();
@ -227,10 +226,13 @@ QSize Photo::countCurrentSize(int newWidth) {
}
const auto maxWithCaption = qMin(st::msgMaxWidth, captionMaxWidth);
newWidth = qMin(qMax(newWidth, maxWithCaption), thumbMaxWidth);
imageHeight = newHeight = adjustHeightForLessCrop(
newHeight = adjustHeightForLessCrop(
dimensions,
{ newWidth, newHeight });
}
if (newWidth >= maxWidth()) {
newHeight = qMin(newHeight, minHeight());
}
const auto enlargeInner = st::historyPageEnlargeSize;
const auto enlargeOuter = 2 * st::historyPageEnlargeSkip + enlargeInner;
const auto showEnlarge = (_parent->media() != this)
@ -238,7 +240,7 @@ QSize Photo::countCurrentSize(int newWidth) {
&& _parent->data()->media()->webpage()
&& _parent->data()->media()->webpage()->suggestEnlargePhoto()
&& (newWidth >= enlargeOuter)
&& (imageHeight >= enlargeOuter);
&& (newHeight >= enlargeOuter);
_showEnlarge = showEnlarge ? 1 : 0;
return { newWidth, newHeight };
}