From 08a3a5747a0af45a12d0034f82a8c854f3ad08a2 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 17 May 2019 19:54:24 +0300 Subject: [PATCH] Added custom background to top of main menu. --- .../SourceFiles/window/window_main_menu.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 8f7d71d21..b85dbe051 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -247,13 +247,26 @@ void MainMenu::updatePhone() { void MainMenu::paintEvent(QPaintEvent *e) { Painter p(this); - auto clip = e->rect(); - auto cover = QRect(0, 0, width(), st::mainMenuCoverHeight).intersected(clip); + const auto clip = e->rect(); + const auto fill = QRect(0, 0, width(), st::mainMenuCoverHeight); + const auto cover = fill.intersected(clip); + + if (const auto color = Window::Theme::Background()->colorForFill()) { + p.fillRect(fill, *color); + } else { + PainterHighQualityEnabler hq(p); + + const auto &pix = Window::Theme::Background()->pixmap(); + QRect to, from; + Window::Theme::ComputeBackgroundRects(fill, pix.size(), to, from); + p.drawPixmap(to, pix, from); + } + if (!cover.isEmpty()) { const auto widthText = _cloudButton ? _cloudButton->x() - st::mainMenuCloudSize : width() - 2 * st::mainMenuCoverTextLeft; - p.fillRect(cover, st::mainMenuCoverBg); + p.fillRect(cover, QColor(0, 0, 0, 51)); // 20% opacity. p.setPen(st::mainMenuCoverFg); p.setFont(st::semiboldFont); Auth().user()->nameText.drawLeftElided(