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