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); description->moveToLeft(st::boxPadding.left(), 0); auto phoneValue = QString(); _code.create(this, st::defaultInputField, langFactory(lng_change_phone_code_title), phoneValue); _code->setAutoSubmit(_codeLength, [=] { submit(); }); _code->setChangedCallback([=] { hideError(); }); _code->resize(st::boxWidth - 2 * st::boxPadding.left(), _code->height()); _code->moveToLeft(st::boxPadding.left(), description->bottomNoMargins()); connect(_code, &Ui::InputField::submitted, [=] { submit(); }); setDimensions(st::boxWidth, countHeight()); if (_callTimeout > 0) { _call.setStatus({ SentCodeCall::State::Waiting, _callTimeout }); updateCall(); } addButton(langFactory(lng_change_phone_new_submit), [=] { submit(); }); addButton(langFactory(lng_cancel), [=] { closeBox(); }); }
void ConfirmPhoneBox::prepare() { _about.create(this, st::confirmPhoneAboutLabel); TextWithEntities aboutText; auto formattedPhone = App::formatPhone(_phone); aboutText.text = lng_confirm_phone_about(lt_phone, formattedPhone); auto phonePosition = aboutText.text.indexOf(formattedPhone); if (phonePosition >= 0) { aboutText.entities.push_back(EntityInText(EntityInTextBold, phonePosition, formattedPhone.size())); } _about->setMarkedText(aboutText); _code.create(this, st::confirmPhoneCodeField, langFactory(lng_code_ph)); _code->setAutoSubmit(_sentCodeLength, [this] { onSendCode(); }); _code->setChangedCallback([this] { showError(QString()); }); setTitle(langFactory(lng_confirm_phone_title)); addButton(langFactory(lng_confirm_phone_send), [this] { onSendCode(); }); addButton(langFactory(lng_cancel), [this] { closeBox(); }); setDimensions(st::boxWidth, st::usernamePadding.top() + _code->height() + st::usernameSkip + _about->height() + st::usernameSkip); connect(_code, SIGNAL(submitted(bool)), this, SLOT(onSendCode())); showChildren(); }
PhoneWidget::PhoneWidget(QWidget *parent, Widget::Data *data) : Step(parent, data) , _country(this, st::introCountry) , _code(this, st::introCountryCode) , _phone(this, st::introPhone) , _checkRequest(this) { connect(_phone, SIGNAL(voidBackspace(QKeyEvent*)), _code, SLOT(startErasing(QKeyEvent*))); connect(_country, SIGNAL(codeChanged(const QString &)), _code, SLOT(codeSelected(const QString &))); connect(_code, SIGNAL(codeChanged(const QString &)), _country, SLOT(onChooseCode(const QString &))); connect(_code, SIGNAL(codeChanged(const QString &)), _phone, SLOT(onChooseCode(const QString &))); connect(_country, SIGNAL(codeChanged(const QString &)), _phone, SLOT(onChooseCode(const QString &))); connect(_code, SIGNAL(addedToNumber(const QString &)), _phone, SLOT(addedToNumber(const QString &))); connect(_phone, SIGNAL(changed()), this, SLOT(onInputChange())); connect(_code, SIGNAL(changed()), this, SLOT(onInputChange())); connect(_checkRequest, SIGNAL(timeout()), this, SLOT(onCheckRequest())); setTitleText(langFactory(lng_phone_title)); setDescriptionText(langFactory(lng_phone_desc)); subscribe(getData()->updated, [this] { countryChanged(); }); setErrorCentered(true); if (!_country->onChooseCountry(getData()->country)) { _country->onChooseCountry(qsl("US")); } _changed = false; Messenger::Instance().destroyStaleAuthorizationKeys(); }
bool PhoneWidget::phoneSubmitFail(const RPCError &error) { if (MTP::isFloodError(error)) { stopCheck(); _sentRequest = 0; showPhoneError(langFactory(lng_flood_error)); return true; } if (MTP::isDefaultHandledError(error)) return false; stopCheck(); _sentRequest = 0; auto &err = error.type(); if (err == qstr("PHONE_NUMBER_FLOOD")) { Ui::show(Box<InformBox>(lang(lng_error_phone_flood))); return true; } else if (err == qstr("PHONE_NUMBER_INVALID")) { // show error showPhoneError(langFactory(lng_bad_phone)); return true; } if (cDebug()) { // internal server error auto text = err + ": " + error.description(); showPhoneError([text] { return text; }); } else { showPhoneError(langFactory(lng_server_error)); } return false; }
WarningWidget::WarningWidget(QWidget *parent) : TWidget(parent) , _timer([=] { handleTimer(); }) , _secondsLeft(kWaitBeforeRevertMs / 1000) , _keepChanges(this, langFactory(lng_theme_keep_changes), st::defaultBoxButton) , _revert(this, langFactory(lng_theme_revert), st::defaultBoxButton) { _keepChanges->setClickedCallback([] { Window::Theme::KeepApplied(); }); _revert->setClickedCallback([] { Window::Theme::Revert(); }); updateText(); }
CoverWidget::CoverWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, QString()) , _self(App::self()) , _userpicButton( this, App::wnd()->controller(), _self, Ui::UserpicButton::Role::OpenPhoto, st::settingsPhoto) , _name(this, st::settingsNameLabel) , _editNameInline(this, st::settingsEditButton) , _setPhoto(this, langFactory(lng_settings_upload), st::settingsPrimaryButton) , _editName(this, langFactory(lng_settings_edit), st::settingsSecondaryButton) { if (_self) { _self->updateFull(); } setAcceptDrops(true); _name->setSelectable(true); _name->setContextCopyText(lang(lng_profile_copy_fullname)); _setPhoto->setClickedCallback(App::LambdaDelayed( st::settingsPrimaryButton.ripple.hideDuration, this, [this] { chooseNewPhoto(); })); _editName->addClickHandler([this] { editName(); }); _editNameInline->addClickHandler([this] { editName(); }); auto observeEvents = Notify::PeerUpdate::Flag::NameChanged | Notify::PeerUpdate::Flag::PhotoChanged; subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdated(update); })); connect( &Messenger::Instance(), &Messenger::peerPhotoDone, this, &CoverWidget::onPhotoUploadStatusChanged); connect( &Messenger::Instance(), &Messenger::peerPhotoFail, this, &CoverWidget::onPhotoUploadStatusChanged); _userpicButton->addClickHandler([this] { showPhoto(); }); validatePhoto(); refreshNameText(); subscribe(Global::RefConnectionTypeChanged(), [this] { refreshStatusText(); }); refreshStatusText(); }
void ChangePhoneBox::prepare() { setTitle(langFactory(lng_change_phone_title)); addButton(langFactory(lng_change_phone_button), [] { Ui::show(Box<ConfirmBox>(lang(lng_change_phone_warning), [] { Ui::show(Box<EnterPhone>()); })); }); addButton(langFactory(lng_cancel), [this] { closeBox(); }); auto label = object_ptr<Ui::FlatLabel>(this, lang(lng_change_phone_description), Ui::FlatLabel::InitType::Rich, st::changePhoneDescription); label->moveToLeft((st::boxWideWidth - label->width()) / 2, st::changePhoneDescriptionTop); setDimensions(st::boxWideWidth, label->bottomNoMargins() + st::boxLittleSkip); }
void LocalStorageBox::prepare() { setTitle(langFactory(lng_local_storage_title)); addButton(langFactory(lng_box_ok), [this] { closeBox(); }); _clear->setClickedCallback([this] { clearStorage(); }); connect(App::wnd(), SIGNAL(tempDirCleared(int)), this, SLOT(onTempDirCleared(int))); connect(App::wnd(), SIGNAL(tempDirClearFailed(int)), this, SLOT(onTempDirClearFailed(int))); subscribe(Auth().downloaderTaskFinished(), [this] { update(); }); updateControls(); checkLocalStoredCounts(); }
void PhoneWidget::submit() { if (_sentRequest || isHidden()) return; const auto phone = fullNumber(); if (!AllowPhoneAttempt(phone)) { showPhoneError(langFactory(lng_bad_phone)); _phone->setFocus(); return; } hidePhoneError(); _checkRequest->start(1000); _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), MTP_int(ApiId), MTP_string(ApiHash), MTP_codeSettings( MTP_flags(0), MTPstring())), rpcDone(&PhoneWidget::phoneSubmitDone), rpcFail(&PhoneWidget::phoneSubmitFail)); }
void PhoneWidget::submit() { if (_sentRequest || isHidden()) return; if (!App::isValidPhone(fullNumber())) { showPhoneError(langFactory(lng_bad_phone)); _phone->setFocus(); return; } hidePhoneError(); _checkRequest->start(1000); _sentPhone = fullNumber(); Messenger::Instance().mtp()->setUserPhone(_sentPhone); //_sentRequest = MTP::send(MTPauth_CheckPhone(MTP_string(_sentPhone)), rpcDone(&PhoneWidget::phoneCheckDone), rpcFail(&PhoneWidget::phoneSubmitFail)); _sentRequest = MTP::send( MTPauth_SendCode( MTP_flags(0), MTP_string(_sentPhone), MTPBool(), MTP_int(ApiId), MTP_string(ApiHash)), rpcDone(&PhoneWidget::phoneSubmitDone), rpcFail(&PhoneWidget::phoneSubmitFail)); }
void ManagePeerBox::prepare() { _channel->updateFull(); setTitle(ManagePeerTitle(_channel)); addButton(langFactory(lng_cancel), [this] { closeBox(); }); setupContent(); }
void ChangePhoneBox::EnterPhone::prepare() { setTitle(langFactory(lng_change_phone_title)); auto phoneValue = QString(); _phone.create(this, st::defaultInputField, langFactory(lng_change_phone_new_title), phoneValue); _phone->resize(st::boxWidth - 2 * st::boxPadding.left(), _phone->height()); _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 errorSkip = st::boxLittleSkip + st::changePhoneError.style.font->height; description->moveToLeft(st::boxPadding.left(), _phone->y() + _phone->height() + errorSkip + st::boxLittleSkip); setDimensions(st::boxWidth, description->bottomNoMargins() + st::boxLittleSkip); addButton(langFactory(lng_change_phone_new_submit), [this] { submit(); }); addButton(langFactory(lng_cancel), [this] { closeBox(); }); }
void SessionsBox::prepare() { setTitle(langFactory(lng_sessions_other_header)); addButton(langFactory(lng_close), [this] { closeBox(); }); setDimensions(st::boxWideWidth, st::sessionsHeight); connect(_inner, SIGNAL(oneTerminated()), this, SLOT(onOneTerminated())); connect(_inner, SIGNAL(allTerminated()), this, SLOT(onAllTerminated())); connect(_inner, SIGNAL(terminateAll()), this, SLOT(onTerminateAll())); connect(App::wnd(), SIGNAL(checkNewAuthorization()), this, SLOT(onCheckNewAuthorization())); connect(_shortPollTimer, SIGNAL(timeout()), this, SLOT(onShortPollAuthorizations())); _inner = setInnerWidget(object_ptr<Inner>(this, &_list, &_current), st::sessionsScroll); _inner->resize(width(), st::noContactsHeight); setLoading(true); MTP::send(MTPaccount_GetAuthorizations(), rpcDone(&SessionsBox::gotAuthorizations)); }
void UsernameBox::prepare() { _goodText = App::self()->username.isEmpty() ? QString() : lang(lng_username_available); setTitle(langFactory(lng_username_title)); addButton(langFactory(lng_settings_save), [this] { onSave(); }); addButton(langFactory(lng_cancel), [this] { closeBox(); }); connect(_username, SIGNAL(changed()), this, SLOT(onChanged())); connect(_username, SIGNAL(submitted(bool)), this, SLOT(onSave())); connect(_link, SIGNAL(clicked()), this, SLOT(onLinkClick())); _about.setRichText(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); connect(_checkTimer, SIGNAL(timeout()), this, SLOT(onCheck())); updateLinkText(); }
void UsernameBox::prepare() { _goodText = App::self()->username.isEmpty() ? QString() : lang(lng_username_available); setTitle(langFactory(lng_username_title)); addButton(langFactory(lng_settings_save), [=] { save(); }); addButton(langFactory(lng_cancel), [=] { closeBox(); }); connect(_username, &Ui::MaskedInputField::changed, [=] { changed(); }); connect(_username, &Ui::MaskedInputField::submitted, [=] { save(); }); _link->addClickHandler([=] { linkClick(); }); _about.setRichText(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); connect(_checkTimer, &QTimer::timeout, [=] { check(); }); updateLinkText(); }
void ChatSearchFromController::prepare() { setSearchNoResultsText(lang(lng_blocked_list_not_found)); delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled); delegate()->peerListSetTitle(langFactory(lng_search_messages_from)); rebuildRows(); subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::MembersChanged, [this](const Notify::PeerUpdate &update) { if (update.peer == _chat) { rebuildRows(); } })); }
void MainMenu::refreshMenu() { _menu->clearActions(); _menu->addAction(lang(lng_create_group_title), [] { App::wnd()->onShowNewGroup(); }, &st::mainMenuNewGroup, &st::mainMenuNewGroupOver); _menu->addAction(lang(lng_create_channel_title), [] { App::wnd()->onShowNewChannel(); }, &st::mainMenuNewChannel, &st::mainMenuNewChannelOver); _menu->addAction(lang(lng_menu_contacts), [] { Ui::show(Box<PeerListBox>(std::make_unique<ContactsBoxController>(), [](not_null<PeerListBox*> box) { box->addButton(langFactory(lng_close), [box] { box->closeBox(); }); box->addLeftButton(langFactory(lng_profile_add_contact), [] { App::wnd()->onShowAddContact(); }); })); }, &st::mainMenuContacts, &st::mainMenuContactsOver); if (Global::PhoneCallsEnabled()) { _menu->addAction(lang(lng_menu_calls), [] { Ui::show(Box<PeerListBox>(std::make_unique<Calls::BoxController>(), [](not_null<PeerListBox*> box) { box->addButton(langFactory(lng_close), [box] { box->closeBox(); }); })); }, &st::mainMenuCalls, &st::mainMenuCallsOver); } _menu->addAction(lang(lng_menu_settings), [] { App::wnd()->showSettings(); }, &st::mainMenuSettings, &st::mainMenuSettingsOver); _nightThemeAction = std::make_shared<QPointer<QAction>>(nullptr); auto action = _menu->addAction(lang(lng_menu_night_mode), [this] { if (auto action = *_nightThemeAction) { action->setChecked(!action->isChecked()); _nightThemeSwitch.callOnce(st::mainMenu.itemToggle.duration); } }, &st::mainMenuNightMode, &st::mainMenuNightModeOver); *_nightThemeAction = action; action->setCheckable(true); action->setChecked(Window::Theme::IsNightMode()); _menu->finishAnimating(); updatePhone(); }
bool CodeWidget::noTelegramCodeFail(const RPCError &error) { if (MTP::isFloodError(error)) { showCodeError(langFactory(lng_flood_error)); return true; } if (MTP::isDefaultHandledError(error)) return false; if (Logs::DebugEnabled()) { // internal server error auto text = error.type() + ": " + error.description(); showCodeError([text] { return text; }); } else { showCodeError(&Lang::Hard::ServerError); } return false; }
void CodeWidget::updateDescText() { setDescriptionText(langFactory(getData()->codeByTelegram ? lng_code_telegram : lng_code_desc)); if (getData()->codeByTelegram) { _noTelegramCode->show(); _callTimer->stop(); } else { _noTelegramCode->hide(); _callStatus = getData()->callStatus; _callTimeout = getData()->callTimeout; if (_callStatus == Widget::Data::CallStatus::Waiting && !_callTimer->isActive()) { _callTimer->start(1000); } } updateCallText(); }
bool PhoneWidget::phoneSubmitFail(const RPCError &error) { if (MTP::isFloodError(error)) { stopCheck(); _sentRequest = 0; showPhoneError(langFactory(lng_flood_error)); return true; } if (MTP::isDefaultHandledError(error)) return false; stopCheck(); _sentRequest = 0; auto &err = error.type(); if (err == qstr("PHONE_NUMBER_FLOOD")) { Ui::show(Box<InformBox>(lang(lng_error_phone_flood))); return true; } else if (err == qstr("PHONE_NUMBER_INVALID")) { // show error showPhoneError(langFactory(lng_bad_phone)); return true; } else if (err == qstr("PHONE_NUMBER_BANNED")) { const auto phone = _sentPhone; Ui::show(Box<ConfirmBox>( lang(lng_signin_banned_text), lang(lng_box_ok), lang(lng_signin_banned_help), [] { Ui::hideLayer(); }, [phone] { SendToBannedHelp(phone); Ui::hideLayer(); })); return true; } if (Logs::DebugEnabled()) { // internal server error auto text = err + ": " + error.description(); showPhoneError([text] { return text; }); } else { showPhoneError(&Lang::Hard::ServerError); } return false; }
bool CodeWidget::codeSubmitFail(const RPCError &error) { if (MTP::isFloodError(error)) { stopCheck(); _sentRequest = 0; showCodeError(langFactory(lng_flood_error)); return true; } if (MTP::isDefaultHandledError(error)) return false; stopCheck(); _sentRequest = 0; auto &err = error.type(); if (err == qstr("PHONE_NUMBER_INVALID") || err == qstr("PHONE_CODE_EXPIRED")) { // show error goBack(); return true; } else if (err == qstr("PHONE_CODE_EMPTY") || err == qstr("PHONE_CODE_INVALID")) { showCodeError(langFactory(lng_bad_code)); return true; } else if (err == qstr("PHONE_NUMBER_UNOCCUPIED")) { // success, need to signUp getData()->code = _sentCode; goReplace(new Intro::SignupWidget(parentWidget(), getData())); return true; } else if (err == qstr("SESSION_PASSWORD_NEEDED")) { getData()->code = _sentCode; _checkRequest->start(1000); _sentRequest = MTP::send(MTPaccount_GetPassword(), rpcDone(&CodeWidget::gotPassword), rpcFail(&CodeWidget::codeSubmitFail)); return true; } if (Logs::DebugEnabled()) { // internal server error auto text = err + ": " + error.description(); showCodeError([text] { return text; }); } else { showCodeError(&Lang::Hard::ServerError); } return false; }
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::submit() { if (_sentRequest || isHidden()) return; if (!App::isValidPhone(fullNumber())) { showPhoneError(langFactory(lng_bad_phone)); _phone->setFocus(); return; } hidePhoneError(); _checkRequest->start(1000); _sentPhone = fullNumber(); _sentRequest = MTP::send(MTPauth_CheckPhone(MTP_string(_sentPhone)), rpcDone(&PhoneWidget::phoneCheckDone), rpcFail(&PhoneWidget::phoneSubmitFail)); }
CodeWidget::CodeWidget(QWidget *parent, Widget::Data *data) : Step(parent, data) , _noTelegramCode(this, lang(lng_code_no_telegram), st::introLink) , _code(this, st::introCode, langFactory(lng_code_ph)) , _callTimer(this) , _callStatus(getData()->callStatus) , _callTimeout(getData()->callTimeout) , _callLabel(this, st::introDescription) , _checkRequest(this) { subscribe(Lang::Current().updated(), [this] { refreshLang(); }); connect(_code, SIGNAL(changed()), this, SLOT(onInputChange())); connect(_callTimer, SIGNAL(timeout()), this, SLOT(onSendCall())); connect(_checkRequest, SIGNAL(timeout()), this, SLOT(onCheckRequest())); connect(_noTelegramCode, SIGNAL(clicked()), this, SLOT(onNoTelegramCode())); _code->setDigitsCountMax(getData()->codeLength); setErrorBelowLink(true); setTitleText([text = App::formatPhone(getData()->phone)] { return text; }); updateDescText(); }
void CalendarBox::prepare() { _previous->setClickedCallback([this] { if (isPreviousEnabled()) { _context->skipMonth(-1); } }); _next->setClickedCallback([this] { if (isNextEnabled()) { _context->skipMonth(1); } }); // _inner = setInnerWidget(object_ptr<Inner>(this, _context.get()), st::calendarScroll, st::calendarTitleHeight); _inner->setDateChosenCallback(std::move(_callback)); addButton(langFactory(lng_close), [this] { closeBox(); }); subscribe(_context->month(), [this](QDate month) { monthChanged(month); }); _context->start(); }
void AboutBox::prepare() { setTitle([] { return qsl("Telegram Desktop"); }); 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); _version->setClickedCallback([this] { showVersionHistory(); }); setDimensions(st::aboutWidth, st::aboutTextTop + _text1->height() + st::aboutSkip + _text2->height() + st::aboutSkip + _text3->height()); }
void PeerListBox::createMultiSelect() { Expects(_select == nullptr); auto entity = object_ptr<Ui::MultiSelect>(this, st::contactsMultiSelect, langFactory(lng_participant_filter)); _select.create(this, std::move(entity)); _select->heightValue( ) | rpl::start_with_next( [this] { updateScrollSkips(); }, lifetime()); _select->entity()->setSubmittedCallback([this](bool chtrlShiftEnter) { content()->submitted(); }); _select->entity()->setQueryChangedCallback([this](const QString &query) { searchQueryChanged(query); }); _select->entity()->setItemRemovedCallback([this](uint64 itemId) { if (auto peer = App::peerLoaded(itemId)) { if (auto row = peerListFindRow(peer->id)) { content()->changeCheckState(row, false, PeerListRow::SetStyle::Animated); update(); } _controller->itemDeselectedHook(peer); } }); _select->resizeToWidth(st::boxWideWidth); _select->moveToLeft(0, 0); }
void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) { stopCheck(); _sentRequest = 0; if (result.type() != mtpc_auth_sentCode) { showPhoneError(langFactory(lng_server_error)); return; } auto &d = result.c_auth_sentCode(); fillSentCodeData(d.vtype); getData()->phone = _sentPhone; getData()->phoneHash = qba(d.vphone_code_hash); getData()->phoneIsRegistered = d.is_phone_registered(); if (d.has_next_type() && d.vnext_type.type() == mtpc_auth_codeTypeCall) { getData()->callStatus = Widget::Data::CallStatus::Waiting; getData()->callTimeout = d.has_timeout() ? d.vtimeout.v : 60; } else { getData()->callStatus = Widget::Data::CallStatus::Disabled; getData()->callTimeout = 0; } goNext(new Intro::CodeWidget(parentWidget(), getData())); }
void MainMenu::refreshMenu() { _menu->clearActions(); if (!Auth().supportMode()) { _menu->addAction(lang(lng_create_group_title), [] { App::wnd()->onShowNewGroup(); }, &st::mainMenuNewGroup, &st::mainMenuNewGroupOver); _menu->addAction(lang(lng_create_channel_title), [] { App::wnd()->onShowNewChannel(); }, &st::mainMenuNewChannel, &st::mainMenuNewChannelOver); _menu->addAction(lang(lng_menu_contacts), [] { Ui::show(Box<PeerListBox>(std::make_unique<ContactsBoxController>(), [](not_null<PeerListBox*> box) { box->addButton(langFactory(lng_close), [box] { box->closeBox(); }); box->addLeftButton(langFactory(lng_profile_add_contact), [] { App::wnd()->onShowAddContact(); }); })); }, &st::mainMenuContacts, &st::mainMenuContactsOver); if (Global::PhoneCallsEnabled()) { _menu->addAction(lang(lng_menu_calls), [] { Ui::show(Box<PeerListBox>(std::make_unique<Calls::BoxController>(), [](not_null<PeerListBox*> box) { box->addButton(langFactory(lng_close), [box] { box->closeBox(); }); })); }, &st::mainMenuCalls, &st::mainMenuCallsOver); } } else { _menu->addAction(lang(lng_profile_add_contact), [] { App::wnd()->onShowAddContact(); }, &st::mainMenuContacts, &st::mainMenuContactsOver); const auto fix = std::make_shared<QPointer<QAction>>(); *fix = _menu->addAction(qsl("Fix chats order"), [=] { (*fix)->setChecked(!(*fix)->isChecked()); Auth().settings().setSupportFixChatsOrder((*fix)->isChecked()); Local::writeUserSettings(); }, &st::mainMenuFixOrder, &st::mainMenuFixOrderOver); (*fix)->setCheckable(true); (*fix)->setChecked(Auth().settings().supportFixChatsOrder()); const auto subscription = Ui::AttachAsChild(_menu, rpl::lifetime()); _menu->addAction(qsl("Reload templates"), [=] { *subscription = Auth().supportTemplates()->errors( ) | rpl::start_with_next([=](QStringList errors) { Ui::Toast::Show(errors.isEmpty() ? "Templates reloaded!" : ("Errors:\n\n" + errors.join("\n\n"))); }); Auth().supportTemplates()->reload(); }, &st::mainMenuReload, &st::mainMenuReloadOver); } _menu->addAction(lang(lng_menu_settings), [] { App::wnd()->showSettings(); }, &st::mainMenuSettings, &st::mainMenuSettingsOver); _nightThemeAction = std::make_shared<QPointer<QAction>>(); auto action = _menu->addAction(lang(lng_menu_night_mode), [=] { if (auto action = *_nightThemeAction) { action->setChecked(!action->isChecked()); _nightThemeSwitch.callOnce(st::mainMenu.itemToggle.duration); } }, &st::mainMenuNightMode, &st::mainMenuNightModeOver); *_nightThemeAction = action; action->setCheckable(true); action->setChecked(Window::Theme::IsNightMode()); _menu->finishAnimating(); updatePhone(); }
void ChannelSearchFromController::prepare() { ParticipantsBoxController::prepare(); delegate()->peerListSetTitle(langFactory(lng_search_messages_from)); }