MainMenu::MainMenu( QWidget *parent, not_null<Controller*> controller) : TWidget(parent) , _controller(controller) , _menu(this, st::mainMenu) , _telegram(this, st::mainMenuTelegramLabel) , _version(this, st::mainMenuVersionLabel) { setAttribute(Qt::WA_OpaquePaintEvent); subscribe(Global::RefSelfChanged(), [this] { checkSelf(); }); checkSelf(); _nightThemeSwitch.setCallback([this] { if (const auto action = *_nightThemeAction) { const auto nightMode = Window::Theme::IsNightMode(); if (action->isChecked() != nightMode) { Window::Theme::ToggleNightMode(); } } }); resize(st::mainMenuWidth, parentWidget()->height()); _menu->setTriggeredCallback([](QAction *action, int actionTop, Ui::Menu::TriggeredSource source) { emit action->triggered(); }); refreshMenu(); _telegram->setRichText(textcmdLink(1, qsl("Telegram Desktop"))); _telegram->setLink(1, std::make_shared<UrlClickHandler>(qsl("https://desktop.telegram.org"))); _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>()); })); subscribe(Auth().downloaderTaskFinished(), [this] { update(); }); subscribe(Auth().downloaderTaskFinished(), [this] { update(); }); subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::UserPhoneChanged, [this](const Notify::PeerUpdate &update) { if (update.peer->isSelf()) { updatePhone(); } })); subscribe(Global::RefPhoneCallsEnabledChanged(), [this] { refreshMenu(); }); subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) { if (update.type == Window::Theme::BackgroundUpdate::Type::ApplyingTheme) { refreshMenu(); } }); updatePhone(); }
QString HistoryItem::inDialogsText(DrawInDialog way) const { auto getText = [this]() { if (_media) { return _media->chatListText(); } else if (!emptyText()) { return TextUtilities::Clean(_text.originalText()); } return QString(); }; const auto plainText = getText(); const auto sender = [&]() -> PeerData* { if (isPost() || isEmpty() || (way == DrawInDialog::WithoutSender)) { return nullptr; } else if (!_history->peer->isUser() || out()) { return author(); } else if (_history->peer->isSelf() && !Has<HistoryMessageForwarded>()) { return senderOriginal(); } return nullptr; }(); if (sender) { auto fromText = sender->isSelf() ? lang(lng_from_you) : sender->shortName(); auto fromWrapped = textcmdLink(1, lng_dialogs_text_from_wrapped(lt_from, TextUtilities::Clean(fromText))); return lng_dialogs_text_with_from(lt_from_part, fromWrapped, lt_message, plainText); } return plainText; }
QString WithCaptionDialogsText( const QString &attachType, const QString &caption) { if (caption.isEmpty()) { return textcmdLink(1, TextUtilities::Clean(attachType)); } auto captionText = TextUtilities::Clean(caption); auto attachTypeWrapped = textcmdLink(1, lng_dialogs_text_media_wrapped( lt_media, TextUtilities::Clean(attachType))); return lng_dialogs_text_media( lt_media_part, attachTypeWrapped, lt_caption, captionText); }
void InfoWidget::refreshMobileNumber() { TextWithEntities phoneText; if (const auto user = self()->asUser()) { phoneText.text = Auth().data().findContactPhone(user); } setLabeledText( _mobileNumber, lang(lng_profile_mobile_number), phoneText, TextWithEntities(), lang(lng_profile_copy_phone)); if (auto text = _mobileNumber->entity()->textLabel()) { text->setRichText(textcmdLink(1, phoneText.text)); text->setLink(1, std::make_shared<LambdaClickHandler>([] { Ui::show(Box<ChangePhoneBox>()); })); } }