diff --git a/Telegram/Resources/art/topic_icons/general.svg b/Telegram/Resources/art/topic_icons/general.svg
new file mode 100644
index 0000000000..140ed8da5d
--- /dev/null
+++ b/Telegram/Resources/art/topic_icons/general.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Telegram/Resources/qrc/telegram/telegram.qrc b/Telegram/Resources/qrc/telegram/telegram.qrc
index d9b026c88d..8eac62c66a 100644
--- a/Telegram/Resources/qrc/telegram/telegram.qrc
+++ b/Telegram/Resources/qrc/telegram/telegram.qrc
@@ -35,6 +35,7 @@
../../art/topic_icons/rose.svg
../../art/topic_icons/red.svg
../../art/topic_icons/gray.svg
+ ../../art/topic_icons/general.svg
../../icons/calls/hands.lottie
diff --git a/Telegram/SourceFiles/data/data_forum_topic.cpp b/Telegram/SourceFiles/data/data_forum_topic.cpp
index 9e18cf5c2f..e9e168aae0 100644
--- a/Telegram/SourceFiles/data/data_forum_topic.cpp
+++ b/Telegram/SourceFiles/data/data_forum_topic.cpp
@@ -143,6 +143,24 @@ QImage ForumTopicIconFrame(
return background;
}
+QImage ForumTopicGeneralIconFrame(int size, const style::color &color) {
+ const auto ratio = style::DevicePixelRatio();
+ auto svg = QSvgRenderer(ForumTopicIconPath(u"general"_q));
+ auto result = QImage(
+ QSize(size, size) * ratio,
+ QImage::Format_ARGB32_Premultiplied);
+ result.setDevicePixelRatio(ratio);
+ result.fill(Qt::transparent);
+
+ const auto use = size * 0.8;
+ const auto skip = size * 0.1;
+ auto p = QPainter(&result);
+ svg.render(&p, QRectF(skip, 0, use, use));
+ p.end();
+
+ return style::colorizeImage(result, color);
+}
+
TextWithEntities ForumTopicIconWithTitle(
DocumentId iconId,
const QString &title) {
@@ -185,6 +203,13 @@ ForumTopic::ForumTopic(not_null forum, MsgId rootId)
previous.value_or(0),
previous.has_value()));
}, _replies->lifetime());
+
+ if (isGeneral()) {
+ style::PaletteChanged(
+ ) | rpl::start_with_next([=] {
+ _defaultIcon = QImage();
+ }, _lifetime);
+ }
}
ForumTopic::~ForumTopic() {
@@ -540,7 +565,11 @@ void ForumTopic::paintUserpic(
.paused = context.paused,
});
} else {
- validateDefaultIcon();
+ if (isGeneral()) {
+ validateGeneralIcon(context);
+ } else {
+ validateDefaultIcon();
+ }
const auto size = st::defaultForumTopicIcon.size;
if (context.narrow) {
position = QPoint(
@@ -562,12 +591,34 @@ void ForumTopic::clearUserpicLoops() {
}
void ForumTopic::validateDefaultIcon() const {
- if (_defaultIcon.isNull()) {
- _defaultIcon = ForumTopicIconFrame(
- _colorId,
- _title,
- st::defaultForumTopicIcon);
+ if (!_defaultIcon.isNull()) {
+ return;
}
+ _defaultIcon = ForumTopicIconFrame(
+ _colorId,
+ _title,
+ st::defaultForumTopicIcon);
+}
+
+void ForumTopic::validateGeneralIcon(
+ const Dialogs::Ui::PaintContext &context) const {
+ const auto mask = Flag::GeneralIconActive | Flag::GeneralIconSelected;
+ const auto flags = context.active
+ ? Flag::GeneralIconActive
+ : context.selected
+ ? Flag::GeneralIconSelected
+ : Flag(0);
+ if (!_defaultIcon.isNull() && ((_flags & mask) == flags)) {
+ return;
+ }
+ const auto size = st::defaultForumTopicIcon.size;
+ const auto &color = context.active
+ ? st::dialogsTextFgActive
+ : context.selected
+ ? st::dialogsTextFgOver
+ : st::dialogsTextFg;
+ _defaultIcon = ForumTopicGeneralIconFrame(size, color);
+ _flags = (_flags & ~mask) | flags;
}
void ForumTopic::requestChatListMessage() {
diff --git a/Telegram/SourceFiles/data/data_forum_topic.h b/Telegram/SourceFiles/data/data_forum_topic.h
index 7720981e42..329b4cf8f3 100644
--- a/Telegram/SourceFiles/data/data_forum_topic.h
+++ b/Telegram/SourceFiles/data/data_forum_topic.h
@@ -45,6 +45,9 @@ class Forum;
int32 colorId,
const QString &title,
const style::ForumTopicIcon &st);
+[[nodiscard]] QImage ForumTopicGeneralIconFrame(
+ int size,
+ const style::color &color);
[[nodiscard]] TextWithEntities ForumTopicIconWithTitle(
DocumentId iconId,
const QString &title);
@@ -160,12 +163,15 @@ private:
Closed = (1 << 0),
My = (1 << 1),
HasPinnedMessages = (1 << 2),
+ GeneralIconActive = (1 << 3),
+ GeneralIconSelected = (1 << 4),
};
friend inline constexpr bool is_flag_type(Flag) { return true; }
using Flags = base::flags;
void indexTitleParts();
void validateDefaultIcon() const;
+ void validateGeneralIcon(const Dialogs::Ui::PaintContext &context) const;
void applyTopicTopMessage(MsgId topMessageId);
void growLastKnownServerMessageId(MsgId id);
@@ -197,7 +203,7 @@ private:
TimeId _creationDate = 0;
int _titleVersion = 0;
int32 _colorId = 0;
- Flags _flags;
+ mutable Flags _flags;
std::unique_ptr _icon;
mutable QImage _defaultIcon; // on-demand
diff --git a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp
index 0c82c76dfc..b4b8964219 100644
--- a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp
+++ b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp
@@ -216,11 +216,17 @@ void TopicIconView::setupPlayer(not_null topic) {
}
void TopicIconView::setupImage(not_null topic) {
+ using namespace Data;
+ if (topic->isGeneral()) {
+ _image = ForumTopicGeneralIconFrame(
+ st::infoForumTopicIcon.size,
+ st::windowSubTextFg);
+ return;
+ }
rpl::combine(
TitleValue(topic),
ColorIdValue(topic)
) | rpl::map([=](const QString &title, int32 colorId) {
- using namespace Data;
return ForumTopicIconFrame(colorId, title, st::infoForumTopicIcon);
}) | rpl::start_with_next([=](QImage &&image) {
_image = std::move(image);