2017-09-25 12:02:55 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-09-25 12:02:55 +03:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-09-25 12:02:55 +03:00
|
|
|
*/
|
|
|
|
#include "info/profile/info_profile_cover.h"
|
|
|
|
|
2017-09-26 14:49:16 +03:00
|
|
|
#include "data/data_photo.h"
|
2017-12-17 12:13:26 +04:00
|
|
|
#include "data/data_peer_values.h"
|
2019-01-04 15:09:48 +04:00
|
|
|
#include "data/data_channel.h"
|
|
|
|
#include "data/data_chat.h"
|
2022-08-09 20:15:42 +03:00
|
|
|
#include "data/data_user.h"
|
2020-06-12 16:12:34 +04:00
|
|
|
#include "data/data_changes.h"
|
2022-08-09 20:15:42 +03:00
|
|
|
#include "data/data_session.h"
|
|
|
|
#include "data/data_document.h"
|
|
|
|
#include "data/stickers/data_custom_emoji.h"
|
2021-02-22 05:10:27 +03:00
|
|
|
#include "editor/photo_editor_layer_widget.h"
|
2017-09-25 12:02:55 +03:00
|
|
|
#include "info/profile/info_profile_values.h"
|
2017-11-13 19:50:10 +04:00
|
|
|
#include "info/info_controller.h"
|
2017-11-17 21:02:49 +04:00
|
|
|
#include "info/info_memento.h"
|
2017-09-25 12:02:55 +03:00
|
|
|
#include "lang/lang_keys.h"
|
|
|
|
#include "ui/widgets/labels.h"
|
2022-06-03 16:11:44 +04:00
|
|
|
#include "ui/widgets/buttons.h"
|
2017-09-25 12:02:55 +03:00
|
|
|
#include "ui/effects/ripple_animation.h"
|
2022-01-05 00:26:13 +03:00
|
|
|
#include "ui/text/text_utilities.h"
|
2017-11-13 19:50:10 +04:00
|
|
|
#include "ui/special_buttons.h"
|
2019-06-23 14:18:33 +02:00
|
|
|
#include "ui/unread_badge.h"
|
2019-07-10 19:28:33 +02:00
|
|
|
#include "base/unixtime.h"
|
2019-06-06 13:21:40 +03:00
|
|
|
#include "window/window_session_controller.h"
|
2022-08-09 20:15:42 +03:00
|
|
|
#include "window/window_controller.h"
|
2019-01-21 17:42:21 +04:00
|
|
|
#include "core/application.h"
|
2019-07-24 13:45:24 +02:00
|
|
|
#include "main/main_session.h"
|
2022-06-03 16:11:44 +04:00
|
|
|
#include "settings/settings_premium.h"
|
2017-09-25 12:02:55 +03:00
|
|
|
#include "apiwrap.h"
|
2022-08-09 20:15:42 +03:00
|
|
|
#include "mainwindow.h"
|
2021-10-20 19:54:22 +03:00
|
|
|
#include "api/api_peer_photo.h"
|
2022-08-09 20:15:42 +03:00
|
|
|
#include "chat_helpers/tabbed_panel.h"
|
|
|
|
#include "chat_helpers/tabbed_selector.h"
|
2019-09-18 11:05:37 +03:00
|
|
|
#include "styles/style_boxes.h"
|
|
|
|
#include "styles/style_info.h"
|
2022-08-09 20:15:42 +03:00
|
|
|
#include "styles/style_chat_helpers.h"
|
2017-09-25 12:02:55 +03:00
|
|
|
|
|
|
|
namespace Info {
|
|
|
|
namespace Profile {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
auto MembersStatusText(int count) {
|
2019-06-19 18:39:25 +02:00
|
|
|
return tr::lng_chat_status_members(tr::now, lt_count_decimal, count);
|
2017-09-25 12:02:55 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
auto OnlineStatusText(int count) {
|
2019-06-19 18:39:25 +02:00
|
|
|
return tr::lng_chat_status_online(tr::now, lt_count_decimal, count);
|
2017-09-25 12:02:55 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
auto ChatStatusText(int fullCount, int onlineCount, bool isGroup) {
|
2017-10-22 15:07:57 +03:00
|
|
|
if (onlineCount > 1 && onlineCount <= fullCount) {
|
2019-06-19 17:09:03 +02:00
|
|
|
return tr::lng_chat_status_members_online(
|
|
|
|
tr::now,
|
|
|
|
lt_members_count,
|
|
|
|
MembersStatusText(fullCount),
|
|
|
|
lt_online_count,
|
|
|
|
OnlineStatusText(onlineCount));
|
2017-09-25 12:02:55 +03:00
|
|
|
} else if (fullCount > 0) {
|
2020-05-01 14:20:57 +03:00
|
|
|
return isGroup
|
|
|
|
? tr::lng_chat_status_members(
|
|
|
|
tr::now,
|
|
|
|
lt_count_decimal,
|
|
|
|
fullCount)
|
|
|
|
: tr::lng_chat_status_subscribers(
|
|
|
|
tr::now,
|
|
|
|
lt_count_decimal,
|
|
|
|
fullCount);
|
2017-09-25 12:02:55 +03:00
|
|
|
}
|
2019-06-19 17:09:03 +02:00
|
|
|
return isGroup
|
|
|
|
? tr::lng_group_status(tr::now)
|
|
|
|
: tr::lng_channel_status(tr::now);
|
2017-09-25 12:02:55 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2017-11-13 19:50:10 +04:00
|
|
|
Cover::Cover(
|
|
|
|
QWidget *parent,
|
2018-09-05 22:39:35 +03:00
|
|
|
not_null<PeerData*> peer,
|
2019-06-06 13:21:40 +03:00
|
|
|
not_null<Window::SessionController*> controller)
|
2019-06-10 17:47:22 +02:00
|
|
|
: Cover(parent, peer, controller, NameValue(
|
|
|
|
peer
|
|
|
|
) | rpl::map([=](const TextWithEntities &name) {
|
|
|
|
return name.text;
|
|
|
|
})) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Cover::Cover(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
not_null<Window::SessionController*> controller,
|
|
|
|
rpl::producer<QString> title)
|
2022-05-30 17:09:36 +04:00
|
|
|
: FixedHeightWidget(
|
2017-09-25 12:02:55 +03:00
|
|
|
parent,
|
|
|
|
st::infoProfilePhotoTop
|
2017-11-13 19:50:10 +04:00
|
|
|
+ st::infoProfilePhoto.size.height()
|
2017-09-25 12:02:55 +03:00
|
|
|
+ st::infoProfilePhotoBottom)
|
2022-06-03 16:11:44 +04:00
|
|
|
, _controller(controller)
|
2018-09-05 22:39:35 +03:00
|
|
|
, _peer(peer)
|
2017-11-13 19:50:10 +04:00
|
|
|
, _userpic(
|
|
|
|
this,
|
2018-09-05 22:39:35 +03:00
|
|
|
controller,
|
2017-11-13 19:50:10 +04:00
|
|
|
_peer,
|
|
|
|
Ui::UserpicButton::Role::OpenPhoto,
|
|
|
|
st::infoProfilePhoto)
|
2017-09-25 12:02:55 +03:00
|
|
|
, _name(this, st::infoProfileNameLabel)
|
2017-11-17 21:02:49 +04:00
|
|
|
, _status(
|
|
|
|
this,
|
|
|
|
_peer->isMegagroup()
|
|
|
|
? st::infoProfileMegagroupStatusLabel
|
2017-11-24 19:51:47 +04:00
|
|
|
: st::infoProfileStatusLabel)
|
|
|
|
, _refreshStatusTimer([this] { refreshStatusText(); }) {
|
2017-09-25 12:02:55 +03:00
|
|
|
_peer->updateFull();
|
|
|
|
|
|
|
|
_name->setSelectable(true);
|
2019-06-19 17:09:03 +02:00
|
|
|
_name->setContextCopyText(tr::lng_profile_copy_fullname(tr::now));
|
2017-11-17 21:02:49 +04:00
|
|
|
|
|
|
|
if (!_peer->isMegagroup()) {
|
|
|
|
_status->setAttribute(Qt::WA_TransparentForMouseEvents);
|
|
|
|
}
|
2017-09-25 12:02:55 +03:00
|
|
|
|
2019-06-10 17:47:22 +02:00
|
|
|
initViewers(std::move(title));
|
2017-09-25 12:02:55 +03:00
|
|
|
setupChildGeometry();
|
2021-02-22 05:10:27 +03:00
|
|
|
|
|
|
|
_userpic->uploadPhotoRequests(
|
|
|
|
) | rpl::start_with_next([=] {
|
2021-10-20 19:54:22 +03:00
|
|
|
_peer->session().api().peerPhoto().upload(
|
2021-02-22 05:10:27 +03:00
|
|
|
_peer,
|
|
|
|
_userpic->takeResultImage());
|
|
|
|
}, _userpic->lifetime());
|
2017-09-25 12:02:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Cover::setupChildGeometry() {
|
2022-05-30 17:09:36 +04:00
|
|
|
widthValue(
|
2018-05-17 11:15:52 +03:00
|
|
|
) | rpl::start_with_next([this](int newWidth) {
|
2017-12-22 11:05:20 +04:00
|
|
|
_userpic->moveToLeft(
|
|
|
|
st::infoProfilePhotoLeft,
|
|
|
|
st::infoProfilePhotoTop,
|
|
|
|
newWidth);
|
|
|
|
refreshNameGeometry(newWidth);
|
|
|
|
refreshStatusGeometry(newWidth);
|
|
|
|
}, lifetime());
|
2017-09-25 12:02:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Cover *Cover::setOnlineCount(rpl::producer<int> &&count) {
|
2017-12-22 11:05:20 +04:00
|
|
|
std::move(
|
|
|
|
count
|
|
|
|
) | rpl::start_with_next([this](int count) {
|
|
|
|
_onlineCount = count;
|
|
|
|
refreshStatusText();
|
|
|
|
}, lifetime());
|
2017-09-25 12:02:55 +03:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2019-06-10 17:47:22 +02:00
|
|
|
void Cover::initViewers(rpl::producer<QString> title) {
|
2020-06-12 16:12:34 +04:00
|
|
|
using Flag = Data::PeerUpdate::Flag;
|
2019-06-10 17:47:22 +02:00
|
|
|
std::move(
|
|
|
|
title
|
|
|
|
) | rpl::start_with_next([=](const QString &title) {
|
|
|
|
_name->setText(title);
|
2018-09-09 20:38:08 +03:00
|
|
|
refreshNameGeometry(width());
|
|
|
|
}, lifetime());
|
|
|
|
|
2020-06-12 16:12:34 +04:00
|
|
|
_peer->session().changes().peerFlagsValue(
|
2017-12-22 11:05:20 +04:00
|
|
|
_peer,
|
2020-06-12 16:12:34 +04:00
|
|
|
Flag::OnlineStatus | Flag::Members
|
2017-12-22 11:05:20 +04:00
|
|
|
) | rpl::start_with_next(
|
2019-01-05 14:50:04 +04:00
|
|
|
[=] { refreshStatusText(); },
|
2017-12-22 11:05:20 +04:00
|
|
|
lifetime());
|
2017-11-13 21:12:36 +04:00
|
|
|
if (!_peer->isUser()) {
|
2020-06-12 16:12:34 +04:00
|
|
|
_peer->session().changes().peerFlagsValue(
|
2017-12-22 11:05:20 +04:00
|
|
|
_peer,
|
2020-06-12 16:12:34 +04:00
|
|
|
Flag::Rights
|
2017-12-22 11:05:20 +04:00
|
|
|
) | rpl::start_with_next(
|
2019-01-05 14:50:04 +04:00
|
|
|
[=] { refreshUploadPhotoOverlay(); },
|
2017-09-25 12:02:55 +03:00
|
|
|
lifetime());
|
2018-09-13 23:09:26 +03:00
|
|
|
} else if (_peer->isSelf()) {
|
|
|
|
refreshUploadPhotoOverlay();
|
2017-12-22 11:05:20 +04:00
|
|
|
}
|
2022-08-09 20:15:42 +03:00
|
|
|
rpl::combine(
|
|
|
|
BadgeValue(_peer),
|
|
|
|
EmojiStatusIdValue(_peer)
|
|
|
|
) | rpl::start_with_next([=](Badge badge, DocumentId emojiStatusId) {
|
|
|
|
setBadge(badge, emojiStatusId);
|
2019-06-23 14:18:33 +02:00
|
|
|
}, lifetime());
|
2017-09-25 12:02:55 +03:00
|
|
|
}
|
|
|
|
|
2017-11-13 21:12:36 +04:00
|
|
|
void Cover::refreshUploadPhotoOverlay() {
|
|
|
|
_userpic->switchChangePhotoOverlay([&] {
|
2018-09-13 23:09:26 +03:00
|
|
|
if (const auto chat = _peer->asChat()) {
|
2019-01-03 18:39:19 +04:00
|
|
|
return chat->canEditInformation();
|
2018-09-13 23:09:26 +03:00
|
|
|
} else if (const auto channel = _peer->asChannel()) {
|
2017-11-13 21:12:36 +04:00
|
|
|
return channel->canEditInformation();
|
|
|
|
}
|
2018-09-13 23:09:26 +03:00
|
|
|
return _peer->isSelf();
|
2017-11-13 21:12:36 +04:00
|
|
|
}());
|
|
|
|
}
|
|
|
|
|
2022-08-09 20:15:42 +03:00
|
|
|
void Cover::setBadge(Badge badge, DocumentId emojiStatusId) {
|
|
|
|
if (!_peer->session().premiumBadgesShown() && badge == Badge::Premium) {
|
|
|
|
badge = Badge::None;
|
|
|
|
}
|
|
|
|
if (badge != Badge::Premium) {
|
|
|
|
emojiStatusId = 0;
|
|
|
|
}
|
|
|
|
if (_badge == badge && _emojiStatusId == emojiStatusId) {
|
2017-11-06 18:13:56 +04:00
|
|
|
return;
|
|
|
|
}
|
2021-01-21 16:39:40 +04:00
|
|
|
_badge = badge;
|
2022-08-09 20:15:42 +03:00
|
|
|
_emojiStatusId = emojiStatusId;
|
|
|
|
_emojiStatus = nullptr;
|
2021-01-21 16:39:40 +04:00
|
|
|
_verifiedCheck.destroy();
|
|
|
|
_scamFakeBadge.destroy();
|
|
|
|
switch (_badge) {
|
|
|
|
case Badge::Verified:
|
2022-05-20 19:28:50 +04:00
|
|
|
case Badge::Premium: {
|
|
|
|
const auto icon = (_badge == Badge::Verified)
|
|
|
|
? &st::infoVerifiedCheck
|
|
|
|
: &st::infoPremiumStar;
|
2017-11-06 18:13:56 +04:00
|
|
|
_verifiedCheck.create(this);
|
|
|
|
_verifiedCheck->show();
|
2022-05-20 19:28:50 +04:00
|
|
|
_verifiedCheck->resize(icon->size());
|
2022-08-09 20:15:42 +03:00
|
|
|
if (_emojiStatusId) {
|
|
|
|
auto &owner = _controller->session().data();
|
|
|
|
_emojiStatus = owner.customEmojiManager().create(
|
|
|
|
_emojiStatusId,
|
|
|
|
[raw = _verifiedCheck.data()]{ raw->update(); },
|
|
|
|
Data::CustomEmojiManager::SizeTag::Normal);
|
|
|
|
}
|
|
|
|
|
2017-12-22 11:05:20 +04:00
|
|
|
_verifiedCheck->paintRequest(
|
2022-08-09 20:15:42 +03:00
|
|
|
) | rpl::start_with_next([=, check = _verifiedCheck.data()] {
|
2017-12-22 11:05:20 +04:00
|
|
|
Painter p(check);
|
2022-08-09 20:15:42 +03:00
|
|
|
if (_emojiStatus) {
|
|
|
|
_emojiStatus->paint(
|
|
|
|
p,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
crl::now(),
|
|
|
|
st::windowBgOver->c,
|
|
|
|
_controller->isGifPausedAtLeastFor(
|
|
|
|
Window::GifPauseReason::Layer));
|
|
|
|
} else {
|
|
|
|
icon->paint(p, 0, 0, check->width());
|
|
|
|
}
|
2022-05-20 19:28:50 +04:00
|
|
|
}, _verifiedCheck->lifetime());
|
2022-08-09 20:15:42 +03:00
|
|
|
|
2022-06-03 16:11:44 +04:00
|
|
|
if (_badge == Badge::Premium) {
|
|
|
|
const auto userId = peerToUser(_peer->id).bare;
|
|
|
|
_verifiedCheck->setClickedCallback([=] {
|
2022-08-09 20:15:42 +03:00
|
|
|
if (_peer->isSelf()) {
|
|
|
|
showEmojiStatusSelector();
|
|
|
|
} else {
|
|
|
|
::Settings::ShowPremium(
|
|
|
|
_controller,
|
|
|
|
u"profile__%1"_q.arg(userId));
|
|
|
|
}
|
2022-06-03 16:11:44 +04:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
_verifiedCheck->setAttribute(Qt::WA_TransparentForMouseEvents);
|
|
|
|
}
|
2022-05-20 19:28:50 +04:00
|
|
|
} break;
|
2021-01-21 16:39:40 +04:00
|
|
|
case Badge::Scam:
|
|
|
|
case Badge::Fake: {
|
|
|
|
const auto fake = (_badge == Badge::Fake);
|
|
|
|
const auto size = Ui::ScamBadgeSize(fake);
|
2019-06-23 14:18:33 +02:00
|
|
|
const auto skip = st::infoVerifiedCheckPosition.x();
|
2021-01-21 16:39:40 +04:00
|
|
|
_scamFakeBadge.create(this);
|
|
|
|
_scamFakeBadge->show();
|
|
|
|
_scamFakeBadge->resize(
|
2019-06-23 14:18:33 +02:00
|
|
|
size.width() + 2 * skip,
|
|
|
|
size.height() + 2 * skip);
|
2021-01-21 16:39:40 +04:00
|
|
|
_scamFakeBadge->paintRequest(
|
|
|
|
) | rpl::start_with_next([=, badge = _scamFakeBadge.data()]{
|
2019-06-23 14:18:33 +02:00
|
|
|
Painter p(badge);
|
|
|
|
Ui::DrawScamBadge(
|
2021-01-21 16:39:40 +04:00
|
|
|
fake,
|
2019-06-23 14:18:33 +02:00
|
|
|
p,
|
|
|
|
badge->rect().marginsRemoved({ skip, skip, skip, skip }),
|
|
|
|
badge->width(),
|
|
|
|
st::attentionButtonFg);
|
2021-01-21 16:39:40 +04:00
|
|
|
}, _scamFakeBadge->lifetime());
|
|
|
|
} break;
|
2019-06-23 14:18:33 +02:00
|
|
|
}
|
|
|
|
refreshNameGeometry(width());
|
|
|
|
}
|
|
|
|
|
2022-08-09 20:15:42 +03:00
|
|
|
void Cover::showEmojiStatusSelector() {
|
|
|
|
Expects(_verifiedCheck != nullptr);
|
|
|
|
|
|
|
|
if (!_emojiStatusPanel) {
|
|
|
|
createEmojiStatusSelector();
|
|
|
|
}
|
|
|
|
const auto parent = _emojiStatusPanel->parentWidget();
|
|
|
|
const auto global = _verifiedCheck->mapToGlobal({ 0, 0 });
|
|
|
|
const auto local = parent->mapFromGlobal(global);
|
|
|
|
_emojiStatusPanel->moveBottomRight(
|
|
|
|
local.y(),
|
|
|
|
local.x() + _verifiedCheck->width() * 3);
|
|
|
|
_emojiStatusPanel->toggleAnimated();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cover::createEmojiStatusSelector() {
|
|
|
|
const auto container = _controller->window().widget()->bodyWidget();
|
|
|
|
using Selector = ChatHelpers::TabbedSelector;
|
|
|
|
_emojiStatusPanel = base::make_unique_q<ChatHelpers::TabbedPanel>(
|
|
|
|
container,
|
|
|
|
_controller,
|
|
|
|
object_ptr<Selector>(
|
|
|
|
nullptr,
|
|
|
|
_controller,
|
|
|
|
Window::GifPauseReason::Layer,
|
|
|
|
ChatHelpers::TabbedSelector::Mode::EmojiOnly));
|
|
|
|
_emojiStatusPanel->setDesiredHeightValues(
|
|
|
|
1.,
|
|
|
|
st::emojiPanMinHeight / 2,
|
|
|
|
st::emojiPanMinHeight);
|
|
|
|
_emojiStatusPanel->hide();
|
|
|
|
_emojiStatusPanel->selector()->setAllowEmojiWithoutPremium(false);
|
|
|
|
_emojiStatusPanel->selector()->customEmojiChosen(
|
|
|
|
) | rpl::start_with_next([=](Selector::FileChosen data) {
|
|
|
|
_controller->session().user()->setEmojiStatus(data.document->id);
|
|
|
|
_controller->session().api().request(MTPaccount_UpdateEmojiStatus(
|
|
|
|
MTP_emojiStatus(MTP_long(data.document->id))
|
|
|
|
)).send();
|
|
|
|
_emojiStatusPanel->hideAnimated();
|
|
|
|
}, _emojiStatusPanel->lifetime());
|
|
|
|
_emojiStatusPanel->selector()->showPromoForPremiumEmoji();
|
|
|
|
}
|
|
|
|
|
2017-09-25 12:02:55 +03:00
|
|
|
void Cover::refreshStatusText() {
|
2017-11-17 21:02:49 +04:00
|
|
|
auto hasMembersLink = [&] {
|
|
|
|
if (auto megagroup = _peer->asMegagroup()) {
|
|
|
|
return megagroup->canViewMembers();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}();
|
2022-01-05 00:26:13 +03:00
|
|
|
auto statusText = [&]() -> TextWithEntities {
|
|
|
|
using namespace Ui::Text;
|
2019-07-10 19:28:33 +02:00
|
|
|
auto currentTime = base::unixtime::now();
|
2017-09-25 12:02:55 +03:00
|
|
|
if (auto user = _peer->asUser()) {
|
2017-12-17 12:13:26 +04:00
|
|
|
const auto result = Data::OnlineTextFull(user, currentTime);
|
|
|
|
const auto showOnline = Data::OnlineTextActive(user, currentTime);
|
|
|
|
const auto updateIn = Data::OnlineChangeTimeout(user, currentTime);
|
2017-11-24 19:51:47 +04:00
|
|
|
if (showOnline) {
|
2017-12-17 12:13:26 +04:00
|
|
|
_refreshStatusTimer.callOnce(updateIn);
|
2017-11-24 19:51:47 +04:00
|
|
|
}
|
|
|
|
return showOnline
|
2022-01-05 00:26:13 +03:00
|
|
|
? PlainLink(result)
|
|
|
|
: TextWithEntities{ .text = result };
|
2017-09-25 12:02:55 +03:00
|
|
|
} else if (auto chat = _peer->asChat()) {
|
|
|
|
if (!chat->amIn()) {
|
2022-01-05 00:26:13 +03:00
|
|
|
return tr::lng_chat_status_unaccessible({}, WithEntities);
|
2017-09-25 12:02:55 +03:00
|
|
|
}
|
2017-12-01 22:38:44 +04:00
|
|
|
auto fullCount = std::max(
|
2017-09-25 12:02:55 +03:00
|
|
|
chat->count,
|
2017-12-01 22:38:44 +04:00
|
|
|
int(chat->participants.size()));
|
2022-01-05 00:26:13 +03:00
|
|
|
return { .text = ChatStatusText(fullCount, _onlineCount, true) };
|
2017-09-25 12:02:55 +03:00
|
|
|
} else if (auto channel = _peer->asChannel()) {
|
|
|
|
auto fullCount = qMax(channel->membersCount(), 1);
|
2017-11-17 21:02:49 +04:00
|
|
|
auto result = ChatStatusText(
|
2017-09-25 12:02:55 +03:00
|
|
|
fullCount,
|
|
|
|
_onlineCount,
|
|
|
|
channel->isMegagroup());
|
2022-01-05 00:26:13 +03:00
|
|
|
return hasMembersLink
|
|
|
|
? PlainLink(result)
|
|
|
|
: TextWithEntities{ .text = result };
|
2017-09-25 12:02:55 +03:00
|
|
|
}
|
2022-01-05 00:26:13 +03:00
|
|
|
return tr::lng_chat_status_unaccessible(tr::now, WithEntities);
|
2017-09-25 12:02:55 +03:00
|
|
|
}();
|
2022-01-05 00:26:13 +03:00
|
|
|
_status->setMarkedText(statusText);
|
2017-11-17 21:02:49 +04:00
|
|
|
if (hasMembersLink) {
|
2017-12-18 13:07:18 +04:00
|
|
|
_status->setLink(1, std::make_shared<LambdaClickHandler>([=] {
|
2018-09-05 22:39:35 +03:00
|
|
|
_showSection.fire(Section::Type::Members);
|
2017-11-17 21:02:49 +04:00
|
|
|
}));
|
|
|
|
}
|
2017-09-25 12:02:55 +03:00
|
|
|
refreshStatusGeometry(width());
|
|
|
|
}
|
|
|
|
|
2017-10-25 19:32:22 +03:00
|
|
|
Cover::~Cover() {
|
|
|
|
}
|
|
|
|
|
2017-09-25 12:02:55 +03:00
|
|
|
void Cover::refreshNameGeometry(int newWidth) {
|
2017-11-06 18:13:56 +04:00
|
|
|
auto nameLeft = st::infoProfileNameLeft;
|
|
|
|
auto nameTop = st::infoProfileNameTop;
|
2017-09-25 12:02:55 +03:00
|
|
|
auto nameWidth = newWidth
|
2017-11-06 18:13:56 +04:00
|
|
|
- nameLeft
|
2022-05-30 17:09:36 +04:00
|
|
|
- st::infoProfileNameRight;
|
2017-11-06 18:13:56 +04:00
|
|
|
if (_verifiedCheck) {
|
|
|
|
nameWidth -= st::infoVerifiedCheckPosition.x()
|
2019-06-23 14:18:33 +02:00
|
|
|
+ _verifiedCheck->width();
|
2021-01-21 16:39:40 +04:00
|
|
|
} else if (_scamFakeBadge) {
|
2019-06-23 14:18:33 +02:00
|
|
|
nameWidth -= st::infoVerifiedCheckPosition.x()
|
2021-01-21 16:39:40 +04:00
|
|
|
+ _scamFakeBadge->width();
|
2017-11-06 18:13:56 +04:00
|
|
|
}
|
|
|
|
_name->resizeToNaturalWidth(nameWidth);
|
|
|
|
_name->moveToLeft(nameLeft, nameTop, newWidth);
|
|
|
|
if (_verifiedCheck) {
|
2019-06-23 14:18:33 +02:00
|
|
|
const auto checkLeft = nameLeft
|
2017-11-06 18:13:56 +04:00
|
|
|
+ _name->width()
|
|
|
|
+ st::infoVerifiedCheckPosition.x();
|
2019-06-23 14:18:33 +02:00
|
|
|
const auto checkTop = nameTop
|
2017-11-06 18:13:56 +04:00
|
|
|
+ st::infoVerifiedCheckPosition.y();
|
|
|
|
_verifiedCheck->moveToLeft(checkLeft, checkTop, newWidth);
|
2021-01-21 16:39:40 +04:00
|
|
|
} else if (_scamFakeBadge) {
|
2019-06-23 14:18:33 +02:00
|
|
|
const auto skip = st::infoVerifiedCheckPosition.x();
|
|
|
|
const auto badgeLeft = nameLeft
|
|
|
|
+ _name->width()
|
|
|
|
+ st::infoVerifiedCheckPosition.x()
|
|
|
|
- skip;
|
|
|
|
const auto badgeTop = nameTop
|
2021-01-21 16:39:40 +04:00
|
|
|
+ (_name->height() - _scamFakeBadge->height()) / 2;
|
|
|
|
_scamFakeBadge->moveToLeft(badgeLeft, badgeTop, newWidth);
|
2017-11-06 18:13:56 +04:00
|
|
|
}
|
2017-09-25 12:02:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Cover::refreshStatusGeometry(int newWidth) {
|
|
|
|
auto statusWidth = newWidth
|
|
|
|
- st::infoProfileStatusLeft
|
2022-05-30 17:09:36 +04:00
|
|
|
- st::infoProfileStatusRight;
|
2017-09-25 12:02:55 +03:00
|
|
|
_status->resizeToWidth(statusWidth);
|
|
|
|
_status->moveToLeft(
|
|
|
|
st::infoProfileStatusLeft,
|
|
|
|
st::infoProfileStatusTop,
|
|
|
|
newWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Profile
|
|
|
|
} // namespace Info
|