Retina handling fixed in the new notifications.

This commit is contained in:
John Preston 2016-10-07 16:14:02 +03:00
parent eb47b9468c
commit 15ee4b40dc
5 changed files with 23 additions and 9 deletions

View File

@ -235,6 +235,13 @@ void NotificationsBox::prepareNotificationSampleSmall() {
_notificationSampleSmall.setDevicePixelRatio(cRetinaFactor());
}
void NotificationsBox::prepareNotificationSampleUserpic() {
if (_notificationSampleUserpic.isNull()) {
_notificationSampleUserpic = App::pixmapFromImageInPlace(App::wnd()->iconLarge().scaled(st::notifyPhotoSize * cIntRetinaFactor(), st::notifyPhotoSize * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
_notificationSampleUserpic.setDevicePixelRatio(cRetinaFactor());
}
}
void NotificationsBox::prepareNotificationSampleLarge() {
int w = st::notifyWidth, h = st::notifyMinHeight;
auto sampleImage = QImage(w * cIntRetinaFactor(), h * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
@ -247,14 +254,14 @@ void NotificationsBox::prepareNotificationSampleLarge() {
p.fillRect(st::notifyBorderWidth, h - st::notifyBorderWidth, w - st::notifyBorderWidth, st::notifyBorderWidth, st::notifyBorder->b);
p.fillRect(0, st::notifyBorderWidth, st::notifyBorderWidth, h - st::notifyBorderWidth, st::notifyBorder->b);
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(), icon);
prepareNotificationSampleUserpic();
p.drawPixmap(st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), _notificationSampleUserpic);
int itemWidth = w - st::notifyPhotoPos.x() - st::notifyPhotoSize - st::notifyTextLeft - st::notifyClosePos.x() - st::notifyClose.width;
auto rectForName = rtlrect(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyTextTop, itemWidth, st::msgNameFont->height, w);
static QString notifyText = st::dialogsTextFont->elided(lang(lng_notification_preview), itemWidth);
auto notifyText = st::dialogsTextFont->elided(lang(lng_notification_preview), itemWidth);
p.setFont(st::dialogsTextFont);
p.setPen(st::dialogsTextFgService);
p.drawText(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyItemTop + st::msgNameFont->height + st::dialogsTextFont->ascent, notifyText);
@ -262,8 +269,11 @@ void NotificationsBox::prepareNotificationSampleLarge() {
p.setPen(st::dialogsNameFg);
p.setFont(st::msgNameFont);
static QString notifyTitle = st::msgNameFont->elided(qsl("Telegram Desktop"), rectForName.width());
auto notifyTitle = st::msgNameFont->elided(qsl("Telegram Desktop"), rectForName.width());
p.drawText(rectForName.left(), rectForName.top() + st::msgNameFont->ascent, notifyTitle);
p.setOpacity(st::notifyClose.opacity);
p.drawSpriteLeft(w - st::notifyClosePos.x() - st::notifyClose.width + st::notifyClose.iconPos.x(), st::notifyClosePos.y() + st::notifyClose.iconPos.y(), w, st::notifyClose.icon);
}
_notificationSampleLarge = App::pixmapFromImageInPlace(std_::move(sampleImage));

View File

@ -57,7 +57,9 @@ private:
int getContentLeft() const;
void prepareNotificationSampleSmall();
void prepareNotificationSampleLarge();
void prepareNotificationSampleUserpic();
QPixmap _notificationSampleUserpic;
QPixmap _notificationSampleSmall;
QPixmap _notificationSampleLarge;
ScreenCorner _chosenCorner;

View File

@ -95,7 +95,7 @@ namespace Platform {
namespace Notifications {
void start() {
if (cPlatform() != dbipMacOld) {
if (false && cPlatform() != dbipMacOld) {
ManagerInstance.makeIfNull();
}
}

View File

@ -515,6 +515,7 @@ void Notification::prepareActionsCache() {
auto actionsCacheWidth = _reply->width() + _replyPadding + fadeWidth;
auto actionsCacheHeight = height() - actionsTop;
auto actionsCacheImg = QImage(actionsCacheWidth * cIntRetinaFactor(), actionsCacheHeight * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
actionsCacheImg.setDevicePixelRatio(cRetinaFactor());
actionsCacheImg.fill(st::transparent->c);
{
Painter p(&actionsCacheImg);
@ -611,6 +612,7 @@ void Notification::updateNotifyDisplay() {
_history->peer->paintUserpicLeft(p, st::notifyPhotoSize, st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), width());
} 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);
}

View File

@ -56,11 +56,11 @@ public:
~Manager();
private:
using Notification = internal::Notification;
friend class Notification;
using HideAllButton = internal::HideAllButton;
friend class HideAllButton;
friend class internal::Notification;
friend class internal::HideAllButton;
friend class internal::Widget;
using Notification = internal::Notification;
using HideAllButton = internal::HideAllButton;
void doUpdateAll() override;
void doShowNotification(HistoryItem *item, int forwardedCount) override;