Fix upload progress and message time display.

Fixes #6909.
This commit is contained in:
John Preston 2019-12-30 13:38:36 +03:00
parent 57b27d217c
commit 4aaecfd531
2 changed files with 19 additions and 13 deletions

View File

@ -253,7 +253,7 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
const auto item = _parent->data(); const auto item = _parent->data();
const auto displayLoading = (item->id < 0) || _data->displayLoading(); const auto displayLoading = item->isSending() || _data->displayLoading();
const auto selected = (selection == FullSelection); const auto selected = (selection == FullSelection);
const auto autoPaused = App::wnd()->sessionController()->isGifPausedAtLeastFor(Window::GifPauseReason::Any); const auto autoPaused = App::wnd()->sessionController()->isGifPausedAtLeastFor(Window::GifPauseReason::Any);
const auto cornerDownload = downloadInCorner(); const auto cornerDownload = downloadInCorner();
@ -294,6 +294,7 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms
if (displayLoading if (displayLoading
&& (!streamedForWaiting && (!streamedForWaiting
|| item->isSending() || item->isSending()
|| _data->uploading()
|| (cornerDownload && _data->loading()))) { || (cornerDownload && _data->loading()))) {
ensureAnimation(); ensureAnimation();
if (!_animation->radial.animating()) { if (!_animation->radial.animating()) {
@ -595,8 +596,8 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms
fullRight = maxRight; fullRight = maxRight;
} }
} }
if (isRound) { if (isRound || needInfoDisplay()) {
_parent->drawInfo(p, fullRight, fullBottom, 2 * paintx + paintw, selected, InfoDisplayType::Background); _parent->drawInfo(p, fullRight, fullBottom, 2 * paintx + paintw, selected, isRound ? InfoDisplayType::Background : InfoDisplayType::Image);
} }
if (!bubble && _parent->displayRightAction()) { if (!bubble && _parent->displayRightAction()) {
auto fastShareLeft = (fullRight + st::historyFastShareLeft); auto fastShareLeft = (fullRight + st::historyFastShareLeft);
@ -611,7 +612,7 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms
} }
void Gif::drawCornerStatus(Painter &p, bool selected, QPoint position) const { void Gif::drawCornerStatus(Painter &p, bool selected, QPoint position) const {
if (!needInfoDisplay()) { if (!needCornerStatusDisplay()) {
return; return;
} }
const auto own = activeOwnStreamed(); const auto own = activeOwnStreamed();
@ -662,7 +663,7 @@ TextState Gif::cornerStatusTextState(
StateRequest request, StateRequest request,
QPoint position) const { QPoint position) const {
auto result = TextState(_parent); auto result = TextState(_parent);
if (!needInfoDisplay() || !downloadInCorner() || _data->loaded()) { if (!needCornerStatusDisplay() || !downloadInCorner() || _data->loaded()) {
return result; return result;
} }
const auto padding = st::msgDateImgPadding; const auto padding = st::msgDateImgPadding;
@ -1430,10 +1431,14 @@ bool Gif::dataLoaded() const {
} }
bool Gif::needInfoDisplay() const { bool Gif::needInfoDisplay() const {
return _data->isVideoFile() return _parent->data()->isSending()
|| _parent->data()->isSending()
|| _data->uploading() || _data->uploading()
|| _parent->isUnderCursor(); || _parent->isUnderCursor();
} }
bool Gif::needCornerStatusDisplay() const {
return _data->isVideoFile()
|| needInfoDisplay();
}
} // namespace HistoryView } // namespace HistoryView

View File

@ -135,14 +135,15 @@ private:
void streamingReady(::Media::Streaming::Information &&info); void streamingReady(::Media::Streaming::Information &&info);
void repaintStreamedContent(); void repaintStreamedContent();
bool needInfoDisplay() const; [[nodiscard]] bool needInfoDisplay() const;
int additionalWidth( [[nodiscard]] bool needCornerStatusDisplay() const;
[[nodiscard]] int additionalWidth(
const HistoryMessageVia *via, const HistoryMessageVia *via,
const HistoryMessageReply *reply, const HistoryMessageReply *reply,
const HistoryMessageForwarded *forwarded) const; const HistoryMessageForwarded *forwarded) const;
int additionalWidth() const; [[nodiscard]] int additionalWidth() const;
QString mediaTypeString() const; [[nodiscard]] QString mediaTypeString() const;
bool isSeparateRoundVideo() const; [[nodiscard]] bool isSeparateRoundVideo() const;
void validateGroupedCache( void validateGroupedCache(
const QRect &geometry, const QRect &geometry,
@ -151,7 +152,7 @@ private:
not_null<QPixmap*> cache) const; not_null<QPixmap*> cache) const;
void setStatusSize(int newSize) const; void setStatusSize(int newSize) const;
void updateStatusText() const; void updateStatusText() const;
QSize sizeForAspectRatio() const; [[nodiscard]] QSize sizeForAspectRatio() const;
[[nodiscard]] bool downloadInCorner() const; [[nodiscard]] bool downloadInCorner() const;
void drawCornerStatus(Painter &p, bool selected, QPoint position) const; void drawCornerStatus(Painter &p, bool selected, QPoint position) const;