From 993877b0d4cecfb4cde434da44020c66f222333e Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 5 Dec 2017 20:48:03 +0400 Subject: [PATCH] Change main menu cloud icon to saved messages. --- Telegram/SourceFiles/ui/empty_userpic.cpp | 17 ++++++++++++-- Telegram/SourceFiles/ui/empty_userpic.h | 8 +++++++ Telegram/SourceFiles/window/window.style | 2 +- .../SourceFiles/window/window_main_menu.cpp | 23 ++++++++++++++----- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/ui/empty_userpic.cpp b/Telegram/SourceFiles/ui/empty_userpic.cpp index b32400a19..dfb04037b 100644 --- a/Telegram/SourceFiles/ui/empty_userpic.cpp +++ b/Telegram/SourceFiles/ui/empty_userpic.cpp @@ -84,10 +84,23 @@ void EmptyUserpic::PaintSavedMessages( int y, int outerWidth, int size) { + const auto &bg = st::historyPeer4UserpicBg; + const auto &fg = st::historyPeerUserpicFg; + PaintSavedMessages(p, x, y, outerWidth, size, bg, fg); +} + +void EmptyUserpic::PaintSavedMessages( + Painter &p, + int x, + int y, + int outerWidth, + int size, + const style::color &bg, + const style::color &fg) { x = rtl() ? (outerWidth - x - size) : x; PainterHighQualityEnabler hq(p); - p.setBrush(st::historyPeer4UserpicBg); + p.setBrush(bg); p.setPen(Qt::NoPen); p.drawEllipse(x, y, size, size); @@ -118,7 +131,7 @@ void EmptyUserpic::PaintSavedMessages( const auto half = (top + bottom) / 2; p.setBrush(Qt::NoBrush); - auto pen = st::historyPeerUserpicFg->p; + auto pen = fg->p; pen.setWidthF(thinkness); pen.setCapStyle(Qt::FlatCap); diff --git a/Telegram/SourceFiles/ui/empty_userpic.h b/Telegram/SourceFiles/ui/empty_userpic.h index b2ed69f62..3230643d9 100644 --- a/Telegram/SourceFiles/ui/empty_userpic.h +++ b/Telegram/SourceFiles/ui/empty_userpic.h @@ -53,6 +53,14 @@ public: int y, int outerWidth, int size); + static void PaintSavedMessages( + Painter &p, + int x, + int y, + int outerWidth, + int size, + const style::color &bg, + const style::color &fg); ~EmptyUserpic(); diff --git a/Telegram/SourceFiles/window/window.style b/Telegram/SourceFiles/window/window.style index c1cb87560..0b0865f68 100644 --- a/Telegram/SourceFiles/window/window.style +++ b/Telegram/SourceFiles/window/window.style @@ -113,7 +113,7 @@ mainMenuCloudButton: IconButton { height: 64px; icon: icon { - { "menu_cloud", mainMenuCloudFg }, +// { "menu_cloud", mainMenuCloudFg }, }; iconPosition: point(22px, 22px); } diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 61dafc79d..71aaf2f62 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -27,6 +27,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "ui/widgets/labels.h" #include "ui/widgets/menu.h" #include "ui/special_buttons.h" +#include "ui/empty_userpic.h" #include "mainwindow.h" #include "storage/localstorage.h" #include "boxes/about_box.h" @@ -199,13 +200,23 @@ void MainMenu::paintEvent(QPaintEvent *e) { p.drawTextLeft(st::mainMenuCoverTextLeft, st::mainMenuCoverStatusTop, width(), _phoneText); } if (_cloudButton) { - PainterHighQualityEnabler hq(p); - p.setPen(Qt::NoPen); - p.setBrush(st::mainMenuCloudBg); - auto cloudBg = QRect(_cloudButton->x() + (_cloudButton->width() - st::mainMenuCloudSize) / 2, + Ui::EmptyUserpic::PaintSavedMessages( + p, + _cloudButton->x() + (_cloudButton->width() - st::mainMenuCloudSize) / 2, _cloudButton->y() + (_cloudButton->height() - st::mainMenuCloudSize) / 2, - st::mainMenuCloudSize, st::mainMenuCloudSize); - p.drawEllipse(cloudBg); + width(), + st::mainMenuCloudSize, + st::mainMenuCloudBg, + st::mainMenuCloudFg); + //PainterHighQualityEnabler hq(p); + //p.setPen(Qt::NoPen); + //p.setBrush(st::mainMenuCloudBg); + //auto cloudBg = QRect( + // _cloudButton->x() + (_cloudButton->width() - st::mainMenuCloudSize) / 2, + // _cloudButton->y() + (_cloudButton->height() - st::mainMenuCloudSize) / 2, + // st::mainMenuCloudSize, + // st::mainMenuCloudSize); + //p.drawEllipse(cloudBg); } } auto other = QRect(0, st::mainMenuCoverHeight, width(), height() - st::mainMenuCoverHeight).intersected(clip);