Remove custom PeerData::isVerifyCodes() userpic.

This commit is contained in:
John Preston 2024-09-24 23:06:31 +04:00
parent 962d4d29ee
commit 39fb0a5b66
16 changed files with 2 additions and 188 deletions

View file

@ -150,7 +150,6 @@ PaintRoundImageCallback ExceptionRow::generatePaintUserpicCallback(
const auto peer = this->peer();
const auto saved = peer->isSelf();
const auto replies = peer->isRepliesChat();
const auto verifyCodes = peer->isVerifyCodes();
auto userpic = saved ? Ui::PeerUserpicView() : ensureUserpicView();
if (forceRound && peer->isForum()) {
return ForceRoundUserpicCallback(peer);
@ -161,8 +160,6 @@ PaintRoundImageCallback ExceptionRow::generatePaintUserpicCallback(
EmptyUserpic::PaintSavedMessages(p, x, y, outerWidth, size);
} else if (replies) {
EmptyUserpic::PaintRepliesMessages(p, x, y, outerWidth, size);
} else if (verifyCodes) {
EmptyUserpic::PaintVerifyCodes(p, x, y, outerWidth, size);
} else {
peer->paintUserpicLeft(p, userpic, x, y, outerWidth, size);
}

View file

@ -142,8 +142,9 @@ void FilterChatsPreview::paintEvent(QPaintEvent *e) {
width(),
st.photoSize);
} else {
Ui::EmptyUserpic::PaintVerifyCodes(
history->peer->paintUserpicLeft(
p,
userpic,
iconLeft,
top + iconTop,
width(),

View file

@ -328,7 +328,6 @@ PaintRoundImageCallback ChatRow::generatePaintUserpicCallback(
const auto peer = this->peer();
const auto saved = peer->isSelf();
const auto replies = peer->isRepliesChat();
const auto verifyCodes = peer->isVerifyCodes();
auto userpic = (saved || replies)
? Ui::PeerUserpicView()
: ensureUserpicView();
@ -345,8 +344,6 @@ PaintRoundImageCallback ChatRow::generatePaintUserpicCallback(
EmptyUserpic::PaintSavedMessages(p, x, y, outerWidth, size);
} else if (replies) {
EmptyUserpic::PaintRepliesMessages(p, x, y, outerWidth, size);
} else if (verifyCodes) {
EmptyUserpic::PaintVerifyCodes(p, x, y, outerWidth, size);
} else {
peer->paintUserpicLeft(p, userpic, x, y, outerWidth, size);
}

View file

@ -55,10 +55,6 @@ PaintRoundImageCallback PaintUserpicCallback(
return [](QPainter &p, int x, int y, int outerWidth, int size) {
Ui::EmptyUserpic::PaintRepliesMessages(p, x, y, outerWidth, size);
};
} else if (peer->isVerifyCodes()) {
return [](QPainter &p, int x, int y, int outerWidth, int size) {
Ui::EmptyUserpic::PaintVerifyCodes(p, x, y, outerWidth, size);
};
}
}
auto userpic = Ui::PeerUserpicView();
@ -719,7 +715,6 @@ PaintRoundImageCallback PeerListRow::generatePaintUserpicCallback(
bool forceRound) {
const auto saved = !_savedMessagesStatus.isEmpty();
const auto replies = _isRepliesMessagesChat;
const auto verifyCodes = _isVerifyCodesChat;
const auto peer = this->peer();
auto userpic = saved ? Ui::PeerUserpicView() : ensureUserpicView();
if (forceRound && peer->isForum()) {
@ -731,8 +726,6 @@ PaintRoundImageCallback PeerListRow::generatePaintUserpicCallback(
EmptyUserpic::PaintSavedMessages(p, x, y, outerWidth, size);
} else if (replies) {
EmptyUserpic::PaintRepliesMessages(p, x, y, outerWidth, size);
} else if (verifyCodes) {
EmptyUserpic::PaintVerifyCodes(p, x, y, outerWidth, size);
} else {
peer->paintUserpicLeft(p, userpic, x, y, outerWidth, size);
}
@ -894,8 +887,6 @@ void PeerListRow::paintDisabledCheckUserpic(
Ui::EmptyUserpic::PaintSavedMessages(p, userpicLeft, userpicTop, outerWidth, size);
} else if (_isRepliesMessagesChat) {
Ui::EmptyUserpic::PaintRepliesMessages(p, userpicLeft, userpicTop, outerWidth, size);
} else if (_isVerifyCodesChat) {
Ui::EmptyUserpic::PaintVerifyCodes(p, userpicLeft, userpicTop, outerWidth, size);
} else {
peer()->paintUserpicLeft(p, _userpic, userpicLeft, userpicTop, outerWidth, size);
}

View file

@ -604,8 +604,6 @@ std::unique_ptr<Ui::Text::CustomEmoji> CustomEmojiManager::userpic(
image = Ui::MakeSavedMessagesThumbnail();
} else if (v[0] == u"replies"_q) {
image = Ui::MakeRepliesThumbnail();
} else if (v[0] == u"verify_codes"_q) {
image = Ui::MakeVerifyCodesThumbnail();
} else {
const auto id = PeerId(v[0].toULongLong());
image = Ui::MakeUserpicThumbnail(_owner->peer(id));
@ -1019,8 +1017,6 @@ QString CustomEmojiManager::registerInternalEmoji(
? u"self"_q
: peer->isRepliesChat()
? u"replies"_q
: peer->isVerifyCodes()
? u"verify_codes"_q
: QString::number(peer->id.value);
return UserpicEmojiPrefix() + id + InternalPadding(padding);
}

View file

@ -355,7 +355,6 @@ dialogsForumIcon: ThreeStateIcon {
}
dialogsArchiveUserpic: icon {{ "archive_userpic", historyPeerUserpicFg }};
dialogsRepliesUserpic: icon {{ "replies_userpic", historyPeerUserpicFg }};
dialogsVerifyCodesUserpic: icon {{ "replies_userpic", historyPeerUserpicFg }};
dialogsInaccessibleUserpic: icon {{ "dialogs/inaccessible_userpic", historyPeerUserpicFg }};
dialogsHiddenAuthorUserpic: icon {{ "dialogs/avatar_hidden", premiumButtonFg }};
dialogsMyNotesUserpic: icon {{ "dialogs/avatar_notes", historyPeerUserpicFg }};

View file

@ -311,13 +311,6 @@ void PaintRow(
context.st->padding.top(),
context.width,
context.st->photoSize);
} else if (flags & Flag::VerifyCodes) {
EmptyUserpic::PaintVerifyCodes(
p,
context.st->padding.left(),
context.st->padding.top(),
context.width,
context.st->photoSize);
} else if (flags & Flag::HiddenAuthor) {
EmptyUserpic::PaintHiddenAuthor(
p,

View file

@ -56,10 +56,6 @@ inline bool IsRepliesPeer(PeerData *peer) {
return peer && peer->isRepliesChat();
}
inline bool IsVerifyCodesPeer(PeerData *peer) {
return peer && peer->isVerifyCodes();
}
QImage PrepareImage() {
const auto s = kCircleDiameter * style::DevicePixelRatio();
auto result = QImage(QSize(s, s), QImage::Format_ARGB32_Premultiplied);
@ -85,15 +81,6 @@ QImage RepliesMessagesUserpic() {
return result;
}
QImage VerifyCodesUserpic() {
auto result = PrepareImage();
Painter paint(&result);
const auto s = result.width();
Ui::EmptyUserpic::PaintVerifyCodes(paint, 0, 0, s, s);
return result;
}
QImage ArchiveUserpic(not_null<Data::Folder*> folder) {
auto result = PrepareImage();
Painter paint(&result);
@ -187,13 +174,11 @@ NSRect PeerRectByIndex(int index) {
std::vector<std::unique_ptr<Pin>> _pins;
QImage _savedMessages;
QImage _repliesMessages;
QImage _verifyCodes;
QImage _archive;
bool _hasArchive;
bool _selfUnpinned;
bool _repliesUnpinned;
bool _verifyCodesUnpinned;
rpl::event_stream<not_null<NSEvent*>> _touches;
rpl::event_stream<not_null<NSPressGestureRecognizer*>> _gestures;
@ -477,7 +462,6 @@ NSRect PeerRectByIndex(int index) {
_hasArchive = _selfUnpinned = false;
_savedMessages = SavedMessagesUserpic();
_repliesMessages = RepliesMessagesUserpic();
_verifyCodes = VerifyCodesUserpic();
auto *gesture = [[[NSPressGestureRecognizer alloc]
initWithTarget:self
@ -527,9 +511,6 @@ NSRect PeerRectByIndex(int index) {
} else if (IsRepliesPeer(pin->peer)) {
pin->userpic = _repliesMessages;
return;
} else if (IsVerifyCodesPeer(pin->peer)) {
pin->userpic = _verifyCodes;
return;
}
auto userpic = PrepareImage();
Painter p(&userpic);
@ -654,7 +635,6 @@ NSRect PeerRectByIndex(int index) {
}) | ranges::to_vector;
_selfUnpinned = ranges::none_of(peers, &PeerData::isSelf);
_repliesUnpinned = ranges::none_of(peers, &PeerData::isRepliesChat);
_verifyCodesUnpinned = ranges::none_of(peers, &PeerData::isVerifyCodes);
peerChangedLifetime->destroy();
for (const auto &pin : _pins) {
@ -734,7 +714,6 @@ NSRect PeerRectByIndex(int index) {
}
_savedMessages = SavedMessagesUserpic();
_repliesMessages = RepliesMessagesUserpic();
_verifyCodes = VerifyCodesUserpic();
updateUserpics();
});
}, _lifetime);
@ -803,8 +782,6 @@ NSRect PeerRectByIndex(int index) {
return _savedMessages;
} else if (_repliesUnpinned) {
return _repliesMessages;
} else if (_verifyCodesUnpinned) {
return _verifyCodes;
}
}
return _pins[i]->userpic;

View file

@ -495,13 +495,6 @@ void UserpicButton::paintEvent(QPaintEvent *e) {
photoPosition.y(),
width(),
_st.photoSize);
} else if (showVerifyCodes()) {
Ui::EmptyUserpic::PaintVerifyCodes(
p,
photoPosition.x(),
photoPosition.y(),
width(),
_st.photoSize);
} else {
if (_a_appearance.animating()) {
p.drawPixmapLeft(photoPosition, width(), _oldUserpic);
@ -905,10 +898,6 @@ bool UserpicButton::showRepliesMessages() const {
return _showSavedMessagesOnSelf && _peer && _peer->isRepliesChat();
}
bool UserpicButton::showVerifyCodes() const {
return _showSavedMessagesOnSelf && _peer && _peer->isVerifyCodes();
}
void UserpicButton::startChangeOverlayAnimation() {
auto over = isOver() || isDown();
_changeOverlayShown.start(

View file

@ -138,7 +138,6 @@ private:
void updateVideo();
[[nodiscard]] bool showSavedMessages() const;
[[nodiscard]] bool showRepliesMessages() const;
[[nodiscard]] bool showVerifyCodes() const;
void checkStreamedIsStarted();
bool createStreamingObjects(not_null<PhotoData*> photo);
void clearStreaming();

View file

@ -157,19 +157,6 @@ private:
};
class VerifyCodesUserpic final : public DynamicImage {
public:
std::shared_ptr<DynamicImage> clone() override;
QImage image(int size) override;
void subscribeToUpdates(Fn<void()> callback) override;
private:
QImage _frame;
int _paletteVersion = 0;
};
class HiddenAuthorUserpic final : public DynamicImage {
public:
std::shared_ptr<DynamicImage> clone() override;
@ -508,37 +495,6 @@ void RepliesUserpic::subscribeToUpdates(Fn<void()> callback) {
}
}
std::shared_ptr<DynamicImage> VerifyCodesUserpic::clone() {
return std::make_shared<VerifyCodesUserpic>();
}
QImage VerifyCodesUserpic::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::PaintVerifyCodes(p, 0, 0, size, size);
}
return _frame;
}
void VerifyCodesUserpic::subscribeToUpdates(Fn<void()> callback) {
if (!callback) {
_frame = {};
}
}
std::shared_ptr<DynamicImage> HiddenAuthorUserpic::clone() {
return std::make_shared<HiddenAuthorUserpic>();
}
@ -667,10 +623,6 @@ std::shared_ptr<DynamicImage> MakeRepliesThumbnail() {
return std::make_shared<RepliesUserpic>();
}
std::shared_ptr<DynamicImage> MakeVerifyCodesThumbnail() {
return std::make_shared<VerifyCodesUserpic>();
}
std::shared_ptr<DynamicImage> MakeHiddenAuthorThumbnail() {
return std::make_shared<HiddenAuthorUserpic>();
}

View file

@ -23,7 +23,6 @@ class DynamicImage;
bool forceRound = false);
[[nodiscard]] std::shared_ptr<DynamicImage> MakeSavedMessagesThumbnail();
[[nodiscard]] std::shared_ptr<DynamicImage> MakeRepliesThumbnail();
[[nodiscard]] std::shared_ptr<DynamicImage> MakeVerifyCodesThumbnail();
[[nodiscard]] std::shared_ptr<DynamicImage> MakeHiddenAuthorThumbnail();
[[nodiscard]] std::shared_ptr<DynamicImage> MakeStoryThumbnail(
not_null<Data::Story*> story);

View file

@ -226,22 +226,6 @@ void PaintInaccessibleAccountInner(
}
}
void PaintVerifyCodesInner(
QPainter &p,
int x,
int y,
int size,
const style::color &fg) {
PaintIconInner(
p,
x,
y,
size,
st::defaultDialogRow.photoSize,
st::dialogsVerifyCodesUserpic,
fg);
}
[[nodiscard]] QImage Generate(int size, Fn<void(QPainter&)> callback) {
auto result = QImage(
QSize(size, size) * style::DevicePixelRatio(),
@ -445,45 +429,6 @@ QImage EmptyUserpic::GenerateRepliesMessages(int size) {
});
}
void EmptyUserpic::PaintVerifyCodes(
QPainter &p,
int x,
int y,
int outerWidth,
int size) {
auto bg = QLinearGradient(x, y, x, y + size);
bg.setStops({
{ 0., st::historyPeerSavedMessagesBg->c },
{ 1., st::historyPeerSavedMessagesBg2->c }
});
const auto &fg = st::historyPeerUserpicFg;
PaintVerifyCodes(p, x, y, outerWidth, size, QBrush(bg), fg);
}
void EmptyUserpic::PaintVerifyCodes(
QPainter &p,
int x,
int y,
int outerWidth,
int size,
QBrush bg,
const style::color &fg) {
x = style::RightToLeft() ? (outerWidth - x - size) : x;
PainterHighQualityEnabler hq(p);
p.setBrush(bg);
p.setPen(Qt::NoPen);
p.drawEllipse(x, y, size, size);
PaintVerifyCodesInner(p, x, y, size, fg);
}
QImage EmptyUserpic::GenerateVerifyCodes(int size) {
return Generate(size, [&](QPainter &p) {
PaintVerifyCodes(p, 0, 0, size, size);
});
}
void EmptyUserpic::PaintHiddenAuthor(
QPainter &p,
int x,

View file

@ -81,22 +81,6 @@ public:
const style::color &fg);
[[nodiscard]] static QImage GenerateRepliesMessages(int size);
static void PaintVerifyCodes(
QPainter &p,
int x,
int y,
int outerWidth,
int size);
static void PaintVerifyCodes(
QPainter &p,
int x,
int y,
int outerWidth,
int size,
QBrush bg,
const style::color &fg);
[[nodiscard]] static QImage GenerateVerifyCodes(int size);
static void PaintHiddenAuthor(
QPainter &p,
int x,

View file

@ -870,9 +870,6 @@ void Notification::updateNotifyDisplay() {
} else if (_history->peer->isRepliesChat()) {
Ui::EmptyUserpic::PaintRepliesMessages(p, st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), width(), st::notifyPhotoSize);
_userpicLoaded = true;
} else if (_history->peer->isVerifyCodes()) {
Ui::EmptyUserpic::PaintVerifyCodes(p, st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), width(), st::notifyPhotoSize);
_userpicLoaded = true;
} else {
_userpicView = _history->peer->createUserpicView();
_history->peer->loadUserpic();

View file

@ -28,8 +28,6 @@ QImage GenerateUserpic(not_null<PeerData*> peer, Ui::PeerUserpicView &view) {
? Ui::EmptyUserpic::GenerateSavedMessages(st::notifyMacPhotoSize)
: peer->isRepliesChat()
? Ui::EmptyUserpic::GenerateRepliesMessages(st::notifyMacPhotoSize)
: peer->isVerifyCodes()
? Ui::EmptyUserpic::GenerateVerifyCodes(st::notifyMacPhotoSize)
: PeerData::GenerateUserpicImage(peer, view, st::notifyMacPhotoSize);
}