2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Allow several accounts in Core::App.

This commit is contained in:
John Preston
2020-06-15 20:25:02 +04:00
parent 815e26eea5
commit 6fc5e22882
36 changed files with 834 additions and 267 deletions

View File

@@ -105,18 +105,16 @@ void ConvertIconToBlack(QImage &image) {
}
}
QIcon CreateOfficialIcon(Main::Account *account) {
QIcon CreateOfficialIcon(Main::Session *session) {
auto image = Core::IsAppLaunched() ? Core::App().logo() : LoadLogo();
if (account
&& account->sessionExists()
&& account->session().supportMode()) {
if (session && session->supportMode()) {
ConvertIconToBlack(image);
}
return QIcon(App::pixmapFromImageInPlace(std::move(image)));
}
QIcon CreateIcon(Main::Account *account) {
auto result = CreateOfficialIcon(account);
QIcon CreateIcon(Main::Session *session) {
auto result = CreateOfficialIcon(session);
#if defined Q_OS_UNIX && !defined Q_OS_MAC
return QIcon::fromTheme(Platform::GetIconName(), result);
#endif
@@ -295,10 +293,12 @@ bool MainWindow::computeIsActive() const {
}
void MainWindow::updateWindowIcon() {
const auto supportIcon = account().sessionExists()
&& account().session().supportMode();
const auto session = sessionController()
? &sessionController()->session()
: nullptr;
const auto supportIcon = session && session->supportMode();
if (supportIcon != _usingSupportIcon || _icon.isNull()) {
_icon = CreateIcon(&account());
_icon = CreateIcon(session);
_usingSupportIcon = supportIcon;
}
setWindowIcon(_icon);
@@ -528,9 +528,7 @@ void MainWindow::updateControlsGeometry() {
void MainWindow::updateUnreadCounter() {
if (!Global::started() || App::quitting()) return;
const auto counter = account().sessionExists()
? account().session().data().unreadBadge()
: 0;
const auto counter = Core::App().unreadBadge();
_titleText = (counter > 0) ? qsl("Telegram (%1)").arg(counter) : qsl("Telegram");
unreadCounterChangedHook();