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 (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(
|
||||
(width() - st::confirmInvitePhotoSize) / 2,
|
||||
st::confirmInvitePhotoTop,
|
||||
image->pixCircled(
|
||||
st::confirmInvitePhotoSize,
|
||||
st::confirmInvitePhotoSize));
|
||||
source);
|
||||
}
|
||||
} else if (_photoEmpty) {
|
||||
_photoEmpty->paint(
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_photo_media.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "ui/empty_userpic.h"
|
||||
#include "ui/rect_part.h"
|
||||
#include "apiwrap.h" // requestFullPeer.
|
||||
#include "styles/style_calls.h"
|
||||
#include "styles/style_widgets.h"
|
||||
|
|
@ -193,13 +194,28 @@ void Userpic::createCache(Image *image) {
|
|||
height = qMax((height * real) / width, 1);
|
||||
width = real;
|
||||
}
|
||||
_userPhoto = image->pixNoCache(
|
||||
width,
|
||||
height,
|
||||
options,
|
||||
size,
|
||||
size);
|
||||
_userPhoto.setDevicePixelRatio(cRetinaFactor());
|
||||
const auto callRounded = [=](const ImageRoundRadius radius) {
|
||||
return image->pixRounded(width, height, radius, RectPart::AllCorners, size, size);
|
||||
};
|
||||
switch (cUserpicCornersType()) {
|
||||
case 0:
|
||||
_userPhoto = callRounded(ImageRoundRadius::None);
|
||||
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 {
|
||||
auto filled = QImage(QSize(real, real), QImage::Format_ARGB32_Premultiplied);
|
||||
filled.setDevicePixelRatio(cRetinaFactor());
|
||||
|
|
|
|||
|
|
@ -352,7 +352,9 @@ const QPixmap &Image::pixRounded(
|
|||
int w,
|
||||
int h,
|
||||
ImageRoundRadius radius,
|
||||
RectParts corners) const {
|
||||
RectParts corners,
|
||||
int outerw,
|
||||
int outerh) const {
|
||||
if (w <= 0 || !width() || !height()) {
|
||||
w = width();
|
||||
} else {
|
||||
|
|
@ -376,7 +378,7 @@ const QPixmap &Image::pixRounded(
|
|||
auto k = PixKey(w, h, options);
|
||||
auto i = _cache.find(k);
|
||||
if (i == _cache.cend()) {
|
||||
auto p = pixNoCache(w, h, options);
|
||||
auto p = pixNoCache(w, h, options, outerw, outerh);
|
||||
p.setDevicePixelRatio(cRetinaFactor());
|
||||
i = _cache.emplace_or_assign(k, p).first;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,9 @@ public:
|
|||
int w = 0,
|
||||
int h = 0,
|
||||
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 &pixColored(style::color add, int w = 0, int h = 0) const;
|
||||
[[nodiscard]] const QPixmap &pixBlurredColored(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue