dont cache default background image, cmd+m minimizes window in os x

This commit is contained in:
John Preston 2015-04-16 14:14:25 +03:00
parent 34d5c3777b
commit a356a4dc06
5 changed files with 21 additions and 3 deletions

View File

@ -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)));

View File

@ -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);

View File

@ -78,7 +78,7 @@ void BackgroundInner::gotWallpapers(const MTPVector<MTPWallPaper> &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;

View File

@ -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);

View File

@ -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;