mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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) {
|
if (v.size() != 5 && v.size() != 1) {
|
||||||
return nullptr;
|
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)
|
const auto padding = (v.size() == 5)
|
||||||
? QMargins(v[1].toInt(), v[2].toInt(), v[3].toInt(), v[4].toInt())
|
? QMargins(v[1].toInt(), v[2].toInt(), v[3].toInt(), v[4].toInt())
|
||||||
: QMargins();
|
: QMargins();
|
||||||
return std::make_unique<Ui::CustomEmoji::DynamicImageEmoji>(
|
return std::make_unique<Ui::CustomEmoji::DynamicImageEmoji>(
|
||||||
data.toString(),
|
data.toString(),
|
||||||
Ui::MakeUserpicThumbnail(_owner->peer(id)),
|
std::move(image),
|
||||||
std::move(update),
|
std::move(update),
|
||||||
padding,
|
padding,
|
||||||
size);
|
size);
|
||||||
|
@ -992,10 +1000,16 @@ QString CustomEmojiManager::registerInternalEmoji(
|
||||||
|
|
||||||
[[nodiscard]] QString CustomEmojiManager::peerUserpicEmojiData(
|
[[nodiscard]] QString CustomEmojiManager::peerUserpicEmojiData(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
QMargins padding) {
|
QMargins padding,
|
||||||
return UserpicEmojiPrefix()
|
bool respectSavedRepliesEtc) {
|
||||||
+ QString::number(peer->id.value)
|
const auto id = !respectSavedRepliesEtc
|
||||||
+ InternalPadding(padding);
|
? 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) {
|
int FrameSizeFromTag(SizeTag tag) {
|
||||||
|
|
|
@ -94,7 +94,8 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] QString peerUserpicEmojiData(
|
[[nodiscard]] QString peerUserpicEmojiData(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
QMargins padding = {});
|
QMargins padding = {},
|
||||||
|
bool respectSavedRepliesEtc = false);
|
||||||
|
|
||||||
[[nodiscard]] uint64 coloredSetId() const;
|
[[nodiscard]] uint64 coloredSetId() const;
|
||||||
|
|
||||||
|
|
|
@ -522,7 +522,7 @@ forumTopicRow: DialogRow(defaultDialogRow) {
|
||||||
photoSize: 20px;
|
photoSize: 20px;
|
||||||
nameLeft: 39px;
|
nameLeft: 39px;
|
||||||
nameTop: 7px;
|
nameTop: 7px;
|
||||||
textLeft: 68px;
|
textLeft: 39px;
|
||||||
textTop: 29px;
|
textTop: 29px;
|
||||||
unreadMarkDiameter: 8px;
|
unreadMarkDiameter: 8px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3145,6 +3145,7 @@ void InnerWidget::refreshEmpty() {
|
||||||
} else {
|
} else {
|
||||||
_searchEmpty.destroy();
|
_searchEmpty.destroy();
|
||||||
_loadingAnimation.destroy();
|
_loadingAnimation.destroy();
|
||||||
|
_searchEmptyState = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto data = &session().data();
|
const auto data = &session().data();
|
||||||
|
|
|
@ -1279,11 +1279,15 @@ void Widget::updateSearchTabs() {
|
||||||
const auto peerShortLabel = peer
|
const auto peerShortLabel = peer
|
||||||
? Ui::Text::SingleCustomEmoji(
|
? Ui::Text::SingleCustomEmoji(
|
||||||
session().data().customEmojiManager().peerUserpicEmojiData(
|
session().data().customEmojiManager().peerUserpicEmojiData(
|
||||||
peer))
|
peer,
|
||||||
|
{},
|
||||||
|
true))
|
||||||
: sublist
|
: sublist
|
||||||
? Ui::Text::SingleCustomEmoji(
|
? Ui::Text::SingleCustomEmoji(
|
||||||
session().data().customEmojiManager().peerUserpicEmojiData(
|
session().data().customEmojiManager().peerUserpicEmojiData(
|
||||||
sublist->peer()))
|
sublist->peer(),
|
||||||
|
{},
|
||||||
|
true))
|
||||||
: TextWithEntities();
|
: TextWithEntities();
|
||||||
const auto myShortLabel = DefaultShortLabel(ChatSearchTab::MyMessages);
|
const auto myShortLabel = DefaultShortLabel(ChatSearchTab::MyMessages);
|
||||||
const auto publicShortLabel = _searchingHashtag
|
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)
|
PeerUserpic::PeerUserpic(not_null<PeerData*> peer, bool forceRound)
|
||||||
: _peer(peer)
|
: _peer(peer)
|
||||||
, _forceRound(forceRound) {
|
, _forceRound(forceRound) {
|
||||||
|
@ -358,6 +369,30 @@ QImage SavedMessagesUserpic::image(int size) {
|
||||||
void SavedMessagesUserpic::subscribeToUpdates(Fn<void()> callback) {
|
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
|
} // namespace
|
||||||
|
|
||||||
std::shared_ptr<DynamicImage> MakeUserpicThumbnail(
|
std::shared_ptr<DynamicImage> MakeUserpicThumbnail(
|
||||||
|
@ -370,6 +405,10 @@ std::shared_ptr<DynamicImage> MakeSavedMessagesThumbnail() {
|
||||||
return std::make_shared<SavedMessagesUserpic>();
|
return std::make_shared<SavedMessagesUserpic>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<DynamicImage> MakeRepliesThumbnail() {
|
||||||
|
return std::make_shared<RepliesUserpic>();
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<DynamicImage> MakeStoryThumbnail(
|
std::shared_ptr<DynamicImage> MakeStoryThumbnail(
|
||||||
not_null<Data::Story*> story) {
|
not_null<Data::Story*> story) {
|
||||||
using Result = std::shared_ptr<DynamicImage>;
|
using Result = std::shared_ptr<DynamicImage>;
|
||||||
|
|
|
@ -21,6 +21,7 @@ class DynamicImage;
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
bool forceRound = false);
|
bool forceRound = false);
|
||||||
[[nodiscard]] std::shared_ptr<DynamicImage> MakeSavedMessagesThumbnail();
|
[[nodiscard]] std::shared_ptr<DynamicImage> MakeSavedMessagesThumbnail();
|
||||||
|
[[nodiscard]] std::shared_ptr<DynamicImage> MakeRepliesThumbnail();
|
||||||
[[nodiscard]] std::shared_ptr<DynamicImage> MakeStoryThumbnail(
|
[[nodiscard]] std::shared_ptr<DynamicImage> MakeStoryThumbnail(
|
||||||
not_null<Data::Story*> story);
|
not_null<Data::Story*> story);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue