mirror of https://github.com/procxx/kepka.git
Fix grouped media display in MediaView.
This commit is contained in:
parent
b6087ce7ce
commit
efa72578cd
|
@ -480,7 +480,7 @@ EditCaptionBox::EditCaptionBox(QWidget*, HistoryMedia *media, FullMsgId msgId) :
|
||||||
|
|
||||||
case MediaTypePhoto: {
|
case MediaTypePhoto: {
|
||||||
_photo = true;
|
_photo = true;
|
||||||
auto photo = static_cast<HistoryPhoto*>(media)->photo();
|
auto photo = static_cast<HistoryPhoto*>(media)->getPhoto();
|
||||||
dimensions = QSize(photo->full->width(), photo->full->height());
|
dimensions = QSize(photo->full->width(), photo->full->height());
|
||||||
image = photo->full;
|
image = photo->full;
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -291,7 +291,7 @@ base::optional<bool> SharedMediaWithLastSlice::IsLastIsolated(
|
||||||
| [](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->type() == MediaTypePhoto)
|
||||||
? static_cast<HistoryPhoto*>(media)->photo().get()
|
? static_cast<HistoryPhoto*>(media)->getPhoto()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
}
|
}
|
||||||
| [](PhotoData *photo) { return photo ? photo->id : 0; }
|
| [](PhotoData *photo) { return photo ? photo->id : 0; }
|
||||||
|
|
|
@ -138,7 +138,10 @@ public:
|
||||||
not_null<HistoryItem*> newParent,
|
not_null<HistoryItem*> newParent,
|
||||||
not_null<HistoryItem*> realParent) const = 0;
|
not_null<HistoryItem*> realParent) const = 0;
|
||||||
|
|
||||||
virtual DocumentData *getDocument() {
|
virtual PhotoData *getPhoto() const {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
virtual DocumentData *getDocument() const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
virtual Media::Clip::Reader *getClipReader() {
|
virtual Media::Clip::Reader *getClipReader() {
|
||||||
|
|
|
@ -65,6 +65,13 @@ public:
|
||||||
return !_caption.isEmpty();
|
return !_caption.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PhotoData *getPhoto() const override {
|
||||||
|
return main()->getPhoto();
|
||||||
|
}
|
||||||
|
DocumentData *getDocument() const override {
|
||||||
|
return main()->getDocument();
|
||||||
|
}
|
||||||
|
|
||||||
QString notificationText() const override;
|
QString notificationText() const override;
|
||||||
QString inDialogsText() const override;
|
QString inDialogsText() const override;
|
||||||
TextWithEntities selectedText(TextSelection selection) const override;
|
TextWithEntities selectedText(TextSelection selection) const override;
|
||||||
|
|
|
@ -123,7 +123,7 @@ QSize CountPixSizeForSize(QSize original, QSize geometry) {
|
||||||
auto tw = original.width();
|
auto tw = original.width();
|
||||||
auto th = original.height();
|
auto th = original.height();
|
||||||
if (tw * height > th * width) {
|
if (tw * height > th * width) {
|
||||||
if (tw * height < 2 * th * width) {
|
if (th > height || tw * height < 2 * th * width) {
|
||||||
tw = (height * tw) / th;
|
tw = (height * tw) / th;
|
||||||
th = height;
|
th = height;
|
||||||
} else if (tw < width) {
|
} else if (tw < width) {
|
||||||
|
@ -131,7 +131,7 @@ QSize CountPixSizeForSize(QSize original, QSize geometry) {
|
||||||
tw = width;
|
tw = width;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (th * width < 2 * tw * height) {
|
if (tw > width || th * width < 2 * tw * height) {
|
||||||
th = (width * th) / tw;
|
th = (width * th) / tw;
|
||||||
tw = width;
|
tw = width;
|
||||||
} else if (tw > 0 && th < height) {
|
} else if (tw > 0 && th < height) {
|
||||||
|
|
|
@ -199,7 +199,7 @@ public:
|
||||||
|
|
||||||
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
||||||
|
|
||||||
not_null<PhotoData*> photo() const {
|
PhotoData *getPhoto() const override {
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ public:
|
||||||
|
|
||||||
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
||||||
|
|
||||||
DocumentData *getDocument() override {
|
DocumentData *getDocument() const override {
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,7 +517,7 @@ public:
|
||||||
return _data->uploading();
|
return _data->uploading();
|
||||||
}
|
}
|
||||||
|
|
||||||
DocumentData *getDocument() override {
|
DocumentData *getDocument() const override {
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,7 +632,7 @@ public:
|
||||||
return _data->uploading();
|
return _data->uploading();
|
||||||
}
|
}
|
||||||
|
|
||||||
DocumentData *getDocument() override {
|
DocumentData *getDocument() const override {
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
Media::Clip::Reader *getClipReader() override {
|
Media::Clip::Reader *getClipReader() override {
|
||||||
|
@ -743,7 +743,7 @@ public:
|
||||||
QString notificationText() const override;
|
QString notificationText() const override;
|
||||||
TextWithEntities selectedText(TextSelection selection) const override;
|
TextWithEntities selectedText(TextSelection selection) const override;
|
||||||
|
|
||||||
DocumentData *getDocument() override {
|
DocumentData *getDocument() const override {
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -973,7 +973,10 @@ public:
|
||||||
bool isDisplayed() const override {
|
bool isDisplayed() const override {
|
||||||
return !_data->pendingTill && !_parent->Has<HistoryMessageLogEntryOriginal>();
|
return !_data->pendingTill && !_parent->Has<HistoryMessageLogEntryOriginal>();
|
||||||
}
|
}
|
||||||
DocumentData *getDocument() override {
|
PhotoData *getPhoto() const override {
|
||||||
|
return _attach ? _attach->getPhoto() : nullptr;
|
||||||
|
}
|
||||||
|
DocumentData *getDocument() const override {
|
||||||
return _attach ? _attach->getDocument() : nullptr;
|
return _attach ? _attach->getDocument() : nullptr;
|
||||||
}
|
}
|
||||||
Media::Clip::Reader *getClipReader() override {
|
Media::Clip::Reader *getClipReader() override {
|
||||||
|
@ -1089,7 +1092,10 @@ public:
|
||||||
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
|
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
|
||||||
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
|
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
|
||||||
|
|
||||||
DocumentData *getDocument() override {
|
PhotoData *getPhoto() const override {
|
||||||
|
return _attach ? _attach->getPhoto() : nullptr;
|
||||||
|
}
|
||||||
|
DocumentData *getDocument() const override {
|
||||||
return _attach ? _attach->getDocument() : nullptr;
|
return _attach ? _attach->getDocument() : nullptr;
|
||||||
}
|
}
|
||||||
Media::Clip::Reader *getClipReader() override {
|
Media::Clip::Reader *getClipReader() override {
|
||||||
|
|
|
@ -4508,7 +4508,7 @@ 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() && item->getMedia()->type() == MediaTypePhoto)
|
||||||
? static_cast<HistoryPhoto*>(item->getMedia())->photo().get()
|
? static_cast<HistoryPhoto*>(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);
|
||||||
|
|
|
@ -849,7 +849,7 @@ std::unique_ptr<BaseLayout> ListWidget::createLayout(
|
||||||
auto getPhoto = [&]() -> PhotoData* {
|
auto getPhoto = [&]() -> PhotoData* {
|
||||||
if (auto media = item->getMedia()) {
|
if (auto media = item->getMedia()) {
|
||||||
if (media->type() == MediaTypePhoto) {
|
if (media->type() == MediaTypePhoto) {
|
||||||
return static_cast<HistoryPhoto*>(media)->photo();
|
return static_cast<HistoryPhoto*>(media)->getPhoto();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -1266,8 +1266,9 @@ void MediaView::displayPhoto(not_null<PhotoData*> photo, HistoryItem *item) {
|
||||||
_zoom = 0;
|
_zoom = 0;
|
||||||
|
|
||||||
_caption = Text();
|
_caption = Text();
|
||||||
if (auto itemMsg = item ? item->toHistoryMessage() : nullptr) {
|
if (const auto media = item ? item->getMedia() : nullptr) {
|
||||||
if (auto photoMsg = dynamic_cast<HistoryPhoto*>(itemMsg->getMedia())) {
|
const auto caption = media->getCaption();
|
||||||
|
if (!caption.text.isEmpty()) {
|
||||||
auto asBot = (item->author()->isUser()
|
auto asBot = (item->author()->isUser()
|
||||||
&& item->author()->asUser()->botInfo);
|
&& item->author()->asUser()->botInfo);
|
||||||
auto skipw = qMax(_dateNav.left() + _dateNav.width(), _headerNav.left() + _headerNav.width());
|
auto skipw = qMax(_dateNav.left() + _dateNav.width(), _headerNav.left() + _headerNav.width());
|
||||||
|
@ -1275,7 +1276,7 @@ void MediaView::displayPhoto(not_null<PhotoData*> photo, HistoryItem *item) {
|
||||||
_caption = Text(maxw);
|
_caption = Text(maxw);
|
||||||
_caption.setMarkedText(
|
_caption.setMarkedText(
|
||||||
st::mediaviewCaptionStyle,
|
st::mediaviewCaptionStyle,
|
||||||
photoMsg->getCaption(),
|
caption,
|
||||||
itemTextOptions(item));
|
itemTextOptions(item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2254,21 +2255,16 @@ MediaView::Entity MediaView::entityForSharedMedia(int index) const {
|
||||||
return { base::none, nullptr };
|
return { base::none, nullptr };
|
||||||
}
|
}
|
||||||
auto value = (*_sharedMediaData)[index];
|
auto value = (*_sharedMediaData)[index];
|
||||||
if (auto photo = base::get_if<not_null<PhotoData*>>(&value)) {
|
if (const auto photo = base::get_if<not_null<PhotoData*>>(&value)) {
|
||||||
// Last peer photo.
|
// Last peer photo.
|
||||||
return { *photo, nullptr };
|
return { *photo, nullptr };
|
||||||
} else if (auto itemId = base::get_if<FullMsgId>(&value)) {
|
} else if (const auto itemId = base::get_if<FullMsgId>(&value)) {
|
||||||
if (auto item = App::histItemById(*itemId)) {
|
if (const auto item = App::histItemById(*itemId)) {
|
||||||
if (auto media = item->getMedia()) {
|
if (const auto media = item->getMedia()) {
|
||||||
switch (media->type()) {
|
if (const auto photo = media->getPhoto()) {
|
||||||
case MediaTypePhoto: return {
|
return { photo, item };
|
||||||
static_cast<HistoryPhoto*>(item->getMedia())->photo(),
|
} else if (const auto document = media->getDocument()) {
|
||||||
item
|
return { document, item };
|
||||||
};
|
|
||||||
case MediaTypeFile:
|
|
||||||
case MediaTypeVideo:
|
|
||||||
case MediaTypeGif:
|
|
||||||
case MediaTypeSticker: return { media->getDocument(), item };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { base::none, item };
|
return { base::none, item };
|
||||||
|
|
Loading…
Reference in New Issue