| 819 | } |
| 820 | |
| 821 | void 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 | |
| 873 | QRect MainWindow::computeDesktopRect() const { |
| 874 | return screen()->availableGeometry(); |
no test coverage detected