示例#1
0
void ChannelData::setPhoto(PhotoId photoId, const MTPChatPhoto &photo) {
	if (photo.type() == mtpc_chatPhoto) {
		const auto &data = photo.c_chatPhoto();
		updateUserpic(photoId, data.vphoto_small);
	} else {
		clearUserpic();
	}
}
示例#2
0
ConfirmInviteBox::ConfirmInviteBox(const QString &title, const MTPChatPhoto &photo, int count, const QVector<UserData*> &participants) : AbstractBox()
    , _title(this, st::confirmInviteTitle)
    , _status(this, st::confirmInviteStatus)
    , _photo(chatDefPhoto(0))
    , _participants(participants)
    , _join(this, lang(lng_group_invite_join), st::defaultBoxButton)
    , _cancel(this, lang(lng_cancel), st::cancelBoxButton) {
    if (_participants.size() > 4) {
        _participants.resize(4);
    }

    _title->setText(title);
    QString status;
    if (_participants.isEmpty() || _participants.size() >= count) {
        status = lng_chat_status_members(lt_count, count);
    } else {
        status = lng_group_invite_members(lt_count, count);
    }
    _status->setText(status);
    if (photo.type() == mtpc_chatPhoto) {
        auto &d = photo.c_chatPhoto();
        auto location = App::imageLocation(160, 160, d.vphoto_small);
        if (!location.isNull()) {
            _photo = ImagePtr(location);
            if (!_photo->loaded()) {
                subscribe(FileDownload::ImageLoaded(), [this] { update(); });
                _photo->load();
            }
        }
    }

    int h = st::confirmInviteStatusTop + _status->height() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _join->height() + st::boxButtonPadding.bottom();
    if (!_participants.isEmpty()) {
        int skip = (width() - 4 * st::confirmInviteUserPhotoSize) / 5;
        int padding = skip / 2;
        _userWidth = (st::confirmInviteUserPhotoSize + 2 * padding);
        int sumWidth = _participants.size() * _userWidth;
        int left = (width() - sumWidth) / 2;
        for_const (auto user, _participants) {
            auto name = new FlatLabel(this, st::confirmInviteUserName);
            name->resizeToWidth(st::confirmInviteUserPhotoSize + padding);
            name->setText(user->firstName.isEmpty() ? App::peerName(user) : user->firstName);
            name->moveToLeft(left + (padding / 2), st::confirmInviteUserNameTop);
            left += _userWidth;
        }