Skip to content

Commit

Permalink
Move logo images to Messenger. Set call panel icon.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed May 12, 2017
1 parent 7593be4 commit b74dea8
Show file tree
Hide file tree
Showing 23 changed files with 111 additions and 63 deletions.
Binary file added Telegram/Resources/art/logo_256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
4 changes: 2 additions & 2 deletions Telegram/Resources/qrc/telegram.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<file alias="fonts/OpenSans-Semibold.ttf">../fonts/OpenSans-Semibold.ttf</file>
<file alias="art/bg.jpg">../art/bg.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/iconbig256.png">../art/iconbig256.png</file>
<file alias="art/logo_256.png">../art/logo_256.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>
</qresource>
<qresource prefix="/sounds">
Expand Down
5 changes: 3 additions & 2 deletions Telegram/SourceFiles/boxes/notifications_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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());
}
}
Expand Down
7 changes: 7 additions & 0 deletions Telegram/SourceFiles/calls/calls_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -248,6 +250,7 @@ Panel::Panel(gsl::not_null<Call*> call)
, _name(this, st::callName)
, _status(this, st::callStatus) {
setMouseTracking(true);
setWindowIcon(Window::CreateIcon());
initControls();
initLayout();
showAndActivate();
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/calls/calls_panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Panel : public TWidget, private base::Subscriber, private Ui::AbstractTool

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;
Expand Down
30 changes: 13 additions & 17 deletions Telegram/SourceFiles/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -1084,7 +1080,7 @@ PreLaunchWindow *PreLaunchWindow::instance() {

PreLaunchWindow::~PreLaunchWindow() {
if (PreLaunchWindowInstance == this) {
PreLaunchWindowInstance = 0;
PreLaunchWindowInstance = nullptr;
}
}

Expand Down
2 changes: 0 additions & 2 deletions Telegram/SourceFiles/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ class MainWindow : public Platform::MainWindow {
TempDirState localStorageState();
void tempDirDelete(int task);

QImage iconLarge() const;

void sendPaths();

void changingMsgId(HistoryItem *row, MsgId newId) override;
Expand Down
8 changes: 6 additions & 2 deletions Telegram/SourceFiles/messenger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ struct Messenger::Private {

Messenger::Messenger() : QObject()
, _private(std::make_unique<Private>())
, _audio(std::make_unique<Media::Audio::Instance>()) {
t_assert(SingleInstance == nullptr);
, _audio(std::make_unique<Media::Audio::Instance>())
, _logo(Window::LoadLogo())
, _logoNoMargin(Window::LoadLogoNoMargin()) {
Expects(!_logo.isNull());
Expects(!_logoNoMargin.isNull());
Expects(SingleInstance == nullptr);
SingleInstance = this;

Fonts::Start();
Expand Down
8 changes: 8 additions & 0 deletions Telegram/SourceFiles/messenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class Messenger final : public QObject, public RPCSender, private base::Subscrib

MainWindow *mainWindow();
QPoint getPointForCallPanelCenter() const;
QImage logo() const {
return _logo;
}
QImage logoNoMargin() const {
return _logoNoMargin;
}

static Messenger *InstancePointer();
static Messenger &Instance() {
Expand Down Expand Up @@ -192,5 +198,7 @@ public slots:
base::Observable<void> _passcodedChanged;

std::unique_ptr<Media::Audio::Instance> _audio;
QImage _logo;
QImage _logoNoMargin;

};
18 changes: 6 additions & 12 deletions Telegram/SourceFiles/platform/linux/main_window_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -182,21 +183,14 @@ 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);

connect(&_psUpdateIndicatorTimer, SIGNAL(timeout()), this, SLOT(psUpdateIndicator()));
_psUpdateIndicatorTimer.setSingleShot(true);
}

void MainWindow::initHook() {
setWindowIcon(wndIcon);
}

bool MainWindow::hasTrayIcon() const {
return trayIcon || ((useAppIndicator || (useStatusIcon && trayIconChecked)) && (Global::WorkMode().value() != dbiwmWindowOnly));
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions Telegram/SourceFiles/platform/linux/main_window_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public slots:
void psUpdateIndicator();

protected:
void initHook() override;
void unreadCounterChangedHook() override;

bool hasTrayIcon() const override;
Expand All @@ -60,8 +59,6 @@ public slots:

QSystemTrayIcon *trayIcon = nullptr;
QMenu *trayIconMenu = nullptr;
QImage icon256, iconbig256;
QIcon wndIcon;

void psTrayMenuUpdated();
void psSetupTrayIcon();
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/platform/linux/specific_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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'"));
}
}
Expand Down
3 changes: 1 addition & 2 deletions Telegram/SourceFiles/platform/mac/main_window_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public slots:

void stateChangedHook(Qt::WindowState state) override;
void initHook() override;
void updateWindowIcon() override;
void titleVisibilityChangedHook() override;
void unreadCounterChangedHook() override;

Expand All @@ -82,8 +83,6 @@ public slots:

QSystemTrayIcon *trayIcon = nullptr;
QMenu *trayIconMenu = nullptr;
QImage icon256, iconbig256;
QIcon wndIcon;

QImage trayImg, trayImgSel;

Expand Down
8 changes: 4 additions & 4 deletions Telegram/SourceFiles/platform/mac/main_window_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,7 @@ - (void) windowWillExitFullScreen:(NSNotification *)aNotification {
}

MainWindow::MainWindow()
: icon256(qsl(":/gui/art/icon256.png"))
, iconbig256(qsl(":/gui/art/iconbig256.png"))
, wndIcon(QPixmap::fromImage(iconbig256, Qt::ColorOnly))
, _private(std::make_unique<Private>(this)) {
: _private(std::make_unique<Private>(this)) {
trayImg = st::macTrayIcon.instance(QColor(0, 0, 0, 180), dbisOne);
trayImgSel = st::macTrayIcon.instance(QColor(255, 255, 255), dbisOne);

Expand Down Expand Up @@ -255,6 +252,9 @@ - (void) windowWillExitFullScreen:(NSNotification *)aNotification {
}
}

void MainWindow::updateWindowIcon() {
}

void MainWindow::titleVisibilityChangedHook() {
updateTitleCounter();
}
Expand Down
10 changes: 3 additions & 7 deletions Telegram/SourceFiles/platform/win/main_window_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -796,8 +794,6 @@ void MainWindow::initHook() {
}

psInitSysMenu();

setWindowIcon(wndIcon);
}

Q_DECLARE_METATYPE(QMargins);
Expand Down
2 changes: 0 additions & 2 deletions Telegram/SourceFiles/platform/win/main_window_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ public slots:

QSystemTrayIcon *trayIcon = nullptr;
Ui::PopupMenu *trayIconMenu = nullptr;
QImage icon256, iconbig256;
QIcon wndIcon;

void psTrayMenuUpdated();
void psSetupTrayIcon();
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading

0 comments on commit b74dea8

Please sign in to comment.