mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Improve grouped media display.
This commit is contained in:
parent
6d48ca850e
commit
d9da2edd7c
9 changed files with 34 additions and 25 deletions
|
@ -492,6 +492,17 @@ EditCaptionBox::EditCaptionBox(QWidget*, HistoryMedia *media, FullMsgId msgId) :
|
|||
image = doc->thumb;
|
||||
} break;
|
||||
|
||||
case MediaTypeGrouped: {
|
||||
if (const auto photo = media->getPhoto()) {
|
||||
dimensions = QSize(photo->full->width(), photo->full->height());
|
||||
image = photo->full;
|
||||
} else if (const auto doc = media->getDocument()) {
|
||||
dimensions = doc->dimensions;
|
||||
image = doc->thumb;
|
||||
_animated = true;
|
||||
}
|
||||
} break;
|
||||
|
||||
case MediaTypeFile:
|
||||
case MediaTypeMusicFile:
|
||||
case MediaTypeVoiceFile: {
|
||||
|
|
|
@ -290,9 +290,7 @@ base::optional<bool> SharedMediaWithLastSlice::IsLastIsolated(
|
|||
| [](FullMsgId msgId) { return App::histItemById(msgId); }
|
||||
| [](HistoryItem *item) { return item ? item->getMedia() : nullptr; }
|
||||
| [](HistoryMedia *media) {
|
||||
return (media && media->type() == MediaTypePhoto)
|
||||
? static_cast<HistoryPhoto*>(media)->getPhoto()
|
||||
: nullptr;
|
||||
return media ? media->getPhoto() : nullptr;
|
||||
}
|
||||
| [](PhotoData *photo) { return photo ? photo->id : 0; }
|
||||
| [&](PhotoId photoId) { return *lastPeerPhotoId != photoId; };
|
||||
|
|
|
@ -426,14 +426,12 @@ bool HistoryGroupedMedia::computeNeedBubble() const {
|
|||
if (!_caption.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
for (const auto &element : _elements) {
|
||||
if (const auto message = element.item->toHistoryMessage()) {
|
||||
if (message->viaBot()
|
||||
|| message->Has<HistoryMessageForwarded>()
|
||||
|| message->Has<HistoryMessageReply>()
|
||||
|| message->displayFromName()) {
|
||||
return true;
|
||||
}
|
||||
if (const auto message = _parent->toHistoryMessage()) {
|
||||
if (message->viaBot()
|
||||
|| message->Has<HistoryMessageReply>()
|
||||
|| message->displayForwardedFrom()
|
||||
|| message->displayFromName()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -640,9 +640,9 @@ void HistoryPhoto::drawGrouped(
|
|||
const auto roundRadius = ImageRoundRadius::Large;
|
||||
const auto roundCorners = ImageRoundCorner::None
|
||||
| ((corners & RectPart::TopLeft) ? ImageRoundCorner::TopLeft : ImageRoundCorner::None)
|
||||
| ((corners & RectPart::TopRight) ? ImageRoundCorner::TopLeft : ImageRoundCorner::None)
|
||||
| ((corners & RectPart::BottomLeft) ? ImageRoundCorner::TopLeft : ImageRoundCorner::None)
|
||||
| ((corners & RectPart::BottomRight) ? ImageRoundCorner::TopLeft : ImageRoundCorner::None);
|
||||
| ((corners & RectPart::TopRight) ? ImageRoundCorner::TopRight : ImageRoundCorner::None)
|
||||
| ((corners & RectPart::BottomLeft) ? ImageRoundCorner::BottomLeft : ImageRoundCorner::None)
|
||||
| ((corners & RectPart::BottomRight) ? ImageRoundCorner::BottomRight : ImageRoundCorner::None);
|
||||
App::complexOverlayRect(p, geometry, roundRadius, roundCorners);
|
||||
}
|
||||
|
||||
|
@ -857,8 +857,8 @@ bool HistoryPhoto::needsBubble() const {
|
|||
}
|
||||
if (auto message = _parent->toHistoryMessage()) {
|
||||
return message->viaBot()
|
||||
|| message->Has<HistoryMessageForwarded>()
|
||||
|| message->Has<HistoryMessageReply>()
|
||||
|| message->displayForwardedFrom()
|
||||
|| message->displayFromName();
|
||||
}
|
||||
return false;
|
||||
|
@ -1333,8 +1333,8 @@ bool HistoryVideo::needsBubble() const {
|
|||
}
|
||||
if (auto message = _parent->toHistoryMessage()) {
|
||||
return message->viaBot()
|
||||
|| message->Has<HistoryMessageForwarded>()
|
||||
|| message->Has<HistoryMessageReply>()
|
||||
|| message->displayForwardedFrom()
|
||||
|| message->displayFromName();
|
||||
}
|
||||
return false;
|
||||
|
@ -2809,8 +2809,8 @@ bool HistoryGif::needsBubble() const {
|
|||
}
|
||||
if (auto message = _parent->toHistoryMessage()) {
|
||||
return message->viaBot()
|
||||
|| message->Has<HistoryMessageForwarded>()
|
||||
|| message->Has<HistoryMessageReply>()
|
||||
|| message->displayForwardedFrom()
|
||||
|| message->displayFromName();
|
||||
}
|
||||
return false;
|
||||
|
@ -5318,8 +5318,8 @@ bool HistoryLocation::needsBubble() const {
|
|||
}
|
||||
if (auto message = _parent->toHistoryMessage()) {
|
||||
return message->viaBot()
|
||||
|| message->Has<HistoryMessageForwarded>()
|
||||
|| message->Has<HistoryMessageReply>()
|
||||
|| message->displayForwardedFrom()
|
||||
|| message->displayFromName();
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -125,6 +125,7 @@ bool HasMediaItems(const HistoryItemsList &items) {
|
|||
switch (media->type()) {
|
||||
case MediaTypePhoto:
|
||||
case MediaTypeVideo:
|
||||
case MediaTypeGrouped:
|
||||
case MediaTypeFile:
|
||||
case MediaTypeMusicFile:
|
||||
case MediaTypeVoiceFile: return true;
|
||||
|
|
|
@ -163,6 +163,7 @@ public:
|
|||
if (isAttachedToPrevious()) return false;
|
||||
return true;
|
||||
}
|
||||
bool displayForwardedFrom() const;
|
||||
bool displayEditedBadge(bool hasViaBotOrInlineMarkup) const;
|
||||
bool uploading() const;
|
||||
bool displayRightAction() const override;
|
||||
|
@ -321,7 +322,6 @@ private:
|
|||
int performResizeGetHeight();
|
||||
void applyEditionToEmpty();
|
||||
|
||||
bool displayForwardedFrom() const;
|
||||
void paintFromName(Painter &p, QRect &trect, bool selected) const;
|
||||
void paintForwardedInfo(Painter &p, QRect &trect, bool selected) const;
|
||||
void paintReplyInfo(Painter &p, QRect &trect, bool selected) const;
|
||||
|
|
|
@ -286,6 +286,9 @@ HistoryService::PreparedText HistoryService::preparePinnedText() {
|
|||
switch (media ? media->type() : MediaTypeCount) {
|
||||
case MediaTypePhoto: return lang(lng_action_pinned_media_photo);
|
||||
case MediaTypeVideo: return lang(lng_action_pinned_media_video);
|
||||
case MediaTypeGrouped: return lang(media->getPhoto()
|
||||
? lng_action_pinned_media_photo
|
||||
: lng_action_pinned_media_video);
|
||||
case MediaTypeContact: return lang(lng_action_pinned_media_contact);
|
||||
case MediaTypeFile: return lang(lng_action_pinned_media_file);
|
||||
case MediaTypeGif: {
|
||||
|
|
|
@ -4513,8 +4513,8 @@ void HistoryWidget::onThumbDocumentUploaded(
|
|||
|
||||
void HistoryWidget::onPhotoProgress(const FullMsgId &newId) {
|
||||
if (const auto item = App::histItemById(newId)) {
|
||||
const auto photo = (item->getMedia() && item->getMedia()->type() == MediaTypePhoto)
|
||||
? static_cast<HistoryPhoto*>(item->getMedia())->getPhoto()
|
||||
const auto photo = item->getMedia()
|
||||
? item->getMedia()->getPhoto()
|
||||
: nullptr;
|
||||
updateSendAction(item->history(), SendAction::Type::UploadPhoto, 0);
|
||||
Auth().data().requestItemRepaint(item);
|
||||
|
|
|
@ -847,10 +847,8 @@ std::unique_ptr<BaseLayout> ListWidget::createLayout(
|
|||
return nullptr;
|
||||
}
|
||||
auto getPhoto = [&]() -> PhotoData* {
|
||||
if (auto media = item->getMedia()) {
|
||||
if (media->type() == MediaTypePhoto) {
|
||||
return static_cast<HistoryPhoto*>(media)->getPhoto();
|
||||
}
|
||||
if (const auto media = item->getMedia()) {
|
||||
return media->getPhoto();
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue