From aea5ca9013a45e3cc171376ace9eee2328fde7de Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Mon, 7 Oct 2019 02:58:56 +0300 Subject: [PATCH] Option to hide phone number in drawer --- .../default_kotato-settings-custom.json | 4 ++- Telegram/SourceFiles/core/kotato_settings.cpp | 6 +++++ Telegram/SourceFiles/settings.cpp | 2 ++ Telegram/SourceFiles/settings.h | 2 ++ .../SourceFiles/window/window_main_menu.cpp | 27 +++++++++++++------ 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Telegram/Resources/default_kotato-settings-custom.json b/Telegram/Resources/default_kotato-settings-custom.json index 28d1fc853..bde92f961 100644 --- a/Telegram/Resources/default_kotato-settings-custom.json +++ b/Telegram/Resources/default_kotato-settings-custom.json @@ -11,5 +11,7 @@ // "sticker_height": 128, // "big_emoji_outline": false, // "always_show_scheduled": true, - // "show_chat_id": true + // "show_chat_id": true, + // "net_speed_boost": null, + // "show_phone_in_drawer": true } diff --git a/Telegram/SourceFiles/core/kotato_settings.cpp b/Telegram/SourceFiles/core/kotato_settings.cpp index bb8bce827..789074a6a 100644 --- a/Telegram/SourceFiles/core/kotato_settings.cpp +++ b/Telegram/SourceFiles/core/kotato_settings.cpp @@ -218,6 +218,11 @@ bool Manager::readCustomFile() { cSetNetUploadRequestInterval(500); } } + + const auto settingsShowDrawerPhoneIt = settings.constFind(qsl("show_phone_in_drawer")); + if (settingsShowDrawerPhoneIt != settings.constEnd() && (*settingsShowDrawerPhoneIt).isBool()) { + cSetShowPhoneInDrawer((*settingsShowDrawerPhoneIt).toBool()); + } return true; } @@ -250,6 +255,7 @@ void Manager::writeDefaultFile() { settings.insert(qsl("always_show_scheduled"), cAlwaysShowScheduled()); settings.insert(qsl("show_chat_id"), cShowChatId()); settings.insert(qsl("net_speed_boost"), QJsonValue(QJsonValue::Null)); + settings.insert(qsl("show_phone_in_drawer"), cShowPhoneInDrawer()); auto document = QJsonDocument(); document.setObject(settings); diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp index 222d87be2..2d85f1b30 100644 --- a/Telegram/SourceFiles/settings.cpp +++ b/Telegram/SourceFiles/settings.cpp @@ -220,3 +220,5 @@ int gNetDownloadSessionsCount = 2; int gNetUploadSessionsCount = 2; int gNetMaxFileQueries = 16; int gNetUploadRequestInterval = 500; + +bool gShowPhoneInDrawer = true; diff --git a/Telegram/SourceFiles/settings.h b/Telegram/SourceFiles/settings.h index c58061e2b..4b182f5ec 100644 --- a/Telegram/SourceFiles/settings.h +++ b/Telegram/SourceFiles/settings.h @@ -194,3 +194,5 @@ DeclareSetting(int, NetDownloadSessionsCount); DeclareSetting(int, NetUploadSessionsCount); DeclareSetting(int, NetMaxFileQueries); DeclareSetting(int, NetUploadRequestInterval); + +DeclareSetting(bool, ShowPhoneInDrawer); \ No newline at end of file diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index b8adfb13f..319d020d4 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -419,14 +419,25 @@ void MainMenu::paintEvent(QPaintEvent *e) { } p.setPen(st::mainMenuCoverFg); p.setFont(st::semiboldFont); - _controller->session().user()->nameText().drawLeftElided( - p, - st::mainMenuCoverTextLeft, - st::mainMenuCoverNameTop, - widthText, - width()); - p.setFont(st::normalFont); - p.drawTextLeft(st::mainMenuCoverTextLeft, st::mainMenuCoverStatusTop, width(), _phoneText); + if (cShowPhoneInDrawer()) { + _controller->session().user()->nameText().drawLeftElided( + p, + st::mainMenuCoverTextLeft, + st::mainMenuCoverNameTop, + widthText, + width()); + p.setFont(st::normalFont); + p.drawTextLeft(st::mainMenuCoverTextLeft, st::mainMenuCoverStatusTop, width(), _phoneText); + } else { + const auto diff = st::mainMenuCoverStatusTop - st::mainMenuCoverNameTop; + _controller->session().user()->nameText().drawLeftElided( + p, + st::mainMenuCoverTextLeft, + st::mainMenuCoverNameTop + (diff / 2), + widthText, + width()); + + } if (_cloudButton) { Ui::EmptyUserpic::PaintSavedMessages( p,