Allow adding up to 10 accounts
Also warn when adding more than 3 accounts.
This commit is contained in:
parent
532243092b
commit
e221962dd4
5 changed files with 23 additions and 3 deletions
|
|
@ -2556,5 +2556,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"ktg_channel_status_not_in" = "not subscribed";
|
||||
"ktg_group_status_owner" = "is owner";
|
||||
"ktg_group_status_admin" = "is admin";
|
||||
"ktg_too_many_accounts_warning" = "Warning! Using too many accounts at the same time is not recommended due to higher memory comsumption and possible crashes because of it.\n\nYou sure you want to add a new account?";
|
||||
"ktg_account_add_anyway" = "Add anyway";
|
||||
|
||||
// Keys finished
|
||||
|
|
|
|||
|
|
@ -147,5 +147,7 @@
|
|||
"ktg_group_status_not_in": "не участник",
|
||||
"ktg_channel_status_not_in": "не подписчик",
|
||||
"ktg_group_status_owner": "вы владелец",
|
||||
"ktg_group_status_admin": "вы админ"
|
||||
"ktg_group_status_admin": "вы админ",
|
||||
"ktg_too_many_accounts_warning": "Внимание! Использование слишком большого количества аккаунтов одновременно не рекомендуется из-за высокого потребления памяти, а также возможных вылетов из-за этого.\n\nВы точно хотите добавить новый аккаунт?",
|
||||
"ktg_account_add_anyway": "Всё равно добавить"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ public:
|
|||
std::unique_ptr<Account> account;
|
||||
};
|
||||
|
||||
static constexpr auto kMaxAccounts = 3;
|
||||
static constexpr auto kMaxAccountsWarn = 3;
|
||||
static constexpr auto kMaxAccounts = 10;
|
||||
|
||||
explicit Domain(const QString &dataName);
|
||||
~Domain();
|
||||
|
|
|
|||
|
|
@ -760,6 +760,8 @@ void MainMenu::rebuildAccounts() {
|
|||
_addAccount->toggle(
|
||||
(count < Main::Domain::kMaxAccounts),
|
||||
anim::type::instant);
|
||||
|
||||
_accountsCount = count;
|
||||
}
|
||||
|
||||
not_null<Ui::SlideWrap<Ui::RippleButton>*> MainMenu::setupAddAccount(
|
||||
|
|
@ -797,7 +799,19 @@ not_null<Ui::SlideWrap<Ui::RippleButton>*> MainMenu::setupAddAccount(
|
|||
}, button->lifetime());
|
||||
|
||||
const auto add = [=](MTP::Environment environment) {
|
||||
Core::App().domain().addActivated(environment);
|
||||
const auto sure = [=] {
|
||||
Core::App().domain().addActivated(environment);
|
||||
};
|
||||
if (_accountsCount >= Main::Domain::kMaxAccountsWarn) {
|
||||
Ui::show(
|
||||
Box<ConfirmBox>(
|
||||
tr::ktg_too_many_accounts_warning(tr::now),
|
||||
tr::ktg_account_add_anyway(tr::now),
|
||||
sure),
|
||||
Ui::LayerOption::KeepOther);
|
||||
} else {
|
||||
sure();
|
||||
}
|
||||
};
|
||||
|
||||
button->setAcceptBoth(true);
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ private:
|
|||
not_null<Main::Account*>,
|
||||
base::unique_qptr<AccountButton>> _watched;
|
||||
not_null<Ui::SlideWrap<Ui::VerticalLayout>*> _accounts;
|
||||
int _accountsCount = 0;
|
||||
Ui::SlideWrap<Ui::RippleButton> *_addAccount = nullptr;
|
||||
not_null<Ui::SlideWrap<Ui::PlainShadow>*> _shadow;
|
||||
not_null<Ui::Menu*> _menu;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue