Fix profile picture rounding inconsistencies (#304)
* Respect round settings in invite link info box Fixes #297 * Respect round settings in the call window
This commit is contained in:
parent
6af09ec529
commit
2c5f0283e2
4 changed files with 40 additions and 13 deletions
|
|
@ -252,12 +252,19 @@ void ConfirmInviteBox::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
if (_photo) {
|
if (_photo) {
|
||||||
if (const auto image = _photo->image(Data::PhotoSize::Small)) {
|
if (const auto image = _photo->image(Data::PhotoSize::Small)) {
|
||||||
|
auto source = [=] {
|
||||||
|
const auto size = st::confirmInvitePhotoSize;
|
||||||
|
switch (cUserpicCornersType()) {
|
||||||
|
case 0: return image->pixRounded(size, size, ImageRoundRadius::None);
|
||||||
|
case 1: return image->pixRounded(size, size, ImageRoundRadius::Small);
|
||||||
|
case 2: return image->pixRounded(size, size, ImageRoundRadius::Large);
|
||||||
|
default: return image->pixCircled(size, size);
|
||||||
|
}
|
||||||
|
}();
|
||||||
p.drawPixmap(
|
p.drawPixmap(
|
||||||
(width() - st::confirmInvitePhotoSize) / 2,
|
(width() - st::confirmInvitePhotoSize) / 2,
|
||||||
st::confirmInvitePhotoTop,
|
st::confirmInvitePhotoTop,
|
||||||
image->pixCircled(
|
source);
|
||||||
st::confirmInvitePhotoSize,
|
|
||||||
st::confirmInvitePhotoSize));
|
|
||||||
}
|
}
|
||||||
} else if (_photoEmpty) {
|
} else if (_photoEmpty) {
|
||||||
_photoEmpty->paint(
|
_photoEmpty->paint(
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_photo_media.h"
|
#include "data/data_photo_media.h"
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
#include "ui/empty_userpic.h"
|
#include "ui/empty_userpic.h"
|
||||||
|
#include "ui/rect_part.h"
|
||||||
#include "apiwrap.h" // requestFullPeer.
|
#include "apiwrap.h" // requestFullPeer.
|
||||||
#include "styles/style_calls.h"
|
#include "styles/style_calls.h"
|
||||||
#include "styles/style_widgets.h"
|
#include "styles/style_widgets.h"
|
||||||
|
|
@ -193,13 +194,28 @@ void Userpic::createCache(Image *image) {
|
||||||
height = qMax((height * real) / width, 1);
|
height = qMax((height * real) / width, 1);
|
||||||
width = real;
|
width = real;
|
||||||
}
|
}
|
||||||
_userPhoto = image->pixNoCache(
|
const auto callRounded = [=](const ImageRoundRadius radius) {
|
||||||
width,
|
return image->pixRounded(width, height, radius, RectPart::AllCorners, size, size);
|
||||||
height,
|
};
|
||||||
options,
|
switch (cUserpicCornersType()) {
|
||||||
size,
|
case 0:
|
||||||
size);
|
_userPhoto = callRounded(ImageRoundRadius::None);
|
||||||
_userPhoto.setDevicePixelRatio(cRetinaFactor());
|
break;
|
||||||
|
case 1:
|
||||||
|
_userPhoto = callRounded(ImageRoundRadius::Small);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
_userPhoto = callRounded(ImageRoundRadius::Large);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_userPhoto = image->pixNoCache(
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
options,
|
||||||
|
size,
|
||||||
|
size);
|
||||||
|
_userPhoto.setDevicePixelRatio(cRetinaFactor());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
auto filled = QImage(QSize(real, real), QImage::Format_ARGB32_Premultiplied);
|
auto filled = QImage(QSize(real, real), QImage::Format_ARGB32_Premultiplied);
|
||||||
filled.setDevicePixelRatio(cRetinaFactor());
|
filled.setDevicePixelRatio(cRetinaFactor());
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,9 @@ const QPixmap &Image::pixRounded(
|
||||||
int w,
|
int w,
|
||||||
int h,
|
int h,
|
||||||
ImageRoundRadius radius,
|
ImageRoundRadius radius,
|
||||||
RectParts corners) const {
|
RectParts corners,
|
||||||
|
int outerw,
|
||||||
|
int outerh) const {
|
||||||
if (w <= 0 || !width() || !height()) {
|
if (w <= 0 || !width() || !height()) {
|
||||||
w = width();
|
w = width();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -376,7 +378,7 @@ const QPixmap &Image::pixRounded(
|
||||||
auto k = PixKey(w, h, options);
|
auto k = PixKey(w, h, options);
|
||||||
auto i = _cache.find(k);
|
auto i = _cache.find(k);
|
||||||
if (i == _cache.cend()) {
|
if (i == _cache.cend()) {
|
||||||
auto p = pixNoCache(w, h, options);
|
auto p = pixNoCache(w, h, options, outerw, outerh);
|
||||||
p.setDevicePixelRatio(cRetinaFactor());
|
p.setDevicePixelRatio(cRetinaFactor());
|
||||||
i = _cache.emplace_or_assign(k, p).first;
|
i = _cache.emplace_or_assign(k, p).first;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,9 @@ public:
|
||||||
int w = 0,
|
int w = 0,
|
||||||
int h = 0,
|
int h = 0,
|
||||||
ImageRoundRadius radius = ImageRoundRadius::None,
|
ImageRoundRadius radius = ImageRoundRadius::None,
|
||||||
RectParts corners = RectPart::AllCorners) const;
|
RectParts corners = RectPart::AllCorners,
|
||||||
|
int outerw = -1,
|
||||||
|
int outerh = -1) const;
|
||||||
[[nodiscard]] const QPixmap &pixBlurred(int w = 0, int h = 0) const;
|
[[nodiscard]] const QPixmap &pixBlurred(int w = 0, int h = 0) const;
|
||||||
[[nodiscard]] const QPixmap &pixColored(style::color add, int w = 0, int h = 0) const;
|
[[nodiscard]] const QPixmap &pixColored(style::color add, int w = 0, int h = 0) const;
|
||||||
[[nodiscard]] const QPixmap &pixBlurredColored(
|
[[nodiscard]] const QPixmap &pixBlurredColored(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue