mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-26 19:14:02 +02:00
Fix layout of some media, enable GIF autoplay.
This commit is contained in:
parent
d326c7e3fa
commit
e6baf8ef5b
17 changed files with 66 additions and 194 deletions
|
@ -970,6 +970,7 @@ bool DocumentData::setRemoteVersion(int32 version) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentData::setRemoteLocation(int32 dc, uint64 access) {
|
void DocumentData::setRemoteLocation(int32 dc, uint64 access) {
|
||||||
|
if (_dc != dc || _access != access) {
|
||||||
_dc = dc;
|
_dc = dc;
|
||||||
_access = access;
|
_access = access;
|
||||||
if (isValid()) {
|
if (isValid()) {
|
||||||
|
@ -979,6 +980,7 @@ void DocumentData::setRemoteLocation(int32 dc, uint64 access) {
|
||||||
_location = Local::readFileLocation(mediaKey());
|
_location = Local::readFileLocation(mediaKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentData::setContentUrl(const QString &url) {
|
void DocumentData::setContentUrl(const QString &url) {
|
||||||
|
|
|
@ -850,7 +850,7 @@ QString MediaWebPage::pinnedTextSubstring() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MediaWebPage::allowsEdit() const {
|
bool MediaWebPage::allowsEdit() const {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MediaWebPage::updateInlineResultMedia(const MTPMessageMedia &media) {
|
bool MediaWebPage::updateInlineResultMedia(const MTPMessageMedia &media) {
|
||||||
|
|
|
@ -786,7 +786,6 @@ void Session::documentConvert(
|
||||||
}
|
}
|
||||||
documentApplyFields(original, data);
|
documentApplyFields(original, data);
|
||||||
if (idChanged) {
|
if (idChanged) {
|
||||||
// #TODO check audio, sticker, GIF animation, saved GIF?..
|
|
||||||
const auto newKey = original->mediaKey();
|
const auto newKey = original->mediaKey();
|
||||||
if (oldKey != newKey) {
|
if (oldKey != newKey) {
|
||||||
if (original->isVoiceMessage()) {
|
if (original->isVoiceMessage()) {
|
||||||
|
@ -842,7 +841,6 @@ void Session::documentApplyFields(
|
||||||
document->setattributes(attributes);
|
document->setattributes(attributes);
|
||||||
document->setRemoteVersion(version);
|
document->setRemoteVersion(version);
|
||||||
if (dc != 0 && access != 0) {
|
if (dc != 0 && access != 0) {
|
||||||
// #TODO was "!document->isValid()" - check if it is fine for convert
|
|
||||||
document->setRemoteLocation(dc, access);
|
document->setRemoteLocation(dc, access);
|
||||||
}
|
}
|
||||||
document->date = date;
|
document->date = date;
|
||||||
|
|
|
@ -242,11 +242,8 @@ bool isLayerShown() {
|
||||||
void autoplayMediaInlineAsync(const FullMsgId &msgId) {
|
void autoplayMediaInlineAsync(const FullMsgId &msgId) {
|
||||||
if (auto main = App::main()) {
|
if (auto main = App::main()) {
|
||||||
InvokeQueued(main, [msgId] {
|
InvokeQueued(main, [msgId] {
|
||||||
if (auto item = App::histItemById(msgId)) {
|
if (const auto item = App::histItemById(msgId)) {
|
||||||
// #TODO GIFs
|
Auth().data().requestItemPlayInline(item);
|
||||||
//if (auto media = item->getMedia()) {
|
|
||||||
// media->playInline(true);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1462,7 +1462,6 @@ void History::addItemToBlock(not_null<HistoryItem*> item) {
|
||||||
HistoryInner::ElementDelegate()));
|
HistoryInner::ElementDelegate()));
|
||||||
const auto view = block->messages.back().get();
|
const auto view = block->messages.back().get();
|
||||||
view->attachToBlock(block, block->messages.size() - 1);
|
view->attachToBlock(block, block->messages.size() - 1);
|
||||||
view->previousInBlocksChanged();
|
|
||||||
|
|
||||||
if (isBuildingFrontBlock() && _buildingFrontBlock->expectedItemsCount > 0) {
|
if (isBuildingFrontBlock() && _buildingFrontBlock->expectedItemsCount > 0) {
|
||||||
--_buildingFrontBlock->expectedItemsCount;
|
--_buildingFrontBlock->expectedItemsCount;
|
||||||
|
@ -2014,7 +2013,6 @@ not_null<HistoryItem*> History::addNewInTheMiddle(
|
||||||
item->createView(
|
item->createView(
|
||||||
HistoryInner::ElementDelegate()));
|
HistoryInner::ElementDelegate()));
|
||||||
(*it)->attachToBlock(block.get(), itemIndex);
|
(*it)->attachToBlock(block.get(), itemIndex);
|
||||||
(*it)->previousInBlocksChanged();
|
|
||||||
if (itemIndex + 1 < block->messages.size()) {
|
if (itemIndex + 1 < block->messages.size()) {
|
||||||
for (auto i = itemIndex + 1, l = int(block->messages.size()); i != l; ++i) {
|
for (auto i = itemIndex + 1, l = int(block->messages.size()); i != l; ++i) {
|
||||||
block->messages[i]->setIndexInBlock(i);
|
block->messages[i]->setIndexInBlock(i);
|
||||||
|
@ -2028,63 +2026,6 @@ not_null<HistoryItem*> History::addNewInTheMiddle(
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
//HistoryView::Element *History::findNextItem(
|
|
||||||
// not_null<HistoryView::Element*> view) const {
|
|
||||||
// const auto nextBlockIndex = view->block()->indexInHistory() + 1;
|
|
||||||
// const auto nextItemIndex = view->indexInBlock() + 1;
|
|
||||||
// if (nextItemIndex < int(view->block()->messages.size())) {
|
|
||||||
// return view->block()->messages[nextItemIndex].get();
|
|
||||||
// } else if (nextBlockIndex < int(blocks.size())) {
|
|
||||||
// return blocks[nextBlockIndex]->messages.front().get();
|
|
||||||
// }
|
|
||||||
// return nullptr;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//HistoryView::Element *History::findPreviousItem(
|
|
||||||
// not_null<HistoryView::Element*> view) const {
|
|
||||||
// const auto blockIndex = view->block()->indexInHistory();
|
|
||||||
// const auto itemIndex = view->indexInBlock();
|
|
||||||
// if (itemIndex > 0) {
|
|
||||||
// return view->block()->messages[itemIndex - 1].get();
|
|
||||||
// } else if (blockIndex > 0) {
|
|
||||||
// return blocks[blockIndex - 1]->messages.back().get();
|
|
||||||
// }
|
|
||||||
// return nullptr;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//not_null<HistoryView::Element*> History::findGroupFirst(
|
|
||||||
// not_null<HistoryView::Element*> view) const {
|
|
||||||
// const auto group = view->Get<HistoryView::Group>();
|
|
||||||
// Assert(group != nullptr);
|
|
||||||
// Assert(group->leader != nullptr);
|
|
||||||
//
|
|
||||||
// const auto leaderGroup = (group->leader == view)
|
|
||||||
// ? group
|
|
||||||
// : group->leader->Get<HistoryView::Group>();
|
|
||||||
// Assert(leaderGroup != nullptr);
|
|
||||||
//
|
|
||||||
// return leaderGroup->others.empty()
|
|
||||||
// ? group->leader
|
|
||||||
// : leaderGroup->others.front().get();
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//not_null<HistoryView::Element*> History::findGroupLast(
|
|
||||||
// not_null<HistoryView::Element*> view) const {
|
|
||||||
// const auto group = view->Get<HistoryView::Group>();
|
|
||||||
// Assert(group != nullptr);
|
|
||||||
//
|
|
||||||
// return group->leader;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void History::recountGroupingAround(not_null<HistoryItem*> item) {
|
|
||||||
// Expects(item->history() == this);
|
|
||||||
//
|
|
||||||
// if (item->mainView() && item->groupId()) {
|
|
||||||
// const auto [groupFrom, groupTill] = recountGroupingFromTill(item->mainView());
|
|
||||||
// recountGrouping(groupFrom, groupTill);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
int History::chatListUnreadCount() const {
|
int History::chatListUnreadCount() const {
|
||||||
const auto result = unreadCount();
|
const auto result = unreadCount();
|
||||||
|
@ -2115,65 +2056,6 @@ void History::paintUserpic(
|
||||||
int size) const {
|
int size) const {
|
||||||
peer->paintUserpic(p, x, y, size);
|
peer->paintUserpic(p, x, y, size);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
//auto History::recountGroupingFromTill(not_null<HistoryView::Element*> view)
|
|
||||||
//-> std::pair<not_null<HistoryView::Element*>, not_null<HistoryView::Element*>> {
|
|
||||||
// const auto recountFromItem = [&] {
|
|
||||||
// if (const auto prev = findPreviousItem(view)) {
|
|
||||||
// if (prev->data()->groupId()) {
|
|
||||||
// return findGroupFirst(prev);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return view;
|
|
||||||
// }();
|
|
||||||
// if (recountFromItem == view && !view->data()->groupId()) {
|
|
||||||
// return { view, view };
|
|
||||||
// }
|
|
||||||
// const auto recountTillItem = [&] {
|
|
||||||
// if (const auto next = findNextItem(view)) {
|
|
||||||
// if (next->data()->groupId()) {
|
|
||||||
// return findGroupLast(next);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return view;
|
|
||||||
// }();
|
|
||||||
// return { recountFromItem, recountTillItem };
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void History::recountGrouping(
|
|
||||||
// not_null<HistoryView::Element*> from,
|
|
||||||
// not_null<HistoryView::Element*> till) {
|
|
||||||
// from->validateGroupId();
|
|
||||||
// auto others = std::vector<not_null<HistoryView::Element*>>();
|
|
||||||
// auto currentGroupId = from->data()->groupId();
|
|
||||||
// auto prev = from;
|
|
||||||
// while (prev != till) {
|
|
||||||
// auto item = findNextItem(prev);
|
|
||||||
// item->validateGroupId();
|
|
||||||
// const auto groupId = item->data()->groupId();
|
|
||||||
// if (currentGroupId) {
|
|
||||||
// if (groupId == currentGroupId) {
|
|
||||||
// others.push_back(prev);
|
|
||||||
// } else {
|
|
||||||
// for (const auto other : others) {
|
|
||||||
// other->makeGroupMember(prev);
|
|
||||||
// }
|
|
||||||
// prev->makeGroupLeader(base::take(others));
|
|
||||||
// currentGroupId = groupId;
|
|
||||||
// }
|
|
||||||
// } else if (groupId) {
|
|
||||||
// currentGroupId = groupId;
|
|
||||||
// }
|
|
||||||
// prev = item;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (currentGroupId) {
|
|
||||||
// for (const auto other : others) {
|
|
||||||
// other->makeGroupMember(prev);
|
|
||||||
// }
|
|
||||||
// till->makeGroupLeader(base::take(others));
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
void History::startBuildingFrontBlock(int expectedItemsCount) {
|
void History::startBuildingFrontBlock(int expectedItemsCount) {
|
||||||
Assert(!isBuildingFrontBlock());
|
Assert(!isBuildingFrontBlock());
|
||||||
|
|
|
@ -329,7 +329,6 @@ public:
|
||||||
}
|
}
|
||||||
HistoryItemsList validateForwardDraft();
|
HistoryItemsList validateForwardDraft();
|
||||||
void setForwardDraft(MessageIdsList &&items);
|
void setForwardDraft(MessageIdsList &&items);
|
||||||
void recountGroupingAround(not_null<HistoryItem*> item);
|
|
||||||
|
|
||||||
bool needUpdateInChatList() const override;
|
bool needUpdateInChatList() const override;
|
||||||
bool toImportant() const override {
|
bool toImportant() const override {
|
||||||
|
@ -456,20 +455,6 @@ private:
|
||||||
void addItemsToLists(const std::vector<not_null<HistoryItem*>> &items);
|
void addItemsToLists(const std::vector<not_null<HistoryItem*>> &items);
|
||||||
void clearSendAction(not_null<UserData*> from);
|
void clearSendAction(not_null<UserData*> from);
|
||||||
|
|
||||||
HistoryView::Element *findPreviousItem(
|
|
||||||
not_null<HistoryView::Element*> view) const;
|
|
||||||
HistoryView::Element *findNextItem(
|
|
||||||
not_null<HistoryView::Element*> view) const;
|
|
||||||
not_null<HistoryView::Element*> findGroupFirst(
|
|
||||||
not_null<HistoryView::Element*> view) const;
|
|
||||||
not_null<HistoryView::Element*> findGroupLast(
|
|
||||||
not_null<HistoryView::Element*> view) const;
|
|
||||||
auto recountGroupingFromTill(not_null<HistoryView::Element*> view)
|
|
||||||
-> std::pair<not_null<HistoryView::Element*>, not_null<HistoryView::Element*>>;
|
|
||||||
void recountGrouping(
|
|
||||||
not_null<HistoryView::Element*> from,
|
|
||||||
not_null<HistoryView::Element*> till);
|
|
||||||
|
|
||||||
enum class Flag {
|
enum class Flag {
|
||||||
f_has_pending_resized_items = (1 << 0),
|
f_has_pending_resized_items = (1 << 0),
|
||||||
f_pending_resize = (1 << 1),
|
f_pending_resize = (1 << 1),
|
||||||
|
|
|
@ -197,9 +197,6 @@ public:
|
||||||
bool emptyText() const {
|
bool emptyText() const {
|
||||||
return _text.isEmpty();
|
return _text.isEmpty();
|
||||||
}
|
}
|
||||||
Text cloneText() const {
|
|
||||||
return _text;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isPinned() const;
|
bool isPinned() const;
|
||||||
bool canPin() const;
|
bool canPin() const;
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/view/history_view_element.h"
|
#include "history/view/history_view_element.h"
|
||||||
#include "storage/storage_shared_media.h"
|
#include "storage/storage_shared_media.h"
|
||||||
|
#include "ui/text_options.h"
|
||||||
|
|
||||||
Storage::SharedMediaTypesMask HistoryMedia::sharedMediaTypes() const {
|
Storage::SharedMediaTypesMask HistoryMedia::sharedMediaTypes() const {
|
||||||
return {};
|
return {};
|
||||||
|
@ -23,6 +24,24 @@ QSize HistoryMedia::countCurrentSize(int newWidth) {
|
||||||
return QSize(qMin(newWidth, maxWidth()), minHeight());
|
return QSize(qMin(newWidth, maxWidth()), minHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text HistoryMedia::createCaption(not_null<HistoryItem*> item) const {
|
||||||
|
if (item->emptyText()) {
|
||||||
|
return Text();
|
||||||
|
}
|
||||||
|
const auto minResizeWidth = st::minPhotoSize
|
||||||
|
- st::msgPadding.left()
|
||||||
|
- st::msgPadding.right();
|
||||||
|
auto result = Text(minResizeWidth);
|
||||||
|
result.setMarkedText(
|
||||||
|
st::messageTextStyle,
|
||||||
|
item->originalText(),
|
||||||
|
Ui::ItemTextOptions(item));
|
||||||
|
if (const auto width = _parent->skipBlockWidth()) {
|
||||||
|
result.updateSkipBlock(width, _parent->skipBlockHeight());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
TextSelection HistoryMedia::skipSelection(TextSelection selection) const {
|
TextSelection HistoryMedia::skipSelection(TextSelection selection) const {
|
||||||
return HistoryView::UnshiftItemSelection(
|
return HistoryView::UnshiftItemSelection(
|
||||||
selection,
|
selection,
|
||||||
|
|
|
@ -241,6 +241,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QSize countCurrentSize(int newWidth) override;
|
QSize countCurrentSize(int newWidth) override;
|
||||||
|
Text createCaption(not_null<HistoryItem*> item) const;
|
||||||
|
|
||||||
not_null<Element*> _parent;
|
not_null<Element*> _parent;
|
||||||
MediaInBubbleState _inBubbleState = MediaInBubbleState::None;
|
MediaInBubbleState _inBubbleState = MediaInBubbleState::None;
|
||||||
|
|
|
@ -379,7 +379,7 @@ void HistoryGroupedMedia::updateNeedBubbleState() {
|
||||||
return true;
|
return true;
|
||||||
}();
|
}();
|
||||||
if (hasCaption) {
|
if (hasCaption) {
|
||||||
_caption = _parts.front().item->cloneText();
|
_caption = createCaption(_parts.front().item);
|
||||||
}
|
}
|
||||||
_needBubble = computeNeedBubble();
|
_needBubble = computeNeedBubble();
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,7 +228,7 @@ HistoryPhoto::HistoryPhoto(
|
||||||
std::make_shared<PhotoOpenClickHandler>(_data, fullId),
|
std::make_shared<PhotoOpenClickHandler>(_data, fullId),
|
||||||
std::make_shared<PhotoSaveClickHandler>(_data, fullId),
|
std::make_shared<PhotoSaveClickHandler>(_data, fullId),
|
||||||
std::make_shared<PhotoCancelClickHandler>(_data, fullId));
|
std::make_shared<PhotoCancelClickHandler>(_data, fullId));
|
||||||
_caption = realParent->cloneText();
|
_caption = createCaption(realParent);
|
||||||
create(realParent->fullId());
|
create(realParent->fullId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,7 +731,7 @@ HistoryVideo::HistoryVideo(
|
||||||
, _data(document)
|
, _data(document)
|
||||||
, _thumbw(1)
|
, _thumbw(1)
|
||||||
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) {
|
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) {
|
||||||
_caption = realParent->cloneText();
|
_caption = createCaption(realParent);
|
||||||
|
|
||||||
setDocumentLinks(_data, realParent);
|
setDocumentLinks(_data, realParent);
|
||||||
|
|
||||||
|
@ -1199,7 +1199,7 @@ HistoryDocument::HistoryDocument(
|
||||||
, DocumentViewRegister(parent, document)
|
, DocumentViewRegister(parent, document)
|
||||||
, _data(document) {
|
, _data(document) {
|
||||||
const auto item = parent->data();
|
const auto item = parent->data();
|
||||||
auto caption = item->cloneText();
|
auto caption = createCaption(item);
|
||||||
|
|
||||||
createComponents(!caption.isEmpty());
|
createComponents(!caption.isEmpty());
|
||||||
if (auto named = Get<HistoryDocumentNamed>()) {
|
if (auto named = Get<HistoryDocumentNamed>()) {
|
||||||
|
@ -1308,7 +1308,7 @@ QSize HistoryDocument::countOptimalSize() {
|
||||||
|
|
||||||
if (auto named = Get<HistoryDocumentNamed>()) {
|
if (auto named = Get<HistoryDocumentNamed>()) {
|
||||||
accumulate_max(maxWidth, tleft + named->_namew + tright);
|
accumulate_max(maxWidth, tleft + named->_namew + tright);
|
||||||
accumulate_max(maxWidth, st::msgMaxWidth);
|
accumulate_min(maxWidth, st::msgMaxWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto minHeight = 0;
|
auto minHeight = 0;
|
||||||
|
@ -1952,7 +1952,7 @@ HistoryGif::HistoryGif(
|
||||||
|
|
||||||
setStatusSize(FileStatusSizeReady);
|
setStatusSize(FileStatusSizeReady);
|
||||||
|
|
||||||
_caption = item->cloneText();
|
_caption = createCaption(item);
|
||||||
_data->thumb->load();
|
_data->thumb->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2117,7 +2117,9 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeM
|
||||||
auto displayLoading = (item->id < 0) || _data->displayLoading();
|
auto displayLoading = (item->id < 0) || _data->displayLoading();
|
||||||
auto selected = (selection == FullSelection);
|
auto selected = (selection == FullSelection);
|
||||||
|
|
||||||
auto videoFinished = _gif && (_gif->mode() == Media::Clip::Reader::Mode::Video) && (_gif->state() == Media::Clip::State::Finished);
|
auto videoFinished = _gif
|
||||||
|
&& (_gif->mode() == Media::Clip::Reader::Mode::Video)
|
||||||
|
&& (_gif->state() == Media::Clip::State::Finished);
|
||||||
if (loaded && cAutoPlayGif() && ((!_gif && !_gif.isBad()) || videoFinished)) {
|
if (loaded && cAutoPlayGif() && ((!_gif && !_gif.isBad()) || videoFinished)) {
|
||||||
Ui::autoplayMediaInlineAsync(item->fullId());
|
Ui::autoplayMediaInlineAsync(item->fullId());
|
||||||
}
|
}
|
||||||
|
@ -3087,7 +3089,7 @@ QSize HistoryContact::countOptimalSize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
accumulate_max(maxWidth, tleft + _name.maxWidth() + tright);
|
accumulate_max(maxWidth, tleft + _name.maxWidth() + tright);
|
||||||
accumulate_max(maxWidth, st::msgMaxWidth);
|
accumulate_min(maxWidth, st::msgMaxWidth);
|
||||||
auto minHeight = 0;
|
auto minHeight = 0;
|
||||||
if (_userId) {
|
if (_userId) {
|
||||||
minHeight = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom();
|
minHeight = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom();
|
||||||
|
|
|
@ -851,10 +851,6 @@ void HistoryMessage::replaceBuyWithReceiptInMarkup() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 HistoryMessage::plainMaxWidth() const {
|
|
||||||
return st::msgPadding.left() + _text.maxWidth() + st::msgPadding.right();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HistoryMessage::applyEdition(const MTPDmessage &message) {
|
void HistoryMessage::applyEdition(const MTPDmessage &message) {
|
||||||
int keyboardTop = -1;
|
int keyboardTop = -1;
|
||||||
//if (!pendingResize()) {// #TODO edit bot message
|
//if (!pendingResize()) {// #TODO edit bot message
|
||||||
|
@ -941,33 +937,6 @@ Storage::SharedMediaTypesMask HistoryMessage::sharedMediaTypes() const {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void HistoryMessage::setMedia(const MTPMessageMedia *media) {
|
|
||||||
|
|
||||||
// #TODO grouping and games
|
|
||||||
//bool mediaRemovedSkipBlock = false;
|
|
||||||
//if (_media) {
|
|
||||||
// // Don't update Game media because we loose the consumed text of the message.
|
|
||||||
// if (_media->type() == MediaTypeGame) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// mediaRemovedSkipBlock = _media->isDisplayed() && _media->isBubbleBottom();
|
|
||||||
// _media.reset();
|
|
||||||
//}
|
|
||||||
//refreshMedia(media);
|
|
||||||
//auto mediaDisplayed = _media && _media->isDisplayed();
|
|
||||||
//if (mediaDisplayed && _media->isBubbleBottom() && !mediaRemovedSkipBlock) {
|
|
||||||
// _text.removeSkipBlock();
|
|
||||||
// _textWidth = -1;
|
|
||||||
// _textHeight = 0;
|
|
||||||
//} else if (mediaRemovedSkipBlock && (!mediaDisplayed || !_media->isBubbleBottom())) {
|
|
||||||
// _text.updateSkipBlock(skipBlockWidth(), skipBlockHeight());
|
|
||||||
// _textWidth = -1;
|
|
||||||
// _textHeight = 0;
|
|
||||||
//}
|
|
||||||
//_history->recountGroupingAround(this);
|
|
||||||
//}
|
|
||||||
|
|
||||||
void HistoryMessage::setText(const TextWithEntities &textWithEntities) {
|
void HistoryMessage::setText(const TextWithEntities &textWithEntities) {
|
||||||
for_const (auto &entity, textWithEntities.entities) {
|
for_const (auto &entity, textWithEntities.entities) {
|
||||||
auto type = entity.type();
|
auto type = entity.type();
|
||||||
|
|
|
@ -94,8 +94,6 @@ public:
|
||||||
not_null<HistoryMessage*> item,
|
not_null<HistoryMessage*> item,
|
||||||
const MTPMessageMedia &media);
|
const MTPMessageMedia &media);
|
||||||
|
|
||||||
int32 plainMaxWidth() const;
|
|
||||||
|
|
||||||
bool allowsForward() const override;
|
bool allowsForward() const override;
|
||||||
bool allowsEdit(const QDateTime &now) const override;
|
bool allowsEdit(const QDateTime &now) const override;
|
||||||
bool uploading() const;
|
bool uploading() const;
|
||||||
|
|
|
@ -573,6 +573,14 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null<Window::Controller*> cont
|
||||||
) | rpl::start_with_next([this](auto item) {
|
) | rpl::start_with_next([this](auto item) {
|
||||||
item->refreshMainView();
|
item->refreshMainView();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
Auth().data().itemPlayInlineRequest(
|
||||||
|
) | rpl::start_with_next([this](auto item) {
|
||||||
|
if (const auto view = item->mainView()) {
|
||||||
|
if (const auto media = view->media()) {
|
||||||
|
media->playInline(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, lifetime());
|
||||||
subscribe(Auth().data().contactsLoaded(), [this](bool) {
|
subscribe(Auth().data().contactsLoaded(), [this](bool) {
|
||||||
if (_peer) {
|
if (_peer) {
|
||||||
updateReportSpamStatus();
|
updateReportSpamStatus();
|
||||||
|
|
|
@ -491,6 +491,7 @@ void Element::attachToBlock(not_null<HistoryBlock*> block, int index) {
|
||||||
_block = block;
|
_block = block;
|
||||||
_indexInBlock = index;
|
_indexInBlock = index;
|
||||||
_data->setMainView(this);
|
_data->setMainView(this);
|
||||||
|
previousInBlocksChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Element::removeFromBlock() {
|
void Element::removeFromBlock() {
|
||||||
|
|
|
@ -257,7 +257,7 @@ QSize Message::performCountOptimalSize() {
|
||||||
item->_textHeight = 0;
|
item->_textHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
maxWidth = item->plainMaxWidth();
|
maxWidth = plainMaxWidth();
|
||||||
minHeight = hasVisibleText() ? item->_text.minHeight() : 0;
|
minHeight = hasVisibleText() ? item->_text.minHeight() : 0;
|
||||||
if (!mediaOnBottom) {
|
if (!mediaOnBottom) {
|
||||||
minHeight += st::msgPadding.bottom();
|
minHeight += st::msgPadding.bottom();
|
||||||
|
@ -604,6 +604,9 @@ void Message::paintViaBotIdInfo(Painter &p, QRect &trect, bool selected) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Message::paintText(Painter &p, QRect &trect, TextSelection selection) const {
|
void Message::paintText(Painter &p, QRect &trect, TextSelection selection) const {
|
||||||
|
if (!hasVisibleText()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto item = message();
|
const auto item = message();
|
||||||
|
|
||||||
const auto outbg = hasOutLayout();
|
const auto outbg = hasOutLayout();
|
||||||
|
@ -890,6 +893,9 @@ bool Message::getStateText(
|
||||||
QRect &trect,
|
QRect &trect,
|
||||||
not_null<HistoryTextState*> outResult,
|
not_null<HistoryTextState*> outResult,
|
||||||
HistoryStateRequest request) const {
|
HistoryStateRequest request) const {
|
||||||
|
if (!hasVisibleText()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const auto item = message();
|
const auto item = message();
|
||||||
if (trect.contains(point)) {
|
if (trect.contains(point)) {
|
||||||
*outResult = HistoryTextState(item, item->_text.getState(
|
*outResult = HistoryTextState(item, item->_text.getState(
|
||||||
|
@ -1209,6 +1215,12 @@ int Message::timeLeft() const {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Message::plainMaxWidth() const {
|
||||||
|
return st::msgPadding.left()
|
||||||
|
+ (hasVisibleText() ? message()->_text.maxWidth() : 0)
|
||||||
|
+ st::msgPadding.right();
|
||||||
|
}
|
||||||
|
|
||||||
void Message::initLogEntryOriginal() {
|
void Message::initLogEntryOriginal() {
|
||||||
if (const auto log = message()->Get<HistoryMessageLogEntryOriginal>()) {
|
if (const auto log = message()->Get<HistoryMessageLogEntryOriginal>()) {
|
||||||
AddComponents(LogEntryOriginal::Bit());
|
AddComponents(LogEntryOriginal::Bit());
|
||||||
|
@ -1478,7 +1490,7 @@ QRect Message::countGeometry() const {
|
||||||
|
|
||||||
auto maxwidth = qMin(st::msgMaxWidth, maxWidth());
|
auto maxwidth = qMin(st::msgMaxWidth, maxWidth());
|
||||||
if (media && media->width() < maxwidth) {
|
if (media && media->width() < maxwidth) {
|
||||||
maxwidth = qMax(media->width(), qMin(maxwidth, item->plainMaxWidth()));
|
maxwidth = qMax(media->width(), qMin(maxwidth, plainMaxWidth()));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto outbg = hasOutLayout();
|
const auto outbg = hasOutLayout();
|
||||||
|
|
|
@ -138,6 +138,7 @@ private:
|
||||||
HistoryMessageEdited *displayedEditBadge();
|
HistoryMessageEdited *displayedEditBadge();
|
||||||
void initTime();
|
void initTime();
|
||||||
int timeLeft() const;
|
int timeLeft() const;
|
||||||
|
int plainMaxWidth() const;
|
||||||
|
|
||||||
HistoryWebPage *logEntryOriginal() const;
|
HistoryWebPage *logEntryOriginal() const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue