Fix non-streamable videos layout.

This commit is contained in:
John Preston 2019-03-11 09:36:06 +04:00
parent 2ce4abfdfe
commit a886c598c1
4 changed files with 14 additions and 14 deletions

View File

@ -236,7 +236,7 @@ void HistoryVideo::draw(Painter &p, const QRect &r, TextSelection selection, crl
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
} else if (!IsServerMsgId(_parent->data()->id)) {
return nullptr;
} else if (_data->canBePlayed()) {
} else if (loaded || _data->canBePlayed()) {
return &(selected ? st::historyFileThumbPlaySelected : st::historyFileThumbPlay);
}
return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload);
@ -303,7 +303,7 @@ TextState HistoryVideo::textState(QPoint point, StateRequest request) const {
if (_data->loading() || _data->uploading()) {
result.link = _cancell;
} else if (!IsServerMsgId(_parent->data()->id)) {
} else if (_data->canBePlayed()) {
} else if (_data->loaded() || _data->canBePlayed()) {
result.link = _openl;
} else {
result.link = _savel;
@ -395,7 +395,6 @@ void HistoryVideo::drawGrouped(
p.drawEllipse(inner);
}
const auto canPlay = _data->canBePlayed();
auto icon = [&]() -> const style::icon * {
if (_data->waitingForAlbum()) {
return &(selected ? st::historyFileThumbWaitingSelected : st::historyFileThumbWaiting);
@ -403,7 +402,7 @@ void HistoryVideo::drawGrouped(
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
} else if (!IsServerMsgId(_realParent->id)) {
return nullptr;
} else if (_data->canBePlayed()) {
} else if (loaded || _data->canBePlayed()) {
return &(selected ? st::historyFileThumbPlaySelected : st::historyFileThumbPlay);
}
return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload);
@ -444,7 +443,7 @@ TextState HistoryVideo::getStateGrouped(
? _cancell
: !IsServerMsgId(_realParent->id)
? nullptr
: _data->canBePlayed()
: (_data->loaded() || _data->canBePlayed())
? _openl
: _savel);
}

View File

@ -1741,7 +1741,9 @@ void OverlayWidget::displayDocument(DocumentData *doc, HistoryItem *item) {
const auto documentChanged = !doc
|| (doc != _doc)
|| (item && item->fullId() != _msgid);
if (documentChanged || (!doc->isAnimation() && !doc->isVideoFile())) {
if (documentChanged
|| (!doc->isAnimation() && !doc->isVideoFile())
|| !doc->canBePlayed()) {
_fullScreenVideo = false;
_current = QPixmap();
clearStreaming();

View File

@ -112,6 +112,7 @@ int TcpConnection::Protocol::Version0::readPacketLength(
if (bytes.empty()) {
return kUnknownSize;
}
const auto first = static_cast<char>(bytes[0]);
if (first == 0x7F) {
if (bytes.size() < 4) {

View File

@ -492,7 +492,7 @@ void Video::paint(Painter &p, const QRect &clip, TextSelection selection, const
if (selected) {
p.setBrush(st::msgDateImgBgSelected);
} else {
auto over = ClickHandler::showAsActive((_data->loading() || _data->uploading()) ? _cancell : _data->canBePlayed() ? _openl : _savel);
auto over = ClickHandler::showAsActive((_data->loading() || _data->uploading()) ? _cancell : (loaded || _data->canBePlayed()) ? _openl : _savel);
p.setBrush(anim::brush(st::msgDateImgBg, st::msgDateImgBgOver, _a_iconOver.current(context->ms, over ? 1. : 0.)));
}
@ -505,7 +505,7 @@ void Video::paint(Painter &p, const QRect &clip, TextSelection selection, const
const auto icon = [&] {
if (_data->loading() || _data->uploading()) {
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
} else if (_data->canBePlayed()) {
} else if (loaded || _data->canBePlayed()) {
return &(selected ? st::historyFileThumbPlaySelected : st::historyFileThumbPlay);
}
return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload);
@ -543,12 +543,10 @@ bool Video::iconAnimated() const {
TextState Video::getState(
QPoint point,
StateRequest request) const {
bool loaded = _data->loaded();
if (hasPoint(point)) {
const auto link = (_data->loading() || _data->uploading())
? _cancell
: _data->canBePlayed()
: (_data->loaded() || _data->canBePlayed())
? _openl
: _savel;
return { parent(), link };
@ -944,7 +942,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 : _data->canBePlayed() ? _openl : _openl);
auto over = ClickHandler::showAsActive((_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.)));
}
@ -964,7 +962,7 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con
return &(selected ? _st.songCancelSelected : _st.songCancel);
} else if (showPause) {
return &(selected ? _st.songPauseSelected : _st.songPause);
} else if (_data->canBePlayed()) {
} else if (loaded || _data->canBePlayed()) {
return &(selected ? _st.songPlaySelected : _st.songPlay);
}
return &(selected ? _st.songDownloadSelected : _st.songDownload);
@ -1103,7 +1101,7 @@ TextState Document::getState(
if (inner.contains(point)) {
const auto link = (_data->loading() || _data->uploading())
? _cancell
: _data->canBePlayed()
: (loaded || _data->canBePlayed())
? _openl
: _savel;
return { parent(), link };