mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 17:51:41 -05:00
Remove pseudo-HTML from langpacks and Ui::Text::String.
This commit is contained in:
parent
9066acd2dd
commit
ca7c50fbcd
53 changed files with 253 additions and 314 deletions
|
@ -174,7 +174,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
"lng_phone_title" = "Your Phone Number";
|
||||
"lng_phone_desc" = "Please confirm your country code and\nenter your mobile phone number.";
|
||||
"lng_phone_notreg" = "If you don't have a Telegram account yet,\nplease [b]sign up[/b] with {link_start}Android / iPhone{link_end} or {signup_start}here{signup_end}";
|
||||
"lng_country_code" = "Country Code";
|
||||
"lng_bad_country_code" = "Invalid Country Code";
|
||||
"lng_country_ph" = "Search";
|
||||
|
@ -183,7 +182,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
"lng_code_ph" = "Your code";
|
||||
"lng_code_desc" = "We have sent you a message with activation\ncode to your phone. Please enter it below.";
|
||||
"lng_code_telegram" = "Please enter the code you've just received\nin your previous [b]Telegram[/b] app.";
|
||||
"lng_code_from_telegram" = "Please enter the code you've just received\nin your previous **Telegram** app.";
|
||||
"lng_code_no_telegram" = "Send code via SMS";
|
||||
"lng_code_call" = "Telegram will call you in {minutes}:{seconds}";
|
||||
"lng_code_calling" = "Requesting a call from Telegram...";
|
||||
|
@ -687,7 +686,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_self_destruct_years#other" = "{count} years";
|
||||
|
||||
"lng_change_phone_title" = "Change phone number";
|
||||
"lng_change_phone_description" = "You can change your Telegram number\nhere. Your account and all your cloud data\n— messages, media, contacts, etc. will be\nmoved to the new number.\n\n[b]Important[/b]: all your Telegram contacts will\nget your [b]new number[/b] added to their address\nbook, provided they had your old number and\nyou haven't blocked them in Telegram.";
|
||||
"lng_change_phone_about" = "You can change your Telegram number\nhere. Your account and all your cloud data\n— messages, media, contacts, etc. will be\nmoved to the new number.\n\n**Important**: all your Telegram contacts will\nget your **new number** added to their address\nbook, provided they had your old number and\nyou haven't blocked them in Telegram.";
|
||||
"lng_change_phone_warning" = "All your Telegram contacts will get your new number added to their address book, provided they had your old number and you haven't blocked them in Telegram.";
|
||||
"lng_change_phone_occupied" = "The number {phone} is already connected to a Telegram account. Please delete that account before migrating to the new number.";
|
||||
"lng_change_phone_button" = "Change number";
|
||||
|
@ -1473,9 +1472,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_box_leave" = "Leave";
|
||||
|
||||
"lng_about_version" = "version {version}";
|
||||
"lng_about_text_1" = "Official free messaging app based on [a href=\"https://core.telegram.org/api\"]Telegram API[/a]\nfor speed and security.";
|
||||
"lng_about_text_2" = "This software is licensed under [a href=\"https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE\"]GNU GPL[/a] version 3.\nSource code is available on [a href=\"https://github.com/telegramdesktop/tdesktop\"]GitHub[/a].";
|
||||
"lng_about_text_3" = "Visit {faq_open}Telegram FAQ{faq_close} for more info.";
|
||||
"lng_about_text1" = "Official free messaging app based on {api_link}\nfor speed and security.";
|
||||
"lng_about_text1_api" = "Telegram API";
|
||||
"lng_about_text2" = "This software is licensed under {gpl_link} version 3.\nSource code is available on {github_link}.";
|
||||
"lng_about_text2_gpl" = "GNU GPL";
|
||||
"lng_about_text2_github" = "GitHub";
|
||||
"lng_about_text3" = "Visit {faq_link} for more info.";
|
||||
"lng_about_text3_faq" = "Telegram FAQ";
|
||||
"lng_about_done" = "Done";
|
||||
|
||||
"lng_search_no_results" = "No messages found";
|
||||
|
@ -1502,7 +1505,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_mediaview_yesterday" = "yesterday at {time}";
|
||||
"lng_mediaview_date_time" = "{date} at {time}";
|
||||
|
||||
"lng_mediaview_saved" = "Image was saved to your [c]Downloads[/c] folder";
|
||||
"lng_mediaview_saved_to" = "Image was saved to your {downloads} folder";
|
||||
"lng_mediaview_downloads" = "Downloads";
|
||||
"lng_mediaview_video_loading" = "Loading - {percent}";
|
||||
|
||||
"lng_theme_preview_title" = "Theme Preview";
|
||||
|
|
|
@ -13,17 +13,48 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/confirm_box.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "platform/platform_file_utilities.h"
|
||||
#include "platform/platform_info.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "core/update_checker.h"
|
||||
#include "styles/style_boxes.h"
|
||||
|
||||
namespace {
|
||||
|
||||
rpl::producer<TextWithEntities> Text1() {
|
||||
return rpl::single(lng_about_text1__rich(
|
||||
lt_api_link,
|
||||
Ui::Text::Link(
|
||||
lang(lng_about_text1_api),
|
||||
"https://core.telegram.org/api")));
|
||||
}
|
||||
|
||||
rpl::producer<TextWithEntities> Text2() {
|
||||
return rpl::single(lng_about_text2__rich(
|
||||
lt_gpl_link,
|
||||
Ui::Text::Link(
|
||||
lang(lng_about_text2_gpl),
|
||||
"https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE"),
|
||||
lt_github_link,
|
||||
Ui::Text::Link(
|
||||
lang(lng_about_text2_github),
|
||||
"https://github.com/telegramdesktop/tdesktop")));
|
||||
}
|
||||
|
||||
rpl::producer<TextWithEntities> Text3() {
|
||||
return rpl::single(lng_about_text3__rich(
|
||||
lt_faq_link,
|
||||
Ui::Text::Link(lang(lng_about_text3_faq), telegramFaqLink())));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AboutBox::AboutBox(QWidget *parent)
|
||||
: _version(this, lng_about_version(lt_version, currentVersionText()), st::aboutVersionLink)
|
||||
, _text1(this, lang(lng_about_text_1), Ui::FlatLabel::InitType::Rich, st::aboutLabel)
|
||||
, _text2(this, lang(lng_about_text_2), Ui::FlatLabel::InitType::Rich, st::aboutLabel)
|
||||
, _text3(this, st::aboutLabel) {
|
||||
, _text1(this, Text1(), st::aboutLabel)
|
||||
, _text2(this, Text2(), st::aboutLabel)
|
||||
, _text3(this, Text3(), st::aboutLabel) {
|
||||
}
|
||||
|
||||
void AboutBox::prepare() {
|
||||
|
@ -31,18 +62,9 @@ void AboutBox::prepare() {
|
|||
|
||||
addButton(langFactory(lng_close), [this] { closeBox(); });
|
||||
|
||||
const auto linkFilter = [](const ClickHandlerPtr &link, auto button) {
|
||||
if (const auto url = dynamic_cast<UrlClickHandler*>(link.get())) {
|
||||
url->UrlClickHandler::onClick({ button });
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
_text3->setRichText(lng_about_text_3(lt_faq_open, qsl("[a href=\"%1\"]").arg(telegramFaqLink()), lt_faq_close, qsl("[/a]")));
|
||||
_text1->setClickHandlerFilter(linkFilter);
|
||||
_text2->setClickHandlerFilter(linkFilter);
|
||||
_text3->setClickHandlerFilter(linkFilter);
|
||||
_text1->setLinksTrusted();
|
||||
_text2->setLinksTrusted();
|
||||
_text3->setLinksTrusted();
|
||||
|
||||
_version->setClickedCallback([this] { showVersionHistory(); });
|
||||
|
||||
|
|
|
@ -1249,7 +1249,6 @@ RevokePublicLinkBox::RevokePublicLinkBox(
|
|||
: _aboutRevoke(
|
||||
this,
|
||||
lang(lng_channels_too_much_public_about),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::aboutRevokePublicLabel)
|
||||
, _revokeCallback(std::move(revokeCallback)) {
|
||||
}
|
||||
|
|
|
@ -11,8 +11,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
#include "ui/wrap/fade_wrap.h"
|
||||
#include "boxes/confirm_phone_box.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "boxes/confirm_phone_box.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "auth_session.h"
|
||||
#include "data/data_session.h"
|
||||
|
@ -48,7 +49,6 @@ void createErrorLabel(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
parent,
|
||||
text,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::changePhoneError));
|
||||
label->hide(anim::type::instant);
|
||||
label->moveToLeft(x, y);
|
||||
|
@ -129,7 +129,7 @@ void ChangePhoneBox::EnterPhone::prepare() {
|
|||
_phone->moveToLeft(st::boxPadding.left(), st::boxLittleSkip);
|
||||
connect(_phone, &Ui::PhoneInput::submitted, [=] { submit(); });
|
||||
|
||||
auto description = object_ptr<Ui::FlatLabel>(this, lang(lng_change_phone_new_description), Ui::FlatLabel::InitType::Simple, st::changePhoneLabel);
|
||||
auto description = object_ptr<Ui::FlatLabel>(this, lang(lng_change_phone_new_description), st::changePhoneLabel);
|
||||
auto errorSkip = st::boxLittleSkip + st::changePhoneError.style.font->height;
|
||||
description->moveToLeft(st::boxPadding.left(), _phone->y() + _phone->height() + errorSkip + st::boxLittleSkip);
|
||||
|
||||
|
@ -237,8 +237,10 @@ ChangePhoneBox::EnterCode::EnterCode(QWidget*, const QString &phone, const QStri
|
|||
void ChangePhoneBox::EnterCode::prepare() {
|
||||
setTitle(langFactory(lng_change_phone_title));
|
||||
|
||||
auto descriptionText = lng_change_phone_code_description(lt_phone, textcmdStartSemibold() + App::formatPhone(_phone) + textcmdStopSemibold());
|
||||
auto description = object_ptr<Ui::FlatLabel>(this, descriptionText, Ui::FlatLabel::InitType::Rich, st::changePhoneLabel);
|
||||
auto descriptionText = lng_change_phone_code_description__rich(
|
||||
lt_phone,
|
||||
Ui::Text::Bold(App::formatPhone(_phone)));
|
||||
auto description = object_ptr<Ui::FlatLabel>(this, rpl::single(descriptionText), st::changePhoneLabel);
|
||||
description->moveToLeft(st::boxPadding.left(), 0);
|
||||
|
||||
auto phoneValue = QString();
|
||||
|
@ -299,7 +301,7 @@ void ChangePhoneBox::EnterCode::updateCall() {
|
|||
if (text.isEmpty()) {
|
||||
_callLabel.destroy();
|
||||
} else if (!_callLabel) {
|
||||
_callLabel.create(this, text, Ui::FlatLabel::InitType::Simple, st::changePhoneLabel);
|
||||
_callLabel.create(this, text, st::changePhoneLabel);
|
||||
_callLabel->moveToLeft(st::boxPadding.left(), countHeight() - _callLabel->height());
|
||||
_callLabel->show();
|
||||
} else {
|
||||
|
@ -346,7 +348,12 @@ void ChangePhoneBox::prepare() {
|
|||
closeBox();
|
||||
});
|
||||
|
||||
auto label = object_ptr<Ui::FlatLabel>(this, lang(lng_change_phone_description), Ui::FlatLabel::InitType::Rich, st::changePhoneDescription);
|
||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||
this,
|
||||
Lang::Viewer(
|
||||
lng_change_phone_about
|
||||
) | Ui::Text::ToRichLangValue(),
|
||||
st::changePhoneDescription);
|
||||
label->moveToLeft((st::boxWideWidth - label->width()) / 2, st::changePhoneDescriptionTop);
|
||||
|
||||
setDimensions(st::boxWideWidth, label->bottomNoMargins() + st::boxLittleSkip);
|
||||
|
|
|
@ -392,7 +392,7 @@ PinMessageBox::PinMessageBox(
|
|||
MsgId msgId)
|
||||
: _peer(peer)
|
||||
, _msgId(msgId)
|
||||
, _text(this, lang(lng_pinned_pin_sure), Ui::FlatLabel::InitType::Simple, st::boxLabel) {
|
||||
, _text(this, lang(lng_pinned_pin_sure), st::boxLabel) {
|
||||
}
|
||||
|
||||
void PinMessageBox::prepare() {
|
||||
|
@ -649,11 +649,11 @@ auto DeleteMessagesBox::revokeText(not_null<PeerData*> peer) const
|
|||
boldName.entities.push_back(
|
||||
{ EntityType::Bold, 0, boldName.text.size() });
|
||||
if (canRevokeOutgoingCount == 1) {
|
||||
result.description = lng_selected_unsend_about_user_one__generic<TextWithEntities>(
|
||||
result.description = lng_selected_unsend_about_user_one__rich(
|
||||
lt_user,
|
||||
boldName);
|
||||
} else {
|
||||
result.description = lng_selected_unsend_about_user__generic<TextWithEntities>(
|
||||
result.description = lng_selected_unsend_about_user__rich(
|
||||
lt_count,
|
||||
canRevokeOutgoingCount,
|
||||
lt_user,
|
||||
|
@ -911,12 +911,12 @@ ConfirmInviteBox::~ConfirmInviteBox() = default;
|
|||
|
||||
ConfirmDontWarnBox::ConfirmDontWarnBox(
|
||||
QWidget*,
|
||||
const QString &text,
|
||||
rpl::producer<TextWithEntities> text,
|
||||
const QString &checkbox,
|
||||
const QString &confirm,
|
||||
FnMut<void(bool)> callback)
|
||||
: _confirm(confirm)
|
||||
, _content(setupContent(text, checkbox, std::move(callback))) {
|
||||
, _content(setupContent(std::move(text), checkbox, std::move(callback))) {
|
||||
}
|
||||
|
||||
void ConfirmDontWarnBox::prepare() {
|
||||
|
@ -926,15 +926,14 @@ void ConfirmDontWarnBox::prepare() {
|
|||
}
|
||||
|
||||
not_null<Ui::RpWidget*> ConfirmDontWarnBox::setupContent(
|
||||
const QString &text,
|
||||
rpl::producer<TextWithEntities> text,
|
||||
const QString &checkbox,
|
||||
FnMut<void(bool)> callback) {
|
||||
const auto result = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
result->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
result,
|
||||
text,
|
||||
Ui::FlatLabel::InitType::Rich,
|
||||
std::move(text),
|
||||
st::boxLabel),
|
||||
st::boxPadding);
|
||||
const auto control = result->add(
|
||||
|
|
|
@ -224,7 +224,7 @@ class ConfirmDontWarnBox : public BoxContent {
|
|||
public:
|
||||
ConfirmDontWarnBox(
|
||||
QWidget*,
|
||||
const QString &text,
|
||||
rpl::producer<TextWithEntities> text,
|
||||
const QString &checkbox,
|
||||
const QString &confirm,
|
||||
FnMut<void(bool)> callback);
|
||||
|
@ -234,7 +234,7 @@ protected:
|
|||
|
||||
private:
|
||||
not_null<Ui::RpWidget*> setupContent(
|
||||
const QString &text,
|
||||
rpl::producer<TextWithEntities> text,
|
||||
const QString &checkbox,
|
||||
FnMut<void(bool)> callback);
|
||||
|
||||
|
|
|
@ -534,7 +534,6 @@ void ProxiesBox::setupContent() {
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
inner,
|
||||
lang(lng_proxy_about),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::boxDividerLabel),
|
||||
st::proxyAboutPadding),
|
||||
style::margins(0, 0, 0, st::proxyRowPadding.top()));
|
||||
|
@ -652,7 +651,6 @@ void ProxiesBox::createNoRowsLabel() {
|
|||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||
_noRows.get(),
|
||||
lang(lng_proxy_description),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::proxyEmptyListLabel);
|
||||
_noRows->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
|
@ -780,7 +778,6 @@ void ProxyBox::setupTypes() {
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
_content,
|
||||
lang(lng_proxy_sponsor_warning),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::boxDividerLabel),
|
||||
st::proxyAboutSponsorPadding)));
|
||||
}
|
||||
|
@ -911,7 +908,6 @@ void ProxyBox::addLabel(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
parent,
|
||||
text,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::proxyEditTitle),
|
||||
st::proxyEditTitlePadding);
|
||||
}
|
||||
|
|
|
@ -150,7 +150,6 @@ not_null<Ui::FlatLabel*> CreateWarningLabel(
|
|||
const auto result = Ui::CreateChild<Ui::FlatLabel>(
|
||||
parent.get(),
|
||||
QString(),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::createPollWarning);
|
||||
result->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
QObject::connect(field, &Ui::InputField::changed, [=] {
|
||||
|
|
|
@ -160,12 +160,10 @@ LocalStorageBox::Row::Row(
|
|||
, _title(
|
||||
this,
|
||||
titleText(data),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::localStorageRowTitle)
|
||||
, _description(
|
||||
this,
|
||||
sizeText(data),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::localStorageRowSize)
|
||||
, _clear(this, std::move(clear), st::localStorageClear) {
|
||||
_clear->setVisible(data.count != 0);
|
||||
|
@ -192,7 +190,6 @@ void LocalStorageBox::Row::toggleProgress(bool shown) {
|
|||
_clearing = object_ptr<Ui::FlatLabel>(
|
||||
this,
|
||||
lang(lng_local_storage_clearing),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::localStorageRowSize);
|
||||
_clearing->show();
|
||||
_description->hide();
|
||||
|
|
|
@ -87,7 +87,7 @@ void PasscodeBox::prepare() {
|
|||
addButton(langFactory(_turningOff ? lng_passcode_remove_button : lng_settings_save), [=] { save(); });
|
||||
addButton(langFactory(lng_cancel), [=] { closeBox(); });
|
||||
|
||||
_about.setRichText(st::passcodeTextStyle, lang(_cloudPwd ? lng_cloud_password_about : lng_passcode_about));
|
||||
_about.setText(st::passcodeTextStyle, lang(_cloudPwd ? lng_cloud_password_about : lng_passcode_about));
|
||||
_aboutHeight = _about.countHeight(st::boxWidth - st::boxPadding.left() * 1.5);
|
||||
if (_turningOff) {
|
||||
_oldPasscode->show();
|
||||
|
|
|
@ -246,7 +246,7 @@ void PeerListController::setDescriptionText(const QString &text) {
|
|||
if (text.isEmpty()) {
|
||||
setDescription(nullptr);
|
||||
} else {
|
||||
setDescription(object_ptr<Ui::FlatLabel>(nullptr, text, Ui::FlatLabel::InitType::Simple, st::membersAbout));
|
||||
setDescription(object_ptr<Ui::FlatLabel>(nullptr, text, st::membersAbout));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ void PeerListController::setSearchLoadingText(const QString &text) {
|
|||
if (text.isEmpty()) {
|
||||
setSearchLoading(nullptr);
|
||||
} else {
|
||||
setSearchLoading(object_ptr<Ui::FlatLabel>(nullptr, text, Ui::FlatLabel::InitType::Simple, st::membersAbout));
|
||||
setSearchLoading(object_ptr<Ui::FlatLabel>(nullptr, text, st::membersAbout));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,7 +262,7 @@ void PeerListController::setSearchNoResultsText(const QString &text) {
|
|||
if (text.isEmpty()) {
|
||||
setSearchNoResults(nullptr);
|
||||
} else {
|
||||
setSearchNoResults(object_ptr<Ui::FlatLabel>(nullptr, text, Ui::FlatLabel::InitType::Simple, st::membersAbout));
|
||||
setSearchNoResults(object_ptr<Ui::FlatLabel>(nullptr, text, st::membersAbout));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -886,7 +886,6 @@ void PeerListContent::setSearchMode(PeerListSearchMode mode) {
|
|||
setSearchLoading(object_ptr<Ui::FlatLabel>(
|
||||
this,
|
||||
lang(lng_contacts_loading),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::membersAbout));
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -214,14 +214,14 @@ void Builder::setupWarning() {
|
|||
const auto name = _user->shortName();
|
||||
const auto nameWithEntities = TextWithEntities{ name };
|
||||
const auto text = _phone.isEmpty()
|
||||
? lng_contact_phone_after__generic<TextWithEntities>(
|
||||
? lng_contact_phone_after__rich(
|
||||
lt_user,
|
||||
nameWithEntities,
|
||||
lt_visible,
|
||||
Ui::Text::Bold(lang(lng_contact_phone_visible)),
|
||||
lt_name,
|
||||
nameWithEntities)
|
||||
: lng_contact_phone_show__generic<TextWithEntities>(
|
||||
: lng_contact_phone_show__rich(
|
||||
lt_button,
|
||||
Ui::Text::Bold(lang(lng_box_done).toUpper()),
|
||||
lt_user,
|
||||
|
|
|
@ -117,9 +117,7 @@ void Controller::rowClicked(not_null<PeerListRow*> row) {
|
|||
}
|
||||
|
||||
void Controller::choose(not_null<ChannelData*> chat) {
|
||||
auto text = lng_manage_discussion_group_sure__generic<
|
||||
TextWithEntities
|
||||
>(
|
||||
auto text = lng_manage_discussion_group_sure__rich(
|
||||
lt_group,
|
||||
Ui::Text::Bold(chat->name),
|
||||
lt_channel,
|
||||
|
@ -132,7 +130,7 @@ void Controller::choose(not_null<ChannelData*> chat) {
|
|||
text.append("\n\n" + lang(lng_manage_discussion_group_private));
|
||||
if (chat->hiddenPreHistory()) {
|
||||
text.append("\n\n");
|
||||
text.append(lng_manage_discussion_group_warning__generic(
|
||||
text.append(lng_manage_discussion_group_warning__rich(
|
||||
lt_visible,
|
||||
Ui::Text::Bold(lang(lng_manage_discussion_group_visible))));
|
||||
}
|
||||
|
@ -154,9 +152,7 @@ void Controller::choose(not_null<ChannelData*> chat) {
|
|||
}
|
||||
|
||||
void Controller::choose(not_null<ChatData*> chat) {
|
||||
auto text = lng_manage_discussion_group_sure__generic<
|
||||
TextWithEntities
|
||||
>(
|
||||
auto text = lng_manage_discussion_group_sure__rich(
|
||||
lt_group,
|
||||
Ui::Text::Bold(chat->name),
|
||||
lt_channel,
|
||||
|
@ -196,17 +192,16 @@ object_ptr<Ui::RpWidget> SetupAbout(
|
|||
auto about = object_ptr<Ui::FlatLabel>(
|
||||
parent,
|
||||
QString(),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::linkedChatAbout);
|
||||
about->setMarkedText([&]() -> TextWithEntities {
|
||||
if (!channel->isBroadcast()) {
|
||||
return lng_manage_linked_channel_about__generic<
|
||||
TextWithEntities
|
||||
>(lt_channel, Ui::Text::Bold(chat->name));
|
||||
return lng_manage_linked_channel_about__rich(
|
||||
lt_channel,
|
||||
Ui::Text::Bold(chat->name));
|
||||
} else if (chat != nullptr) {
|
||||
return lng_manage_discussion_group_about_chosen__generic<
|
||||
TextWithEntities
|
||||
>(lt_group, Ui::Text::Bold(chat->name));
|
||||
return lng_manage_discussion_group_about_chosen__rich(
|
||||
lt_group,
|
||||
Ui::Text::Bold(chat->name));
|
||||
} else {
|
||||
return { lang(lng_manage_discussion_group_about) };
|
||||
}
|
||||
|
@ -222,7 +217,6 @@ object_ptr<Ui::RpWidget> SetupFooter(
|
|||
lang(channel->isBroadcast()
|
||||
? lng_manage_discussion_group_posted
|
||||
: lng_manage_linked_channel_posted),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::linkedChatAbout);
|
||||
}
|
||||
|
||||
|
|
|
@ -365,7 +365,6 @@ void EditRestrictedBox::prepare() {
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
this,
|
||||
lang(lng_rights_chat_banned_until_header),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::rightsHeaderLabel),
|
||||
st::rightsHeaderMargin);
|
||||
setRestrictUntil(_until);
|
||||
|
|
|
@ -21,7 +21,6 @@ SelfDestructionBox::SelfDestructionBox(
|
|||
, _loading(
|
||||
this,
|
||||
lang(lng_contacts_loading),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::membersAbout) {
|
||||
std::move(
|
||||
preloaded
|
||||
|
@ -55,7 +54,6 @@ void SelfDestructionBox::showContent() {
|
|||
_description.create(
|
||||
this,
|
||||
lang(lng_self_destruct_description),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::boxLabel);
|
||||
_description->moveToLeft(st::boxPadding.left(), y);
|
||||
y += _description->height() + st::boxMediumSkip;
|
||||
|
@ -93,7 +91,6 @@ void SelfDestructionBox::prepare() {
|
|||
auto fake = object_ptr<Ui::FlatLabel>(
|
||||
this,
|
||||
lang(lng_self_destruct_description),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::boxLabel);
|
||||
const auto boxHeight = st::boxOptionListPadding.top()
|
||||
+ fake->height() + st::boxMediumSkip
|
||||
|
|
|
@ -675,7 +675,7 @@ StickersBox::Inner::Inner(QWidget *parent, not_null<ChannelData*> megagroup) : T
|
|||
, _megagroupSetInput(_megagroupSet->mgInfo->stickerSet)
|
||||
, _megagroupSetField(this, st::groupStickersField, [] { return qsl("stickerset"); }, QString(), true)
|
||||
, _megagroupDivider(this)
|
||||
, _megagroupSubTitle(this, lang(lng_stickers_group_from_your), Ui::FlatLabel::InitType::Simple, st::boxTitle) {
|
||||
, _megagroupSubTitle(this, lang(lng_stickers_group_from_your), st::boxTitle) {
|
||||
_megagroupSetField->setLinkPlaceholder(Core::App().createInternalLink(qsl("addstickers/")));
|
||||
_megagroupSetField->setPlaceholderHidden(false);
|
||||
_megagroupSetAddressChangedTimer.setCallback([this] { handleMegagroupSetAddressChange(); });
|
||||
|
|
|
@ -149,7 +149,6 @@ not_null<Ui::RpWidget*> UrlAuthBox::setupContent(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
result,
|
||||
lng_url_auth_open_confirm(lt_link, url),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::boxLabel),
|
||||
st::boxPadding);
|
||||
const auto addCheckbox = [&](const QString &text) {
|
||||
|
|
|
@ -51,7 +51,7 @@ void UsernameBox::prepare() {
|
|||
connect(_username, &Ui::MaskedInputField::submitted, [=] { save(); });
|
||||
_link->addClickHandler([=] { linkClick(); });
|
||||
|
||||
_about.setRichText(st::usernameTextStyle, lang(lng_username_about));
|
||||
_about.setText(st::usernameTextStyle, lang(lng_username_about));
|
||||
setDimensions(st::boxWidth, st::usernamePadding.top() + _username->height() + st::usernameSkip + _about.countHeight(st::boxWidth - st::usernamePadding.left()) + 3 * st::usernameTextStyle.lineHeight + st::usernamePadding.bottom());
|
||||
|
||||
_checkTimer->setSingleShot(true);
|
||||
|
|
|
@ -541,7 +541,6 @@ void Row::setupLabels(const Set &set) {
|
|||
const auto name = Ui::CreateChild<Ui::FlatLabel>(
|
||||
this,
|
||||
set.name,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::localStorageRowTitle);
|
||||
name->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
_status = Ui::CreateChild<Ui::FlatLabel>(
|
||||
|
|
|
@ -685,7 +685,6 @@ void TabbedSelector::checkRestrictedPeer() {
|
|||
_restrictedLabel.create(
|
||||
this,
|
||||
lang(*errorKey),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::stickersRestrictedLabel);
|
||||
_restrictedLabel->show();
|
||||
updateRestrictedLabelGeometry();
|
||||
|
|
|
@ -169,6 +169,7 @@ inline ResultString " << (isPlural ? entry.keyBase : key) << "__generic(" << gen
|
|||
return result;\n\
|
||||
}\n\
|
||||
constexpr auto " << (isPlural ? entry.keyBase : key) << " = &" << (isPlural ? entry.keyBase : key) << "__generic<QString>;\n\
|
||||
constexpr auto " << (isPlural ? entry.keyBase : key) << "__rich = &" << (isPlural ? entry.keyBase : key) << "__generic<TextWithEntities>;\n\
|
||||
\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/confirm_box.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/image/image_source.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "mainwindow.h"
|
||||
#include "core/application.h"
|
||||
#include "lottie/lottie_animation.h"
|
||||
|
@ -96,9 +97,9 @@ void LaunchWithWarning(const QString &name, HistoryItem *item) {
|
|||
File::Launch(name);
|
||||
};
|
||||
Ui::show(Box<ConfirmDontWarnBox>(
|
||||
lng_launch_exe_warning(
|
||||
rpl::single(lng_launch_exe_warning__rich(
|
||||
lt_extension,
|
||||
textcmdStartSemibold() + extension + textcmdStopSemibold()),
|
||||
Ui::Text::Bold(extension))),
|
||||
lang(lng_launch_exe_dont_ask),
|
||||
lang(lng_launch_exe_sure),
|
||||
callback));
|
||||
|
|
|
@ -53,7 +53,6 @@ void SuggestBox::prepare() {
|
|||
const auto content = Ui::CreateChild<Ui::FlatLabel>(
|
||||
this,
|
||||
lang(lng_export_suggest_text),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::boxLabel);
|
||||
widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
|
@ -233,7 +232,6 @@ void PanelController::showCriticalError(const QString &text) {
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
_panel.get(),
|
||||
text,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::exportErrorLabel),
|
||||
style::margins(0, st::exportPanelSize.height() / 4, 0, 0));
|
||||
container->widthValue(
|
||||
|
|
|
@ -91,14 +91,12 @@ void ProgressWidget::Row::fillCurrentInstance() {
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
this,
|
||||
_data.label,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::exportProgressLabel));
|
||||
_current.info = base::make_unique_q<Ui::FadeWrap<Ui::FlatLabel>>(
|
||||
this,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
this,
|
||||
_data.info,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::exportProgressInfoLabel));
|
||||
_current.label->hide(anim::type::instant);
|
||||
_current.info->hide(anim::type::instant);
|
||||
|
@ -248,7 +246,6 @@ ProgressWidget::ProgressWidget(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
this,
|
||||
lang(lng_export_progress),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::exportAboutLabel),
|
||||
st::exportAboutPadding);
|
||||
|
||||
|
|
|
@ -262,7 +262,7 @@ void SettingsWidget::addLocationLabel(
|
|||
0,
|
||||
text.size(),
|
||||
QString("internal:edit_export_path") });
|
||||
return lng_export_option_location__generic<TextWithEntities>(
|
||||
return lng_export_option_location__rich(
|
||||
lt_path,
|
||||
pathLink);
|
||||
});
|
||||
|
@ -303,7 +303,7 @@ void SettingsWidget::addLimitsLabel(
|
|||
0,
|
||||
end.size(),
|
||||
QString("internal:edit_till") });
|
||||
return lng_export_limits__generic<TextWithEntities>(
|
||||
return lng_export_limits__rich(
|
||||
lt_from,
|
||||
fromLink,
|
||||
lt_till,
|
||||
|
@ -454,7 +454,6 @@ void SettingsWidget::addHeader(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
lang(key),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::exportHeaderLabel),
|
||||
st::exportHeaderPadding);
|
||||
}
|
||||
|
@ -493,7 +492,6 @@ not_null<Ui::Checkbox*> SettingsWidget::addOptionWithAbout(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
lang(about),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::exportAboutOptionLabel),
|
||||
st::exportAboutOptionPadding);
|
||||
return result;
|
||||
|
|
|
@ -2100,7 +2100,6 @@ void HistoryWidget::refreshAboutProxyPromotion() {
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
this,
|
||||
lang(lng_proxy_sponsor_about),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::historyAboutProxy),
|
||||
st::historyAboutProxyPadding);
|
||||
}
|
||||
|
|
|
@ -486,7 +486,7 @@ bool TopBar::computeCanDelete() const {
|
|||
Ui::StringWithNumbers TopBar::generateSelectedText() const {
|
||||
using Data = Ui::StringWithNumbers;
|
||||
using Type = Storage::SharedMediaType;
|
||||
auto phrase = [&] {
|
||||
const auto phrase = [&] {
|
||||
switch (_selectedItems.type) {
|
||||
case Type::Photo: return lng_media_selected_photo__generic<Data>;
|
||||
case Type::Video: return lng_media_selected_video__generic<Data>;
|
||||
|
|
|
@ -90,7 +90,7 @@ void Inner::checkRestrictedPeer() {
|
|||
ChatRestriction::f_send_inline);
|
||||
if (errorKey) {
|
||||
if (!_restrictedLabel) {
|
||||
_restrictedLabel.create(this, lang(*errorKey), Ui::FlatLabel::InitType::Simple, st::stickersRestrictedLabel);
|
||||
_restrictedLabel.create(this, lang(*errorKey), st::stickersRestrictedLabel);
|
||||
_restrictedLabel->show();
|
||||
_restrictedLabel->move(st::inlineResultsLeft - st::buttonRadius, st::stickerPanPadding);
|
||||
if (_switchPmButton) {
|
||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/update_checker.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "styles/style_intro.h"
|
||||
|
||||
|
@ -101,7 +102,11 @@ void CodeWidget::refreshLang() {
|
|||
}
|
||||
|
||||
void CodeWidget::updateDescText() {
|
||||
setDescriptionText(langFactory(getData()->codeByTelegram ? lng_code_telegram : lng_code_desc));
|
||||
const auto byTelegram = getData()->codeByTelegram;
|
||||
setDescriptionText([=] {
|
||||
return Ui::Text::RichLangValue(
|
||||
lang(byTelegram ? lng_code_from_telegram : lng_code_desc));
|
||||
});
|
||||
if (getData()->codeByTelegram) {
|
||||
_noTelegramCode->show();
|
||||
_callTimer->stop();
|
||||
|
|
|
@ -85,23 +85,6 @@ void PhoneWidget::hidePhoneError() {
|
|||
}
|
||||
}
|
||||
|
||||
//void PhoneWidget::showSignup() {
|
||||
// showPhoneError(langFactory(lng_bad_phone_noreg));
|
||||
// if (!_signup) {
|
||||
// auto signupText = lng_phone_notreg(lt_link_start, textcmdStartLink(1), lt_link_end, textcmdStopLink(), lt_signup_start, textcmdStartLink(2), lt_signup_end, textcmdStopLink());
|
||||
// auto inner = object_ptr<Ui::FlatLabel>(this, signupText, Ui::FlatLabel::InitType::Rich, st::introDescription);
|
||||
// _signup.create(this, std::move(inner));
|
||||
// _signup->entity()->setLink(1, std::make_shared<UrlClickHandler>(qsl("https://telegram.org"), false));
|
||||
// _signup->entity()->setLink(2, std::make_shared<LambdaClickHandler>([this] {
|
||||
// toSignUp();
|
||||
// }));
|
||||
// _signup->hide(anim::type::instant);
|
||||
// updateSignupGeometry();
|
||||
// }
|
||||
// _signup->show(anim::type::normal);
|
||||
// hideDescription();
|
||||
//}
|
||||
|
||||
void PhoneWidget::countryChanged() {
|
||||
if (!_changed) {
|
||||
selectCountry(getData()->country);
|
||||
|
@ -129,7 +112,6 @@ void PhoneWidget::submit() {
|
|||
|
||||
_sentPhone = phone;
|
||||
Core::App().mtp()->setUserPhone(_sentPhone);
|
||||
//_sentRequest = MTP::send(MTPauth_CheckPhone(MTP_string(_sentPhone)), rpcDone(&PhoneWidget::phoneCheckDone), rpcFail(&PhoneWidget::phoneSubmitFail));
|
||||
_sentRequest = MTP::send(
|
||||
MTPauth_SendCode(
|
||||
MTP_string(_sentPhone),
|
||||
|
@ -158,22 +140,6 @@ void PhoneWidget::onCheckRequest() {
|
|||
stopCheck();
|
||||
}
|
||||
}
|
||||
//
|
||||
//void PhoneWidget::phoneCheckDone(const MTPauth_CheckedPhone &result) {
|
||||
// stopCheck();
|
||||
//
|
||||
// auto &d = result.c_auth_checkedPhone();
|
||||
// if (mtpIsTrue(d.vphone_registered)) {
|
||||
// hidePhoneError();
|
||||
//
|
||||
// _checkRequest->start(1000);
|
||||
//
|
||||
// _sentRequest = MTP::send(MTPauth_SendCode(MTP_flags(0), MTP_string(_sentPhone), MTPBool(), MTP_int(ApiId), MTP_string(ApiHash)), rpcDone(&PhoneWidget::phoneSubmitDone), rpcFail(&PhoneWidget::phoneSubmitFail));
|
||||
// } else {
|
||||
// showSignup();
|
||||
// _sentRequest = 0;
|
||||
// }
|
||||
//}
|
||||
|
||||
void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) {
|
||||
stopCheck();
|
||||
|
@ -199,14 +165,6 @@ void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) {
|
|||
goNext(new Intro::CodeWidget(parentWidget(), getData()));
|
||||
}
|
||||
|
||||
//void PhoneWidget::toSignUp() {
|
||||
// hideError(); // Hide error, but leave the signup label visible.
|
||||
//
|
||||
// _checkRequest->start(1000);
|
||||
//
|
||||
// _sentRequest = MTP::send(MTPauth_SendCode(MTP_flags(0), MTP_string(_sentPhone), MTPBool(), MTP_int(ApiId), MTP_string(ApiHash)), rpcDone(&PhoneWidget::phoneSubmitDone), rpcFail(&PhoneWidget::phoneSubmitFail));
|
||||
//}
|
||||
|
||||
bool PhoneWidget::phoneSubmitFail(const RPCError &error) {
|
||||
if (MTP::isFloodError(error)) {
|
||||
stopCheck();
|
||||
|
|
|
@ -48,18 +48,14 @@ private:
|
|||
void updateSignupGeometry();
|
||||
void countryChanged();
|
||||
|
||||
//void phoneCheckDone(const MTPauth_CheckedPhone &result);
|
||||
void phoneSubmitDone(const MTPauth_SentCode &result);
|
||||
bool phoneSubmitFail(const RPCError &error);
|
||||
|
||||
//void toSignUp();
|
||||
|
||||
QString fullNumber() const;
|
||||
void stopCheck();
|
||||
|
||||
void showPhoneError(Fn<QString()> textFactory);
|
||||
void hidePhoneError();
|
||||
//void showSignup();
|
||||
|
||||
bool _changed = false;
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ void PwdCheckWidget::showReset() {
|
|||
void PwdCheckWidget::updateDescriptionText() {
|
||||
auto pwdHidden = _pwdField->isHidden();
|
||||
auto emailPattern = _emailPattern;
|
||||
setDescriptionText([pwdHidden, emailPattern] {
|
||||
setDescriptionText([=] {
|
||||
return pwdHidden ? lng_signin_recover_desc(lt_email, emailPattern) : lang(lng_signin_desc);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/application.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "ui/text/text.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/wrap/fade_wrap.h"
|
||||
|
@ -324,17 +325,19 @@ void Widget::showTerms() {
|
|||
} else if (!_terms) {
|
||||
auto entity = object_ptr<Ui::FlatLabel>(
|
||||
this,
|
||||
lng_terms_signup(
|
||||
rpl::single(lng_terms_signup__rich(
|
||||
lt_link,
|
||||
textcmdLink(1, lang(lng_terms_signup_link))),
|
||||
Ui::FlatLabel::InitType::Rich,
|
||||
Ui::Text::Link(lang(lng_terms_signup_link)))),
|
||||
st::introTermsLabel);
|
||||
_terms.create(this, std::move(entity));
|
||||
_terms->entity()->setLink(
|
||||
1,
|
||||
std::make_shared<LambdaClickHandler>([=] {
|
||||
_terms->entity()->setClickHandlerFilter([=](
|
||||
const ClickHandlerPtr &handler,
|
||||
Qt::MouseButton button) {
|
||||
if (button == Qt::LeftButton) {
|
||||
showTerms(nullptr);
|
||||
}));
|
||||
}
|
||||
return false;
|
||||
});
|
||||
updateControlsGeometry();
|
||||
_terms->hide(anim::type::instant);
|
||||
}
|
||||
|
@ -670,24 +673,32 @@ void Widget::Step::updateLabelsPosition() {
|
|||
}
|
||||
}
|
||||
|
||||
void Widget::Step::setTitleText(Fn<QString()> richTitleTextFactory) {
|
||||
_titleTextFactory = std::move(richTitleTextFactory);
|
||||
void Widget::Step::setTitleText(Fn<QString()> titleTextFactory) {
|
||||
_titleTextFactory = std::move(titleTextFactory);
|
||||
refreshTitle();
|
||||
updateLabelsPosition();
|
||||
}
|
||||
|
||||
void Widget::Step::refreshTitle() {
|
||||
_title->setRichText(_titleTextFactory());
|
||||
_title->setText(_titleTextFactory());
|
||||
}
|
||||
|
||||
void Widget::Step::setDescriptionText(Fn<QString()> richDescriptionTextFactory) {
|
||||
void Widget::Step::setDescriptionText(Fn<QString()> descriptionTextFactory) {
|
||||
_descriptionTextFactory = [=] {
|
||||
return TextWithEntities{ descriptionTextFactory() };
|
||||
};
|
||||
refreshDescription();
|
||||
updateLabelsPosition();
|
||||
}
|
||||
|
||||
void Widget::Step::setDescriptionText(Fn<TextWithEntities()> richDescriptionTextFactory) {
|
||||
_descriptionTextFactory = std::move(richDescriptionTextFactory);
|
||||
refreshDescription();
|
||||
updateLabelsPosition();
|
||||
}
|
||||
|
||||
void Widget::Step::refreshDescription() {
|
||||
_description->entity()->setRichText(_descriptionTextFactory());
|
||||
_description->entity()->setMarkedText(_descriptionTextFactory());
|
||||
}
|
||||
|
||||
void Widget::Step::refreshLang() {
|
||||
|
|
|
@ -138,8 +138,9 @@ public:
|
|||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
void setTitleText(Fn<QString()> richTitleTextFactory);
|
||||
void setDescriptionText(Fn<QString()> richDescriptionTextFactory);
|
||||
void setTitleText(Fn<QString()> titleTextFactory);
|
||||
void setDescriptionText(Fn<QString()> descriptionTextFactory);
|
||||
void setDescriptionText(Fn<TextWithEntities()> richDescriptionTextFactory);
|
||||
bool paintAnimated(Painter &p, QRect clip);
|
||||
|
||||
void fillSentCodeData(const MTPDauth_sentCode &type);
|
||||
|
@ -213,7 +214,7 @@ public:
|
|||
object_ptr<Ui::FlatLabel> _title;
|
||||
Fn<QString()> _titleTextFactory;
|
||||
object_ptr<Ui::FadeWrap<Ui::FlatLabel>> _description;
|
||||
Fn<QString()> _descriptionTextFactory;
|
||||
Fn<TextWithEntities()> _descriptionTextFactory;
|
||||
|
||||
bool _errorCentered = false;
|
||||
bool _errorBelowLink = false;
|
||||
|
|
|
@ -89,8 +89,8 @@ void ConfirmSwitchBox::prepare() {
|
|||
0,
|
||||
percent.text.size() });
|
||||
const auto text = (_official
|
||||
? lng_language_switch_about_official__generic<TextWithEntities>
|
||||
: lng_language_switch_about_unofficial__generic<TextWithEntities>)(
|
||||
? lng_language_switch_about_official__rich
|
||||
: lng_language_switch_about_unofficial__rich)(
|
||||
lt_lang_name,
|
||||
name,
|
||||
lt_percent,
|
||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/popup_menu.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/text_options.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "media/audio/media_audio.h"
|
||||
|
@ -235,11 +236,13 @@ OverlayWidget::OverlayWidget()
|
|||
setWindowIcon(Window::CreateIcon(&Core::App().activeAccount()));
|
||||
setWindowTitle(qsl("Media viewer"));
|
||||
|
||||
TextCustomTagsMap custom;
|
||||
custom.insert(QChar('c'), qMakePair(textcmdStartLink(1), textcmdStopLink()));
|
||||
_saveMsgText.setRichText(st::mediaviewSaveMsgStyle, lang(lng_mediaview_saved), Ui::DialogTextOptions(), custom);
|
||||
const auto text = lng_mediaview_saved_to__rich(
|
||||
lt_downloads,
|
||||
Ui::Text::Link(
|
||||
lang(lng_mediaview_downloads),
|
||||
"internal:show_saved_message"));
|
||||
_saveMsgText.setMarkedText(st::mediaviewSaveMsgStyle, text, Ui::DialogTextOptions());
|
||||
_saveMsg = QRect(0, 0, _saveMsgText.maxWidth() + st::mediaviewSaveMsgPadding.left() + st::mediaviewSaveMsgPadding.right(), st::mediaviewSaveMsgStyle.font->height + st::mediaviewSaveMsgPadding.top() + st::mediaviewSaveMsgPadding.bottom());
|
||||
_saveMsgText.setLink(1, std::make_shared<LambdaClickHandler>([this] { showSaveMsgFile(); }));
|
||||
|
||||
connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(onScreenResized(int)));
|
||||
|
||||
|
@ -3441,7 +3444,11 @@ void OverlayWidget::updateOver(QPoint pos) {
|
|||
void OverlayWidget::mouseReleaseEvent(QMouseEvent *e) {
|
||||
updateOver(e->pos());
|
||||
|
||||
if (ClickHandlerPtr activated = ClickHandler::unpressed()) {
|
||||
if (const auto activated = ClickHandler::unpressed()) {
|
||||
if (activated->dragText() == qstr("internal:show_saved_message")) {
|
||||
showSaveMsgFile();
|
||||
return;
|
||||
}
|
||||
App::activateClickHandler(activated, e->button());
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,6 @@ void Panel::showCriticalError(const QString &error) {
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
_widget.get(),
|
||||
error,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportErrorLabel),
|
||||
style::margins(0, st::passportPanelSize.height() / 3, 0, 0));
|
||||
container->widthValue(
|
||||
|
|
|
@ -530,7 +530,6 @@ DateRow::DateRow(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
this,
|
||||
QString(" / "),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportDetailsSeparator),
|
||||
st::passportDetailsSeparatorPadding)
|
||||
, _month(
|
||||
|
@ -543,7 +542,6 @@ DateRow::DateRow(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
this,
|
||||
QString(" / "),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportDetailsSeparator),
|
||||
st::passportDetailsSeparatorPadding)
|
||||
, _year(
|
||||
|
@ -1066,7 +1064,6 @@ void PanelDetailsRow::showError(std::optional<QString> error) {
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
this,
|
||||
*error,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportVerifyErrorLabel));
|
||||
} else {
|
||||
_error->entity()->setText(*error);
|
||||
|
|
|
@ -102,7 +102,6 @@ void VerifyBox::setupControls(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
_content,
|
||||
text,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::boxLabel),
|
||||
small);
|
||||
_code = _content->add(
|
||||
|
@ -118,7 +117,6 @@ void VerifyBox::setupControls(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
_content,
|
||||
QString(),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportVerifyErrorLabel)),
|
||||
small);
|
||||
const auto waiter = _content->add(
|
||||
|
@ -256,14 +254,12 @@ void PanelEditContact::setupControls(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
_content,
|
||||
_scheme.aboutExisting,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::boxDividerLabel),
|
||||
st::passportFormLabelPadding));
|
||||
_content->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
_content,
|
||||
_scheme.newHeader,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportFormHeader),
|
||||
st::passportDetailsHeaderPadding);
|
||||
}
|
||||
|
@ -308,7 +304,6 @@ void PanelEditContact::setupControls(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
_content,
|
||||
QString(),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportVerifyErrorLabel),
|
||||
st::passportContactErrorPadding),
|
||||
st::passportContactErrorMargin);
|
||||
|
@ -320,7 +315,6 @@ void PanelEditContact::setupControls(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
_content,
|
||||
_scheme.aboutNew,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::boxDividerLabel),
|
||||
st::passportFormLabelPadding));
|
||||
|
||||
|
|
|
@ -101,14 +101,13 @@ void RequestTypeBox::setupControls(
|
|||
const auto header = Ui::CreateChild<Ui::FlatLabel>(
|
||||
this,
|
||||
lang(lng_passport_document_type),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::boxDividerLabel);
|
||||
|
||||
const auto group = std::make_shared<Ui::RadiobuttonGroup>(0);
|
||||
auto buttons = std::vector<QPointer<Ui::Radiobutton>>();
|
||||
auto index = 0;
|
||||
for (const auto &label : labels) {
|
||||
buttons.push_back(Ui::CreateChild<Ui::Radiobutton>(
|
||||
buttons.emplace_back(Ui::CreateChild<Ui::Radiobutton>(
|
||||
this,
|
||||
group,
|
||||
index++,
|
||||
|
@ -119,7 +118,6 @@ void RequestTypeBox::setupControls(
|
|||
const auto description = Ui::CreateChild<Ui::FlatLabel>(
|
||||
this,
|
||||
about,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::boxDividerLabel);
|
||||
|
||||
auto y = 0;
|
||||
|
@ -169,7 +167,6 @@ void DeleteDocumentBox::setupControls(
|
|||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||
this,
|
||||
text,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::boxLabel);
|
||||
const auto details = !detailsCheckbox.isEmpty()
|
||||
? Ui::CreateChild<Ui::Checkbox>(
|
||||
|
@ -377,7 +374,6 @@ not_null<Ui::RpWidget*> PanelEditDocument::setupContent(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
inner,
|
||||
*error,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportVerifyErrorLabel),
|
||||
st::passportValueErrorPadding));
|
||||
_commonError->toggle(true, anim::type::instant);
|
||||
|
@ -386,7 +382,6 @@ not_null<Ui::RpWidget*> PanelEditDocument::setupContent(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
inner,
|
||||
data ? _scheme.detailsHeader : _scheme.fieldsHeader,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportFormHeader),
|
||||
st::passportDetailsHeaderPadding);
|
||||
enumerateRows([&](
|
||||
|
|
|
@ -519,7 +519,6 @@ void EditScans::setupScans(const QString &header) {
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
inner,
|
||||
_error,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportVerifyErrorLabel),
|
||||
st::passportValueErrorPadding));
|
||||
_commonError->toggle(true, anim::type::instant);
|
||||
|
@ -555,7 +554,6 @@ void EditScans::setupList(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
header,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportFormHeader),
|
||||
st::passportUploadHeaderPadding));
|
||||
list.header->toggle(
|
||||
|
@ -568,7 +566,6 @@ void EditScans::setupList(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
list.errorMissing,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportVerifyErrorLabel),
|
||||
st::passportUploadErrorPadding));
|
||||
list.uploadMoreError->toggle(true, anim::type::instant);
|
||||
|
@ -659,7 +656,6 @@ void EditScans::setupSpecialScans(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
inner,
|
||||
_error,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportVerifyErrorLabel),
|
||||
st::passportValueErrorPadding));
|
||||
_commonError->toggle(true, anim::type::instant);
|
||||
|
@ -678,7 +674,6 @@ void EditScans::setupSpecialScans(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
inner,
|
||||
header,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportFormHeader),
|
||||
st::passportUploadHeaderPadding));
|
||||
scan.header->toggle(scan.file.key.id != 0, anim::type::instant);
|
||||
|
@ -707,7 +702,6 @@ void EditScans::setupSpecialScans(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
inner,
|
||||
description(type),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::boxDividerLabel),
|
||||
st::passportFormLabelPadding));
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/wrap/fade_wrap.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/text_options.h"
|
||||
#include "ui/special_buttons.h"
|
||||
#include "styles/style_passport.h"
|
||||
|
@ -232,7 +233,6 @@ not_null<Ui::RpWidget*> PanelForm::setupContent() {
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
inner,
|
||||
lng_passport_request1(lt_bot, App::peerName(bot)),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportPasswordLabelBold)),
|
||||
st::passportFormAbout1Padding)->entity();
|
||||
|
||||
|
@ -242,7 +242,6 @@ not_null<Ui::RpWidget*> PanelForm::setupContent() {
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
inner,
|
||||
lang(lng_passport_request2),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportPasswordLabel)),
|
||||
st::passportFormAbout2Padding)->entity();
|
||||
|
||||
|
@ -253,7 +252,6 @@ not_null<Ui::RpWidget*> PanelForm::setupContent() {
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
inner,
|
||||
lang(lng_passport_header),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportFormHeader),
|
||||
st::passportFormHeaderPadding);
|
||||
|
||||
|
@ -294,24 +292,22 @@ not_null<Ui::RpWidget*> PanelForm::setupContent() {
|
|||
});
|
||||
}, lifetime());
|
||||
const auto policyUrl = _controller->privacyPolicyUrl();
|
||||
const auto richText = policyUrl.isEmpty()
|
||||
? TextWithEntities{ lng_passport_allow(lt_bot, '@' + bot->username) }
|
||||
: lng_passport_accept_allow__rich(
|
||||
lt_policy,
|
||||
Ui::Text::Link(
|
||||
lng_passport_policy(lt_bot, App::peerName(bot)),
|
||||
policyUrl),
|
||||
lt_bot,
|
||||
TextWithEntities{ '@' + bot->username });
|
||||
const auto policy = inner->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
inner,
|
||||
(policyUrl.isEmpty()
|
||||
? lng_passport_allow(lt_bot, '@' + bot->username)
|
||||
: lng_passport_accept_allow(
|
||||
lt_policy,
|
||||
textcmdLink(
|
||||
1,
|
||||
lng_passport_policy(lt_bot, App::peerName(bot))),
|
||||
lt_bot,
|
||||
'@' + bot->username)),
|
||||
Ui::FlatLabel::InitType::Rich,
|
||||
rpl::single(richText),
|
||||
st::passportFormPolicy),
|
||||
st::passportFormPolicyPadding);
|
||||
if (!policyUrl.isEmpty()) {
|
||||
policy->setLink(1, std::make_shared<UrlClickHandler>(policyUrl));
|
||||
}
|
||||
policy->setLinksTrusted();
|
||||
|
||||
return inner;
|
||||
}
|
||||
|
|
|
@ -36,12 +36,10 @@ PanelAskPassword::PanelAskPassword(
|
|||
, _about1(
|
||||
this,
|
||||
lng_passport_request1(lt_bot, App::peerName(_controller->bot())),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportPasswordLabelBold)
|
||||
, _about2(
|
||||
this,
|
||||
lang(lng_passport_request2),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportPasswordLabel)
|
||||
, _password(
|
||||
this,
|
||||
|
@ -59,7 +57,6 @@ PanelAskPassword::PanelAskPassword(
|
|||
_hint.create(
|
||||
this,
|
||||
hint,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportPasswordHintLabel);
|
||||
}
|
||||
_controller->passwordError(
|
||||
|
@ -84,7 +81,6 @@ void PanelAskPassword::showError(const QString &error) {
|
|||
_error.create(
|
||||
this,
|
||||
error,
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportErrorLabel);
|
||||
_error->show();
|
||||
updateControlsGeometry();
|
||||
|
@ -180,7 +176,6 @@ void PanelNoPassword::setupContent() {
|
|||
lng_passport_request1(
|
||||
lt_bot,
|
||||
App::peerName(_controller->bot())),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportPasswordLabelBold)),
|
||||
st::passportPasswordAbout1Padding)->entity();
|
||||
|
||||
|
@ -190,7 +185,6 @@ void PanelNoPassword::setupContent() {
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
_inner,
|
||||
lang(lng_passport_request2),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportPasswordLabel)),
|
||||
st::passportPasswordAbout2Padding)->entity();
|
||||
|
||||
|
@ -212,7 +206,6 @@ void PanelNoPassword::setupContent() {
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
_inner,
|
||||
lang(lng_passport_create_password),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportPasswordSetupLabel)),
|
||||
st::passportFormAbout2Padding)->entity();
|
||||
|
||||
|
@ -229,7 +222,6 @@ void PanelNoPassword::refreshBottom() {
|
|||
(pattern.isEmpty()
|
||||
? lang(lng_passport_about_password)
|
||||
: lng_passport_code_sent(lt_email, pattern)),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::passportPasswordSetupLabel)),
|
||||
st::passportFormAbout2Padding)->entity());
|
||||
if (pattern.isEmpty()) {
|
||||
|
|
|
@ -304,7 +304,6 @@ BioManager SetupBio(
|
|||
const auto countdown = Ui::CreateChild<Ui::FlatLabel>(
|
||||
container.get(),
|
||||
QString(),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::settingsBioCountdown);
|
||||
|
||||
rpl::combine(
|
||||
|
|
|
@ -2652,82 +2652,9 @@ void String::setMarkedText(const style::TextStyle &st, const TextWithEntities &t
|
|||
recountNaturalSize(true, options.dir);
|
||||
}
|
||||
|
||||
void String::setRichText(const style::TextStyle &st, const QString &text, TextParseOptions options, const TextCustomTagsMap &custom) {
|
||||
QString parsed;
|
||||
parsed.reserve(text.size());
|
||||
const QChar *s = text.constData(), *ch = s;
|
||||
for (const QChar *b = s, *e = b + text.size(); ch != e; ++ch) {
|
||||
if (ch->unicode() == '\\') {
|
||||
if (ch > s) parsed.append(s, ch - s);
|
||||
s = ch + 1;
|
||||
|
||||
if (s < e) ++ch;
|
||||
continue;
|
||||
}
|
||||
if (ch->unicode() == '[') {
|
||||
if (ch > s) parsed.append(s, ch - s);
|
||||
s = ch;
|
||||
|
||||
const QChar *tag = ch + 1;
|
||||
if (tag >= e) continue;
|
||||
|
||||
bool closing = false, other = false;
|
||||
if (tag->unicode() == '/') {
|
||||
closing = true;
|
||||
if (++tag >= e) continue;
|
||||
}
|
||||
|
||||
TextCommands cmd;
|
||||
switch (tag->unicode()) {
|
||||
case 'b': cmd = closing ? TextCommandNoBold : TextCommandBold; break;
|
||||
case 'i': cmd = closing ? TextCommandNoItalic : TextCommandItalic; break;
|
||||
case 'u': cmd = closing ? TextCommandNoUnderline : TextCommandUnderline; break;
|
||||
default : other = true; break;
|
||||
}
|
||||
|
||||
if (!other) {
|
||||
if (++tag >= e || tag->unicode() != ']') continue;
|
||||
parsed.append(TextCommand).append(QChar(cmd)).append(TextCommand);
|
||||
ch = tag;
|
||||
s = ch + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tag->unicode() != 'a') {
|
||||
TextCustomTagsMap::const_iterator i = custom.constFind(*tag);
|
||||
if (++tag >= e || tag->unicode() != ']' || i == custom.cend()) continue;
|
||||
parsed.append(closing ? i->second : i->first);
|
||||
ch = tag;
|
||||
s = ch + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (closing) {
|
||||
if (++tag >= e || tag->unicode() != ']') continue;
|
||||
parsed.append(textcmdStopLink());
|
||||
ch = tag;
|
||||
s = ch + 1;
|
||||
continue;
|
||||
}
|
||||
if (++tag >= e || tag->unicode() != ' ') continue;
|
||||
while (tag < e && tag->unicode() == ' ') ++tag;
|
||||
if (tag + 5 < e && text.midRef(tag - b, 6) == qsl("href=\"")) {
|
||||
tag += 6;
|
||||
const QChar *tagend = tag;
|
||||
while (tagend < e && tagend->unicode() != '"') ++tagend;
|
||||
if (++tagend >= e || tagend->unicode() != ']') continue;
|
||||
parsed.append(textcmdStartLink(QString(tag, tagend - 1 - tag)));
|
||||
ch = tagend;
|
||||
s = ch + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ch > s) parsed.append(s, ch - s);
|
||||
s = ch;
|
||||
|
||||
void String::setRichText(const style::TextStyle &st, const QString &text, TextParseOptions options) {
|
||||
options.flags |= TextParseRichText;
|
||||
setText(st, parsed, options);
|
||||
setText(st, text, options);
|
||||
}
|
||||
|
||||
void String::setLink(uint16 lnkIndex, const ClickHandlerPtr &lnk) {
|
||||
|
|
|
@ -64,9 +64,6 @@ inline bool operator!=(TextSelection a, TextSelection b) {
|
|||
|
||||
static constexpr TextSelection AllTextSelection = { 0, 0xFFFF };
|
||||
|
||||
typedef QPair<QString, QString> TextCustomTag; // open str and close str
|
||||
typedef QMap<QChar, TextCustomTag> TextCustomTagsMap;
|
||||
|
||||
namespace Ui {
|
||||
namespace Text {
|
||||
|
||||
|
@ -118,7 +115,7 @@ public:
|
|||
int countHeight(int width) const;
|
||||
void countLineWidths(int width, QVector<int> *lineWidths) const;
|
||||
void setText(const style::TextStyle &st, const QString &text, const TextParseOptions &options = _defaultOptions);
|
||||
void setRichText(const style::TextStyle &st, const QString &text, TextParseOptions options = _defaultOptions, const TextCustomTagsMap &custom = TextCustomTagsMap());
|
||||
void setRichText(const style::TextStyle &st, const QString &text, TextParseOptions options = _defaultOptions);
|
||||
void setMarkedText(const style::TextStyle &st, const TextWithEntities &textWithEntities, const TextParseOptions &options = _defaultOptions);
|
||||
|
||||
void setLink(uint16 lnkIndex, const ClickHandlerPtr &lnk);
|
||||
|
|
|
@ -9,10 +9,56 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace Ui {
|
||||
namespace Text {
|
||||
namespace {
|
||||
|
||||
TextWithEntities WithSingleEntity(
|
||||
const QString &text,
|
||||
EntityType type,
|
||||
const QString &data = QString()) {
|
||||
auto result = TextWithEntities{ text };
|
||||
result.entities.push_back({ type, 0, text.size(), data });
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TextWithEntities Bold(const QString &text) {
|
||||
auto result = TextWithEntities{ text };
|
||||
result.entities.push_back({ EntityType::Bold, 0, text.size() });
|
||||
return WithSingleEntity(text, EntityType::Bold);
|
||||
}
|
||||
|
||||
TextWithEntities Link(const QString &text, const QString &url) {
|
||||
return WithSingleEntity(text, EntityType::CustomUrl, url);
|
||||
}
|
||||
|
||||
TextWithEntities RichLangValue(const QString &text) {
|
||||
static const auto kStart = QRegularExpression("(\\*\\*|__)");
|
||||
|
||||
auto result = TextWithEntities();
|
||||
auto offset = 0;
|
||||
while (offset < text.size()) {
|
||||
const auto m = kStart.match(text, offset);
|
||||
if (!m.hasMatch()) {
|
||||
result.text.append(text.midRef(offset));
|
||||
break;
|
||||
}
|
||||
const auto position = m.capturedStart();
|
||||
const auto from = m.capturedEnd();
|
||||
const auto tag = m.capturedRef();
|
||||
const auto till = text.indexOf(tag, from + 1);
|
||||
if (till <= from) {
|
||||
offset = from;
|
||||
continue;
|
||||
}
|
||||
if (position > offset) {
|
||||
result.text.append(text.midRef(offset, position - offset));
|
||||
}
|
||||
const auto type = (tag == qstr("__"))
|
||||
? EntityType::Italic
|
||||
: EntityType::Bold;
|
||||
result.entities.push_back({ type, result.text.size(), till - from });
|
||||
result.text.append(text.midRef(from, till - from));
|
||||
offset = till + tag.size();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,17 +10,31 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace Ui {
|
||||
namespace Text {
|
||||
|
||||
TextWithEntities Bold(const QString &text);
|
||||
|
||||
inline auto ToBold() {
|
||||
return rpl::map(Bold);
|
||||
}
|
||||
|
||||
inline auto ToUpper() {
|
||||
return rpl::map([](QString &&text) {
|
||||
return std::move(text).toUpper();
|
||||
});
|
||||
}
|
||||
|
||||
TextWithEntities Bold(const QString &text);
|
||||
TextWithEntities Link(
|
||||
const QString &text,
|
||||
const QString &url = "internal:action");
|
||||
TextWithEntities RichLangValue(const QString &text);
|
||||
|
||||
inline auto ToBold() {
|
||||
return rpl::map(Bold);
|
||||
}
|
||||
|
||||
inline auto ToLink(const QString &url = "internal:action") {
|
||||
return rpl::map([=](const QString &text) {
|
||||
return Link(text, url);
|
||||
});
|
||||
}
|
||||
|
||||
inline auto ToRichLangValue() {
|
||||
return rpl::map(RichLangValue);
|
||||
}
|
||||
|
||||
} // namespace Text
|
||||
} // namespace Ui
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/labels.h"
|
||||
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "core/click_handler_types.h" // UrlClickHandler
|
||||
#include "chat_helpers/message_field.h" // SetClipboardText/MimeDataFromText
|
||||
#include "mainwindow.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
@ -140,17 +141,12 @@ FlatLabel::FlatLabel(QWidget *parent, const style::FlatLabel &st)
|
|||
FlatLabel::FlatLabel(
|
||||
QWidget *parent,
|
||||
const QString &text,
|
||||
InitType initType,
|
||||
const style::FlatLabel &st)
|
||||
: RpWidget(parent)
|
||||
, _text(st.minWidth ? st.minWidth : QFIXED_MAX)
|
||||
, _st(st)
|
||||
, _contextCopyText(lang(lng_context_copy_text)) {
|
||||
if (initType == InitType::Rich) {
|
||||
setRichText(text);
|
||||
} else {
|
||||
setText(text);
|
||||
}
|
||||
setText(text);
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -289,6 +285,20 @@ void FlatLabel::setLink(uint16 lnkIndex, const ClickHandlerPtr &lnk) {
|
|||
_text.setLink(lnkIndex, lnk);
|
||||
}
|
||||
|
||||
void FlatLabel::setLinksTrusted() {
|
||||
static const auto TrustedLinksFilter = [](
|
||||
const ClickHandlerPtr &link,
|
||||
Qt::MouseButton button) {
|
||||
if (const auto url = dynamic_cast<UrlClickHandler*>(link.get())) {
|
||||
url->UrlClickHandler::onClick({ button });
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
setClickHandlerFilter(TrustedLinksFilter);
|
||||
|
||||
}
|
||||
|
||||
void FlatLabel::setClickHandlerFilter(ClickHandlerFilter &&filter) {
|
||||
_clickHandlerFilter = std::move(filter);
|
||||
}
|
||||
|
|
|
@ -77,14 +77,9 @@ class FlatLabel : public RpWidget, public ClickHandlerHost {
|
|||
public:
|
||||
FlatLabel(QWidget *parent, const style::FlatLabel &st = st::defaultFlatLabel);
|
||||
|
||||
enum class InitType {
|
||||
Simple,
|
||||
Rich,
|
||||
};
|
||||
FlatLabel(
|
||||
QWidget *parent,
|
||||
const QString &text,
|
||||
InitType initType,
|
||||
const style::FlatLabel &st = st::defaultFlatLabel);
|
||||
|
||||
FlatLabel(
|
||||
|
@ -112,6 +107,7 @@ public:
|
|||
QMargins getMargins() const override;
|
||||
|
||||
void setLink(uint16 lnkIndex, const ClickHandlerPtr &lnk);
|
||||
void setLinksTrusted();
|
||||
|
||||
using ClickHandlerFilter = Fn<bool(const ClickHandlerPtr&, Qt::MouseButton)>;
|
||||
void setClickHandlerFilter(ClickHandlerFilter &&filter);
|
||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/menu.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/special_buttons.h"
|
||||
#include "ui/empty_userpic.h"
|
||||
#include "mainwindow.h"
|
||||
|
@ -58,7 +59,7 @@ bool IsShadowShown(const QImage &img, const QRect r, float64 intensityText) {
|
|||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace Window {
|
||||
|
||||
|
@ -192,8 +193,10 @@ MainMenu::MainMenu(
|
|||
refreshMenu();
|
||||
refreshBackground();
|
||||
|
||||
_telegram->setRichText(textcmdLink(1, qsl("Telegram Desktop")));
|
||||
_telegram->setLink(1, std::make_shared<UrlClickHandler>(qsl("https://desktop.telegram.org")));
|
||||
_telegram->setMarkedText(Ui::Text::Link(
|
||||
qsl("Telegram Desktop"),
|
||||
qsl("https://desktop.telegram.org")));
|
||||
_telegram->setLinksTrusted();
|
||||
_version->setRichText(textcmdLink(1, lng_settings_current_version(lt_version, currentVersionText())) + QChar(' ') + QChar(8211) + QChar(' ') + textcmdLink(2, lang(lng_menu_about)));
|
||||
_version->setLink(1, std::make_shared<UrlClickHandler>(qsl("https://desktop.telegram.org/changelog")));
|
||||
_version->setLink(2, std::make_shared<LambdaClickHandler>([] { Ui::show(Box<AboutBox>()); }));
|
||||
|
|
|
@ -50,7 +50,6 @@ Bar::Bar(not_null<QWidget*> parent, QDate date)
|
|||
st::windowOutdatedTitle)
|
||||
, _details(this,
|
||||
QString(),
|
||||
Ui::FlatLabel::InitType::Simple,
|
||||
st::windowOutdatedDetails)
|
||||
, _close(this, st::windowOutdatedClose)
|
||||
, _soon(_date >= QDate::currentDate()) {
|
||||
|
|
|
@ -715,7 +715,7 @@ void PeerMenuBlockUserBox(
|
|||
box->addRow(object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
rpl::single(
|
||||
lng_blocked_list_confirm_text__generic<TextWithEntities>(
|
||||
lng_blocked_list_confirm_text__rich(
|
||||
lt_name,
|
||||
Ui::Text::Bold(name))),
|
||||
st::blockUserConfirmation));
|
||||
|
|
Loading…
Add table
Reference in a new issue