Move logo images to Messenger. Set call panel icon.

This commit is contained in:
John Preston 2017-05-12 18:27:19 +03:00
parent 7593be4361
commit b74dea8662
23 changed files with 111 additions and 63 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -5,8 +5,8 @@
<file alias="fonts/OpenSans-Semibold.ttf">../fonts/OpenSans-Semibold.ttf</file> <file alias="fonts/OpenSans-Semibold.ttf">../fonts/OpenSans-Semibold.ttf</file>
<file alias="art/bg.jpg">../art/bg.jpg</file> <file alias="art/bg.jpg">../art/bg.jpg</file>
<file alias="art/bg_initial.jpg">../art/bg_initial.jpg</file> <file alias="art/bg_initial.jpg">../art/bg_initial.jpg</file>
<file alias="art/icon256.png">../art/icon256.png</file> <file alias="art/logo_256.png">../art/logo_256.png</file>
<file alias="art/iconbig256.png">../art/iconbig256.png</file> <file alias="art/logo_256_no_margin.png">../art/logo_256_no_margin.png</file>
<file alias="art/sunrise.jpg">../art/sunrise.jpg</file> <file alias="art/sunrise.jpg">../art/sunrise.jpg</file>
</qresource> </qresource>
<qresource prefix="/sounds"> <qresource prefix="/sounds">

View File

@ -26,10 +26,11 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
#include "styles/style_window.h" #include "styles/style_window.h"
#include "mainwindow.h" #include "messenger.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "auth_session.h" #include "auth_session.h"
#include "window/notifications_manager.h" #include "window/notifications_manager.h"
#include "platform/platform_specific.h"
namespace { namespace {
@ -259,7 +260,7 @@ void NotificationsBox::prepareNotificationSampleSmall() {
void NotificationsBox::prepareNotificationSampleUserpic() { void NotificationsBox::prepareNotificationSampleUserpic() {
if (_notificationSampleUserpic.isNull()) { 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()); _notificationSampleUserpic.setDevicePixelRatio(cRetinaFactor());
} }
} }

View File

@ -29,12 +29,14 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "ui/effects/ripple_animation.h" #include "ui/effects/ripple_animation.h"
#include "ui/effects/widget_fade_wrap.h" #include "ui/effects/widget_fade_wrap.h"
#include "messenger.h" #include "messenger.h"
#include "mainwindow.h"
#include "lang.h" #include "lang.h"
#include "auth_session.h" #include "auth_session.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "observer_peer.h" #include "observer_peer.h"
#include "platform/platform_specific.h" #include "platform/platform_specific.h"
#include "base/task_queue.h" #include "base/task_queue.h"
#include "window/main_window.h"
namespace Calls { namespace Calls {
namespace { namespace {
@ -248,6 +250,7 @@ Panel::Panel(gsl::not_null<Call*> call)
, _name(this, st::callName) , _name(this, st::callName)
, _status(this, st::callStatus) { , _status(this, st::callStatus) {
setMouseTracking(true); setMouseTracking(true);
setWindowIcon(Window::CreateIcon());
initControls(); initControls();
initLayout(); initLayout();
showAndActivate(); showAndActivate();
@ -641,6 +644,10 @@ void Panel::paintEvent(QPaintEvent *e) {
} }
} }
void Panel::closeEvent(QCloseEvent *e) {
_call->hangup();
}
void Panel::mousePressEvent(QMouseEvent *e) { void Panel::mousePressEvent(QMouseEvent *e) {
auto dragArea = myrtlrect(_padding.left(), _padding.top(), st::callWidth, st::callWidth); auto dragArea = myrtlrect(_padding.left(), _padding.top(), st::callWidth, st::callWidth);
if (e->button() == Qt::LeftButton) { if (e->button() == Qt::LeftButton) {

View File

@ -44,6 +44,7 @@ public:
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void closeEvent(QCloseEvent *e) override;
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;

View File

@ -94,12 +94,15 @@ void ConnectingWidget::onReconnect() {
} }
MainWindow::MainWindow() { MainWindow::MainWindow() {
icon16 = icon256.scaledToWidth(16, Qt::SmoothTransformation); auto logo = Messenger::Instance().logo();
icon32 = icon256.scaledToWidth(32, Qt::SmoothTransformation); icon16 = logo.scaledToWidth(16, Qt::SmoothTransformation);
icon64 = icon256.scaledToWidth(64, Qt::SmoothTransformation); icon32 = logo.scaledToWidth(32, Qt::SmoothTransformation);
iconbig16 = iconbig256.scaledToWidth(16, Qt::SmoothTransformation); icon64 = logo.scaledToWidth(64, Qt::SmoothTransformation);
iconbig32 = iconbig256.scaledToWidth(32, Qt::SmoothTransformation);
iconbig64 = iconbig256.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); resize(st::windowDefaultWidth, st::windowDefaultHeight);
@ -904,10 +907,6 @@ void MainWindow::app_activateClickHandler(ClickHandlerPtr handler, Qt::MouseButt
handler->onClick(button); 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) { void MainWindow::placeSmallCounter(QImage &img, int size, int count, style::color bg, const QPoint &shift, style::color color) {
QPainter p(&img); QPainter p(&img);
@ -1040,15 +1039,12 @@ MainWindow::~MainWindow() {
delete trayIconMenu; delete trayIconMenu;
} }
PreLaunchWindow *PreLaunchWindowInstance = 0; PreLaunchWindow *PreLaunchWindowInstance = nullptr;
PreLaunchWindow::PreLaunchWindow(QString title) : TWidget(0) { PreLaunchWindow::PreLaunchWindow(QString title) {
Fonts::Start(); Fonts::Start();
QIcon icon(App::pixmapFromImageInPlace(QImage(cPlatform() == dbipMac ? qsl(":/gui/art/iconbig256.png") : qsl(":/gui/art/icon256.png")))); auto icon = Window::CreateIcon();
if (cPlatform() == dbipLinux32 || cPlatform() == dbipLinux64) {
icon = QIcon::fromTheme("telegram", icon);
}
setWindowIcon(icon); setWindowIcon(icon);
setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
@ -1084,7 +1080,7 @@ PreLaunchWindow *PreLaunchWindow::instance() {
PreLaunchWindow::~PreLaunchWindow() { PreLaunchWindow::~PreLaunchWindow() {
if (PreLaunchWindowInstance == this) { if (PreLaunchWindowInstance == this) {
PreLaunchWindowInstance = 0; PreLaunchWindowInstance = nullptr;
} }
} }

View File

@ -123,8 +123,6 @@ public:
TempDirState localStorageState(); TempDirState localStorageState();
void tempDirDelete(int task); void tempDirDelete(int task);
QImage iconLarge() const;
void sendPaths(); void sendPaths();
void changingMsgId(HistoryItem *row, MsgId newId) override; void changingMsgId(HistoryItem *row, MsgId newId) override;

View File

@ -66,8 +66,12 @@ struct Messenger::Private {
Messenger::Messenger() : QObject() Messenger::Messenger() : QObject()
, _private(std::make_unique<Private>()) , _private(std::make_unique<Private>())
, _audio(std::make_unique<Media::Audio::Instance>()) { , _audio(std::make_unique<Media::Audio::Instance>())
t_assert(SingleInstance == nullptr); , _logo(Window::LoadLogo())
, _logoNoMargin(Window::LoadLogoNoMargin()) {
Expects(!_logo.isNull());
Expects(!_logoNoMargin.isNull());
Expects(SingleInstance == nullptr);
SingleInstance = this; SingleInstance = this;
Fonts::Start(); Fonts::Start();

View File

@ -60,6 +60,12 @@ public:
MainWindow *mainWindow(); MainWindow *mainWindow();
QPoint getPointForCallPanelCenter() const; QPoint getPointForCallPanelCenter() const;
QImage logo() const {
return _logo;
}
QImage logoNoMargin() const {
return _logoNoMargin;
}
static Messenger *InstancePointer(); static Messenger *InstancePointer();
static Messenger &Instance() { static Messenger &Instance() {
@ -192,5 +198,7 @@ private:
base::Observable<void> _passcodedChanged; base::Observable<void> _passcodedChanged;
std::unique_ptr<Media::Audio::Instance> _audio; std::unique_ptr<Media::Audio::Instance> _audio;
QImage _logo;
QImage _logoNoMargin;
}; };

View File

@ -25,6 +25,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "platform/linux/linux_desktop_environment.h" #include "platform/linux/linux_desktop_environment.h"
#include "platform/platform_notifications_manager.h" #include "platform/platform_notifications_manager.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "messenger.h"
#include "application.h" #include "application.h"
#include "lang.h" #include "lang.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
@ -80,7 +81,7 @@ QImage _trayIconImageGen() {
bool muted = App::histories().unreadOnlyMuted(); bool muted = App::histories().unreadOnlyMuted();
if (_trayIconImage.isNull() || _trayIconImage.width() != _trayIconSize || muted != _trayIconMuted || counterSlice != _trayIconCount) { if (_trayIconImage.isNull() || _trayIconImage.width() != _trayIconSize || muted != _trayIconMuted || counterSlice != _trayIconCount) {
if (_trayIconImageBack.isNull() || _trayIconImageBack.width() != _trayIconSize) { 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); _trayIconImageBack = _trayIconImageBack.convertToFormat(QImage::Format_ARGB32);
int w = _trayIconImageBack.width(), h = _trayIconImageBack.height(), perline = _trayIconImageBack.bytesPerLine(); int w = _trayIconImageBack.width(), h = _trayIconImageBack.height(), perline = _trayIconImageBack.bytesPerLine();
uchar *bytes = _trayIconImageBack.bits(); uchar *bytes = _trayIconImageBack.bits();
@ -182,10 +183,7 @@ UnityLauncherEntry *_psUnityLauncherEntry = nullptr;
} // namespace } // namespace
MainWindow::MainWindow() MainWindow::MainWindow() {
: icon256(qsl(":/gui/art/icon256.png"))
, iconbig256(icon256)
, wndIcon(QIcon::fromTheme("telegram", QIcon(QPixmap::fromImage(icon256, Qt::ColorOnly)))) {
connect(&_psCheckStatusIconTimer, SIGNAL(timeout()), this, SLOT(psStatusIconCheck())); connect(&_psCheckStatusIconTimer, SIGNAL(timeout()), this, SLOT(psStatusIconCheck()));
_psCheckStatusIconTimer.setSingleShot(false); _psCheckStatusIconTimer.setSingleShot(false);
@ -193,10 +191,6 @@ MainWindow::MainWindow()
_psUpdateIndicatorTimer.setSingleShot(true); _psUpdateIndicatorTimer.setSingleShot(true);
} }
void MainWindow::initHook() {
setWindowIcon(wndIcon);
}
bool MainWindow::hasTrayIcon() const { bool MainWindow::hasTrayIcon() const {
return trayIcon || ((useAppIndicator || (useStatusIcon && trayIconChecked)) && (Global::WorkMode().value() != dbiwmWindowOnly)); return trayIcon || ((useAppIndicator || (useStatusIcon && trayIconChecked)) && (Global::WorkMode().value() != dbiwmWindowOnly));
} }
@ -252,7 +246,7 @@ void MainWindow::psSetupTrayIcon() {
QByteArray path = QFile::encodeName(iconFile.absoluteFilePath()); QByteArray path = QFile::encodeName(iconFile.absoluteFilePath());
icon = QIcon(path.constData()); icon = QIcon(path.constData());
} else { } else {
icon = QIcon(QPixmap::fromImage(App::wnd()->iconLarge(), Qt::ColorOnly)); icon = Window::CreateIcon();
} }
trayIcon->setIcon(icon); trayIcon->setIcon(icon);
@ -323,9 +317,9 @@ void MainWindow::unreadCounterChangedHook() {
} }
void MainWindow::updateIconCounters() { void MainWindow::updateIconCounters() {
setWindowIcon(wndIcon); updateWindowIcon();
int32 counter = App::histories().unreadBadge(); auto counter = App::histories().unreadBadge();
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION #ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
if (_psUnityLauncherEntry) { if (_psUnityLauncherEntry) {

View File

@ -51,7 +51,6 @@ public slots:
void psUpdateIndicator(); void psUpdateIndicator();
protected: protected:
void initHook() override;
void unreadCounterChangedHook() override; void unreadCounterChangedHook() override;
bool hasTrayIcon() const override; bool hasTrayIcon() const override;
@ -60,8 +59,6 @@ protected:
QSystemTrayIcon *trayIcon = nullptr; QSystemTrayIcon *trayIcon = nullptr;
QMenu *trayIconMenu = nullptr; QMenu *trayIconMenu = nullptr;
QImage icon256, iconbig256;
QIcon wndIcon;
void psTrayMenuUpdated(); void psTrayMenuUpdated();
void psSetupTrayIcon(); void psSetupTrayIcon();

View File

@ -456,7 +456,7 @@ void psRegisterCustomScheme() {
} }
} }
if (!iconExists) { 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'")); DEBUG_LOG(("App Info: Icon copied to 'tdata'"));
} }
} }

View File

@ -68,6 +68,7 @@ protected:
void stateChangedHook(Qt::WindowState state) override; void stateChangedHook(Qt::WindowState state) override;
void initHook() override; void initHook() override;
void updateWindowIcon() override;
void titleVisibilityChangedHook() override; void titleVisibilityChangedHook() override;
void unreadCounterChangedHook() override; void unreadCounterChangedHook() override;
@ -82,8 +83,6 @@ protected:
QSystemTrayIcon *trayIcon = nullptr; QSystemTrayIcon *trayIcon = nullptr;
QMenu *trayIconMenu = nullptr; QMenu *trayIconMenu = nullptr;
QImage icon256, iconbig256;
QIcon wndIcon;
QImage trayImg, trayImgSel; QImage trayImg, trayImgSel;

View File

@ -215,10 +215,7 @@ MainWindow::Private::~Private() {
} }
MainWindow::MainWindow() MainWindow::MainWindow()
: icon256(qsl(":/gui/art/icon256.png")) : _private(std::make_unique<Private>(this)) {
, iconbig256(qsl(":/gui/art/iconbig256.png"))
, wndIcon(QPixmap::fromImage(iconbig256, Qt::ColorOnly))
, _private(std::make_unique<Private>(this)) {
trayImg = st::macTrayIcon.instance(QColor(0, 0, 0, 180), dbisOne); trayImg = st::macTrayIcon.instance(QColor(0, 0, 0, 180), dbisOne);
trayImgSel = st::macTrayIcon.instance(QColor(255, 255, 255), dbisOne); trayImgSel = st::macTrayIcon.instance(QColor(255, 255, 255), dbisOne);
@ -255,6 +252,9 @@ void MainWindow::initHook() {
} }
} }
void MainWindow::updateWindowIcon() {
}
void MainWindow::titleVisibilityChangedHook() { void MainWindow::titleVisibilityChangedHook() {
updateTitleCounter(); updateTitleCounter();
} }

View File

@ -25,6 +25,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "platform/win/windows_dlls.h" #include "platform/win/windows_dlls.h"
#include "window/notifications_manager.h" #include "window/notifications_manager.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "messenger.h"
#include "application.h" #include "application.h"
#include "lang.h" #include "lang.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
@ -610,10 +611,7 @@ bool handleSessionNotification = false;
UINT MainWindow::_taskbarCreatedMsgId = 0; UINT MainWindow::_taskbarCreatedMsgId = 0;
MainWindow::MainWindow() MainWindow::MainWindow()
: icon256(qsl(":/gui/art/icon256.png")) : ps_tbHider_hWnd(createTaskbarHider()) {
, iconbig256(qsl(":/gui/art/iconbig256.png"))
, wndIcon(QPixmap::fromImage(icon256, Qt::ColorOnly))
, ps_tbHider_hWnd(createTaskbarHider()) {
if (!_taskbarCreatedMsgId) { if (!_taskbarCreatedMsgId) {
_taskbarCreatedMsgId = RegisterWindowMessage(L"TaskbarButtonCreated"); _taskbarCreatedMsgId = RegisterWindowMessage(L"TaskbarButtonCreated");
} }
@ -682,7 +680,7 @@ void MainWindow::psSetupTrayIcon() {
if (!trayIcon) { if (!trayIcon) {
trayIcon = new QSystemTrayIcon(this); 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->setIcon(icon);
trayIcon->setToolTip(str_const_toString(AppName)); trayIcon->setToolTip(str_const_toString(AppName));
@ -796,8 +794,6 @@ void MainWindow::initHook() {
} }
psInitSysMenu(); psInitSysMenu();
setWindowIcon(wndIcon);
} }
Q_DECLARE_METATYPE(QMargins); Q_DECLARE_METATYPE(QMargins);

View File

@ -92,8 +92,6 @@ protected:
QSystemTrayIcon *trayIcon = nullptr; QSystemTrayIcon *trayIcon = nullptr;
Ui::PopupMenu *trayIconMenu = nullptr; Ui::PopupMenu *trayIconMenu = nullptr;
QImage icon256, iconbig256;
QIcon wndIcon;
void psTrayMenuUpdated(); void psTrayMenuUpdated();
void psSetupTrayIcon(); void psSetupTrayIcon();

View File

@ -418,7 +418,7 @@ void UserData::setPhoto(const MTPUserProfilePhoto &p) { // see Local::readPeer a
newPhotoId = 0; newPhotoId = 0;
if (id == ServiceUserId) { if (id == ServiceUserId) {
if (!_userpic) { 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 { } else {
newPhoto = ImagePtr(); newPhoto = ImagePtr();

View File

@ -25,13 +25,39 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "platform/platform_window_title.h" #include "platform/platform_window_title.h"
#include "window/themes/window_theme.h" #include "window/themes/window_theme.h"
#include "mediaview.h" #include "mediaview.h"
#include "messenger.h"
#include "mainwindow.h" #include "mainwindow.h"
namespace Window { 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() MainWindow::MainWindow() : QWidget()
, _positionUpdatedTimer(this) , _positionUpdatedTimer(this)
, _body(this) , _body(this)
, _icon(CreateIcon())
, _titleText(qsl("Telegram")) , _titleText(qsl("Telegram"))
, _isActiveTimer(this) { , _isActiveTimer(this) {
subscribe(Theme::Background(), [this](const Theme::BackgroundUpdate &data) { subscribe(Theme::Background(), [this](const Theme::BackgroundUpdate &data) {
@ -156,8 +182,13 @@ void MainWindow::createMediaView() {
_mediaView.create(nullptr); _mediaView.create(nullptr);
} }
void MainWindow::updateWindowIcon() {
setWindowIcon(_icon);
}
void MainWindow::init() { void MainWindow::init() {
initHook(); initHook();
updateWindowIcon();
_positionUpdatedTimer->setSingleShot(true); _positionUpdatedTimer->setSingleShot(true);
connect(_positionUpdatedTimer, SIGNAL(timeout()), this, SLOT(savePositionByTimer())); connect(_positionUpdatedTimer, SIGNAL(timeout()), this, SLOT(savePositionByTimer()));

View File

@ -28,6 +28,10 @@ namespace Window {
class TitleWidget; class TitleWidget;
QImage LoadLogo();
QImage LoadLogoNoMargin();
QIcon CreateIcon();
class MainWindow : public QWidget, protected base::Subscriber { class MainWindow : public QWidget, protected base::Subscriber {
Q_OBJECT Q_OBJECT
@ -107,6 +111,8 @@ protected:
virtual void clearWidgetsHook() { virtual void clearWidgetsHook() {
} }
virtual void updateWindowIcon();
virtual void stateChangedHook(Qt::WindowState state) { virtual void stateChangedHook(Qt::WindowState state) {
} }
@ -164,6 +170,7 @@ private:
object_ptr<TWidget> _body; object_ptr<TWidget> _body;
object_ptr<TWidget> _rightColumn = { nullptr }; object_ptr<TWidget> _rightColumn = { nullptr };
QIcon _icon;
QString _titleText; QString _titleText;
object_ptr<QTimer> _isActiveTimer; object_ptr<QTimer> _isActiveTimer;

View File

@ -22,7 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "platform/platform_notifications_manager.h" #include "platform/platform_notifications_manager.h"
#include "application.h" #include "application.h"
#include "mainwindow.h" #include "messenger.h"
#include "lang.h" #include "lang.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.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 "styles/style_window.h"
#include "storage/file_download.h" #include "storage/file_download.h"
#include "auth_session.h" #include "auth_session.h"
#include "platform/platform_specific.h"
namespace Window { namespace Window {
namespace Notifications { namespace Notifications {
@ -75,6 +76,14 @@ Manager::Manager(System *system) : Notifications::Manager(system) {
_inputCheckTimer.setTimeoutHandler([this] { checkLastInput(); }); _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 { bool Manager::hasReplyingNotification() const {
for_const (auto &notification, _notifications) { for_const (auto &notification, _notifications) {
if (notification->isReplying()) { if (notification->isReplying()) {
@ -625,9 +634,7 @@ void Notification::updateNotifyDisplay() {
_history->peer->loadUserpic(true, true); _history->peer->loadUserpic(true, true);
_history->peer->paintUserpicLeft(p, st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), width(), st::notifyPhotoSize); _history->peer->paintUserpicLeft(p, st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), width(), st::notifyPhotoSize);
} else { } else {
static QPixmap icon = App::pixmapFromImageInPlace(App::wnd()->iconLarge().scaled(st::notifyPhotoSize, st::notifyPhotoSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); p.drawPixmap(st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), manager()->hiddenUserpicPlaceholder());
icon.setDevicePixelRatio(cRetinaFactor());
p.drawPixmap(st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), icon);
} }
int32 itemWidth = w - st::notifyPhotoPos.x() - st::notifyPhotoSize - st::notifyTextLeft - st::notifyClosePos.x() - st::notifyClose.width; int32 itemWidth = w - st::notifyPhotoPos.x() - st::notifyPhotoSize - st::notifyTextLeft - st::notifyClosePos.x() - st::notifyClose.width;

View File

@ -61,6 +61,8 @@ private:
using Notification = internal::Notification; using Notification = internal::Notification;
using HideAllButton = internal::HideAllButton; using HideAllButton = internal::HideAllButton;
QPixmap hiddenUserpicPlaceholder() const;
void doUpdateAll() override; void doUpdateAll() override;
void doShowNotification(HistoryItem *item, int forwardedCount) override; void doShowNotification(HistoryItem *item, int forwardedCount) override;
void doClearAll() override; void doClearAll() override;
@ -111,6 +113,8 @@ private:
Animation _demoMasterOpacity; Animation _demoMasterOpacity;
mutable QPixmap _hiddenUserpicPlaceholder;
}; };
namespace internal { namespace internal {

View File

@ -21,7 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "window/notifications_utilities.h" #include "window/notifications_utilities.h"
#include "platform/platform_specific.h" #include "platform/platform_specific.h"
#include "mainwindow.h" #include "messenger.h"
#include "styles/style_window.h" #include "styles/style_window.h"
namespace Window { namespace Window {
@ -62,7 +62,7 @@ QString CachedUserpics::get(const StorageKey &key, PeerData *peer) {
peer->saveUserpic(v.path, st::notifyMacPhotoSize); peer->saveUserpic(v.path, st::notifyMacPhotoSize);
} }
} else { } else {
App::wnd()->iconLarge().save(v.path, "PNG"); Messenger::Instance().logoNoMargin().save(v.path, "PNG");
} }
i = _images.insert(key, v); i = _images.insert(key, v);
_someSavedFlag = true; _someSavedFlag = true;