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

Function EditFileCaptionBox

Telegram/SourceFiles/boxes/send_files_box.cpp:185–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183namespace {
184
185void EditFileCaptionBox(
186 not_null<Ui::GenericBox*> box,
187 const style::ComposeControls &st,
188 PeerData *captionToPeer,
189 TextWithTags currentCaption,
190 Fn<bool(TextWithTags)> apply) {
191 box->setTitle(tr::lng_context_upload_edit_caption());
192 const auto window = Core::App().findWindow(box);
193 const auto controller = window ? window->sessionController() : nullptr;
194 const auto maxCaptionLength = [&] {
195 if (captionToPeer) {
196 return Data::PremiumLimits(
197 &captionToPeer->session()).captionLengthCurrent();
198 } else if (controller) {
199 return Data::PremiumLimits(
200 &controller->session()).captionLengthCurrent();
201 }
202 return kMaxMessageLength;
203 }();
204 const auto wrap = box->addRow(
205 object_ptr<Ui::RpWidget>(box),
206 st::boxRowPadding);
207 const auto field = Ui::CreateChild<Ui::InputField>(
208 wrap,
209 st.files.caption,
210 Ui::InputField::Mode::MultiLine,
211 tr::lng_photo_caption());
212 field->setMaxLength(maxCaptionLength);
213 field->setSubmitSettings(Core::App().settings().sendSubmitWay());
214 Ui::ResizeFitChild(wrap, field);
215 if (window) {
216 const auto allow = [=](not_null<DocumentData*> emoji) {
217 return captionToPeer
218 && Data::AllowEmojiWithoutPremium(captionToPeer, emoji);
219 };
220 Ui::SetupCaptionFieldInBox(
221 box,
222 controller,
223 field,
224 captionToPeer,
225 allow,
226 PremiumFeature::EmojiStatus);
227 if (controller) {
228 const auto chatStyle = InitMessageFieldHandlers({
229 .session = &controller->session(),
230 .show = controller->uiShow(),
231 .field = field,
232 .customEmojiPaused = [=] {
233 return controller->isGifPausedAtLeastFor(
234 Window::GifPauseReason::Layer);
235 },
236 .allowPremiumEmoji = allow,
237 .fieldStyle = &st.files.caption,
238 });
239 const auto aiButton = Ui::SetupCaptionAiButton({
240 .parent = field->parentWidget(),
241 .field = field,
242 .session = &controller->session(),

Callers

nothing calls this directly

Calls 15

AppClass · 0.85
AllowEmojiWithoutPremiumFunction · 0.85
SetupCaptionFieldInBoxFunction · 0.85
InitMessageFieldHandlersFunction · 0.85
SetupCaptionAiButtonFunction · 0.85
captionLengthCurrentMethod · 0.80
setMaxLengthMethod · 0.80
sendSubmitWayMethod · 0.80
settingsMethod · 0.80
isGifPausedAtLeastForMethod · 0.80

Tested by

no test coverage detected