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

Method updateTitle

Telegram/SourceFiles/window/main_window.cpp:821–871  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

819}
820
821void MainWindow::updateTitle() {
822 if (Core::Quitting()) {
823 return;
824 }
825
826 const auto settings = Core::App().settings().windowTitleContent();
827 const auto locked = Core::App().passcodeLocked();
828 const auto counter = settings.hideTotalUnread
829 ? 0
830 : Core::App().unreadBadge();
831 const auto added = (counter > 0) ? u" (%1)"_q.arg(counter) : QString();
832 const auto session = locked ? nullptr : _controller->sessionController();
833 const auto user = (session
834 && !settings.hideAccountName
835 && Core::App().domain().accountsAuthedCount() > 1)
836 ? st::wrap_rtl(session->authedName())
837 : QString();
838 const auto separateSharedMediaTitle = session
839 ? TitleFromSeparateSharedMedia(settings, session->windowId())
840 : QString();
841 if (!separateSharedMediaTitle.isEmpty()) {
842 setTitle(separateSharedMediaTitle);
843 return;
844 }
845 const auto key = (session && !settings.hideChatName)
846 ? session->activeChatCurrent()
847 : Dialogs::Key();
848 const auto thread = key ? key.thread() : nullptr;
849 if (!thread) {
850 setTitle((user.isEmpty() ? u"64Gram"_q : user) + added);
851 return;
852 }
853 const auto history = thread->owningHistory();
854 const auto topic = thread->asTopic();
855 const auto name = topic
856 ? topic->title()
857 : history->peer->isSelf()
858 ? tr::lng_saved_messages(tr::now)
859 : history->peer->name();
860 const auto wrapped = st::wrap_rtl(name);
861 const auto threadCounter = thread->chatListBadgesState().unreadCounter;
862 const auto primary = (threadCounter > 0)
863 ? u"(%1) %2"_q.arg(threadCounter).arg(wrapped)
864 : wrapped;
865 const auto middle = !user.isEmpty()
866 ? (u" @ "_q + user)
867 : !added.isEmpty()
868 ? u" \u2013"_q
869 : QString();
870 setTitle(primary + middle + added);
871}
872
873QRect MainWindow::computeDesktopRect() const {
874 return screen()->availableGeometry();

Callers 3

showAccountMethod · 0.45
SessionControllerMethod · 0.45
updateWindowTitlesMethod · 0.45

Calls 15

QuittingFunction · 0.85
AppClass · 0.85
windowTitleContentMethod · 0.80
settingsMethod · 0.80
passcodeLockedMethod · 0.80
accountsAuthedCountMethod · 0.80
authedNameMethod · 0.80
activeChatCurrentMethod · 0.80
asTopicMethod · 0.80
isSelfMethod · 0.80
KeyClass · 0.70

Tested by

no test coverage detected