From d646de7184d1bd44c96cbbd8a06f963e3dcb8dd8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 15 Mar 2019 16:09:05 +0400 Subject: [PATCH] Add button to download audio files. --- .../Resources/icons/history_audio_cancel.png | Bin 0 -> 153 bytes .../icons/history_audio_cancel@2x.png | Bin 0 -> 251 bytes .../icons/history_audio_cancel@3x.png | Bin 0 -> 487 bytes .../icons/history_audio_download.png | Bin 0 -> 160 bytes .../icons/history_audio_download@2x.png | Bin 0 -> 221 bytes .../icons/history_audio_download@3x.png | Bin 0 -> 453 bytes Telegram/SourceFiles/config.h | 2 - Telegram/SourceFiles/data/data_user.cpp | 7 +- Telegram/SourceFiles/history/history.style | 13 +++ .../history/media/history_media_document.cpp | 89 ++++++++++++++++-- .../history/media/history_media_document.h | 6 ++ .../history/media/history_media_video.cpp | 4 +- .../info/media/info_media_list_widget.cpp | 2 + Telegram/SourceFiles/overview/overview.style | 4 + .../SourceFiles/overview/overview_layout.cpp | 83 ++++++++++++++-- .../SourceFiles/overview/overview_layout.h | 10 +- 16 files changed, 193 insertions(+), 27 deletions(-) create mode 100644 Telegram/Resources/icons/history_audio_cancel.png create mode 100644 Telegram/Resources/icons/history_audio_cancel@2x.png create mode 100644 Telegram/Resources/icons/history_audio_cancel@3x.png create mode 100644 Telegram/Resources/icons/history_audio_download.png create mode 100644 Telegram/Resources/icons/history_audio_download@2x.png create mode 100644 Telegram/Resources/icons/history_audio_download@3x.png diff --git a/Telegram/Resources/icons/history_audio_cancel.png b/Telegram/Resources/icons/history_audio_cancel.png new file mode 100644 index 0000000000000000000000000000000000000000..07a45584ad266eb6762959b59c492f4d3628bc95 GIT binary patch literal 153 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a)41Wy;o5RHjj0}pZ@aNzLX-S*r5 z?qSywUT-;Dn?CKW7iy-=NI1gmu&8mfvYY7&tvj`X6CST=nt18%Ks0kb?e2%c}t zy4A6{_RDvV{C>HKXLtk|1tnMCoc#FBvGeoU3K$!k7bwbwU3LT7#o+1c=d#Wzp$Py2 CF*$Jn literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/history_audio_cancel@2x.png b/Telegram/Resources/icons/history_audio_cancel@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..d0e29cc060501324c9a50e2f7097e171d5381f7c GIT binary patch literal 251 zcmVc3$BnGfGnrMZz=(E^RSdIBM;o@CznO!_X!Iw-zVCLIj z*kyOZmk@$Pi}c+l7|{VS)B)9r1?2m_2!cRZmZd!aYQiv-9$b+sJkO*1{Z7zkvmwi} zl=;tr+$f4BuyImy|?rpbQWi7n5f#&l$U9VTA@qWLj!C>%HgKOMV z37+saT0%iy%Aus^vO(ADA8tKB2_TfrIGB|mr z(t10XhE`0O?)v%HMcwqXM=dAhU`M%G}@BV(&sROE0 d2c(n`;sK!Eh5N@PW#a$<002ovPDHLkV1m>W;}rk^ literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/history_audio_download.png b/Telegram/Resources/icons/history_audio_download.png new file mode 100644 index 0000000000000000000000000000000000000000..43fdd0df6c54e9b215696c28f689e429608e9e50 GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a)4bWaz@5RHjjCk1jbC~~+Q-#dT$ zRppWmkvv^z@3h*LIcU^6YjH9>a=6afbLv7A^GUhFbGM?nK4=R5tb4d)X+2Mx8T(nO z%JTV37i6T>Ox|6drjrq;72Fi=Y$j@OdcC0W(SM<(x(quQ73(V)e-tFVdQ I&MBb@0CPJxbpQYW literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/history_audio_download@2x.png b/Telegram/Resources/icons/history_audio_download@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..6eec8fbe66080b0fa45becbc1cfa6083871b2baf GIT binary patch literal 221 zcmV<303!d1P)DW$b9TGa!10P7n1z^nPFzI$VM0TC^m*IIXHLu(U}IT}1M z^U=82&yOn*!~7U<7BVrn0a1u!J_mS^fVmH_AVKpO;1_bjT(@X_x7I#;&Kb-cO9Jo) Xmp!!cvY5lI00000NkvXXu0mjfaaLIh literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/history_audio_download@3x.png b/Telegram/Resources/icons/history_audio_download@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..673bf2eeace9f9567b9a3461d8f4db2681eb945c GIT binary patch literal 453 zcmV;$0XqJPP)=b1&cZGstn1=1Tyy;LBC;K#7NQM@Yp@n2YdZpoT`0!dPBn<`wBuSzi#JI$94A*s^g|x@Xt>5qCa=E-+CW<0Bj`J!tK97^V zUJqdyzD?$QKBL?1%3|#6jN9pSa5|lG%N&nK*tV^btL4GF-EQM>IAoUD@Aqi6TB<=` ztqnArP3(3%w#;_BMWfN+G!ONPQm@ys*=&?$*6THDwHmhy@p@CWTE%L$lFInLk4mM& zmEjACu`CPAj#MMOk*hs)MPBm8+p00000NkvXXu0mjffeO-X literal 0 HcmV?d00001 diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h index 28b74fe82..f59991274 100644 --- a/Telegram/SourceFiles/config.h +++ b/Telegram/SourceFiles/config.h @@ -61,8 +61,6 @@ enum { MaxMessageSize = 4096, - SetOnlineAfterActivity = 30, // user with hidden last seen stays online for such amount of seconds in the interface - WebPageUserId = 701000, UpdateDelayConstPart = 8 * 3600, // 8 hour min time between update check requests diff --git a/Telegram/SourceFiles/data/data_user.cpp b/Telegram/SourceFiles/data/data_user.cpp index acecd1830..a77c8a852 100644 --- a/Telegram/SourceFiles/data/data_user.cpp +++ b/Telegram/SourceFiles/data/data_user.cpp @@ -15,6 +15,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { +// User with hidden last seen stays online in UI for such amount of seconds. +constexpr auto kSetOnlineAfterActivity = TimeId(30); + using UpdateFlag = Notify::PeerUpdate::Flag; } // namespace @@ -213,10 +216,10 @@ void UserData::madeAction(TimeId when) { if (isBot() || isServiceUser() || when <= 0) { return; } else if (onlineTill <= 0 && -onlineTill < when) { - onlineTill = -when - SetOnlineAfterActivity; + onlineTill = -when - kSetOnlineAfterActivity; Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::UserOnlineChanged); } else if (onlineTill > 0 && onlineTill < when + 1) { - onlineTill = when + SetOnlineAfterActivity; + onlineTill = when + kSetOnlineAfterActivity; Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::UserOnlineChanged); } } diff --git a/Telegram/SourceFiles/history/history.style b/Telegram/SourceFiles/history/history.style index 0e9176cf8..0c03fd4cd 100644 --- a/Telegram/SourceFiles/history/history.style +++ b/Telegram/SourceFiles/history/history.style @@ -559,3 +559,16 @@ historyVideoCancel: icon {{ "playlist_cancel", historyFileThumbIconFg }}; historyVideoCancelSelected: icon {{ "playlist_cancel", historyFileThumbIconFgSelected }}; historyVideoDownload: icon {{ "playlist_download", historyFileThumbIconFg }}; historyVideoDownloadSelected: icon {{ "playlist_download", historyFileThumbIconFgSelected }}; +historyVideoRadialLine: 2px; + +historyAudioDownloadSize: 20px; +historyAudioRadialLine: 2px; +historyAudioDownloadShift: 28px; +historyAudioInCancel: icon {{ "history_audio_cancel", historyFileInIconFg }}; +historyAudioInCancelSelected: icon {{ "history_audio_cancel", historyFileInIconFgSelected }}; +historyAudioOutCancel: icon {{ "history_audio_cancel", historyFileOutIconFg }}; +historyAudioOutCancelSelected: icon {{ "history_audio_cancel", historyFileOutIconFgSelected }}; +historyAudioInDownload: icon {{ "history_audio_download", historyFileInIconFg }}; +historyAudioInDownloadSelected: icon {{ "history_audio_download", historyFileInIconFgSelected }}; +historyAudioOutDownload: icon {{ "history_audio_download", historyFileOutIconFg }}; +historyAudioOutDownloadSelected: icon {{ "history_audio_download", historyFileOutIconFgSelected }}; diff --git a/Telegram/SourceFiles/history/media/history_media_document.cpp b/Telegram/SourceFiles/history/media/history_media_document.cpp index 69fb970c0..c7c5ac046 100644 --- a/Telegram/SourceFiles/history/media/history_media_document.cpp +++ b/Telegram/SourceFiles/history/media/history_media_document.cpp @@ -206,6 +206,8 @@ QSize HistoryDocument::countCurrentSize(int newWidth) { void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; + const auto cornerDownload = downloadInCorner(); + _data->automaticLoad(_realParent->fullId(), _parent->data()); bool loaded = _data->loaded(), displayLoading = _data->displayLoading(); bool selected = (selection == FullSelection); @@ -313,14 +315,8 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, p.drawEllipse(inner); } - if (radial) { - QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine))); - auto fg = outbg ? (selected ? st::historyFileOutRadialFgSelected : st::historyFileOutRadialFg) : (selected ? st::historyFileInRadialFgSelected : st::historyFileInRadialFg); - _animation->radial.draw(p, rinner, st::msgFileRadialLine, fg); - } - - auto icon = [&] { - if (_data->loading() || _data->uploading()) { + const auto icon = [&] { + if (!cornerDownload && (_data->loading() || _data->uploading())) { return &(outbg ? (selected ? st::historyFileOutCancelSelected : st::historyFileOutCancel) : (selected ? st::historyFileInCancelSelected : st::historyFileInCancel)); } else if (showPause) { return &(outbg ? (selected ? st::historyFileOutPauseSelected : st::historyFileOutPause) : (selected ? st::historyFileInPauseSelected : st::historyFileInPause)); @@ -335,6 +331,14 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, return &(outbg ? (selected ? st::historyFileOutDownloadSelected : st::historyFileOutDownload) : (selected ? st::historyFileInDownloadSelected : st::historyFileInDownload)); }(); icon->paintInCenter(p, inner); + + if (radial && !cornerDownload) { + QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine))); + auto fg = outbg ? (selected ? st::historyFileOutRadialFgSelected : st::historyFileOutRadialFg) : (selected ? st::historyFileInRadialFgSelected : st::historyFileInRadialFg); + _animation->radial.draw(p, rinner, st::msgFileRadialLine, fg); + } + + drawCornerDownload(p, selected); } auto namewidth = width() - nameleft - nameright; auto statuswidth = namewidth; @@ -449,6 +453,68 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, } } +bool HistoryDocument::downloadInCorner() const { + return _data->isAudioFile() + && _data->canBeStreamed() + && !_data->inappPlaybackFailed() + && IsServerMsgId(_parent->data()->id); +} + +void HistoryDocument::drawCornerDownload(Painter &p, bool selected) const { + if (_data->loaded() || !downloadInCorner()) { + return; + } + auto outbg = _parent->hasOutLayout(); + auto topMinus = isBubbleTop() ? 0 : st::msgFileTopMinus; + const auto shift = st::historyAudioDownloadShift; + const auto size = st::historyAudioDownloadSize; + const auto inner = rtlrect(st::msgFilePadding.left() + shift, st::msgFilePadding.top() - topMinus + shift, size, size, width()); + auto pen = (selected + ? (outbg ? st::msgOutBgSelected : st::msgInBgSelected) + : (outbg ? st::msgOutBg : st::msgInBg))->p; + pen.setWidth(st::lineWidth); + p.setPen(pen); + if (selected) { + p.setBrush(outbg ? st::msgFileOutBgSelected : st::msgFileInBgSelected); + } else { + p.setBrush(outbg ? st::msgFileOutBg : st::msgFileInBg); + } + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } + const auto icon = [&] { + if (_data->loading()) { + return &(outbg ? (selected ? st::historyAudioOutCancelSelected : st::historyAudioOutCancel) : (selected ? st::historyAudioInCancelSelected : st::historyAudioInCancel)); + } + return &(outbg ? (selected ? st::historyAudioOutDownloadSelected : st::historyAudioOutDownload) : (selected ? st::historyAudioInDownloadSelected : st::historyAudioInDownload)); + }(); + icon->paintInCenter(p, inner); + if (_animation && _animation->radial.animating()) { + const auto rinner = inner.marginsRemoved(QMargins(st::historyAudioRadialLine, st::historyAudioRadialLine, st::historyAudioRadialLine, st::historyAudioRadialLine)); + auto fg = outbg ? (selected ? st::historyFileOutRadialFgSelected : st::historyFileOutRadialFg) : (selected ? st::historyFileInRadialFgSelected : st::historyFileInRadialFg); + _animation->radial.draw(p, rinner, st::historyAudioRadialLine, fg); + } +} + +TextState HistoryDocument::cornerDownloadTextState( + QPoint point, + StateRequest request) const { + auto result = TextState(_parent); + if (!downloadInCorner() || _data->loaded()) { + return result; + } + auto topMinus = isBubbleTop() ? 0 : st::msgFileTopMinus; + const auto shift = st::historyAudioDownloadShift; + const auto size = st::historyAudioDownloadSize; + const auto inner = rtlrect(st::msgFilePadding.left() + shift, st::msgFilePadding.top() - topMinus + shift, size, size, width()); + if (inner.contains(point)) { + result.link = _data->loading() ? _cancell : _savel; + } + return result; + +} + TextState HistoryDocument::textState(QPoint point, StateRequest request) const { auto result = TextState(_parent); @@ -491,8 +557,11 @@ TextState HistoryDocument::textState(QPoint point, StateRequest request) const { nametop = st::msgFileNameTop - topMinus; bottom = st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom() - topMinus; + if (const auto state = cornerDownloadTextState(point, request); state.link) { + return state; + } QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top() - topMinus, st::msgFileSize, st::msgFileSize, width())); - if ((_data->loading() || _data->uploading()) && inner.contains(point)) { + if ((_data->loading() || _data->uploading()) && inner.contains(point) && !downloadInCorner()) { result.link = _cancell; return result; } @@ -530,7 +599,7 @@ TextState HistoryDocument::textState(QPoint point, StateRequest request) const { } } if (QRect(0, 0, width(), painth).contains(point) - && !_data->loading() + && (!_data->loading() || downloadInCorner()) && !_data->uploading() && !_data->isNull()) { if (loaded || _data->canBePlayed()) { diff --git a/Telegram/SourceFiles/history/media/history_media_document.h b/Telegram/SourceFiles/history/media/history_media_document.h index 2f862e02a..026910577 100644 --- a/Telegram/SourceFiles/history/media/history_media_document.h +++ b/Telegram/SourceFiles/history/media/history_media_document.h @@ -76,6 +76,12 @@ private: void setStatusSize(int newSize, qint64 realDuration = 0) const; bool updateStatusText() const; // returns showPause + [[nodiscard]] bool downloadInCorner() const; + void drawCornerDownload(Painter &p, bool selected) const; + [[nodiscard]] TextState cornerDownloadTextState( + QPoint point, + StateRequest request) const; + not_null _data; }; diff --git a/Telegram/SourceFiles/history/media/history_media_video.cpp b/Telegram/SourceFiles/history/media/history_media_video.cpp index 1eda9b211..0111b052d 100644 --- a/Telegram/SourceFiles/history/media/history_media_video.cpp +++ b/Telegram/SourceFiles/history/media/history_media_video.cpp @@ -298,8 +298,8 @@ void HistoryVideo::drawCornerStatus(Painter &p, bool selected) const { icon->paintInCenter(p, inner); } if (radial) { - QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine))); - _animation->radial.draw(p, rinner, st::msgFileRadialLine, selected ? st::historyFileThumbRadialFgSelected : st::historyFileThumbRadialFg); + QRect rinner(inner.marginsRemoved(QMargins(st::historyVideoRadialLine, st::historyVideoRadialLine, st::historyVideoRadialLine, st::historyVideoRadialLine))); + _animation->radial.draw(p, rinner, st::historyVideoRadialLine, selected ? st::historyFileThumbRadialFgSelected : st::historyFileThumbRadialFg); } } } diff --git a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp index 816425a53..98b66ea78 100644 --- a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp @@ -79,10 +79,12 @@ public: UniversalMsgId minId() const { Expects(!empty()); + return _items.back().first; } UniversalMsgId maxId() const { Expects(!empty()); + return _items.front().first; } diff --git a/Telegram/SourceFiles/overview/overview.style b/Telegram/SourceFiles/overview/overview.style index e54ed468b..8bdadf8b2 100644 --- a/Telegram/SourceFiles/overview/overview.style +++ b/Telegram/SourceFiles/overview/overview.style @@ -74,6 +74,10 @@ overviewSongCancel: icon {{ "playlist_cancel", historyFileInIconFg }}; overviewSongCancelSelected: icon {{ "playlist_cancel", historyFileInIconFgSelected }}; overviewSongDownload: icon {{ "playlist_download", historyFileInIconFg }}; overviewSongDownloadSelected: icon {{ "playlist_download", historyFileInIconFgSelected }}; +overviewSmallCancel: icon {{ "history_audio_cancel", historyFileInIconFg }}; +overviewSmallCancelSelected: icon {{ "history_audio_cancel", historyFileInIconFgSelected }}; +overviewSmallDownload: icon {{ "history_audio_download", historyFileInIconFg }}; +overviewSmallDownloadSelected: icon {{ "history_audio_download", historyFileInIconFgSelected }}; overviewFileLayout: OverviewFileLayout { maxWidth: 520px; songPadding: margins(17px, 7px, 10px, 6px); diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index 26bc18795..d4ac8d08d 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -898,6 +898,13 @@ Document::Document( } } +bool Document::downloadInCorner() const { + return _data->isAudioFile() + && _data->canBeStreamed() + && !_data->inappPlaybackFailed() + && IsServerMsgId(parent()->id); +} + void Document::initDimensions() { _maxw = _st.maxWidth; if (_data->isSong()) { @@ -910,6 +917,8 @@ void Document::initDimensions() { void Document::paint(Painter &p, const QRect &clip, TextSelection selection, const PaintContext *context) { bool selected = (selection == FullSelection); + const auto cornerDownload = downloadInCorner(); + _data->automaticLoad(parent()->fullId(), parent()); bool loaded = _data->loaded(), displayLoading = _data->displayLoading(); @@ -938,7 +947,7 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con if (selected) { p.setBrush(st::msgFileInBgSelected); } else { - auto over = ClickHandler::showAsActive((_data->loading() || _data->uploading()) ? _cancell : (loaded || _data->canBePlayed()) ? _openl : _savel); + auto over = ClickHandler::showAsActive((!cornerDownload && (_data->loading() || _data->uploading())) ? _cancell : (loaded || _data->canBePlayed()) ? _openl : _savel); p.setBrush(anim::brush(_st.songIconBg, _st.songOverBg, _a_iconOver.current(context->ms, over ? 1. : 0.))); } @@ -947,14 +956,8 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con p.drawEllipse(inner); } - if (radial) { - auto rinner = inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine)); - auto &bg = selected ? st::historyFileInRadialFgSelected : st::historyFileInRadialFg; - _radial->draw(p, rinner, st::msgFileRadialLine, bg); - } - - auto icon = [&] { - if (_data->loading() || _data->uploading()) { + const auto icon = [&] { + if (!cornerDownload && (_data->loading() || _data->uploading())) { return &(selected ? _st.songCancelSelected : _st.songCancel); } else if (showPause) { return &(selected ? _st.songPauseSelected : _st.songPause); @@ -964,6 +967,14 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con return &(selected ? _st.songDownloadSelected : _st.songDownload); }(); icon->paintInCenter(p, inner); + + if (radial && !cornerDownload) { + auto rinner = inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine)); + auto &bg = selected ? st::historyFileInRadialFgSelected : st::historyFileInRadialFg; + _radial->draw(p, rinner, st::msgFileRadialLine, bg); + } + + drawCornerDownload(p, selected, context); } } else { nameleft = _st.fileThumbSize + _st.filePadding.right(); @@ -1073,6 +1084,56 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con paintCheckbox(p, { checkLeft, checkTop }, selected, context); } +void Document::drawCornerDownload(Painter &p, bool selected, const PaintContext *context) const { + if (_data->loaded() || !downloadInCorner()) { + return; + } + const auto size = st::overviewSmallCheck.size; + const auto shift = _st.songThumbSize + st::overviewCheckSkip - size; + const auto inner = rtlrect(_st.songPadding.left() + shift, _st.songPadding.top() + shift, size, size, _width); + auto pen = st::windowBg->p; + pen.setWidth(st::lineWidth); + p.setPen(pen); + if (selected) { + p.setBrush(st::msgFileInBgSelected); + } else { + p.setBrush(_st.songIconBg); + } + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } + const auto icon = [&] { + if (_data->loading()) { + return &(selected ? st::overviewSmallCancelSelected : st::overviewSmallCancel); + } + return &(selected ? st::overviewSmallDownloadSelected : st::overviewSmallDownload); + }(); + icon->paintInCenter(p, inner); + if (_radial && _radial->animating()) { + const auto rinner = inner.marginsRemoved(QMargins(st::historyAudioRadialLine, st::historyAudioRadialLine, st::historyAudioRadialLine, st::historyAudioRadialLine)); + auto fg = selected ? st::historyFileThumbRadialFgSelected : st::historyFileThumbRadialFg; + _radial->draw(p, rinner, st::historyAudioRadialLine, fg); + } +} + +TextState Document::cornerDownloadTextState( + QPoint point, + StateRequest request) const { + auto result = TextState(parent()); + if (!downloadInCorner() || _data->loaded()) { + return result; + } + const auto size = st::overviewSmallCheck.size; + const auto shift = _st.songThumbSize + st::overviewCheckSkip - size; + const auto inner = rtlrect(_st.songPadding.left() + shift, _st.songPadding.top() + shift, size, size, _width); + if (inner.contains(point)) { + result.link = _data->loading() ? _cancell : _savel; + } + return result; + +} + TextState Document::getState( QPoint point, StateRequest request) const { @@ -1088,6 +1149,10 @@ TextState Document::getState( const auto nametop = _st.songNameTop; const auto statustop = _st.songStatusTop; + if (const auto state = cornerDownloadTextState(point, request); state.link) { + return state; + } + const auto inner = rtlrect( _st.songPadding.left(), _st.songPadding.top(), diff --git a/Telegram/SourceFiles/overview/overview_layout.h b/Telegram/SourceFiles/overview/overview_layout.h index ee58eea6f..621ab190f 100644 --- a/Telegram/SourceFiles/overview/overview_layout.h +++ b/Telegram/SourceFiles/overview/overview_layout.h @@ -29,9 +29,9 @@ class Checkbox; class PaintContext : public PaintContextBase { public: - PaintContext(crl::time ms, bool selecting) : PaintContextBase(ms, selecting), isAfterDate(false) { + PaintContext(crl::time ms, bool selecting) : PaintContextBase(ms, selecting) { } - bool isAfterDate; + bool isAfterDate = false; }; @@ -310,6 +310,12 @@ protected: const style::RoundCheckbox &checkboxStyle() const override; private: + [[nodiscard]] bool downloadInCorner() const; + void drawCornerDownload(Painter &p, bool selected, const PaintContext *context) const; + [[nodiscard]] TextState cornerDownloadTextState( + QPoint point, + StateRequest request) const; + not_null _data; StatusText _status; ClickHandlerPtr _msgl, _namel;