From a356a4dc06b4cf412605524c70ff5162caed8b31 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 16 Apr 2015 14:14:25 +0300 Subject: [PATCH] dont cache default background image, cmd+m minimizes window in os x --- Telegram/SourceFiles/app.cpp | 8 +++++++- Telegram/SourceFiles/application.cpp | 3 +++ Telegram/SourceFiles/boxes/backgroundbox.cpp | 2 +- Telegram/SourceFiles/localstorage.cpp | 9 +++++++++ Telegram/SourceFiles/mainwidget.cpp | 2 +- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 5641b061d..90b91f516 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -1808,16 +1808,22 @@ namespace App { if (Local::readBackground()) return; QImage img(p); + bool remove = false; if (p.isNull()) { img.load(st::msgBG); id = 0; + remove = true; } if (img.format() != QImage::Format_ARGB32 && img.format() != QImage::Format_ARGB32_Premultiplied && img.format() != QImage::Format_RGB32) { img = img.convertToFormat(QImage::Format_RGB32); } img.setDevicePixelRatio(cRetinaFactor()); - if (!nowrite) Local::writeBackground(id, img); + if (remove) { + Local::writeBackground(0, QImage()); + } else if (!nowrite) { + Local::writeBackground(id, img); + } delete cChatBackground(); cSetChatBackground(new QPixmap(QPixmap::fromImage(img, Qt::ColorOnly))); diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index 4fde54dfe..c7719bd45 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -60,6 +60,9 @@ namespace { App::wnd()->minimizeToTray(); return true; } + } else if (ev->key() == Qt::Key_M && (ev->modifiers() & (Qt::MetaModifier | Qt::ControlModifier))) { + App::wnd()->setWindowState(Qt::WindowMinimized); + return true; } } return QObject::eventFilter(o, e); diff --git a/Telegram/SourceFiles/boxes/backgroundbox.cpp b/Telegram/SourceFiles/boxes/backgroundbox.cpp index 368210f86..27700560b 100644 --- a/Telegram/SourceFiles/boxes/backgroundbox.cpp +++ b/Telegram/SourceFiles/boxes/backgroundbox.cpp @@ -78,7 +78,7 @@ void BackgroundInner::gotWallpapers(const MTPVector &result) { } } if (thumb && full && full->type() != mtpc_photoSizeEmpty) { - wallpapers.push_back(App::WallPaper(d.vid.v, App::image(*thumb), App::image(*full))); + wallpapers.push_back(App::WallPaper(d.vid.v ? d.vid.v : INT_MAX, App::image(*thumb), App::image(*full))); } } break; diff --git a/Telegram/SourceFiles/localstorage.cpp b/Telegram/SourceFiles/localstorage.cpp index 0c8744b26..43c7f6178 100644 --- a/Telegram/SourceFiles/localstorage.cpp +++ b/Telegram/SourceFiles/localstorage.cpp @@ -2178,6 +2178,15 @@ namespace Local { void writeBackground(int32 id, const QImage &img) { if (!_working()) return; + if (img.isNull()) { + if (_backgroundKey) { + clearKey(_backgroundKey); + _backgroundKey = 0; + _mapChanged = true; + } + _writeMap(); + return; + } QByteArray png; { QBuffer buf(&png); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 8fefcad99..d7469b104 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1591,7 +1591,7 @@ void MainWidget::checkChatBackground() { if (_background->full->isNull()) { App::initBackground(); } else { - App::initBackground(_background->id, _background->full->pix().toImage()); + App::initBackground(_background->id, _background->id ? _background->full->pix().toImage() : QImage()); } delete _background; _background = 0;