MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / initOptionField

Method initOptionField

Telegram/SourceFiles/boxes/create_poll_box.cpp:1036–1120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1034}
1035
1036void Options::initOptionField(not_null<Ui::InputField*> field) {
1037 if (const auto emojiPanel = _emojiPanel) {
1038 const auto isPremium = _controller->session().user()->isPremium();
1039 const auto emojiToggle = Ui::AddEmojiToggleToField(
1040 field,
1041 _box,
1042 _controller,
1043 emojiPanel,
1044 QPoint(
1045 -st::createPollOptionFieldPremium.textMargins.right(),
1046 st::createPollOptionEmojiPositionSkip));
1047 emojiToggle->shownValue() | rpl::on_next([=](bool shown) {
1048 if (!shown) {
1049 return;
1050 }
1051 _emojiPanelLifetime.destroy();
1052 emojiPanel->selector()->emojiChosen(
1053 ) | rpl::on_next([=](ChatHelpers::EmojiChosen data) {
1054 if (field->hasFocus()) {
1055 Ui::InsertEmojiAtCursor(field->textCursor(), data.emoji);
1056 }
1057 }, _emojiPanelLifetime);
1058 if (isPremium) {
1059 emojiPanel->selector()->customEmojiChosen(
1060 ) | rpl::on_next([=](ChatHelpers::FileChosen data) {
1061 if (field->hasFocus()) {
1062 Data::InsertCustomEmoji(field, data.document);
1063 }
1064 }, _emojiPanelLifetime);
1065 }
1066 }, emojiToggle->lifetime());
1067 }
1068 field->submits(
1069 ) | rpl::on_next([=] {
1070 const auto index = findField(field);
1071 if (_list[index]->isGood() && index + 1 < _list.size()) {
1072 _list[index + 1]->setFocus();
1073 }
1074 }, field->lifetime());
1075 field->changes(
1076 ) | rpl::on_next([=] {
1077 auto list = ParsePastedList(field->getLastText());
1078 if (!list.empty()) {
1079 field->setText(list.front());
1080 field->forceProcessContentsChanges();
1081 list.pop_front();
1082 handlePaste(field, list);
1083 }
1084 Ui::PostponeCall(crl::guard(field, [=] {
1085 validateState();
1086 }));
1087 }, field->lifetime());
1088 field->focusedChanges(
1089 ) | rpl::filter(rpl::mappers::_1) | rpl::on_next([=] {
1090 _scrollToWidget.fire_copy(field);
1091 }, field->lifetime());
1092 field->tabbed(
1093 ) | rpl::on_next([=](not_null<bool*> handled) {

Callers

nothing calls this directly

Calls 15

AddEmojiToggleToFieldFunction · 0.85
InsertCustomEmojiFunction · 0.85
emojiChosenMethod · 0.80
selectorMethod · 0.80
customEmojiChosenMethod · 0.80
frontMethod · 0.80
ParsePastedListFunction · 0.70
isPremiumMethod · 0.45
userMethod · 0.45
sessionMethod · 0.45
shownValueMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected