mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-06 11:52:58 +00:00
Added chat theme bubble gradient to all chats.
This commit is contained in:
@@ -247,8 +247,9 @@ constexpr auto kMinAcceptableContrast = 1.14;// 4.5;
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] QImage PrepareBubblesBackground(
|
||||
const ChatThemeBubblesData &data) {
|
||||
} // namespace
|
||||
|
||||
QImage PrepareBubblesBackground(const ChatThemeBubblesData &data) {
|
||||
if (data.colors.size() < 2) {
|
||||
return QImage();
|
||||
}
|
||||
@@ -256,8 +257,6 @@ constexpr auto kMinAcceptableContrast = 1.14;// 4.5;
|
||||
return Images::GenerateLinearGradient(QSize(kSize, kSize), data.colors);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool operator==(const ChatThemeBackground &a, const ChatThemeBackground &b) {
|
||||
return (a.key == b.key)
|
||||
&& (a.prepared.cacheKey() == b.prepared.cacheKey())
|
||||
@@ -551,7 +550,10 @@ void ChatTheme::setBubblesBackground(QImage image) {
|
||||
: _bubblesBackground.area),
|
||||
});
|
||||
if (!_bubblesBackgroundPattern) {
|
||||
_bubblesBackgroundPattern = PrepareBubblePattern(palette());
|
||||
const auto use = _palette
|
||||
? _palette.get()
|
||||
: style::main_palette::get().get();
|
||||
_bubblesBackgroundPattern = PrepareBubblePattern(use);
|
||||
}
|
||||
_bubblesBackgroundPattern->pixmap = _bubblesBackground.pixmap;
|
||||
// setBubblesBackground called only from background thread.
|
||||
|
||||
@@ -287,6 +287,8 @@ struct BackgroundImageFields {
|
||||
int rotation);
|
||||
[[nodiscard]] ChatThemeBackground PrepareBackgroundImage(
|
||||
const ChatThemeBackgroundData &data);
|
||||
[[nodiscard]] QImage PrepareBubblesBackground(
|
||||
const ChatThemeBubblesData &data);
|
||||
[[nodiscard]] QImage PrepareGiftSymbol(
|
||||
const std::unique_ptr<Text::CustomEmoji> &emoji);
|
||||
|
||||
|
||||
@@ -36,7 +36,9 @@ namespace {
|
||||
return result;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::optional<Data::CloudThemeType> SettingsTypeFor(
|
||||
} // namespace
|
||||
|
||||
std::optional<Data::CloudThemeType> ChatThemeVariant(
|
||||
const Data::CloudTheme &theme,
|
||||
bool dark) {
|
||||
const auto type = dark
|
||||
@@ -52,8 +54,6 @@ namespace {
|
||||
: std::nullopt;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Ui::ChatThemeBubblesData PrepareBubblesData(
|
||||
const Data::CloudTheme &theme,
|
||||
Data::CloudThemeType type) {
|
||||
@@ -71,7 +71,7 @@ Ui::ChatThemeBubblesData PrepareBubblesData(
|
||||
std::unique_ptr<Preview> PreviewFromChatTheme(
|
||||
const Data::CloudTheme &theme,
|
||||
bool dark) {
|
||||
const auto used = SettingsTypeFor(theme, dark);
|
||||
const auto used = ChatThemeVariant(theme, dark);
|
||||
if (!used) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ void ApplyChatTheme(
|
||||
not_null<SessionController*> controller,
|
||||
const Data::CloudTheme &theme,
|
||||
bool dark) {
|
||||
const auto used = SettingsTypeFor(theme, dark);
|
||||
const auto used = ChatThemeVariant(theme, dark);
|
||||
if (!used) {
|
||||
return;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ void CheckChatThemeWallPaper(not_null<SessionController*> controller) {
|
||||
if (cloud.emoticon.isEmpty() || cloud.settings.empty()) {
|
||||
return;
|
||||
}
|
||||
const auto used = SettingsTypeFor(cloud, IsNightMode());
|
||||
const auto used = ChatThemeVariant(cloud, IsNightMode());
|
||||
if (!used) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ namespace Window::Theme {
|
||||
|
||||
struct Preview;
|
||||
|
||||
[[nodiscard]] std::optional<Data::CloudThemeType> ChatThemeVariant(
|
||||
const Data::CloudTheme &theme,
|
||||
bool dark);
|
||||
|
||||
[[nodiscard]] Ui::ChatThemeBubblesData PrepareBubblesData(
|
||||
const Data::CloudTheme &theme,
|
||||
Data::CloudThemeType type);
|
||||
|
||||
@@ -3536,6 +3536,22 @@ void SessionController::pushDefaultChatBackground() {
|
||||
.isPattern = paper.isPattern(),
|
||||
.tile = background->tile(),
|
||||
});
|
||||
const auto &cloud = background->themeObject().cloud;
|
||||
auto bubbles = Ui::ChatThemeBubblesData();
|
||||
if (!cloud.emoticon.isEmpty()) {
|
||||
const auto variant = Theme::ChatThemeVariant(
|
||||
cloud,
|
||||
Theme::IsNightMode());
|
||||
if (variant) {
|
||||
bubbles = Theme::PrepareBubblesData(cloud, *variant);
|
||||
}
|
||||
}
|
||||
if (bubbles.colors != _defaultChatThemeBubblesColors) {
|
||||
_defaultChatThemeBubblesColors = bubbles.colors;
|
||||
_defaultChatTheme->setBubblesBackground(
|
||||
Ui::PrepareBubblesBackground(bubbles));
|
||||
_defaultChatTheme->finishCreateOnMain();
|
||||
}
|
||||
}
|
||||
|
||||
void SessionController::cacheChatTheme(
|
||||
|
||||
@@ -864,6 +864,7 @@ private:
|
||||
rpl::event_stream<> _filtersMenuChanged;
|
||||
|
||||
const std::shared_ptr<Ui::ChatTheme> _defaultChatTheme;
|
||||
std::vector<QColor> _defaultChatThemeBubblesColors;
|
||||
base::flat_map<CachedThemeKey, CachedTheme> _customChatThemes;
|
||||
rpl::event_stream<std::shared_ptr<Ui::ChatTheme>> _cachedThemesStream;
|
||||
rpl::event_stream<> _giftSymbolLoaded;
|
||||
|
||||
Reference in New Issue
Block a user