[Improvement] Increase account limit
This commit is contained in:
parent
a254d406e7
commit
fb7d376fe8
5 changed files with 46 additions and 9 deletions
|
|
@ -155,6 +155,8 @@
|
||||||
"ktg_channel_status_not_in": "not subscribed",
|
"ktg_channel_status_not_in": "not subscribed",
|
||||||
"ktg_group_status_owner": "is owner",
|
"ktg_group_status_owner": "is owner",
|
||||||
"ktg_group_status_admin": "is admin",
|
"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",
|
||||||
"ktg_forward_go_to_chat": "Go to chat",
|
"ktg_forward_go_to_chat": "Go to chat",
|
||||||
"ktg_settings_forward": "Forward",
|
"ktg_settings_forward": "Forward",
|
||||||
"ktg_settings_forward_retain_selection": "Retain selection after forward",
|
"ktg_settings_forward_retain_selection": "Retain selection after forward",
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
|
#include "base/build_config.h"
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
class Domain;
|
class Domain;
|
||||||
|
|
@ -30,7 +31,12 @@ public:
|
||||||
std::unique_ptr<Account> account;
|
std::unique_ptr<Account> account;
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr auto kMaxAccounts = 3;
|
static constexpr auto kMaxAccountsWarn = 3;
|
||||||
|
#ifdef ARCH_CPU_64_BITS
|
||||||
|
static constexpr auto kMaxAccounts = 100;
|
||||||
|
#else
|
||||||
|
static constexpr auto kMaxAccounts = 10;
|
||||||
|
#endif
|
||||||
|
|
||||||
explicit Domain(const QString &dataName);
|
explicit Domain(const QString &dataName);
|
||||||
~Domain();
|
~Domain();
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
#include "boxes/sessions_box.h"
|
#include "boxes/sessions_box.h"
|
||||||
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "window/themes/window_theme_editor_box.h"
|
#include "window/themes/window_theme_editor_box.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
|
|
@ -222,11 +223,24 @@ void FillMenu(
|
||||||
[=] { window->show(Box(Window::Theme::CreateBox, window)); },
|
[=] { window->show(Box(Window::Theme::CreateBox, window)); },
|
||||||
&st::menuIconChangeColors);
|
&st::menuIconChangeColors);
|
||||||
} else {
|
} else {
|
||||||
|
if (type != Type::Kotato) {
|
||||||
const auto &list = Core::App().domain().accounts();
|
const auto &list = Core::App().domain().accounts();
|
||||||
if (list.size() < ::Main::Domain::kMaxAccounts) {
|
if (list.size() < ::Main::Domain::kMaxAccountsWarn) {
|
||||||
addAction(tr::lng_menu_add_account(tr::now), [=] {
|
addAction(tr::lng_menu_add_account(tr::now), [=] {
|
||||||
Core::App().domain().addActivated(MTP::Environment{});
|
Core::App().domain().addActivated(MTP::Environment{});
|
||||||
}, &st::menuIconAddAccount);
|
}, &st::menuIconAddAccount);
|
||||||
|
} else if (list.size() < ::Main::Domain::kMaxAccounts) {
|
||||||
|
addAction(tr::lng_menu_add_account(tr::now), [=] {
|
||||||
|
Ui::show(
|
||||||
|
Box<Ui::ConfirmBox>(
|
||||||
|
ktr("ktg_too_many_accounts_warning"),
|
||||||
|
ktr("ktg_account_add_anyway"),
|
||||||
|
[=] {
|
||||||
|
Core::App().domain().addActivated(MTP::Environment{});
|
||||||
|
}),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
|
}, &st::menuIconAddAccount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const auto customSettingsFile = cWorkingDir() + "tdata/kotato-settings-custom.json";
|
const auto customSettingsFile = cWorkingDir() + "tdata/kotato-settings-custom.json";
|
||||||
if (type != Type::Kotato && !controller->session().supportMode()) {
|
if (type != Type::Kotato && !controller->session().supportMode()) {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_main_menu.h"
|
#include "window/window_main_menu.h"
|
||||||
|
|
||||||
#include "kotato/kotato_settings.h"
|
#include "kotato/kotato_settings.h"
|
||||||
|
#include "kotato/kotato_lang.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
#include "window/window_peer_menu.h"
|
#include "window/window_peer_menu.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
|
@ -892,6 +893,7 @@ void MainMenu::rebuildAccounts() {
|
||||||
(inner->count() < Main::Domain::kMaxAccounts),
|
(inner->count() < Main::Domain::kMaxAccounts),
|
||||||
anim::type::instant);
|
anim::type::instant);
|
||||||
|
|
||||||
|
_accountsCount = inner->count() ;
|
||||||
_reorder->start();
|
_reorder->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -930,10 +932,22 @@ not_null<Ui::SlideWrap<Ui::RippleButton>*> MainMenu::setupAddAccount(
|
||||||
}, button->lifetime());
|
}, button->lifetime());
|
||||||
|
|
||||||
const auto add = [=](MTP::Environment environment) {
|
const auto add = [=](MTP::Environment environment) {
|
||||||
|
const auto sure = [=] {
|
||||||
Core::App().preventOrInvoke([=] {
|
Core::App().preventOrInvoke([=] {
|
||||||
Core::App().domain().addActivated(environment);
|
Core::App().domain().addActivated(environment);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
if (_accountsCount >= Main::Domain::kMaxAccountsWarn) {
|
||||||
|
Ui::show(
|
||||||
|
Box<Ui::ConfirmBox>(
|
||||||
|
ktr("ktg_too_many_accounts_warning"),
|
||||||
|
ktr("ktg_account_add_anyway"),
|
||||||
|
sure),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
|
} else {
|
||||||
|
sure();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
button->setAcceptBoth(true);
|
button->setAcceptBoth(true);
|
||||||
button->clicks(
|
button->clicks(
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ private:
|
||||||
not_null<Main::Account*>,
|
not_null<Main::Account*>,
|
||||||
base::unique_qptr<AccountButton>> _watched;
|
base::unique_qptr<AccountButton>> _watched;
|
||||||
not_null<Ui::SlideWrap<Ui::VerticalLayout>*> _accounts;
|
not_null<Ui::SlideWrap<Ui::VerticalLayout>*> _accounts;
|
||||||
|
int _accountsCount = 0;
|
||||||
Ui::SlideWrap<Ui::RippleButton> *_addAccount = nullptr;
|
Ui::SlideWrap<Ui::RippleButton> *_addAccount = nullptr;
|
||||||
not_null<Ui::SlideWrap<Ui::PlainShadow>*> _shadow;
|
not_null<Ui::SlideWrap<Ui::PlainShadow>*> _shadow;
|
||||||
not_null<Ui::Menu::Menu*> _menu;
|
not_null<Ui::Menu::Menu*> _menu;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue