Skip to content

Commit

Permalink
Move EmptyUserpic from data_peer to empty_userpic.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Dec 5, 2017
1 parent 68009b6 commit 5eeb814
Show file tree
Hide file tree
Showing 14 changed files with 344 additions and 301 deletions.
9 changes: 7 additions & 2 deletions Telegram/SourceFiles/boxes/confirm_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h"
#include "ui/toast/toast.h"
#include "ui/empty_userpic.h"
#include "core/click_handler_types.h"
#include "storage/localstorage.h"
#include "auth_session.h"
Expand Down Expand Up @@ -643,7 +644,9 @@ ConfirmInviteBox::ConfirmInviteBox(QWidget*, const QString &title, bool isChanne
}
}
if (!_photo) {
_photoEmpty.set(0, title);
_photoEmpty = std::make_unique<Ui::EmptyUserpic>(
Data::PeerUserpicColor(0),
title);
}
}

Expand Down Expand Up @@ -693,7 +696,7 @@ void ConfirmInviteBox::paintEvent(QPaintEvent *e) {
if (_photo) {
p.drawPixmap((width() - st::confirmInvitePhotoSize) / 2, st::confirmInvitePhotoTop, _photo->pixCircled(st::confirmInvitePhotoSize, st::confirmInvitePhotoSize));
} else {
_photoEmpty.paint(p, (width() - st::confirmInvitePhotoSize) / 2, st::confirmInvitePhotoTop, width(), st::confirmInvitePhotoSize);
_photoEmpty->paint(p, (width() - st::confirmInvitePhotoSize) / 2, st::confirmInvitePhotoTop, width(), st::confirmInvitePhotoSize);
}

int sumWidth = _participants.size() * _userWidth;
Expand All @@ -703,3 +706,5 @@ void ConfirmInviteBox::paintEvent(QPaintEvent *e) {
left += _userWidth;
}
}

ConfirmInviteBox::~ConfirmInviteBox() = default;
4 changes: 3 additions & 1 deletion Telegram/SourceFiles/boxes/confirm_box.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
namespace Ui {
class Checkbox;
class FlatLabel;
class EmptyUserpic;
} // namespace Ui

class InformBox;
Expand Down Expand Up @@ -207,6 +208,7 @@ class DeleteMessagesBox : public BoxContent, public RPCSender {
class ConfirmInviteBox : public BoxContent, public RPCSender {
public:
ConfirmInviteBox(QWidget*, const QString &title, bool isChannel, const MTPChatPhoto &photo, int count, const QVector<UserData*> &participants);
~ConfirmInviteBox();

protected:
void prepare() override;
Expand All @@ -218,7 +220,7 @@ class ConfirmInviteBox : public BoxContent, public RPCSender {
object_ptr<Ui::FlatLabel> _title;
object_ptr<Ui::FlatLabel> _status;
ImagePtr _photo;
EmptyUserpic _photoEmpty;
std::unique_ptr<Ui::EmptyUserpic> _photoEmpty;
QVector<UserData*> _participants;

int _userWidth = 0;
Expand Down
9 changes: 7 additions & 2 deletions Telegram/SourceFiles/boxes/send_files_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "ui/widgets/checkbox.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h"
#include "ui/empty_userpic.h"
#include "styles/style_history.h"
#include "styles/style_boxes.h"
#include "media/media_clip_reader.h"
Expand Down Expand Up @@ -235,7 +236,9 @@ SendFilesBox::SendFilesBox(QWidget*, const QString &phone, const QString &firstn
_nameText.setText(st::semiboldTextStyle, name, _textNameOptions);
_statusText = _contactPhone;
_statusWidth = qMax(_nameText.maxWidth(), st::normalFont->width(_statusText));
_contactPhotoEmpty.set(0, name);
_contactPhotoEmpty = std::make_unique<Ui::EmptyUserpic>(
Data::PeerUserpicColor(0),
name);
}

void SendFilesBox::prepare() {
Expand Down Expand Up @@ -400,7 +403,7 @@ void SendFilesBox::paintEvent(QPaintEvent *e) {
auto &icon = _fileIsAudio ? st::historyFileOutPlay : _fileIsImage ? st::historyFileOutImage : st::historyFileOutDocument;
icon.paintInCenter(p, inner);
} else {
_contactPhotoEmpty.paint(p, x + st::msgFilePadding.left(), y + st::msgFilePadding.top(), width(), st::msgFileSize);
_contactPhotoEmpty->paint(p, x + st::msgFilePadding.left(), y + st::msgFilePadding.top(), width(), st::msgFileSize);
}
} else {
QRect rthumb(rtlrect(x + st::msgFileThumbPadding.left(), y + st::msgFileThumbPadding.top(), st::msgFileThumbSize, st::msgFileThumbSize, width()));
Expand Down Expand Up @@ -457,6 +460,8 @@ void SendFilesBox::onSend(bool ctrlShiftEnter) {
closeBox();
}

SendFilesBox::~SendFilesBox() = default;

EditCaptionBox::EditCaptionBox(QWidget*, HistoryMedia *media, FullMsgId msgId) : _msgId(msgId) {
Expects(media->canEditCaption());

Expand Down
5 changes: 4 additions & 1 deletion Telegram/SourceFiles/boxes/send_files_box.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace Ui {
class Checkbox;
class RoundButton;
class InputArea;
class EmptyUserpic;
} // namespace Ui

class SendFilesBox : public BoxContent {
Expand All @@ -44,6 +45,8 @@ class SendFilesBox : public BoxContent {
_cancelledCallback = std::move(callback);
}

~SendFilesBox();

protected:
void prepare() override;
void setInnerFocus() override;
Expand Down Expand Up @@ -96,7 +99,7 @@ private slots:
QString _contactPhone;
QString _contactFirstName;
QString _contactLastName;
EmptyUserpic _contactPhotoEmpty;
std::unique_ptr<Ui::EmptyUserpic> _contactPhotoEmpty;

base::lambda<void(const QStringList &files, const QImage &image, std::unique_ptr<FileLoadTask::MediaInformation> information, bool compressed, const QString &caption, bool ctrlShiftEnter)> _confirmedCallback;
base::lambda<void()> _cancelledCallback;
Expand Down
6 changes: 5 additions & 1 deletion Telegram/SourceFiles/calls/calls_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "ui/widgets/shadow.h"
#include "ui/effects/ripple_animation.h"
#include "ui/wrap/fade_wrap.h"
#include "ui/empty_userpic.h"
#include "messenger.h"
#include "mainwindow.h"
#include "lang/lang_keys.h"
Expand Down Expand Up @@ -484,7 +485,10 @@ void Panel::createUserpicCache(ImagePtr image) {
filled.setDevicePixelRatio(cRetinaFactor());
{
Painter p(&filled);
EmptyUserpic(_user->id, _user->name).paintSquare(p, 0, 0, st::callWidth, st::callWidth);
Ui::EmptyUserpic(
Data::PeerUserpicColor(_user->id),
_user->name
).paintSquare(p, 0, 0, st::callWidth, st::callWidth);
}
Images::prepareRound(filled, ImageRoundRadius::Large, ImageRoundCorner::TopLeft | ImageRoundCorner::TopRight);
_userPhoto = App::pixmapFromImageInPlace(std::move(filled));
Expand Down
Loading

0 comments on commit 5eeb814

Please sign in to comment.