From b4eb9a082760095f51643cdd57e7241b074620fe Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 20 Aug 2021 16:24:26 +0300 Subject: [PATCH] Fix single-colored patterns. --- Telegram/SourceFiles/settings/settings_chat.cpp | 5 ++--- Telegram/SourceFiles/window/section_widget.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/settings/settings_chat.cpp b/Telegram/SourceFiles/settings/settings_chat.cpp index 71bf76c05..cff8a298c 100644 --- a/Telegram/SourceFiles/settings/settings_chat.cpp +++ b/Telegram/SourceFiles/settings/settings_chat.cpp @@ -983,9 +983,8 @@ void SetupChatBackground( }, tile->lifetime()); const auto shown = [=] { - return !background->prepared().isNull() - && !background->colorForFill() - && background->gradientForFill().isNull(); + return !background->paper().isPattern() + && !background->colorForFill(); }; tile->toggle(shown(), anim::type::instant); diff --git a/Telegram/SourceFiles/window/section_widget.cpp b/Telegram/SourceFiles/window/section_widget.cpp index 6b5d7b29c..2ac6cea5f 100644 --- a/Telegram/SourceFiles/window/section_widget.cpp +++ b/Telegram/SourceFiles/window/section_widget.cpp @@ -151,6 +151,17 @@ void SectionWidget::PaintBackground( const auto &prepared = background->prepared(); if (prepared.isNull()) { return; + } else if (background->paper().isPattern()) { + const auto w = prepared.width() * fill.height() / prepared.height(); + const auto cx = qCeil(fill.width() / float64(w)); + const auto cols = (cx / 2) * 2 + 1; + const auto xshift = (fill.width() - w * cols) / 2; + for (auto i = 0; i != cols; ++i) { + p.drawImage( + QRect(xshift + i * w, 0, w, fill.height()), + prepared, + QRect(QPoint(), prepared.size())); + } } else if (background->tile()) { const auto &tiled = background->preparedForTiled(); const auto left = clip.left();