mirror of https://github.com/procxx/kepka.git
Limit media count in one HistoryGroupedMedia.
This commit is contained in:
parent
5ebecb4de3
commit
edcaccba1f
|
@ -163,13 +163,6 @@ public:
|
||||||
const QRect &geometry,
|
const QRect &geometry,
|
||||||
QPoint point,
|
QPoint point,
|
||||||
StateRequest request) const;
|
StateRequest request) const;
|
||||||
virtual std::unique_ptr<HistoryMedia> takeLastFromGroup() {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
virtual bool applyGroup(
|
|
||||||
const std::vector<not_null<HistoryItem*>> &items) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool animating() const {
|
virtual bool animating() const {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -21,8 +21,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using TextState = HistoryView::TextState;
|
using TextState = HistoryView::TextState;
|
||||||
using PointState = HistoryView::PointState;
|
using PointState = HistoryView::PointState;
|
||||||
|
|
||||||
|
constexpr auto kMaxDisplayedGroupSize = 10;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
HistoryGroupedMedia::Part::Part(not_null<HistoryItem*> item)
|
HistoryGroupedMedia::Part::Part(not_null<HistoryItem*> item)
|
||||||
|
@ -34,7 +38,11 @@ HistoryGroupedMedia::HistoryGroupedMedia(
|
||||||
const std::vector<not_null<HistoryItem*>> &items)
|
const std::vector<not_null<HistoryItem*>> &items)
|
||||||
: HistoryMedia(parent)
|
: HistoryMedia(parent)
|
||||||
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) {
|
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) {
|
||||||
const auto result = applyGroup(items);
|
const auto result = (items.size() <= kMaxDisplayedGroupSize)
|
||||||
|
? applyGroup(items)
|
||||||
|
: applyGroup(std::vector<not_null<HistoryItem*>>(
|
||||||
|
begin(items),
|
||||||
|
begin(items) + kMaxDisplayedGroupSize));
|
||||||
|
|
||||||
Ensures(result);
|
Ensures(result);
|
||||||
}
|
}
|
||||||
|
@ -302,12 +310,10 @@ void HistoryGroupedMedia::clickHandlerPressedChanged(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<HistoryMedia> HistoryGroupedMedia::takeLastFromGroup() {
|
|
||||||
return std::move(_parts.back().content);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HistoryGroupedMedia::applyGroup(
|
bool HistoryGroupedMedia::applyGroup(
|
||||||
const std::vector<not_null<HistoryItem*>> &items) {
|
const std::vector<not_null<HistoryItem*>> &items) {
|
||||||
|
Expects(items.size() <= kMaxDisplayedGroupSize);
|
||||||
|
|
||||||
if (items.empty()) {
|
if (items.empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -315,14 +321,13 @@ bool HistoryGroupedMedia::applyGroup(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto pushElement = [&](not_null<HistoryItem*> item) {
|
for (const auto item : items) {
|
||||||
const auto media = item->media();
|
const auto media = item->media();
|
||||||
Assert(media != nullptr && media->canBeGrouped());
|
Assert(media != nullptr && media->canBeGrouped());
|
||||||
|
|
||||||
_parts.push_back(Part(item));
|
_parts.push_back(Part(item));
|
||||||
_parts.back().content = media->createView(_parent, item);
|
_parts.back().content = media->createView(_parent, item);
|
||||||
};
|
};
|
||||||
ranges::for_each(items, pushElement);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,10 +59,6 @@ public:
|
||||||
const ClickHandlerPtr &p,
|
const ClickHandlerPtr &p,
|
||||||
bool pressed) override;
|
bool pressed) override;
|
||||||
|
|
||||||
std::unique_ptr<HistoryMedia> takeLastFromGroup() override;
|
|
||||||
bool applyGroup(
|
|
||||||
const std::vector<not_null<HistoryItem*>> &items) override;
|
|
||||||
|
|
||||||
bool hasReplyPreview() const override;
|
bool hasReplyPreview() const override;
|
||||||
ImagePtr replyPreview() override;
|
ImagePtr replyPreview() override;
|
||||||
TextWithEntities getCaption() const override;
|
TextWithEntities getCaption() const override;
|
||||||
|
@ -100,6 +96,7 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool applyGroup(const std::vector<not_null<HistoryItem*>> &items);
|
||||||
QSize countOptimalSize() override;
|
QSize countOptimalSize() override;
|
||||||
QSize countCurrentSize(int newWidth) override;
|
QSize countCurrentSize(int newWidth) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue