diff --git a/Telegram/Resources/art/logo_256.png b/Telegram/Resources/art/logo_256.png
new file mode 100644
index 000000000..2e818f129
Binary files /dev/null and b/Telegram/Resources/art/logo_256.png differ
diff --git a/Telegram/Resources/art/iconbig256.png b/Telegram/Resources/art/logo_256_no_margin.png
similarity index 100%
rename from Telegram/Resources/art/iconbig256.png
rename to Telegram/Resources/art/logo_256_no_margin.png
diff --git a/Telegram/Resources/qrc/telegram.qrc b/Telegram/Resources/qrc/telegram.qrc
index 6b9c6d9a0..111f5c7ee 100644
--- a/Telegram/Resources/qrc/telegram.qrc
+++ b/Telegram/Resources/qrc/telegram.qrc
@@ -5,8 +5,8 @@
../fonts/OpenSans-Semibold.ttf
../art/bg.jpg
../art/bg_initial.jpg
- ../art/icon256.png
- ../art/iconbig256.png
+ ../art/logo_256.png
+ ../art/logo_256_no_margin.png
../art/sunrise.jpg
diff --git a/Telegram/SourceFiles/boxes/notifications_box.cpp b/Telegram/SourceFiles/boxes/notifications_box.cpp
index 46051c53e..fcbf0586b 100644
--- a/Telegram/SourceFiles/boxes/notifications_box.cpp
+++ b/Telegram/SourceFiles/boxes/notifications_box.cpp
@@ -26,10 +26,11 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "styles/style_boxes.h"
#include "styles/style_dialogs.h"
#include "styles/style_window.h"
-#include "mainwindow.h"
+#include "messenger.h"
#include "storage/localstorage.h"
#include "auth_session.h"
#include "window/notifications_manager.h"
+#include "platform/platform_specific.h"
namespace {
@@ -259,7 +260,7 @@ void NotificationsBox::prepareNotificationSampleSmall() {
void NotificationsBox::prepareNotificationSampleUserpic() {
if (_notificationSampleUserpic.isNull()) {
- _notificationSampleUserpic = App::pixmapFromImageInPlace(App::wnd()->iconLarge().scaled(st::notifyPhotoSize * cIntRetinaFactor(), st::notifyPhotoSize * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
+ _notificationSampleUserpic = App::pixmapFromImageInPlace(Messenger::Instance().logoNoMargin().scaled(st::notifyPhotoSize * cIntRetinaFactor(), st::notifyPhotoSize * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
_notificationSampleUserpic.setDevicePixelRatio(cRetinaFactor());
}
}
diff --git a/Telegram/SourceFiles/calls/calls_panel.cpp b/Telegram/SourceFiles/calls/calls_panel.cpp
index d47223b9c..a8a09da95 100644
--- a/Telegram/SourceFiles/calls/calls_panel.cpp
+++ b/Telegram/SourceFiles/calls/calls_panel.cpp
@@ -29,12 +29,14 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "ui/effects/ripple_animation.h"
#include "ui/effects/widget_fade_wrap.h"
#include "messenger.h"
+#include "mainwindow.h"
#include "lang.h"
#include "auth_session.h"
#include "apiwrap.h"
#include "observer_peer.h"
#include "platform/platform_specific.h"
#include "base/task_queue.h"
+#include "window/main_window.h"
namespace Calls {
namespace {
@@ -248,6 +250,7 @@ Panel::Panel(gsl::not_null call)
, _name(this, st::callName)
, _status(this, st::callStatus) {
setMouseTracking(true);
+ setWindowIcon(Window::CreateIcon());
initControls();
initLayout();
showAndActivate();
@@ -641,6 +644,10 @@ void Panel::paintEvent(QPaintEvent *e) {
}
}
+void Panel::closeEvent(QCloseEvent *e) {
+ _call->hangup();
+}
+
void Panel::mousePressEvent(QMouseEvent *e) {
auto dragArea = myrtlrect(_padding.left(), _padding.top(), st::callWidth, st::callWidth);
if (e->button() == Qt::LeftButton) {
diff --git a/Telegram/SourceFiles/calls/calls_panel.h b/Telegram/SourceFiles/calls/calls_panel.h
index ac99b7b11..5b7a52541 100644
--- a/Telegram/SourceFiles/calls/calls_panel.h
+++ b/Telegram/SourceFiles/calls/calls_panel.h
@@ -44,6 +44,7 @@ public:
protected:
void paintEvent(QPaintEvent *e) override;
+ void closeEvent(QCloseEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp
index 2cf83d4c6..0536632f7 100644
--- a/Telegram/SourceFiles/mainwindow.cpp
+++ b/Telegram/SourceFiles/mainwindow.cpp
@@ -94,12 +94,15 @@ void ConnectingWidget::onReconnect() {
}
MainWindow::MainWindow() {
- icon16 = icon256.scaledToWidth(16, Qt::SmoothTransformation);
- icon32 = icon256.scaledToWidth(32, Qt::SmoothTransformation);
- icon64 = icon256.scaledToWidth(64, Qt::SmoothTransformation);
- iconbig16 = iconbig256.scaledToWidth(16, Qt::SmoothTransformation);
- iconbig32 = iconbig256.scaledToWidth(32, Qt::SmoothTransformation);
- iconbig64 = iconbig256.scaledToWidth(64, Qt::SmoothTransformation);
+ auto logo = Messenger::Instance().logo();
+ icon16 = logo.scaledToWidth(16, Qt::SmoothTransformation);
+ icon32 = logo.scaledToWidth(32, Qt::SmoothTransformation);
+ icon64 = logo.scaledToWidth(64, Qt::SmoothTransformation);
+
+ auto logoNoMargin = Messenger::Instance().logoNoMargin();
+ iconbig16 = logoNoMargin.scaledToWidth(16, Qt::SmoothTransformation);
+ iconbig32 = logoNoMargin.scaledToWidth(32, Qt::SmoothTransformation);
+ iconbig64 = logoNoMargin.scaledToWidth(64, Qt::SmoothTransformation);
resize(st::windowDefaultWidth, st::windowDefaultHeight);
@@ -904,10 +907,6 @@ void MainWindow::app_activateClickHandler(ClickHandlerPtr handler, Qt::MouseButt
handler->onClick(button);
}
-QImage MainWindow::iconLarge() const {
- return iconbig256;
-}
-
void MainWindow::placeSmallCounter(QImage &img, int size, int count, style::color bg, const QPoint &shift, style::color color) {
QPainter p(&img);
@@ -1040,15 +1039,12 @@ MainWindow::~MainWindow() {
delete trayIconMenu;
}
-PreLaunchWindow *PreLaunchWindowInstance = 0;
+PreLaunchWindow *PreLaunchWindowInstance = nullptr;
-PreLaunchWindow::PreLaunchWindow(QString title) : TWidget(0) {
+PreLaunchWindow::PreLaunchWindow(QString title) {
Fonts::Start();
- QIcon icon(App::pixmapFromImageInPlace(QImage(cPlatform() == dbipMac ? qsl(":/gui/art/iconbig256.png") : qsl(":/gui/art/icon256.png"))));
- if (cPlatform() == dbipLinux32 || cPlatform() == dbipLinux64) {
- icon = QIcon::fromTheme("telegram", icon);
- }
+ auto icon = Window::CreateIcon();
setWindowIcon(icon);
setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
@@ -1084,7 +1080,7 @@ PreLaunchWindow *PreLaunchWindow::instance() {
PreLaunchWindow::~PreLaunchWindow() {
if (PreLaunchWindowInstance == this) {
- PreLaunchWindowInstance = 0;
+ PreLaunchWindowInstance = nullptr;
}
}
diff --git a/Telegram/SourceFiles/mainwindow.h b/Telegram/SourceFiles/mainwindow.h
index 736d987c2..0cded7d69 100644
--- a/Telegram/SourceFiles/mainwindow.h
+++ b/Telegram/SourceFiles/mainwindow.h
@@ -123,8 +123,6 @@ public:
TempDirState localStorageState();
void tempDirDelete(int task);
- QImage iconLarge() const;
-
void sendPaths();
void changingMsgId(HistoryItem *row, MsgId newId) override;
diff --git a/Telegram/SourceFiles/messenger.cpp b/Telegram/SourceFiles/messenger.cpp
index 3aa5d9403..ff4899d6d 100644
--- a/Telegram/SourceFiles/messenger.cpp
+++ b/Telegram/SourceFiles/messenger.cpp
@@ -66,8 +66,12 @@ struct Messenger::Private {
Messenger::Messenger() : QObject()
, _private(std::make_unique())
-, _audio(std::make_unique()) {
- t_assert(SingleInstance == nullptr);
+, _audio(std::make_unique())
+, _logo(Window::LoadLogo())
+, _logoNoMargin(Window::LoadLogoNoMargin()) {
+ Expects(!_logo.isNull());
+ Expects(!_logoNoMargin.isNull());
+ Expects(SingleInstance == nullptr);
SingleInstance = this;
Fonts::Start();
diff --git a/Telegram/SourceFiles/messenger.h b/Telegram/SourceFiles/messenger.h
index 9d52d273a..eaafa9a0a 100644
--- a/Telegram/SourceFiles/messenger.h
+++ b/Telegram/SourceFiles/messenger.h
@@ -60,6 +60,12 @@ public:
MainWindow *mainWindow();
QPoint getPointForCallPanelCenter() const;
+ QImage logo() const {
+ return _logo;
+ }
+ QImage logoNoMargin() const {
+ return _logoNoMargin;
+ }
static Messenger *InstancePointer();
static Messenger &Instance() {
@@ -192,5 +198,7 @@ private:
base::Observable _passcodedChanged;
std::unique_ptr _audio;
+ QImage _logo;
+ QImage _logoNoMargin;
};
diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp
index 59a03792e..4555358b0 100644
--- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp
+++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp
@@ -25,6 +25,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "platform/linux/linux_desktop_environment.h"
#include "platform/platform_notifications_manager.h"
#include "mainwindow.h"
+#include "messenger.h"
#include "application.h"
#include "lang.h"
#include "storage/localstorage.h"
@@ -80,7 +81,7 @@ QImage _trayIconImageGen() {
bool muted = App::histories().unreadOnlyMuted();
if (_trayIconImage.isNull() || _trayIconImage.width() != _trayIconSize || muted != _trayIconMuted || counterSlice != _trayIconCount) {
if (_trayIconImageBack.isNull() || _trayIconImageBack.width() != _trayIconSize) {
- _trayIconImageBack = App::wnd()->iconLarge().scaled(_trayIconSize, _trayIconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ _trayIconImageBack = Messenger::Instance().logo().scaled(_trayIconSize, _trayIconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
_trayIconImageBack = _trayIconImageBack.convertToFormat(QImage::Format_ARGB32);
int w = _trayIconImageBack.width(), h = _trayIconImageBack.height(), perline = _trayIconImageBack.bytesPerLine();
uchar *bytes = _trayIconImageBack.bits();
@@ -182,10 +183,7 @@ UnityLauncherEntry *_psUnityLauncherEntry = nullptr;
} // namespace
-MainWindow::MainWindow()
-: icon256(qsl(":/gui/art/icon256.png"))
-, iconbig256(icon256)
-, wndIcon(QIcon::fromTheme("telegram", QIcon(QPixmap::fromImage(icon256, Qt::ColorOnly)))) {
+MainWindow::MainWindow() {
connect(&_psCheckStatusIconTimer, SIGNAL(timeout()), this, SLOT(psStatusIconCheck()));
_psCheckStatusIconTimer.setSingleShot(false);
@@ -193,10 +191,6 @@ MainWindow::MainWindow()
_psUpdateIndicatorTimer.setSingleShot(true);
}
-void MainWindow::initHook() {
- setWindowIcon(wndIcon);
-}
-
bool MainWindow::hasTrayIcon() const {
return trayIcon || ((useAppIndicator || (useStatusIcon && trayIconChecked)) && (Global::WorkMode().value() != dbiwmWindowOnly));
}
@@ -252,7 +246,7 @@ void MainWindow::psSetupTrayIcon() {
QByteArray path = QFile::encodeName(iconFile.absoluteFilePath());
icon = QIcon(path.constData());
} else {
- icon = QIcon(QPixmap::fromImage(App::wnd()->iconLarge(), Qt::ColorOnly));
+ icon = Window::CreateIcon();
}
trayIcon->setIcon(icon);
@@ -323,9 +317,9 @@ void MainWindow::unreadCounterChangedHook() {
}
void MainWindow::updateIconCounters() {
- setWindowIcon(wndIcon);
+ updateWindowIcon();
- int32 counter = App::histories().unreadBadge();
+ auto counter = App::histories().unreadBadge();
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
if (_psUnityLauncherEntry) {
diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.h b/Telegram/SourceFiles/platform/linux/main_window_linux.h
index d23f6ac07..10859223e 100644
--- a/Telegram/SourceFiles/platform/linux/main_window_linux.h
+++ b/Telegram/SourceFiles/platform/linux/main_window_linux.h
@@ -51,7 +51,6 @@ public slots:
void psUpdateIndicator();
protected:
- void initHook() override;
void unreadCounterChangedHook() override;
bool hasTrayIcon() const override;
@@ -60,8 +59,6 @@ protected:
QSystemTrayIcon *trayIcon = nullptr;
QMenu *trayIconMenu = nullptr;
- QImage icon256, iconbig256;
- QIcon wndIcon;
void psTrayMenuUpdated();
void psSetupTrayIcon();
diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp
index 3f2192f5c..41531aacb 100644
--- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp
+++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp
@@ -456,7 +456,7 @@ void psRegisterCustomScheme() {
}
}
if (!iconExists) {
- if (QFile(qsl(":/gui/art/icon256.png")).copy(icon)) {
+ if (QFile(qsl(":/gui/art/logo_256.png")).copy(icon)) {
DEBUG_LOG(("App Info: Icon copied to 'tdata'"));
}
}
diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.h b/Telegram/SourceFiles/platform/mac/main_window_mac.h
index 911a19fa8..6470efeef 100644
--- a/Telegram/SourceFiles/platform/mac/main_window_mac.h
+++ b/Telegram/SourceFiles/platform/mac/main_window_mac.h
@@ -68,6 +68,7 @@ protected:
void stateChangedHook(Qt::WindowState state) override;
void initHook() override;
+ void updateWindowIcon() override;
void titleVisibilityChangedHook() override;
void unreadCounterChangedHook() override;
@@ -82,8 +83,6 @@ protected:
QSystemTrayIcon *trayIcon = nullptr;
QMenu *trayIconMenu = nullptr;
- QImage icon256, iconbig256;
- QIcon wndIcon;
QImage trayImg, trayImgSel;
diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm
index eff6609be..748222a99 100644
--- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm
+++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm
@@ -215,10 +215,7 @@ MainWindow::Private::~Private() {
}
MainWindow::MainWindow()
-: icon256(qsl(":/gui/art/icon256.png"))
-, iconbig256(qsl(":/gui/art/iconbig256.png"))
-, wndIcon(QPixmap::fromImage(iconbig256, Qt::ColorOnly))
-, _private(std::make_unique(this)) {
+: _private(std::make_unique(this)) {
trayImg = st::macTrayIcon.instance(QColor(0, 0, 0, 180), dbisOne);
trayImgSel = st::macTrayIcon.instance(QColor(255, 255, 255), dbisOne);
@@ -255,6 +252,9 @@ void MainWindow::initHook() {
}
}
+void MainWindow::updateWindowIcon() {
+}
+
void MainWindow::titleVisibilityChangedHook() {
updateTitleCounter();
}
diff --git a/Telegram/SourceFiles/platform/win/main_window_win.cpp b/Telegram/SourceFiles/platform/win/main_window_win.cpp
index 56206f6f2..6d1bec78b 100644
--- a/Telegram/SourceFiles/platform/win/main_window_win.cpp
+++ b/Telegram/SourceFiles/platform/win/main_window_win.cpp
@@ -25,6 +25,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "platform/win/windows_dlls.h"
#include "window/notifications_manager.h"
#include "mainwindow.h"
+#include "messenger.h"
#include "application.h"
#include "lang.h"
#include "storage/localstorage.h"
@@ -610,10 +611,7 @@ bool handleSessionNotification = false;
UINT MainWindow::_taskbarCreatedMsgId = 0;
MainWindow::MainWindow()
-: icon256(qsl(":/gui/art/icon256.png"))
-, iconbig256(qsl(":/gui/art/iconbig256.png"))
-, wndIcon(QPixmap::fromImage(icon256, Qt::ColorOnly))
-, ps_tbHider_hWnd(createTaskbarHider()) {
+: ps_tbHider_hWnd(createTaskbarHider()) {
if (!_taskbarCreatedMsgId) {
_taskbarCreatedMsgId = RegisterWindowMessage(L"TaskbarButtonCreated");
}
@@ -682,7 +680,7 @@ void MainWindow::psSetupTrayIcon() {
if (!trayIcon) {
trayIcon = new QSystemTrayIcon(this);
- QIcon icon(QPixmap::fromImage(App::wnd()->iconLarge(), Qt::ColorOnly));
+ auto icon = QIcon(App::pixmapFromImageInPlace(Messenger::Instance().logoNoMargin()));
trayIcon->setIcon(icon);
trayIcon->setToolTip(str_const_toString(AppName));
@@ -796,8 +794,6 @@ void MainWindow::initHook() {
}
psInitSysMenu();
-
- setWindowIcon(wndIcon);
}
Q_DECLARE_METATYPE(QMargins);
diff --git a/Telegram/SourceFiles/platform/win/main_window_win.h b/Telegram/SourceFiles/platform/win/main_window_win.h
index d718c6ed8..e72c20f3c 100644
--- a/Telegram/SourceFiles/platform/win/main_window_win.h
+++ b/Telegram/SourceFiles/platform/win/main_window_win.h
@@ -92,8 +92,6 @@ protected:
QSystemTrayIcon *trayIcon = nullptr;
Ui::PopupMenu *trayIconMenu = nullptr;
- QImage icon256, iconbig256;
- QIcon wndIcon;
void psTrayMenuUpdated();
void psSetupTrayIcon();
diff --git a/Telegram/SourceFiles/structs.cpp b/Telegram/SourceFiles/structs.cpp
index 3f45e9606..21813a1d5 100644
--- a/Telegram/SourceFiles/structs.cpp
+++ b/Telegram/SourceFiles/structs.cpp
@@ -418,7 +418,7 @@ void UserData::setPhoto(const MTPUserProfilePhoto &p) { // see Local::readPeer a
newPhotoId = 0;
if (id == ServiceUserId) {
if (!_userpic) {
- newPhoto = ImagePtr(App::pixmapFromImageInPlace(App::wnd()->iconLarge().scaledToWidth(160, Qt::SmoothTransformation)), "PNG");
+ newPhoto = ImagePtr(App::pixmapFromImageInPlace(Messenger::Instance().logoNoMargin().scaledToWidth(160, Qt::SmoothTransformation)), "PNG");
}
} else {
newPhoto = ImagePtr();
diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp
index c75ed9003..154a71fc1 100644
--- a/Telegram/SourceFiles/window/main_window.cpp
+++ b/Telegram/SourceFiles/window/main_window.cpp
@@ -25,13 +25,39 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "platform/platform_window_title.h"
#include "window/themes/window_theme.h"
#include "mediaview.h"
+#include "messenger.h"
#include "mainwindow.h"
namespace Window {
+QImage LoadLogo() {
+ return QImage(qsl(":/gui/art/logo_256.png"));
+}
+
+QImage LoadLogoNoMargin() {
+ return QImage(qsl(":/gui/art/logo_256_no_margin.png"));
+}
+
+QIcon CreateOfficialIcon() {
+ auto useNoMarginLogo = (cPlatform() == dbipMac);
+ if (auto messenger = Messenger::InstancePointer()) {
+ return QIcon(App::pixmapFromImageInPlace(useNoMarginLogo ? messenger->logoNoMargin() : messenger->logo()));
+ }
+ return QIcon(App::pixmapFromImageInPlace(useNoMarginLogo ? LoadLogoNoMargin() : LoadLogo()));
+}
+
+QIcon CreateIcon() {
+ auto result = CreateOfficialIcon();
+ if (cPlatform() == dbipLinux32 || cPlatform() == dbipLinux64) {
+ return QIcon::fromTheme("telegram", result);
+ }
+ return result;
+}
+
MainWindow::MainWindow() : QWidget()
, _positionUpdatedTimer(this)
, _body(this)
+, _icon(CreateIcon())
, _titleText(qsl("Telegram"))
, _isActiveTimer(this) {
subscribe(Theme::Background(), [this](const Theme::BackgroundUpdate &data) {
@@ -156,8 +182,13 @@ void MainWindow::createMediaView() {
_mediaView.create(nullptr);
}
+void MainWindow::updateWindowIcon() {
+ setWindowIcon(_icon);
+}
+
void MainWindow::init() {
initHook();
+ updateWindowIcon();
_positionUpdatedTimer->setSingleShot(true);
connect(_positionUpdatedTimer, SIGNAL(timeout()), this, SLOT(savePositionByTimer()));
diff --git a/Telegram/SourceFiles/window/main_window.h b/Telegram/SourceFiles/window/main_window.h
index b7f30e798..607cf5bb8 100644
--- a/Telegram/SourceFiles/window/main_window.h
+++ b/Telegram/SourceFiles/window/main_window.h
@@ -28,6 +28,10 @@ namespace Window {
class TitleWidget;
+QImage LoadLogo();
+QImage LoadLogoNoMargin();
+QIcon CreateIcon();
+
class MainWindow : public QWidget, protected base::Subscriber {
Q_OBJECT
@@ -107,6 +111,8 @@ protected:
virtual void clearWidgetsHook() {
}
+ virtual void updateWindowIcon();
+
virtual void stateChangedHook(Qt::WindowState state) {
}
@@ -164,6 +170,7 @@ private:
object_ptr _body;
object_ptr _rightColumn = { nullptr };
+ QIcon _icon;
QString _titleText;
object_ptr _isActiveTimer;
diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp
index 34736afbb..51a59b497 100644
--- a/Telegram/SourceFiles/window/notifications_manager_default.cpp
+++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp
@@ -22,7 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "platform/platform_notifications_manager.h"
#include "application.h"
-#include "mainwindow.h"
+#include "messenger.h"
#include "lang.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h"
@@ -33,6 +33,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "styles/style_window.h"
#include "storage/file_download.h"
#include "auth_session.h"
+#include "platform/platform_specific.h"
namespace Window {
namespace Notifications {
@@ -75,6 +76,14 @@ Manager::Manager(System *system) : Notifications::Manager(system) {
_inputCheckTimer.setTimeoutHandler([this] { checkLastInput(); });
}
+QPixmap Manager::hiddenUserpicPlaceholder() const {
+ if (_hiddenUserpicPlaceholder.isNull()) {
+ _hiddenUserpicPlaceholder = App::pixmapFromImageInPlace(Messenger::Instance().logoNoMargin().scaled(st::notifyPhotoSize, st::notifyPhotoSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
+ _hiddenUserpicPlaceholder.setDevicePixelRatio(cRetinaFactor());
+ }
+ return _hiddenUserpicPlaceholder;
+}
+
bool Manager::hasReplyingNotification() const {
for_const (auto ¬ification, _notifications) {
if (notification->isReplying()) {
@@ -625,9 +634,7 @@ void Notification::updateNotifyDisplay() {
_history->peer->loadUserpic(true, true);
_history->peer->paintUserpicLeft(p, st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), width(), st::notifyPhotoSize);
} else {
- static QPixmap icon = App::pixmapFromImageInPlace(App::wnd()->iconLarge().scaled(st::notifyPhotoSize, st::notifyPhotoSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
- icon.setDevicePixelRatio(cRetinaFactor());
- p.drawPixmap(st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), icon);
+ p.drawPixmap(st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), manager()->hiddenUserpicPlaceholder());
}
int32 itemWidth = w - st::notifyPhotoPos.x() - st::notifyPhotoSize - st::notifyTextLeft - st::notifyClosePos.x() - st::notifyClose.width;
diff --git a/Telegram/SourceFiles/window/notifications_manager_default.h b/Telegram/SourceFiles/window/notifications_manager_default.h
index e8666b7a3..800b7c139 100644
--- a/Telegram/SourceFiles/window/notifications_manager_default.h
+++ b/Telegram/SourceFiles/window/notifications_manager_default.h
@@ -61,6 +61,8 @@ private:
using Notification = internal::Notification;
using HideAllButton = internal::HideAllButton;
+ QPixmap hiddenUserpicPlaceholder() const;
+
void doUpdateAll() override;
void doShowNotification(HistoryItem *item, int forwardedCount) override;
void doClearAll() override;
@@ -111,6 +113,8 @@ private:
Animation _demoMasterOpacity;
+ mutable QPixmap _hiddenUserpicPlaceholder;
+
};
namespace internal {
diff --git a/Telegram/SourceFiles/window/notifications_utilities.cpp b/Telegram/SourceFiles/window/notifications_utilities.cpp
index bf91b2190..9180d551a 100644
--- a/Telegram/SourceFiles/window/notifications_utilities.cpp
+++ b/Telegram/SourceFiles/window/notifications_utilities.cpp
@@ -21,7 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "window/notifications_utilities.h"
#include "platform/platform_specific.h"
-#include "mainwindow.h"
+#include "messenger.h"
#include "styles/style_window.h"
namespace Window {
@@ -62,7 +62,7 @@ QString CachedUserpics::get(const StorageKey &key, PeerData *peer) {
peer->saveUserpic(v.path, st::notifyMacPhotoSize);
}
} else {
- App::wnd()->iconLarge().save(v.path, "PNG");
+ Messenger::Instance().logoNoMargin().save(v.path, "PNG");
}
i = _images.insert(key, v);
_someSavedFlag = true;