mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix thumbnailed document layout.
This commit is contained in:
parent
3f4157bab2
commit
e651699e1d
2 changed files with 45 additions and 5 deletions
|
@ -507,8 +507,16 @@ QSize Document::countOptimalSize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto minHeight = st.padding.top() + st.thumbSize + st.padding.bottom();
|
auto minHeight = st.padding.top() + st.thumbSize + st.padding.bottom();
|
||||||
if (isBubbleBottom() && !hasTranscribe && _parent->bottomInfoIsWide()) {
|
if (isBubbleBottom() && !hasTranscribe) {
|
||||||
minHeight += st::msgDateFont->height - st::msgDateDelta.y();
|
if (const auto link = thumbedLinkMaxWidth()) {
|
||||||
|
accumulate_max(
|
||||||
|
maxWidth,
|
||||||
|
(tleft
|
||||||
|
+ link
|
||||||
|
+ st.thumbSkip
|
||||||
|
+ _parent->bottomInfoFirstLineWidth()
|
||||||
|
+ tright));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!isBubbleTop()) {
|
if (!isBubbleTop()) {
|
||||||
minHeight -= st::msgFileTopMinus;
|
minHeight -= st::msgFileTopMinus;
|
||||||
|
@ -530,13 +538,30 @@ QSize Document::countCurrentSize(int newWidth) {
|
||||||
const auto captioned = Get<HistoryDocumentCaptioned>();
|
const auto captioned = Get<HistoryDocumentCaptioned>();
|
||||||
const auto voice = Get<HistoryDocumentVoice>();
|
const auto voice = Get<HistoryDocumentVoice>();
|
||||||
const auto hasTranscribe = voice && !voice->transcribeText.isEmpty();
|
const auto hasTranscribe = voice && !voice->transcribeText.isEmpty();
|
||||||
|
const auto thumbed = Get<HistoryDocumentThumbed>();
|
||||||
|
const auto &st = thumbed ? st::msgFileThumbLayout : st::msgFileLayout;
|
||||||
if (!captioned && !hasTranscribe) {
|
if (!captioned && !hasTranscribe) {
|
||||||
return File::countCurrentSize(newWidth);
|
auto result = File::countCurrentSize(newWidth);
|
||||||
|
if (isBubbleBottom()) {
|
||||||
|
if (const auto link = thumbedLinkMaxWidth()) {
|
||||||
|
const auto needed = st.padding.left()
|
||||||
|
+ st.thumbSize
|
||||||
|
+ st.thumbSkip
|
||||||
|
+ link
|
||||||
|
+ st.thumbSkip
|
||||||
|
+ _parent->bottomInfoFirstLineWidth()
|
||||||
|
+ st.padding.right();
|
||||||
|
if (result.width() < needed) {
|
||||||
|
result.setHeight(result.height()
|
||||||
|
+ st::msgDateFont->height
|
||||||
|
- st::msgDateDelta.y());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
accumulate_min(newWidth, maxWidth());
|
accumulate_min(newWidth, maxWidth());
|
||||||
const auto thumbed = Get<HistoryDocumentThumbed>();
|
|
||||||
const auto &st = thumbed ? st::msgFileThumbLayout : st::msgFileLayout;
|
|
||||||
auto newHeight = st.padding.top() + st.thumbSize + st.padding.bottom();
|
auto newHeight = st.padding.top() + st.thumbSize + st.padding.bottom();
|
||||||
if (!isBubbleTop()) {
|
if (!isBubbleTop()) {
|
||||||
newHeight -= st::msgFileTopMinus;
|
newHeight -= st::msgFileTopMinus;
|
||||||
|
@ -1382,6 +1407,20 @@ bool Document::uploading() const {
|
||||||
return _data->uploading();
|
return _data->uploading();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] int Document::thumbedLinkMaxWidth() const {
|
||||||
|
if (Has<HistoryDocumentThumbed>()) {
|
||||||
|
const auto w = [](const QString &text) {
|
||||||
|
return st::semiboldFont->width(text.toUpper());
|
||||||
|
};
|
||||||
|
return std::max({
|
||||||
|
w(tr::lng_media_download(tr::now)),
|
||||||
|
w(tr::lng_media_open_with(tr::now)),
|
||||||
|
w(tr::lng_media_cancel(tr::now)),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Document::setStatusSize(int64 newSize, TimeId realDuration) const {
|
void Document::setStatusSize(int64 newSize, TimeId realDuration) const {
|
||||||
const auto duration = (_data->isSong()
|
const auto duration = (_data->isSong()
|
||||||
|| _data->isVoiceMessage()
|
|| _data->isVoiceMessage()
|
||||||
|
|
|
@ -139,6 +139,7 @@ private:
|
||||||
|
|
||||||
void setStatusSize(int64 newSize, TimeId realDuration = 0) const;
|
void setStatusSize(int64 newSize, TimeId realDuration = 0) const;
|
||||||
bool updateStatusText() const; // returns showPause
|
bool updateStatusText() const; // returns showPause
|
||||||
|
[[nodiscard]] int thumbedLinkMaxWidth() const;
|
||||||
|
|
||||||
[[nodiscard]] bool downloadInCorner() const;
|
[[nodiscard]] bool downloadInCorner() const;
|
||||||
void drawCornerDownload(
|
void drawCornerDownload(
|
||||||
|
|
Loading…
Add table
Reference in a new issue