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

Method prepare

Telegram/SourceFiles/window/window_lock_widgets.cpp:355–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353}
354
355void TermsBox::prepare() {
356 setTitle(tr::lng_terms_header());
357
358 auto check = std::make_unique<Ui::CheckView>(st::defaultCheck, false);
359 const auto ageCheck = check.get();
360 const auto age = _data.minAge
361 ? Ui::CreateChild<Ui::PaddingWrap<Ui::Checkbox>>(
362 this,
363 object_ptr<Ui::Checkbox>(
364 this,
365 tr::lng_terms_age(tr::now, lt_count, *_data.minAge),
366 st::defaultCheckbox,
367 std::move(check)),
368 st::termsAgePadding)
369 : nullptr;
370 if (age) {
371 age->resizeToNaturalWidth(st::boxWideWidth);
372 }
373
374 const auto content = setInnerWidget(
375 object_ptr<Ui::PaddingWrap<Ui::FlatLabel>>(
376 this,
377 object_ptr<Ui::FlatLabel> (
378 this,
379 rpl::single(_data.text),
380 st::termsContent),
381 st::termsPadding),
382 0,
383 age ? age->height() : 0);
384 const auto show = uiShow();
385 content->entity()->setClickHandlerFilter([=](
386 const ClickHandlerPtr &handler,
387 Qt::MouseButton button) {
388 const auto link = handler
389 ? handler->copyToClipboardText()
390 : QString();
391 if (TextUtilities::RegExpMention().match(link).hasMatch()) {
392 _lastClickedMention = link;
393 show->showToast(
394 tr::lng_terms_agree_to_proceed(tr::now, lt_bot, link));
395 return false;
396 }
397 return true;
398 });
399
400 const auto errorAnimationCallback = [=] {
401 const auto check = ageCheck;
402 const auto error = _ageErrorAnimation.value(
403 _ageErrorShown ? 1. : 0.);
404 if (error == 0.) {
405 check->setUntoggledOverride(std::nullopt);
406 } else {
407 const auto color = anim::color(
408 st::defaultCheck.untoggledFg,
409 st::boxTextFgError,
410 error);
411 check->setUntoggledOverride(color);
412 }

Callers

nothing calls this directly

Calls 13

checkedChangesMethod · 0.80
moveToLeftMethod · 0.80
QStringClass · 0.50
getMethod · 0.45
heightMethod · 0.45
copyToClipboardTextMethod · 0.45
showToastMethod · 0.45
valueMethod · 0.45
startMethod · 0.45
clicksMethod · 0.45
checkedMethod · 0.45
resizeToWidthMethod · 0.45

Tested by

no test coverage detected