mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Fix saved / replies userpics in chats search.
This commit is contained in:
parent
1865fd382c
commit
1ce49df123
7 changed files with 70 additions and 10 deletions
|
@ -598,13 +598,21 @@ std::unique_ptr<Ui::Text::CustomEmoji> CustomEmojiManager::userpic(
|
|||
if (v.size() != 5 && v.size() != 1) {
|
||||
return nullptr;
|
||||
}
|
||||
const auto id = PeerId(v[0].toULongLong());
|
||||
auto image = std::shared_ptr<Ui::DynamicImage>();
|
||||
if (v[0] == u"self"_q) {
|
||||
image = Ui::MakeSavedMessagesThumbnail();
|
||||
} else if (v[0] == u"replies"_q) {
|
||||
image = Ui::MakeRepliesThumbnail();
|
||||
} else {
|
||||
const auto id = PeerId(v[0].toULongLong());
|
||||
image = Ui::MakeUserpicThumbnail(_owner->peer(id));
|
||||
}
|
||||
const auto padding = (v.size() == 5)
|
||||
? QMargins(v[1].toInt(), v[2].toInt(), v[3].toInt(), v[4].toInt())
|
||||
: QMargins();
|
||||
return std::make_unique<Ui::CustomEmoji::DynamicImageEmoji>(
|
||||
data.toString(),
|
||||
Ui::MakeUserpicThumbnail(_owner->peer(id)),
|
||||
std::move(image),
|
||||
std::move(update),
|
||||
padding,
|
||||
size);
|
||||
|
@ -992,10 +1000,16 @@ QString CustomEmojiManager::registerInternalEmoji(
|
|||
|
||||
[[nodiscard]] QString CustomEmojiManager::peerUserpicEmojiData(
|
||||
not_null<PeerData*> peer,
|
||||
QMargins padding) {
|
||||
return UserpicEmojiPrefix()
|
||||
+ QString::number(peer->id.value)
|
||||
+ InternalPadding(padding);
|
||||
QMargins padding,
|
||||
bool respectSavedRepliesEtc) {
|
||||
const auto id = !respectSavedRepliesEtc
|
||||
? QString::number(peer->id.value)
|
||||
: peer->isSelf()
|
||||
? u"self"_q
|
||||
: peer->isRepliesChat()
|
||||
? u"replies"_q
|
||||
: QString::number(peer->id.value);
|
||||
return UserpicEmojiPrefix() + id + InternalPadding(padding);
|
||||
}
|
||||
|
||||
int FrameSizeFromTag(SizeTag tag) {
|
||||
|
|
|
@ -94,7 +94,8 @@ public:
|
|||
|
||||
[[nodiscard]] QString peerUserpicEmojiData(
|
||||
not_null<PeerData*> peer,
|
||||
QMargins padding = {});
|
||||
QMargins padding = {},
|
||||
bool respectSavedRepliesEtc = false);
|
||||
|
||||
[[nodiscard]] uint64 coloredSetId() const;
|
||||
|
||||
|
|
|
@ -522,7 +522,7 @@ forumTopicRow: DialogRow(defaultDialogRow) {
|
|||
photoSize: 20px;
|
||||
nameLeft: 39px;
|
||||
nameTop: 7px;
|
||||
textLeft: 68px;
|
||||
textLeft: 39px;
|
||||
textTop: 29px;
|
||||
unreadMarkDiameter: 8px;
|
||||
}
|
||||
|
|
|
@ -3145,6 +3145,7 @@ void InnerWidget::refreshEmpty() {
|
|||
} else {
|
||||
_searchEmpty.destroy();
|
||||
_loadingAnimation.destroy();
|
||||
_searchEmptyState = {};
|
||||
}
|
||||
|
||||
const auto data = &session().data();
|
||||
|
|
|
@ -1279,11 +1279,15 @@ void Widget::updateSearchTabs() {
|
|||
const auto peerShortLabel = peer
|
||||
? Ui::Text::SingleCustomEmoji(
|
||||
session().data().customEmojiManager().peerUserpicEmojiData(
|
||||
peer))
|
||||
peer,
|
||||
{},
|
||||
true))
|
||||
: sublist
|
||||
? Ui::Text::SingleCustomEmoji(
|
||||
session().data().customEmojiManager().peerUserpicEmojiData(
|
||||
sublist->peer()))
|
||||
sublist->peer(),
|
||||
{},
|
||||
true))
|
||||
: TextWithEntities();
|
||||
const auto myShortLabel = DefaultShortLabel(ChatSearchTab::MyMessages);
|
||||
const auto publicShortLabel = _searchingHashtag
|
||||
|
|
|
@ -130,6 +130,17 @@ private:
|
|||
|
||||
};
|
||||
|
||||
class RepliesUserpic final : public DynamicImage {
|
||||
public:
|
||||
QImage image(int size) override;
|
||||
void subscribeToUpdates(Fn<void()> callback) override;
|
||||
|
||||
private:
|
||||
QImage _frame;
|
||||
int _paletteVersion = 0;
|
||||
|
||||
};
|
||||
|
||||
PeerUserpic::PeerUserpic(not_null<PeerData*> peer, bool forceRound)
|
||||
: _peer(peer)
|
||||
, _forceRound(forceRound) {
|
||||
|
@ -358,6 +369,30 @@ QImage SavedMessagesUserpic::image(int size) {
|
|||
void SavedMessagesUserpic::subscribeToUpdates(Fn<void()> callback) {
|
||||
}
|
||||
|
||||
QImage RepliesUserpic::image(int size) {
|
||||
const auto good = (_frame.width() == size * _frame.devicePixelRatio());
|
||||
const auto paletteVersion = style::PaletteVersion();
|
||||
if (!good || _paletteVersion != paletteVersion) {
|
||||
_paletteVersion = paletteVersion;
|
||||
|
||||
const auto ratio = style::DevicePixelRatio();
|
||||
if (!good) {
|
||||
_frame = QImage(
|
||||
QSize(size, size) * ratio,
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
_frame.setDevicePixelRatio(ratio);
|
||||
}
|
||||
_frame.fill(Qt::transparent);
|
||||
|
||||
auto p = Painter(&_frame);
|
||||
Ui::EmptyUserpic::PaintRepliesMessages(p, 0, 0, size, size);
|
||||
}
|
||||
return _frame;
|
||||
}
|
||||
|
||||
void RepliesUserpic::subscribeToUpdates(Fn<void()> callback) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::shared_ptr<DynamicImage> MakeUserpicThumbnail(
|
||||
|
@ -370,6 +405,10 @@ std::shared_ptr<DynamicImage> MakeSavedMessagesThumbnail() {
|
|||
return std::make_shared<SavedMessagesUserpic>();
|
||||
}
|
||||
|
||||
std::shared_ptr<DynamicImage> MakeRepliesThumbnail() {
|
||||
return std::make_shared<RepliesUserpic>();
|
||||
}
|
||||
|
||||
std::shared_ptr<DynamicImage> MakeStoryThumbnail(
|
||||
not_null<Data::Story*> story) {
|
||||
using Result = std::shared_ptr<DynamicImage>;
|
||||
|
|
|
@ -21,6 +21,7 @@ class DynamicImage;
|
|||
not_null<PeerData*> peer,
|
||||
bool forceRound = false);
|
||||
[[nodiscard]] std::shared_ptr<DynamicImage> MakeSavedMessagesThumbnail();
|
||||
[[nodiscard]] std::shared_ptr<DynamicImage> MakeRepliesThumbnail();
|
||||
[[nodiscard]] std::shared_ptr<DynamicImage> MakeStoryThumbnail(
|
||||
not_null<Data::Story*> story);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue