Move a lot of settings to Core::Settings.

This commit is contained in:
John Preston 2020-06-18 22:04:16 +04:00
parent 4d6cc58f0d
commit 83538675ce
112 changed files with 1761 additions and 1482 deletions

View file

@ -668,10 +668,10 @@ PRIVATE
lang/lang_values.h lang/lang_values.h
main/main_account.cpp main/main_account.cpp
main/main_account.h main/main_account.h
main/main_accounts.cpp
main/main_accounts.h
main/main_app_config.cpp main/main_app_config.cpp
main/main_app_config.h main/main_app_config.h
main/main_domain.cpp
main/main_domain.h
main/main_session.cpp main/main_session.cpp
main/main_session.h main/main_session.h
main/main_session_settings.cpp main/main_session_settings.cpp
@ -914,10 +914,10 @@ PRIVATE
storage/serialize_peer.h storage/serialize_peer.h
storage/storage_account.cpp storage/storage_account.cpp
storage/storage_account.h storage/storage_account.h
storage/storage_accounts.cpp
storage/storage_accounts.h
storage/storage_cloud_blob.cpp storage/storage_cloud_blob.cpp
storage/storage_cloud_blob.h storage/storage_cloud_blob.h
storage/storage_domain.cpp
storage/storage_domain.h
storage/storage_facade.cpp storage/storage_facade.cpp
storage/storage_facade.h storage/storage_facade.h
# storage/storage_feed_messages.cpp # storage/storage_feed_messages.cpp

View file

@ -470,10 +470,13 @@ void ApiWrap::importChatInvite(const QString &hash) {
return PeerId(0); return PeerId(0);
}); });
if (const auto peer = _session->data().peerLoaded(peerId)) { if (const auto peer = _session->data().peerLoaded(peerId)) {
App::wnd()->sessionController()->showPeerHistory( const auto &windows = _session->windows();
if (!windows.empty()) {
windows.front()->showPeerHistory(
peer, peer,
Window::SectionShow::Way::Forward); Window::SectionShow::Way::Forward);
} }
}
}; };
result.match([&](const MTPDupdates &data) { result.match([&](const MTPDupdates &data) {
handleChats(data.vchats()); handleChats(data.vchats());
@ -2727,9 +2730,12 @@ void ApiWrap::requestAttachedStickerSets(not_null<PhotoData*> photo) {
const auto setId = (setData->vid().v && setData->vaccess_hash().v) const auto setId = (setData->vid().v && setData->vaccess_hash().v)
? MTP_inputStickerSetID(setData->vid(), setData->vaccess_hash()) ? MTP_inputStickerSetID(setData->vid(), setData->vaccess_hash())
: MTP_inputStickerSetShortName(setData->vshort_name()); : MTP_inputStickerSetShortName(setData->vshort_name());
const auto &windows = _session->windows();
if (!windows.empty()) {
Ui::show( Ui::show(
Box<StickerSetBox>(App::wnd()->sessionController(), setId), Box<StickerSetBox>(windows.front(), setId),
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
}
}).fail([=](const RPCError &error) { }).fail([=](const RPCError &error) {
Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now))); Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now)));
}).send(); }).send();

View file

@ -40,7 +40,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h" #include "mainwindow.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "facades.h" #include "facades.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
@ -482,7 +481,7 @@ void GroupInfoBox::prepare() {
_title->setMaxLength(kMaxGroupChannelTitle); _title->setMaxLength(kMaxGroupChannelTitle);
_title->setInstantReplaces(Ui::InstantReplaces::Default()); _title->setInstantReplaces(Ui::InstantReplaces::Default());
_title->setInstantReplacesEnabled( _title->setInstantReplacesEnabled(
_navigation->session().settings().replaceEmojiValue()); Core::App().settings().replaceEmojiValue());
Ui::Emoji::SuggestionsController::Init( Ui::Emoji::SuggestionsController::Init(
getDelegate()->outerContainer(), getDelegate()->outerContainer(),
_title, _title,
@ -498,8 +497,9 @@ void GroupInfoBox::prepare() {
_description->setMaxLength(kMaxChannelDescription); _description->setMaxLength(kMaxChannelDescription);
_description->setInstantReplaces(Ui::InstantReplaces::Default()); _description->setInstantReplaces(Ui::InstantReplaces::Default());
_description->setInstantReplacesEnabled( _description->setInstantReplacesEnabled(
_navigation->session().settings().replaceEmojiValue()); Core::App().settings().replaceEmojiValue());
_description->setSubmitSettings(_navigation->session().settings().sendSubmitWay()); _description->setSubmitSettings(
Core::App().settings().sendSubmitWay());
connect(_description, &Ui::InputField::resized, [=] { descriptionResized(); }); connect(_description, &Ui::InputField::resized, [=] { descriptionResized(); });
connect(_description, &Ui::InputField::submitted, [=] { submit(); }); connect(_description, &Ui::InputField::submitted, [=] { submit(); });

View file

@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "core/application.h" #include "core/application.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "main/main_session.h"
#include "ui/widgets/checkbox.h" #include "ui/widgets/checkbox.h"
#include "facades.h" #include "facades.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
@ -28,7 +27,8 @@ void AutoLockBox::prepare() {
auto options = { 60, 300, 3600, 18000 }; auto options = { 60, 300, 3600, 18000 };
auto group = std::make_shared<Ui::RadiobuttonGroup>(Global::AutoLock()); auto group = std::make_shared<Ui::RadiobuttonGroup>(
Core::App().settings().autoLock());
auto y = st::boxOptionListPadding.top() + st::autolockButton.margin.top(); auto y = st::boxOptionListPadding.top() + st::autolockButton.margin.top();
auto count = int(options.size()); auto count = int(options.size());
_options.reserve(count); _options.reserve(count);
@ -43,8 +43,8 @@ void AutoLockBox::prepare() {
} }
void AutoLockBox::durationChanged(int seconds) { void AutoLockBox::durationChanged(int seconds) {
Global::SetAutoLock(seconds); Core::App().settings().setAutoLock(seconds);
_session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
Global::RefLocalPasscodeChanged().notify(); Global::RefLocalPasscodeChanged().notify();
Core::App().checkAutoLock(); Core::App().checkAutoLock();

View file

@ -770,9 +770,10 @@ void DeleteMessagesBox::deleteAndClear() {
if (justClear) { if (justClear) {
peer->session().api().clearHistory(peer, revoke); peer->session().api().clearHistory(peer, revoke);
} else { } else {
const auto controller = App::wnd()->sessionController(); for (const auto controller : peer->session().windows()) {
if (controller->activeChatCurrent().peer() == peer) { if (controller->activeChatCurrent().peer() == peer) {
Ui::showChatsList(); Ui::showChatsList(&peer->session());
}
} }
// Don't delete old history by default, // Don't delete old history by default,
// because Android app doesn't. // because Android app doesn't.

View file

@ -20,7 +20,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/checkbox.h" #include "ui/widgets/checkbox.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h" #include "core/application.h"
#include "core/core_settings.h"
#include "chat_helpers/emoji_suggestions_widget.h" #include "chat_helpers/emoji_suggestions_widget.h"
#include "chat_helpers/message_field.h" #include "chat_helpers/message_field.h"
#include "history/view/history_view_schedule_box.h" #include "history/view/history_view_schedule_box.h"
@ -161,7 +162,7 @@ void InitField(
not_null<Main::Session*> session) { not_null<Main::Session*> session) {
field->setInstantReplaces(Ui::InstantReplaces::Default()); field->setInstantReplaces(Ui::InstantReplaces::Default());
field->setInstantReplacesEnabled( field->setInstantReplacesEnabled(
session->settings().replaceEmojiValue()); Core::App().settings().replaceEmojiValue());
auto options = Ui::Emoji::SuggestionsController::Options(); auto options = Ui::Emoji::SuggestionsController::Options();
options.suggestExactFirstWord = false; options.suggestExactFirstWord = false;
Ui::Emoji::SuggestionsController::Init( Ui::Emoji::SuggestionsController::Init(
@ -841,7 +842,7 @@ not_null<Ui::InputField*> CreatePollBox::setupSolution(
solution->setMaxLength(kSolutionLimit + kErrorLimit); solution->setMaxLength(kSolutionLimit + kErrorLimit);
solution->setInstantReplaces(Ui::InstantReplaces::Default()); solution->setInstantReplaces(Ui::InstantReplaces::Default());
solution->setInstantReplacesEnabled( solution->setInstantReplacesEnabled(
session->settings().replaceEmojiValue()); Core::App().settings().replaceEmojiValue());
solution->setMarkdownReplacesEnabled(rpl::single(true)); solution->setMarkdownReplacesEnabled(rpl::single(true));
solution->setEditLinkCallback( solution->setEditLinkCallback(
DefaultEditLinkCallback(_controller, solution)); DefaultEditLinkCallback(_controller, solution));

View file

@ -13,8 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "chat_helpers/spellchecker_common.h" #include "chat_helpers/spellchecker_common.h"
#include "core/application.h" #include "core/application.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_session.h"
#include "main/main_session_settings.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "mtproto/dedicated_file_loader.h" #include "mtproto/dedicated_file_loader.h"
#include "spellcheck/spellcheck_utils.h" #include "spellcheck/spellcheck_utils.h"
@ -405,7 +403,7 @@ void ManageDictionariesBox::prepare() {
object_ptr<Inner>( object_ptr<Inner>(
this, this,
_controller, _controller,
session->settings().dictionariesEnabled()), Core::App().settings().dictionariesEnabled()),
st::boxScroll, st::boxScroll,
multiSelect->height() multiSelect->height()
); );
@ -423,9 +421,9 @@ void ManageDictionariesBox::prepare() {
setTitle(tr::lng_settings_manage_dictionaries()); setTitle(tr::lng_settings_manage_dictionaries());
addButton(tr::lng_settings_save(), [=] { addButton(tr::lng_settings_save(), [=] {
session->settings().setDictionariesEnabled( Core::App().settings().setDictionariesEnabled(
FilterEnabledDict(inner->enabledRows())); FilterEnabledDict(inner->enabledRows()));
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
// Ignore boxClosing() when the Save button was pressed. // Ignore boxClosing() when the Save button was pressed.
lifetime().destroy(); lifetime().destroy();
closeBox(); closeBox();
@ -433,9 +431,9 @@ void ManageDictionariesBox::prepare() {
addButton(tr::lng_close(), [=] { closeBox(); }); addButton(tr::lng_close(), [=] { closeBox(); });
boxClosing() | rpl::start_with_next([=] { boxClosing() | rpl::start_with_next([=] {
session->settings().setDictionariesEnabled( Core::App().settings().setDictionariesEnabled(
FilterEnabledDict(initialEnabledRows)); FilterEnabledDict(initialEnabledRows));
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
}, lifetime()); }, lifetime());
setDimensionsToContent(st::boxWidth, inner); setDimensionsToContent(st::boxWidth, inner);

View file

@ -12,9 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/checkbox.h" #include "ui/widgets/checkbox.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "platform/platform_specific.h" #include "platform/platform_specific.h"
#include "facades.h" #include "core/application.h"
#include "window/window_session_controller.h" #include "core/core_settings.h"
#include "main/main_session.h"
#include "storage/storage_account.h" #include "storage/storage_account.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
@ -23,8 +22,8 @@ DownloadPathBox::DownloadPathBox(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController*> controller) not_null<Window::SessionController*> controller)
: _controller(controller) : _controller(controller)
, _path(Global::DownloadPath()) , _path(Core::App().settings().downloadPath())
, _pathBookmark(Global::DownloadPathBookmark()) , _pathBookmark(Core::App().settings().downloadPathBookmark())
, _group(std::make_shared<Ui::RadioenumGroup<Directory>>(typeFromPath(_path))) , _group(std::make_shared<Ui::RadioenumGroup<Directory>>(typeFromPath(_path)))
, _default(this, _group, Directory::Downloads, tr::lng_download_path_default_radio(tr::now), st::defaultBoxCheckbox) , _default(this, _group, Directory::Downloads, tr::lng_download_path_default_radio(tr::now), st::defaultBoxCheckbox)
, _temp(this, _group, Directory::Temp, tr::lng_download_path_temp_radio(tr::now), st::defaultBoxCheckbox) , _temp(this, _group, Directory::Temp, tr::lng_download_path_temp_radio(tr::now), st::defaultBoxCheckbox)
@ -91,8 +90,9 @@ void DownloadPathBox::radioChanged(Directory value) {
void DownloadPathBox::editPath() { void DownloadPathBox::editPath() {
const auto initialPath = [] { const auto initialPath = [] {
if (!Global::DownloadPath().isEmpty() && Global::DownloadPath() != qstr("tmp")) { const auto path = Core::App().settings().downloadPath();
return Global::DownloadPath().left(Global::DownloadPath().size() - (Global::DownloadPath().endsWith('/') ? 1 : 0)); if (!path.isEmpty() && path != qstr("tmp")) {
return path.left(path.size() - (path.endsWith('/') ? 1 : 0));
} }
return QString(); return QString();
}(); }();
@ -122,10 +122,10 @@ void DownloadPathBox::save() {
} }
return QString(); return QString();
}; };
Global::SetDownloadPath(computePath()); Core::App().settings().setDownloadPathBookmark(
Global::SetDownloadPathBookmark((value == Directory::Custom) ? _pathBookmark : QByteArray()); (value == Directory::Custom) ? _pathBookmark : QByteArray());
_controller->session().saveSettings(); Core::App().settings().setDownloadPath(computePath());
Global::RefDownloadPathChanged().notify(); Core::App().saveSettings();
closeBox(); closeBox();
#endif // OS_WIN_STORE #endif // OS_WIN_STORE
} }

View file

@ -10,12 +10,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h" #include "apiwrap.h"
#include "api/api_text_entities.h" #include "api/api_text_entities.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "chat_helpers/emoji_suggestions_widget.h" #include "chat_helpers/emoji_suggestions_widget.h"
#include "chat_helpers/message_field.h" #include "chat_helpers/message_field.h"
#include "chat_helpers/tabbed_panel.h" #include "chat_helpers/tabbed_panel.h"
#include "chat_helpers/tabbed_selector.h" #include "chat_helpers/tabbed_selector.h"
#include "base/event_filter.h" #include "base/event_filter.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "core/file_utilities.h" #include "core/file_utilities.h"
#include "core/mime_type.h" #include "core/mime_type.h"
#include "data/data_document.h" #include "data/data_document.h"
@ -309,10 +310,10 @@ EditCaptionBox::EditCaptionBox(
_field->setMaxLength( _field->setMaxLength(
_controller->session().serverConfig().captionLengthMax); _controller->session().serverConfig().captionLengthMax);
_field->setSubmitSettings( _field->setSubmitSettings(
_controller->session().settings().sendSubmitWay()); Core::App().settings().sendSubmitWay());
_field->setInstantReplaces(Ui::InstantReplaces::Default()); _field->setInstantReplaces(Ui::InstantReplaces::Default());
_field->setInstantReplacesEnabled( _field->setInstantReplacesEnabled(
_controller->session().settings().replaceEmojiValue()); Core::App().settings().replaceEmojiValue());
_field->setMarkdownReplacesEnabled(rpl::single(true)); _field->setMarkdownReplacesEnabled(rpl::single(true));
_field->setEditLinkCallback( _field->setEditLinkCallback(
DefaultEditLinkCallback(_controller, _field)); DefaultEditLinkCallback(_controller, _field));

View file

@ -19,12 +19,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_chat_filters.h" #include "data/data_chat_filters.h"
#include "data/data_peer.h" #include "data/data_peer.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "settings/settings_common.h" #include "settings/settings_common.h"
#include "base/event_filter.h" #include "base/event_filter.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "history/history.h" #include "history/history.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_controller.h" #include "window/window_controller.h"
#include "apiwrap.h" #include "apiwrap.h"
@ -501,7 +502,7 @@ void EditFilterBox(
name->setMaxLength(kMaxFilterTitleLength); name->setMaxLength(kMaxFilterTitleLength);
name->setInstantReplaces(Ui::InstantReplaces::Default()); name->setInstantReplaces(Ui::InstantReplaces::Default());
name->setInstantReplacesEnabled( name->setInstantReplacesEnabled(
window->session().settings().replaceEmojiValue()); Core::App().settings().replaceEmojiValue());
Ui::Emoji::SuggestionsController::Init( Ui::Emoji::SuggestionsController::Init(
box->getDelegate()->outerContainer(), box->getDelegate()->outerContainer(),
name, name,

View file

@ -14,9 +14,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h" #include "mainwindow.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_accounts.h" #include "main/main_domain.h"
#include "core/application.h" #include "core/application.h"
#include "storage/storage_accounts.h" #include "storage/storage_domain.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h" #include "ui/widgets/input_fields.h"
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
@ -452,7 +452,7 @@ void PasscodeBox::save(bool force) {
return; return;
} }
if (Core::App().accounts().local().checkPasscode(old.toUtf8())) { if (Core::App().domain().local().checkPasscode(old.toUtf8())) {
cSetPasscodeBadTries(0); cSetPasscodeBadTries(0);
if (_turningOff) pwd = conf = QString(); if (_turningOff) pwd = conf = QString();
} else { } else {
@ -520,7 +520,7 @@ void PasscodeBox::save(bool force) {
closeReplacedBy(); closeReplacedBy();
const auto weak = Ui::MakeWeak(this); const auto weak = Ui::MakeWeak(this);
cSetPasscodeBadTries(0); cSetPasscodeBadTries(0);
Core::App().accounts().local().setPasscode(pwd.toUtf8()); Core::App().domain().local().setPasscode(pwd.toUtf8());
Core::App().localPasscodeChanged(); Core::App().localPasscodeChanged();
if (weak) { if (weak) {
closeBox(); closeBox();

View file

@ -35,7 +35,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/core_cloud_password.h" #include "core/core_cloud_password.h"
#include "base/unixtime.h" #include "base/unixtime.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "facades.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"

View file

@ -9,7 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h" #include "apiwrap.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "boxes/add_contact_box.h" #include "boxes/add_contact_box.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "boxes/peer_list_controllers.h" #include "boxes/peer_list_controllers.h"
@ -20,6 +19,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/peers/edit_linked_chat_box.h" #include "boxes/peers/edit_linked_chat_box.h"
#include "boxes/stickers_box.h" #include "boxes/stickers_box.h"
#include "chat_helpers/emoji_suggestions_widget.h" #include "chat_helpers/emoji_suggestions_widget.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_chat.h" #include "data/data_chat.h"
#include "data/data_peer.h" #include "data/data_peer.h"
@ -465,7 +466,7 @@ object_ptr<Ui::RpWidget> Controller::createTitleEdit() {
result->entity()->setMaxLength(kMaxGroupChannelTitle); result->entity()->setMaxLength(kMaxGroupChannelTitle);
result->entity()->setInstantReplaces(Ui::InstantReplaces::Default()); result->entity()->setInstantReplaces(Ui::InstantReplaces::Default());
result->entity()->setInstantReplacesEnabled( result->entity()->setInstantReplacesEnabled(
_peer->session().settings().replaceEmojiValue()); Core::App().settings().replaceEmojiValue());
Ui::Emoji::SuggestionsController::Init( Ui::Emoji::SuggestionsController::Init(
_wrap->window(), _wrap->window(),
result->entity(), result->entity(),
@ -499,8 +500,8 @@ object_ptr<Ui::RpWidget> Controller::createDescriptionEdit() {
result->entity()->setMaxLength(kMaxChannelDescription); result->entity()->setMaxLength(kMaxChannelDescription);
result->entity()->setInstantReplaces(Ui::InstantReplaces::Default()); result->entity()->setInstantReplaces(Ui::InstantReplaces::Default());
result->entity()->setInstantReplacesEnabled( result->entity()->setInstantReplacesEnabled(
_peer->session().settings().replaceEmojiValue()); Core::App().settings().replaceEmojiValue());
result->entity()->setSubmitSettings(_peer->session().settings().sendSubmitWay()); result->entity()->setSubmitSettings(Core::App().settings().sendSubmitWay());
Ui::Emoji::SuggestionsController::Init( Ui::Emoji::SuggestionsController::Init(
_wrap->window(), _wrap->window(),
result->entity(), result->entity(),
@ -1443,7 +1444,7 @@ void Controller::deleteChannel() {
const auto session = &_peer->session(); const auto session = &_peer->session();
Ui::hideLayer(); Ui::hideLayer();
Ui::showChatsList(); Ui::showChatsList(session);
if (chat) { if (chat) {
session->api().deleteConversation(chat, false); session->api().deleteConversation(chat, false);
} }

View file

@ -14,7 +14,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/input_fields.h" #include "ui/widgets/input_fields.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h" #include "core/application.h"
#include "core/core_settings.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_calls.h" #include "styles/style_calls.h"
@ -86,7 +87,7 @@ void RateCallBox::ratingChanged(int value) {
Ui::InputField::Mode::MultiLine, Ui::InputField::Mode::MultiLine,
tr::lng_call_rate_comment()); tr::lng_call_rate_comment());
_comment->show(); _comment->show();
_comment->setSubmitSettings(_session->settings().sendSubmitWay()); _comment->setSubmitSettings(Core::App().settings().sendSubmitWay());
_comment->setMaxLength(kRateCallCommentLengthMax); _comment->setMaxLength(kRateCallCommentLengthMax);
_comment->resize(width() - (st::callRatingPadding.left() + st::callRatingPadding.right()), _comment->height()); _comment->resize(width() - (st::callRatingPadding.left() + st::callRatingPadding.right()), _comment->height());

View file

@ -10,13 +10,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "data/data_peer.h" #include "data/data_peer.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "ui/widgets/checkbox.h" #include "ui/widgets/checkbox.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h" #include "ui/widgets/input_fields.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "core/core_settings.h"
#include "core/application.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "styles/style_profile.h" #include "styles/style_profile.h"
@ -109,7 +110,7 @@ void ReportBox::reasonChanged(Reason reason) {
Ui::InputField::Mode::MultiLine, Ui::InputField::Mode::MultiLine,
tr::lng_report_reason_description()); tr::lng_report_reason_description());
_reasonOtherText->show(); _reasonOtherText->show();
_reasonOtherText->setSubmitSettings(_peer->session().settings().sendSubmitWay()); _reasonOtherText->setSubmitSettings(Core::App().settings().sendSubmitWay());
_reasonOtherText->setMaxLength(kReportReasonLengthMax); _reasonOtherText->setMaxLength(kReportReasonLengthMax);
_reasonOtherText->resize(width() - (st::boxPadding.left() + st::boxOptionListPadding.left() + st::boxPadding.right()), _reasonOtherText->height()); _reasonOtherText->resize(width() - (st::boxPadding.left() + st::boxOptionListPadding.left() + st::boxPadding.right()), _reasonOtherText->height());

View file

@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/storage_media_prepare.h" #include "storage/storage_media_prepare.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "mtproto/mtproto_config.h" #include "mtproto/mtproto_config.h"
#include "chat_helpers/message_field.h" #include "chat_helpers/message_field.h"
#include "chat_helpers/emoji_suggestions_widget.h" #include "chat_helpers/emoji_suggestions_widget.h"
@ -38,6 +37,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/clip/media_clip_reader.h" #include "media/clip/media_clip_reader.h"
#include "api/api_common.h" #include "api/api_common.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "layout.h" #include "layout.h"
#include "facades.h" // App::LambdaDelayed. #include "facades.h" // App::LambdaDelayed.
#include "app.h" #include "app.h"
@ -1913,7 +1914,7 @@ void SendFilesBox::initSendWay() {
? SendFilesWay::Album ? SendFilesWay::Album
: SendFilesWay::Photos; : SendFilesWay::Photos;
} }
const auto way = _controller->session().settings().sendFilesWay(); const auto way = Core::App().settings().sendFilesWay();
if (way == SendFilesWay::Files) { if (way == SendFilesWay::Files) {
return way; return way;
} else if (way == SendFilesWay::Album) { } else if (way == SendFilesWay::Album) {
@ -2047,7 +2048,7 @@ void SendFilesBox::setupCaption() {
_caption->setMaxLength( _caption->setMaxLength(
_controller->session().serverConfig().captionLengthMax); _controller->session().serverConfig().captionLengthMax);
_caption->setSubmitSettings( _caption->setSubmitSettings(
_controller->session().settings().sendSubmitWay()); Core::App().settings().sendSubmitWay());
connect(_caption, &Ui::InputField::resized, [=] { connect(_caption, &Ui::InputField::resized, [=] {
captionResized(); captionResized();
}); });
@ -2071,7 +2072,7 @@ void SendFilesBox::setupCaption() {
}); });
_caption->setInstantReplaces(Ui::InstantReplaces::Default()); _caption->setInstantReplaces(Ui::InstantReplaces::Default());
_caption->setInstantReplacesEnabled( _caption->setInstantReplacesEnabled(
_controller->session().settings().replaceEmojiValue()); Core::App().settings().replaceEmojiValue());
_caption->setMarkdownReplacesEnabled(rpl::single(true)); _caption->setMarkdownReplacesEnabled(rpl::single(true));
_caption->setEditLinkCallback( _caption->setEditLinkCallback(
DefaultEditLinkCallback(_controller, _caption)); DefaultEditLinkCallback(_controller, _caption));
@ -2344,7 +2345,7 @@ void SendFilesBox::send(
const auto way = _sendWay ? _sendWay->value() : Way::Files; const auto way = _sendWay ? _sendWay->value() : Way::Files;
if (_compressConfirm == CompressConfirm::Auto) { if (_compressConfirm == CompressConfirm::Auto) {
const auto oldWay = _controller->session().settings().sendFilesWay(); const auto oldWay = Core::App().settings().sendFilesWay();
if (way != oldWay) { if (way != oldWay) {
// Check if the user _could_ use the old value, but didn't. // Check if the user _could_ use the old value, but didn't.
if ((oldWay == Way::Album && _sendAlbum) if ((oldWay == Way::Album && _sendAlbum)
@ -2352,8 +2353,8 @@ void SendFilesBox::send(
|| (oldWay == Way::Files && _sendFiles) || (oldWay == Way::Files && _sendFiles)
|| (way == Way::Files && (_sendAlbum || _sendPhotos))) { || (way == Way::Files && (_sendAlbum || _sendPhotos))) {
// And in that case save it to settings. // And in that case save it to settings.
_controller->session().settings().setSendFilesWay(way); Core::App().settings().setSendFilesWay(way);
_controller->session().saveSettingsDelayed(); Core::App().saveSettingsDelayed();
} }
} }
} }

View file

@ -36,7 +36,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_folder.h" #include "data/data_folder.h"
#include "data/data_changes.h" #include "data/data_changes.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "core/application.h" #include "core/application.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
@ -200,11 +199,11 @@ void ShareBox::prepareCommentField() {
field->setInstantReplaces(Ui::InstantReplaces::Default()); field->setInstantReplaces(Ui::InstantReplaces::Default());
field->setInstantReplacesEnabled( field->setInstantReplacesEnabled(
_navigation->session().settings().replaceEmojiValue()); Core::App().settings().replaceEmojiValue());
field->setMarkdownReplacesEnabled(rpl::single(true)); field->setMarkdownReplacesEnabled(rpl::single(true));
field->setEditLinkCallback( field->setEditLinkCallback(
DefaultEditLinkCallback(_navigation->parentController(), field)); DefaultEditLinkCallback(_navigation->parentController(), field));
field->setSubmitSettings(_navigation->session().settings().sendSubmitWay()); field->setSubmitSettings(Core::App().settings().sendSubmitWay());
InitSpellchecker(_navigation->parentController(), field); InitSpellchecker(_navigation->parentController(), field);
Ui::SendPendingMoveResizeEvents(_comment); Ui::SendPendingMoveResizeEvents(_comment);

View file

@ -35,7 +35,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/image/image.h" #include "ui/image/image.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "facades.h"
#include "app.h" #include "app.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"

View file

@ -20,7 +20,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_media_types.h" #include "data/data_media_types.h"
#include "data/data_user.h" #include "data/data_user.h"
#include "facades.h"
#include "app.h" #include "app.h"
namespace Calls { namespace Calls {

View file

@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "calls/calls_call.h" #include "calls/calls_call.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
@ -17,6 +16,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/openssl_help.h" #include "base/openssl_help.h"
#include "mtproto/mtproto_dh_utils.h" #include "mtproto/mtproto_dh_utils.h"
#include "mtproto/mtproto_config.h" #include "mtproto/mtproto_config.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "media/audio/media_audio_track.h" #include "media/audio/media_audio_track.h"
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
#include "calls/calls_panel.h" #include "calls/calls_panel.h"
@ -308,7 +309,7 @@ QString Call::getDebugLog() const {
void Call::startWaitingTrack() { void Call::startWaitingTrack() {
_waitingTrack = Media::Audio::Current().createTrack(); _waitingTrack = Media::Audio::Current().createTrack();
auto trackFileName = _user->session().settings().getSoundPath( auto trackFileName = Core::App().settings().getSoundPath(
(_type == Type::Outgoing) (_type == Type::Outgoing)
? qsl("call_outgoing") ? qsl("call_outgoing")
: qsl("call_incoming")); : qsl("call_incoming"));
@ -610,13 +611,14 @@ void Call::createAndStartController(const MTPDphoneCall &call) {
if (_mute) { if (_mute) {
raw->setMuteMicrophone(_mute); raw->setMuteMicrophone(_mute);
} }
const auto &settings = Core::App().settings();
raw->setAudioOutputDevice( raw->setAudioOutputDevice(
Global::CallOutputDeviceID().toStdString()); settings.callOutputDeviceID().toStdString());
raw->setAudioInputDevice( raw->setAudioInputDevice(
Global::CallInputDeviceID().toStdString()); settings.callInputDeviceID().toStdString());
raw->setOutputVolume(Global::CallOutputVolume() / 100.0f); raw->setOutputVolume(settings.callOutputVolume() / 100.0f);
raw->setInputVolume(Global::CallInputVolume() / 100.0f); raw->setInputVolume(settings.callInputVolume() / 100.0f);
raw->setAudioOutputDuckingEnabled(Global::CallAudioDuckingEnabled()); raw->setAudioOutputDuckingEnabled(settings.callAudioDuckingEnabled());
} }
void Call::handleControllerStateChange( void Call::handleControllerStateChange(

View file

@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mtproto/mtproto_dh_utils.h" #include "mtproto/mtproto_dh_utils.h"
#include "core/application.h" #include "core/application.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
@ -74,7 +73,7 @@ void Instance::playSound(Sound sound) {
if (!_callBusyTrack) { if (!_callBusyTrack) {
_callBusyTrack = Media::Audio::Current().createTrack(); _callBusyTrack = Media::Audio::Current().createTrack();
_callBusyTrack->fillFromFile( _callBusyTrack->fillFromFile(
_session->settings().getSoundPath(qsl("call_busy"))); Core::App().settings().getSoundPath(qsl("call_busy")));
} }
_callBusyTrack->playOnce(); _callBusyTrack->playOnce();
} break; } break;
@ -83,7 +82,7 @@ void Instance::playSound(Sound sound) {
if (!_callEndedTrack) { if (!_callEndedTrack) {
_callEndedTrack = Media::Audio::Current().createTrack(); _callEndedTrack = Media::Audio::Current().createTrack();
_callEndedTrack->fillFromFile( _callEndedTrack->fillFromFile(
_session->settings().getSoundPath(qsl("call_end"))); Core::App().settings().getSoundPath(qsl("call_end")));
} }
_callEndedTrack->playOnce(); _callEndedTrack->playOnce();
} break; } break;
@ -92,7 +91,7 @@ void Instance::playSound(Sound sound) {
if (!_callConnectingTrack) { if (!_callConnectingTrack) {
_callConnectingTrack = Media::Audio::Current().createTrack(); _callConnectingTrack = Media::Audio::Current().createTrack();
_callConnectingTrack->fillFromFile( _callConnectingTrack->fillFromFile(
_session->settings().getSoundPath(qsl("call_connect"))); Core::App().settings().getSoundPath(qsl("call_connect")));
} }
_callConnectingTrack->playOnce(); _callConnectingTrack->playOnce();
} break; } break;

View file

@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h" #include "core/application.h"
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
#include "ui/emoji_config.h" #include "ui/emoji_config.h"
#include "main/main_accounts.h" #include "main/main_domain.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "apiwrap.h" #include "apiwrap.h"
@ -516,7 +516,7 @@ void EmojiKeywords::langPackRefreshed() {
} }
void EmojiKeywords::handleSessionChanges() { void EmojiKeywords::handleSessionChanges() {
Core::App().accounts().activeSessionValue( // #TODO multi someSessionValue Core::App().domain().activeSessionValue( // #TODO multi someSessionValue
) | rpl::map([](Main::Session *session) { ) | rpl::map([](Main::Session *session) {
return session ? &session->api() : nullptr; return session ? &session->api() : nullptr;
}) | rpl::start_with_next([=](ApiWrap *api) { }) | rpl::start_with_next([=](ApiWrap *api) {

View file

@ -16,7 +16,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "emoji_suggestions_data.h" #include "emoji_suggestions_data.h"
#include "emoji_suggestions_helper.h" #include "emoji_suggestions_helper.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h" #include "core/core_settings.h"
#include "core/application.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "facades.h" #include "facades.h"
#include "app.h" #include "app.h"
@ -837,8 +838,7 @@ void EmojiListWidget::setSelected(int newSelected) {
_selected = newSelected; _selected = newSelected;
updateSelected(); updateSelected();
if (_selected >= 0 if (_selected >= 0 && Core::App().settings().suggestEmoji()) {
&& controller()->session().settings().suggestEmoji()) {
Ui::Tooltip::Show(1000, this); Ui::Tooltip::Show(1000, this);
} }

View file

@ -8,6 +8,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "chat_helpers/emoji_suggestions_widget.h" #include "chat_helpers/emoji_suggestions_widget.h"
#include "chat_helpers/emoji_keywords.h" #include "chat_helpers/emoji_keywords.h"
#include "core/core_settings.h"
#include "core/application.h"
#include "emoji_suggestions_helper.h" #include "emoji_suggestions_helper.h"
#include "ui/effects/ripple_animation.h" #include "ui/effects/ripple_animation.h"
#include "ui/widgets/shadow.h" #include "ui/widgets/shadow.h"
@ -19,7 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h" #include "core/application.h"
#include "base/event_filter.h" #include "base/event_filter.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "app.h" #include "app.h"
#include "styles/style_chat_helpers.h" #include "styles/style_chat_helpers.h"
@ -608,7 +609,7 @@ void SuggestionsController::setReplaceCallback(
} }
void SuggestionsController::handleTextChange() { void SuggestionsController::handleTextChange() {
if (_session->settings().suggestEmoji() if (Core::App().settings().suggestEmoji()
&& _field->textCursor().position() > 0) { && _field->textCursor().position() > 0) {
Core::App().emojiKeywords().refresh(); Core::App().emojiKeywords().refresh();
} }
@ -638,7 +639,7 @@ void SuggestionsController::showWithQuery(const QString &query) {
} }
QString SuggestionsController::getEmojiQuery() { QString SuggestionsController::getEmojiQuery() {
if (!_session->settings().suggestEmoji()) { if (!Core::App().settings().suggestEmoji()) {
return QString(); return QString();
} }

View file

@ -21,6 +21,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h" #include "apiwrap.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "storage/storage_account.h" #include "storage/storage_account.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "lottie/lottie_single_player.h" #include "lottie/lottie_single_player.h"
#include "ui/widgets/scroll_area.h" #include "ui/widgets/scroll_area.h"
#include "ui/image/image.h" #include "ui/image/image.h"
@ -563,7 +565,7 @@ bool FieldAutocomplete::chooseSelected(ChooseMethod method) const {
bool FieldAutocomplete::eventFilter(QObject *obj, QEvent *e) { bool FieldAutocomplete::eventFilter(QObject *obj, QEvent *e) {
auto hidden = isHidden(); auto hidden = isHidden();
auto moderate = Global::ModerateModeEnabled(); auto moderate = Core::App().settings().moderateModeEnabled();
if (hidden && !moderate) return QWidget::eventFilter(obj, e); if (hidden && !moderate) return QWidget::eventFilter(obj, e);
if (e->type() == QEvent::KeyPress) { if (e->type() == QEvent::KeyPress) {

View file

@ -28,7 +28,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h" #include "main/main_session.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "history/view/history_view_cursor_state.h" #include "history/view/history_view_cursor_state.h"
#include "facades.h"
#include "app.h" #include "app.h"
#include "styles/style_chat_helpers.h" #include "styles/style_chat_helpers.h"

View file

@ -15,6 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/event_filter.h" #include "base/event_filter.h"
#include "boxes/abstract_box.h" #include "boxes/abstract_box.h"
#include "core/shortcuts.h" #include "core/shortcuts.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "ui/wrap/vertical_layout.h" #include "ui/wrap/vertical_layout.h"
#include "ui/widgets/popup_menu.h" #include "ui/widgets/popup_menu.h"
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
@ -25,7 +27,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "styles/style_history.h" #include "styles/style_history.h"
@ -142,7 +143,7 @@ void EditLinkBox::prepare() {
st::markdownLinkFieldPadding); st::markdownLinkFieldPadding);
text->setInstantReplaces(Ui::InstantReplaces::Default()); text->setInstantReplaces(Ui::InstantReplaces::Default());
text->setInstantReplacesEnabled( text->setInstantReplacesEnabled(
session->settings().replaceEmojiValue()); Core::App().settings().replaceEmojiValue());
Ui::Emoji::SuggestionsController::Init( Ui::Emoji::SuggestionsController::Init(
getDelegate()->outerContainer(), getDelegate()->outerContainer(),
text, text,
@ -289,7 +290,7 @@ void InitMessageField(
field->customTab(true); field->customTab(true);
field->setInstantReplaces(Ui::InstantReplaces::Default()); field->setInstantReplaces(Ui::InstantReplaces::Default());
field->setInstantReplacesEnabled( field->setInstantReplacesEnabled(
controller->session().settings().replaceEmojiValue()); Core::App().settings().replaceEmojiValue());
field->setMarkdownReplacesEnabled(rpl::single(true)); field->setMarkdownReplacesEnabled(rpl::single(true));
field->setEditLinkCallback(DefaultEditLinkCallback(controller, field)); field->setEditLinkCallback(DefaultEditLinkCallback(controller, field));
} }
@ -300,7 +301,7 @@ void InitSpellchecker(
#ifndef TDESKTOP_DISABLE_SPELLCHECK #ifndef TDESKTOP_DISABLE_SPELLCHECK
const auto s = Ui::CreateChild<Spellchecker::SpellingHighlighter>( const auto s = Ui::CreateChild<Spellchecker::SpellingHighlighter>(
field.get(), field.get(),
controller->session().settings().spellcheckerEnabledValue(), Core::App().settings().spellcheckerEnabledValue(),
Spellchecker::SpellingHighlighter::CustomContextMenuItem{ Spellchecker::SpellingHighlighter::CustomContextMenuItem{
tr::lng_settings_manage_dictionaries(tr::now), tr::lng_settings_manage_dictionaries(tr::now),
[=] { Ui::show(Box<Ui::ManageDictionariesBox>(controller)); } [=] { Ui::show(Box<Ui::ManageDictionariesBox>(controller)); }

View file

@ -15,11 +15,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_instance.h" #include "lang/lang_instance.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "spellcheck/platform/platform_spellcheck.h" #include "spellcheck/platform/platform_spellcheck.h"
#include "spellcheck/spellcheck_utils.h" #include "spellcheck/spellcheck_utils.h"
#include "spellcheck/spellcheck_value.h" #include "spellcheck/spellcheck_value.h"
#include "core/application.h"
#include "core/core_settings.h"
#include <QtGui/QGuiApplication> #include <QtGui/QGuiApplication>
#include <QtGui/QInputMethod> #include <QtGui/QInputMethod>
@ -143,11 +144,11 @@ void DownloadDictionaryInBackground(
BackgroundLoaderChanged.fire(0); BackgroundLoaderChanged.fire(0);
if (DictionaryExists(id)) { if (DictionaryExists(id)) {
auto dicts = session->settings().dictionariesEnabled(); auto dicts = Core::App().settings().dictionariesEnabled();
if (!ranges::contains(dicts, id)) { if (!ranges::contains(dicts, id)) {
dicts.push_back(id); dicts.push_back(id);
session->settings().setDictionariesEnabled(std::move(dicts)); Core::App().settings().setDictionariesEnabled(std::move(dicts));
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
} }
} }
@ -317,13 +318,13 @@ rpl::producer<QString> ButtonManageDictsState(
return rpl::single(QString()); return rpl::single(QString());
} }
const auto computeString = [=] { const auto computeString = [=] {
if (!session->settings().spellcheckerEnabled()) { if (!Core::App().settings().spellcheckerEnabled()) {
return QString(); return QString();
} }
if (!session->settings().dictionariesEnabled().size()) { if (!Core::App().settings().dictionariesEnabled().size()) {
return QString(); return QString();
} }
const auto dicts = session->settings().dictionariesEnabled(); const auto dicts = Core::App().settings().dictionariesEnabled();
const auto filtered = ranges::view::all( const auto filtered = ranges::view::all(
dicts dicts
) | ranges::views::filter( ) | ranges::views::filter(
@ -341,9 +342,9 @@ rpl::producer<QString> ButtonManageDictsState(
) | rpl::then( ) | rpl::then(
rpl::merge( rpl::merge(
Spellchecker::SupportedScriptsChanged(), Spellchecker::SupportedScriptsChanged(),
session->settings().dictionariesEnabledChanges( Core::App().settings().dictionariesEnabledChanges(
) | rpl::map(emptyValue), ) | rpl::map(emptyValue),
session->settings().spellcheckerEnabledChanges( Core::App().settings().spellcheckerEnabledChanges(
) | rpl::map(emptyValue) ) | rpl::map(emptyValue)
) | rpl::map(computeString) ) | rpl::map(computeString)
); );
@ -377,7 +378,7 @@ void Start(not_null<Main::Session*> session) {
{ &ph::lng_spellchecker_remove, tr::lng_spellchecker_remove() }, { &ph::lng_spellchecker_remove, tr::lng_spellchecker_remove() },
{ &ph::lng_spellchecker_ignore, tr::lng_spellchecker_ignore() }, { &ph::lng_spellchecker_ignore, tr::lng_spellchecker_ignore() },
} }); } });
const auto settings = &session->settings(); const auto settings = &Core::App().settings();
const auto onEnabled = [=](auto enabled) { const auto onEnabled = [=](auto enabled) {
Platform::Spellchecker::UpdateLanguages( Platform::Spellchecker::UpdateLanguages(

View file

@ -13,10 +13,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_isolated_emoji.h" #include "ui/text/text_isolated_emoji.h"
#include "ui/image/image.h" #include "ui/image/image.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "data/data_file_origin.h" #include "data/data_file_origin.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_document.h" #include "data/data_document.h"
#include "core/core_settings.h"
#include "core/application.h"
#include "base/call_delayed.h" #include "base/call_delayed.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "app.h" #include "app.h"
@ -209,7 +210,7 @@ QSize LargeEmojiImage::Size() {
EmojiPack::EmojiPack(not_null<Main::Session*> session) EmojiPack::EmojiPack(not_null<Main::Session*> session)
: _session(session) : _session(session)
, _imageLoader(prepareSourceImages(), session->settings().largeEmoji()) , _imageLoader(prepareSourceImages(), Core::App().settings().largeEmoji())
, _clearTimer([=] { clearSourceImages(); }) { , _clearTimer([=] { clearSourceImages(); }) {
refresh(); refresh();
@ -220,7 +221,7 @@ EmojiPack::EmojiPack(not_null<Main::Session*> session)
remove(item); remove(item);
}, _lifetime); }, _lifetime);
_session->settings().largeEmojiChanges( Core::App().settings().largeEmojiChanges(
) | rpl::start_with_next([=](bool large) { ) | rpl::start_with_next([=](bool large) {
if (large) { if (large) {
_clearTimer.cancel(); _clearTimer.cancel();
@ -392,7 +393,7 @@ void EmojiPack::refreshItems(
auto EmojiPack::prepareSourceImages() auto EmojiPack::prepareSourceImages()
-> std::shared_ptr<Ui::Emoji::UniversalImages> { -> std::shared_ptr<Ui::Emoji::UniversalImages> {
const auto &images = Ui::Emoji::SourceImages(); const auto &images = Ui::Emoji::SourceImages();
if (_session->settings().largeEmoji()) { if (Core::App().settings().largeEmoji()) {
return images; return images;
} }
Ui::Emoji::ClearSourceImages(images); Ui::Emoji::ClearSourceImages(images);

View file

@ -36,7 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwidget.h" #include "mainwidget.h"
#include "core/file_utilities.h" #include "core/file_utilities.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_accounts.h" #include "main/main_domain.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "media/view/media_view_overlay_widget.h" #include "media/view/media_view_overlay_widget.h"
#include "mtproto/mtproto_dc_options.h" #include "mtproto/mtproto_dc_options.h"
@ -56,7 +56,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/emoji_config.h" #include "ui/emoji_config.h"
#include "ui/effects/animations.h" #include "ui/effects/animations.h"
#include "storage/serialize_common.h" #include "storage/serialize_common.h"
#include "storage/storage_accounts.h" #include "storage/storage_domain.h"
#include "storage/storage_databases.h" #include "storage/storage_databases.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
@ -98,7 +98,7 @@ Application::Application(not_null<Launcher*> launcher)
, _animationsManager(std::make_unique<Ui::Animations::Manager>()) , _animationsManager(std::make_unique<Ui::Animations::Manager>())
, _fallbackProductionConfig( , _fallbackProductionConfig(
std::make_unique<MTP::Config>(MTP::Environment::Production)) std::make_unique<MTP::Config>(MTP::Environment::Production))
, _accounts(std::make_unique<Main::Accounts>(cDataFile())) , _domain(std::make_unique<Main::Domain>(cDataFile()))
, _langpack(std::make_unique<Lang::Instance>()) , _langpack(std::make_unique<Lang::Instance>())
, _langCloudManager(std::make_unique<Lang::CloudManager>(langpack())) , _langCloudManager(std::make_unique<Lang::CloudManager>(langpack()))
, _emojiKeywords(std::make_unique<ChatHelpers::EmojiKeywords>()) , _emojiKeywords(std::make_unique<ChatHelpers::EmojiKeywords>())
@ -116,14 +116,14 @@ Application::Application(not_null<Launcher*> launcher)
_shouldLockAt = 0; _shouldLockAt = 0;
}, _lifetime); }, _lifetime);
accounts().activeSessionChanges( _domain->activeSessionChanges(
) | rpl::start_with_next([=](Main::Session *session) { ) | rpl::start_with_next([=](Main::Session *session) {
if (session && !UpdaterDisabled()) { // #TODO multi someSessionValue if (session && !UpdaterDisabled()) { // #TODO multi someSessionValue
UpdateChecker().setMtproto(session); UpdateChecker().setMtproto(session);
} }
}, _lifetime); }, _lifetime);
accounts().activeValue( _domain->activeValue(
) | rpl::filter(rpl::mappers::_1 != nullptr ) | rpl::filter(rpl::mappers::_1 != nullptr
) | rpl::take(1) | rpl::start_with_next([=] { ) | rpl::take(1) | rpl::start_with_next([=] {
if (_window) { if (_window) {
@ -147,7 +147,7 @@ Application::~Application() {
} }
unlockTerms(); unlockTerms();
accounts().finish(); _domain->finish();
Local::finish(); Local::finish();
@ -220,7 +220,7 @@ void Application::run() {
QMimeDatabase().mimeTypeForName(qsl("text/plain")); QMimeDatabase().mimeTypeForName(qsl("text/plain"));
_window = std::make_unique<Window::Controller>(); _window = std::make_unique<Window::Controller>();
accounts().activeChanges( _domain->activeChanges(
) | rpl::start_with_next([=](not_null<Main::Account*> account) { ) | rpl::start_with_next([=](not_null<Main::Account*> account) {
_window->showAccount(account); _window->showAccount(account);
}, _window->widget()->lifetime()); }, _window->widget()->lifetime());
@ -239,7 +239,7 @@ void Application::run() {
App::initMedia(); App::initMedia();
const auto state = accounts().start(QByteArray()); const auto state = _domain->start(QByteArray());
if (state == Storage::StartResult::IncorrectPasscode) { if (state == Storage::StartResult::IncorrectPasscode) {
Global::SetLocalPasscode(true); Global::SetLocalPasscode(true);
Global::RefLocalPasscodeChanged().notify(); Global::RefLocalPasscodeChanged().notify();
@ -390,6 +390,10 @@ void Application::saveSettingsDelayed(crl::time delay) {
_saveSettingsTimer.callOnce(delay); _saveSettingsTimer.callOnce(delay);
} }
void Application::saveSettings() {
Local::writeSettings();
}
MTP::Config &Application::fallbackProductionConfig() const { MTP::Config &Application::fallbackProductionConfig() const {
if (!_fallbackProductionConfig) { if (!_fallbackProductionConfig) {
_fallbackProductionConfig = std::make_unique<MTP::Config>( _fallbackProductionConfig = std::make_unique<MTP::Config>(
@ -451,14 +455,14 @@ void Application::badMtprotoConfigurationError() {
void Application::startLocalStorage() { void Application::startLocalStorage() {
Local::start(); Local::start();
_saveSettingsTimer.setCallback([=] { Local::writeSettings(); }); _saveSettingsTimer.setCallback([=] { saveSettings(); });
} }
void Application::logout(Main::Account *account) { void Application::logout(Main::Account *account) {
if (account) { if (account) {
account->logOut(); account->logOut();
} else { } else {
accounts().resetWithForgottenPasscode(); _domain->resetWithForgottenPasscode();
} }
} }
@ -549,11 +553,11 @@ void Application::writeInstallBetaVersionsSetting() {
} }
Main::Account &Application::activeAccount() const { Main::Account &Application::activeAccount() const {
return _accounts->active(); return _domain->active();
} }
Main::Session *Application::maybeActiveSession() const { Main::Session *Application::maybeActiveSession() const {
return (_accounts->started() && activeAccount().sessionExists()) return (_domain->started() && activeAccount().sessionExists())
? &activeAccount().session() ? &activeAccount().session()
: nullptr; : nullptr;
} }
@ -571,23 +575,24 @@ bool Application::exportPreventsQuit() {
} }
int Application::unreadBadge() const { int Application::unreadBadge() const {
return accounts().unreadBadge(); return _domain->unreadBadge();
} }
bool Application::unreadBadgeMuted() const { bool Application::unreadBadgeMuted() const {
return accounts().unreadBadgeMuted(); return _domain->unreadBadgeMuted();
} }
rpl::producer<> Application::unreadBadgeChanges() const { rpl::producer<> Application::unreadBadgeChanges() const {
return accounts().unreadBadgeChanges(); return _domain->unreadBadgeChanges();
} }
bool Application::offerLegacyLangPackSwitch() const { bool Application::offerLegacyLangPackSwitch() const {
return (accounts().list().size() == 1) && activeAccount().sessionExists(); return (_domain->accounts().size() == 1)
&& activeAccount().sessionExists();
} }
bool Application::canApplyLangPackWithoutRestart() const { bool Application::canApplyLangPackWithoutRestart() const {
for (const auto &[index, account] : accounts().list()) { for (const auto &[index, account] : _domain->accounts()) {
if (account->sessionExists()) { if (account->sessionExists()) {
return false; return false;
} }
@ -687,8 +692,7 @@ void Application::lockByTerms(const Window::TermsLock &data) {
} }
bool Application::someSessionExists() const { bool Application::someSessionExists() const {
const auto &list = _accounts->list(); for (const auto &[index, account] : _domain->accounts()) {
for (const auto &[index, account] : list) {
if (account->sessionExists()) { if (account->sessionExists()) {
return true; return true;
} }
@ -707,7 +711,7 @@ void Application::checkAutoLock() {
checkLocalTime(); checkLocalTime();
const auto now = crl::now(); const auto now = crl::now();
const auto shouldLockInMs = Global::AutoLock() * 1000LL; const auto shouldLockInMs = _settings.autoLock() * 1000LL;
const auto checkTimeMs = now - lastNonIdleTime(); const auto checkTimeMs = now - lastNonIdleTime();
if (checkTimeMs >= shouldLockInMs || (_shouldLockAt > 0 && now > _shouldLockAt + kAutoLockTimeoutLateMs)) { if (checkTimeMs >= shouldLockInMs || (_shouldLockAt > 0 && now > _shouldLockAt + kAutoLockTimeoutLateMs)) {
_shouldLockAt = 0; _shouldLockAt = 0;
@ -828,8 +832,8 @@ void Application::notifyFileDialogShown(bool shown) {
} }
QWidget *Application::getModalParent() { QWidget *Application::getModalParent() {
return Platform::IsWayland() return (Platform::IsWayland() && activeWindow())
? App::wnd() ? activeWindow()->widget()
: nullptr; : nullptr;
} }
@ -918,7 +922,7 @@ void Application::quitDelayed() {
void Application::startShortcuts() { void Application::startShortcuts() {
Shortcuts::Start(); Shortcuts::Start();
_accounts->activeSessionChanges( _domain->activeSessionChanges(
) | rpl::start_with_next([=](Main::Session *session) { ) | rpl::start_with_next([=](Main::Session *session) {
const auto support = session && session->supportMode(); const auto support = session && session->supportMode();
Shortcuts::ToggleSupportShortcuts(support); Shortcuts::ToggleSupportShortcuts(support);

View file

@ -36,7 +36,7 @@ void quit();
} // namespace App } // namespace App
namespace Main { namespace Main {
class Accounts; class Domain;
class Account; class Account;
class Session; class Session;
} // namespace Main } // namespace Main
@ -136,6 +136,7 @@ public:
return _settings; return _settings;
} }
void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay); void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay);
void saveSettings();
// Fallback config and proxy. // Fallback config and proxy.
[[nodiscard]] MTP::Config &fallbackProductionConfig() const; [[nodiscard]] MTP::Config &fallbackProductionConfig() const;
@ -152,9 +153,9 @@ public:
return *_databases; return *_databases;
} }
// Accounts component. // Domain component.
[[nodiscard]] Main::Accounts &accounts() const { [[nodiscard]] Main::Domain &domain() const {
return *_accounts; return *_domain;
} }
[[nodiscard]] Main::Account &activeAccount() const; [[nodiscard]] Main::Account &activeAccount() const;
[[nodiscard]] bool someSessionExists() const; [[nodiscard]] bool someSessionExists() const;
@ -282,7 +283,7 @@ private:
const std::unique_ptr<Storage::Databases> _databases; const std::unique_ptr<Storage::Databases> _databases;
const std::unique_ptr<Ui::Animations::Manager> _animationsManager; const std::unique_ptr<Ui::Animations::Manager> _animationsManager;
mutable std::unique_ptr<MTP::Config> _fallbackProductionConfig; mutable std::unique_ptr<MTP::Config> _fallbackProductionConfig;
const std::unique_ptr<Main::Accounts> _accounts; const std::unique_ptr<Main::Domain> _domain;
std::unique_ptr<Window::Controller> _window; std::unique_ptr<Window::Controller> _window;
std::unique_ptr<Media::View::OverlayWidget> _mediaView; std::unique_ptr<Media::View::OverlayWidget> _mediaView;
const std::unique_ptr<Lang::Instance> _langpack; const std::unique_ptr<Lang::Instance> _langpack;

View file

@ -9,9 +9,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "core/application.h" #include "core/application.h"
#include "main/main_accounts.h" #include "main/main_domain.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "storage/storage_accounts.h" #include "storage/storage_domain.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "apiwrap.h" #include "apiwrap.h"
@ -82,7 +82,7 @@ Changelogs::Changelogs(not_null<Main::Session*> session, int oldVersion)
std::unique_ptr<Changelogs> Changelogs::Create( std::unique_ptr<Changelogs> Changelogs::Create(
not_null<Main::Session*> session) { not_null<Main::Session*> session) {
auto &local = Core::App().accounts().local(); auto &local = Core::App().domain().local();
const auto oldVersion = local.oldVersion(); const auto oldVersion = local.oldVersion();
local.clearOldVersion(); local.clearOldVersion();
return (oldVersion > 0 && oldVersion < AppVersion) return (oldVersion > 0 && oldVersion < AppVersion)

View file

@ -7,45 +7,284 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "core/core_settings.h" #include "core/core_settings.h"
#include "boxes/send_files_box.h"
#include "ui/widgets/input_fields.h"
#include "storage/serialize_common.h" #include "storage/serialize_common.h"
#include "facades.h"
namespace Core { namespace Core {
Settings::Variables::Variables() { Settings::Settings()
: _sendFilesWay(SendFilesWay::Album)
, _sendSubmitWay(Ui::InputSubmitSettings::Enter) {
} }
QByteArray Settings::serialize() const { QByteArray Settings::serialize() const {
const auto themesAccentColors = _variables.themesAccentColors.serialize(); const auto themesAccentColors = _themesAccentColors.serialize();
auto size = Serialize::bytearraySize(themesAccentColors); auto size = Serialize::bytearraySize(themesAccentColors)
+ sizeof(qint32) * 5
+ Serialize::stringSize(_downloadPath.current())
+ Serialize::bytearraySize(_downloadPathBookmark)
+ sizeof(qint32) * 12
+ Serialize::stringSize(_callOutputDeviceID)
+ Serialize::stringSize(_callInputDeviceID)
+ sizeof(qint32) * 3;
for (const auto &[key, value] : _soundOverrides) {
size += Serialize::stringSize(key) + Serialize::stringSize(value);
}
size += Serialize::bytearraySize(_videoPipGeometry);
auto result = QByteArray(); auto result = QByteArray();
result.reserve(size); result.reserve(size);
{ {
QDataStream stream(&result, QIODevice::WriteOnly); QDataStream stream(&result, QIODevice::WriteOnly);
stream.setVersion(QDataStream::Qt_5_1); stream.setVersion(QDataStream::Qt_5_1);
stream << themesAccentColors; stream
<< themesAccentColors
<< qint32(_adaptiveForWide ? 1 : 0)
<< qint32(_moderateModeEnabled ? 1 : 0)
<< qint32(qRound(_songVolume.current() * 1e6))
<< qint32(qRound(_videoVolume.current() * 1e6))
<< qint32(_askDownloadPath ? 1 : 0)
<< _downloadPath.current()
<< _downloadPathBookmark
<< qint32(_voiceMsgPlaybackDoubled ? 1 : 0)
<< qint32(_soundNotify ? 1 : 0)
<< qint32(_desktopNotify ? 1 : 0)
<< qint32(_flashBounceNotify ? 1 : 0)
<< static_cast<qint32>(_notifyView)
<< qint32(_nativeNotifications ? 1 : 0)
<< qint32(_notificationsCount)
<< static_cast<qint32>(_notificationsCorner)
<< qint32(_autoLock)
<< _callOutputDeviceID
<< _callInputDeviceID
<< qint32(_callOutputVolume)
<< qint32(_callInputVolume)
<< qint32(_callAudioDuckingEnabled ? 1 : 0)
<< qint32(_lastSeenWarningSeen ? 1 : 0)
<< qint32(_soundOverrides.size());
for (const auto &[key, value] : _soundOverrides) {
stream << key << value;
}
stream
<< qint32(_sendFilesWay)
<< qint32(_sendSubmitWay)
<< qint32(_includeMutedCounter ? 1 : 0)
<< qint32(_countUnreadMessages ? 1 : 0)
<< qint32(_exeLaunchWarning ? 1 : 0)
<< qint32(_notifyAboutPinned.current() ? 1 : 0)
<< qint32(_loopAnimatedStickers ? 1 : 0)
<< qint32(_largeEmoji.current() ? 1 : 0)
<< qint32(_replaceEmoji.current() ? 1 : 0)
<< qint32(_suggestEmoji ? 1 : 0)
<< qint32(_suggestStickersByEmoji ? 1 : 0)
<< qint32(_spellcheckerEnabled.current() ? 1 : 0)
<< qint32(SerializePlaybackSpeed(_videoPlaybackSpeed.current()))
<< _videoPipGeometry
<< qint32(_dictionariesEnabled.current().size());
for (const auto i : _dictionariesEnabled.current()) {
stream << quint64(i);
}
stream
<< qint32(_autoDownloadDictionaries.current() ? 1 : 0);
} }
return result; return result;
} }
void Settings::constructFromSerialized(const QByteArray &serialized) { void Settings::addFromSerialized(const QByteArray &serialized) {
if (serialized.isEmpty()) { if (serialized.isEmpty()) {
return; return;
} }
QDataStream stream(serialized); QDataStream stream(serialized);
stream.setVersion(QDataStream::Qt_5_1); stream.setVersion(QDataStream::Qt_5_1);
QByteArray themesAccentColors; QByteArray themesAccentColors;
qint32 adaptiveForWide = _adaptiveForWide ? 1 : 0;
qint32 moderateModeEnabled = _moderateModeEnabled ? 1 : 0;
qint32 songVolume = qint32(qRound(_songVolume.current() * 1e6));
qint32 videoVolume = qint32(qRound(_videoVolume.current() * 1e6));
qint32 askDownloadPath = _askDownloadPath ? 1 : 0;
QString downloadPath = _downloadPath.current();
QByteArray downloadPathBookmark = _downloadPathBookmark;
qint32 voiceMsgPlaybackDoubled = _voiceMsgPlaybackDoubled ? 1 : 0;
qint32 soundNotify = _soundNotify ? 1 : 0;
qint32 desktopNotify = _desktopNotify ? 1 : 0;
qint32 flashBounceNotify = _flashBounceNotify ? 1 : 0;
qint32 notifyView = static_cast<qint32>(_notifyView);
qint32 nativeNotifications = _nativeNotifications ? 1 : 0;
qint32 notificationsCount = _notificationsCount;
qint32 notificationsCorner = static_cast<qint32>(_notificationsCorner);
qint32 autoLock = _autoLock;
QString callOutputDeviceID = _callOutputDeviceID;
QString callInputDeviceID = _callInputDeviceID;
qint32 callOutputVolume = _callOutputVolume;
qint32 callInputVolume = _callInputVolume;
qint32 callAudioDuckingEnabled = _callAudioDuckingEnabled ? 1 : 0;
qint32 lastSeenWarningSeen = _lastSeenWarningSeen ? 1 : 0;
qint32 soundOverridesCount = 0;
base::flat_map<QString, QString> soundOverrides;
qint32 sendFilesWay = static_cast<qint32>(_sendFilesWay);
qint32 sendSubmitWay = static_cast<qint32>(_sendSubmitWay);
qint32 includeMutedCounter = _includeMutedCounter ? 1 : 0;
qint32 countUnreadMessages = _countUnreadMessages ? 1 : 0;
qint32 exeLaunchWarning = _exeLaunchWarning ? 1 : 0;
qint32 notifyAboutPinned = _notifyAboutPinned.current() ? 1 : 0;
qint32 loopAnimatedStickers = _loopAnimatedStickers ? 1 : 0;
qint32 largeEmoji = _largeEmoji.current() ? 1 : 0;
qint32 replaceEmoji = _replaceEmoji.current() ? 1 : 0;
qint32 suggestEmoji = _suggestEmoji ? 1 : 0;
qint32 suggestStickersByEmoji = _suggestStickersByEmoji ? 1 : 0;
qint32 spellcheckerEnabled = _spellcheckerEnabled.current() ? 1 : 0;
qint32 videoPlaybackSpeed = Core::Settings::SerializePlaybackSpeed(_videoPlaybackSpeed.current());
QByteArray videoPipGeometry = _videoPipGeometry;
qint32 dictionariesEnabledCount = 0;
std::vector<int> dictionariesEnabled;
qint32 autoDownloadDictionaries = _autoDownloadDictionaries.current() ? 1 : 0;
stream >> themesAccentColors; stream >> themesAccentColors;
if (!stream.atEnd()) {
stream
>> adaptiveForWide
>> moderateModeEnabled
>> songVolume
>> videoVolume
>> askDownloadPath
>> downloadPath
>> downloadPathBookmark
>> voiceMsgPlaybackDoubled
>> soundNotify
>> desktopNotify
>> flashBounceNotify
>> notifyView
>> nativeNotifications
>> notificationsCount
>> notificationsCorner
>> autoLock
>> callOutputDeviceID
>> callInputDeviceID
>> callOutputVolume
>> callInputVolume
>> callAudioDuckingEnabled
>> lastSeenWarningSeen
>> soundOverridesCount;
if (stream.status() == QDataStream::Ok) {
for (auto i = 0; i != soundOverridesCount; ++i) {
QString key, value;
stream >> key >> value;
soundOverrides.emplace(key, value);
}
}
stream
>> sendFilesWay
>> sendSubmitWay
>> includeMutedCounter
>> countUnreadMessages
>> exeLaunchWarning
>> notifyAboutPinned
>> loopAnimatedStickers
>> largeEmoji
>> replaceEmoji
>> suggestEmoji
>> suggestStickersByEmoji
>> spellcheckerEnabled
>> videoPlaybackSpeed
>> videoPipGeometry
>> dictionariesEnabledCount;
if (stream.status() == QDataStream::Ok) {
for (auto i = 0; i != dictionariesEnabledCount; ++i) {
qint64 langId;
stream >> langId;
dictionariesEnabled.emplace_back(langId);
}
}
stream
>> autoDownloadDictionaries;
}
if (stream.status() != QDataStream::Ok) { if (stream.status() != QDataStream::Ok) {
LOG(("App Error: " LOG(("App Error: "
"Bad data for Core::Settings::constructFromSerialized()")); "Bad data for Core::Settings::constructFromSerialized()"));
return; return;
} } else if (!_themesAccentColors.setFromSerialized(themesAccentColors)) {
if (!_variables.themesAccentColors.setFromSerialized(themesAccentColors)) {
return; return;
} }
_adaptiveForWide = (adaptiveForWide == 1);
_moderateModeEnabled = (moderateModeEnabled == 1);
_songVolume = std::clamp(songVolume / 1e6, 0., 1.);
_videoVolume = std::clamp(videoVolume / 1e6, 0., 1.);
_askDownloadPath = (askDownloadPath == 1);
_downloadPath = downloadPath;
_downloadPathBookmark = downloadPathBookmark;
_voiceMsgPlaybackDoubled = (voiceMsgPlaybackDoubled == 1);
_soundNotify = (soundNotify == 1);
_desktopNotify = (desktopNotify == 1);
_flashBounceNotify = (flashBounceNotify == 1);
const auto uncheckedNotifyView = static_cast<DBINotifyView>(notifyView);
switch (uncheckedNotifyView) {
case dbinvShowNothing:
case dbinvShowName:
case dbinvShowPreview: _notifyView = uncheckedNotifyView; break;
}
_nativeNotifications = (nativeNotifications == 1);
_notificationsCount = (notificationsCount > 0) ? notificationsCount : 3;
const auto uncheckedNotificationsCorner = static_cast<ScreenCorner>(notificationsCorner);
switch (uncheckedNotificationsCorner) {
case ScreenCorner::TopLeft:
case ScreenCorner::TopRight:
case ScreenCorner::BottomRight:
case ScreenCorner::BottomLeft: _notificationsCorner = uncheckedNotificationsCorner; break;
}
_includeMutedCounter = (includeMutedCounter == 1);
_countUnreadMessages = (countUnreadMessages == 1);
_notifyAboutPinned = (notifyAboutPinned == 1);
_autoLock = autoLock;
_callOutputDeviceID = callOutputDeviceID;
_callInputDeviceID = callInputDeviceID;
_callOutputVolume = callOutputVolume;
_callInputVolume = callInputVolume;
_callAudioDuckingEnabled = (callAudioDuckingEnabled == 1);
_lastSeenWarningSeen = (lastSeenWarningSeen == 1);
_soundOverrides = std::move(soundOverrides);
auto uncheckedSendFilesWay = static_cast<SendFilesWay>(sendFilesWay);
switch (uncheckedSendFilesWay) {
case SendFilesWay::Album:
case SendFilesWay::Photos:
case SendFilesWay::Files: _sendFilesWay = uncheckedSendFilesWay; break;
}
auto uncheckedSendSubmitWay = static_cast<Ui::InputSubmitSettings>(sendSubmitWay);
switch (uncheckedSendSubmitWay) {
case Ui::InputSubmitSettings::Enter:
case Ui::InputSubmitSettings::CtrlEnter: _sendSubmitWay = uncheckedSendSubmitWay; break;
}
_includeMutedCounter = (includeMutedCounter == 1);
_countUnreadMessages = (countUnreadMessages == 1);
_exeLaunchWarning = (exeLaunchWarning == 1);
_notifyAboutPinned = (notifyAboutPinned == 1);
_loopAnimatedStickers = (loopAnimatedStickers == 1);
_largeEmoji = (largeEmoji == 1);
_replaceEmoji = (replaceEmoji == 1);
_suggestEmoji = (suggestEmoji == 1);
_suggestStickersByEmoji = (suggestStickersByEmoji == 1);
_spellcheckerEnabled = (spellcheckerEnabled == 1);
_videoPlaybackSpeed = DeserializePlaybackSpeed(videoPlaybackSpeed);
_videoPipGeometry = (videoPipGeometry);
_dictionariesEnabled = std::move(dictionariesEnabled);
_autoDownloadDictionaries = (autoDownloadDictionaries == 1);
}
bool Settings::chatWide() const {
return _adaptiveForWide
&& (Global::AdaptiveChatLayout() == Adaptive::ChatLayout::Wide);
}
QString Settings::getSoundPath(const QString &key) const {
auto it = _soundOverrides.find(key);
if (it != _soundOverrides.end()) {
return it->second;
}
return qsl(":/sounds/") + key + qsl(".mp3");
} }
} // namespace Core } // namespace Core

View file

@ -9,32 +9,408 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/themes/window_themes_embedded.h" #include "window/themes/window_themes_embedded.h"
enum class SendFilesWay;
namespace Ui {
enum class InputSubmitSettings;
} // namespace Ui
namespace Core { namespace Core {
class Settings final { class Settings final {
public: public:
void moveFrom(Settings &&other) { enum class ScreenCorner {
_variables = std::move(other._variables); TopLeft = 0,
} TopRight = 1,
[[nodiscard]] QByteArray serialize() const; BottomRight = 2,
void constructFromSerialized(const QByteArray &serialized); BottomLeft = 3,
};
void setThemesAccentColors(Window::Theme::AccentColors &&colors) { static constexpr auto kDefaultVolume = 0.9;
_variables.themesAccentColors = std::move(colors);
Settings();
[[nodiscard]] static bool IsLeftCorner(ScreenCorner corner) {
return (corner == ScreenCorner::TopLeft)
|| (corner == ScreenCorner::BottomLeft);
}
[[nodiscard]] static bool IsTopCorner(ScreenCorner corner) {
return (corner == ScreenCorner::TopLeft)
|| (corner == ScreenCorner::TopRight);
}
[[nodiscard]] QByteArray serialize() const;
void addFromSerialized(const QByteArray &serialized);
[[nodiscard]] bool chatWide() const;
[[nodiscard]] bool adaptiveForWide() const {
return _adaptiveForWide;
}
void setAdaptiveForWide(bool value) {
_adaptiveForWide = value;
}
[[nodiscard]] bool moderateModeEnabled() const {
return _moderateModeEnabled;
}
void setModerateModeEnabled(bool value) {
_moderateModeEnabled = value;
}
[[nodiscard]] float64 songVolume() const {
return _songVolume.current();
}
[[nodiscard]] rpl::producer<float64> songVolumeChanges() const {
return _songVolume.changes();
}
void setSongVolume(float64 value) {
_songVolume = value;
}
[[nodiscard]] float64 videoVolume() const {
return _videoVolume.current();
}
[[nodiscard]] rpl::producer<float64> videoVolumeChanges() const {
return _videoVolume.changes();
}
void setVideoVolume(float64 value) {
_videoVolume = value;
}
[[nodiscard]] bool askDownloadPath() const {
return _askDownloadPath;
}
void setAskDownloadPath(bool value) {
_askDownloadPath = value;
}
[[nodiscard]] QString downloadPath() const {
return _downloadPath.current();
}
[[nodiscard]] rpl::producer<QString> downloadPathValue() const {
return _downloadPath.value();
}
void setDownloadPath(const QString &value) {
_downloadPath = value;
}
[[nodiscard]] QByteArray downloadPathBookmark() const {
return _downloadPathBookmark;
}
void setDownloadPathBookmark(const QByteArray &value) {
_downloadPathBookmark = value;
}
[[nodiscard]] bool voiceMsgPlaybackDoubled() const {
return _voiceMsgPlaybackDoubled;
}
void setVoiceMsgPlaybackDoubled(bool value) {
_voiceMsgPlaybackDoubled = value;
}
[[nodiscard]] bool soundNotify() const {
return _soundNotify;
}
void setSoundNotify(bool value) {
_soundNotify = value;
}
[[nodiscard]] bool desktopNotify() const {
return _desktopNotify;
}
void setDesktopNotify(bool value) {
_desktopNotify = value;
}
[[nodiscard]] bool flashBounceNotify() const {
return _flashBounceNotify;
}
void setFlashBounceNotify(bool value) {
_flashBounceNotify = value;
}
[[nodiscard]] DBINotifyView notifyView() const {
return _notifyView;
}
void setNotifyView(DBINotifyView value) {
_notifyView = value;
}
[[nodiscard]] bool nativeNotifications() const {
return _nativeNotifications;
}
void setNativeNotifications(bool value) {
_nativeNotifications = value;
}
[[nodiscard]] int notificationsCount() const {
return _notificationsCount;
}
void setNotificationsCount(int value) {
_notificationsCount = value;
}
[[nodiscard]] ScreenCorner notificationsCorner() const {
return _notificationsCorner;
}
void setNotificationsCorner(ScreenCorner corner) {
_notificationsCorner = corner;
}
[[nodiscard]] bool includeMutedCounter() const {
return _includeMutedCounter;
}
void setIncludeMutedCounter(bool value) {
_includeMutedCounter = value;
}
[[nodiscard]] bool countUnreadMessages() const {
return _countUnreadMessages;
}
void setCountUnreadMessages(bool value) {
_countUnreadMessages = value;
}
void setNotifyAboutPinned(bool notify) {
_notifyAboutPinned = notify;
}
[[nodiscard]] bool notifyAboutPinned() const {
return _notifyAboutPinned.current();
}
[[nodiscard]] rpl::producer<bool> notifyAboutPinnedChanges() const {
return _notifyAboutPinned.changes();
}
[[nodiscard]] int autoLock() const {
return _autoLock;
}
void setAutoLock(int value) {
_autoLock = value;
}
[[nodiscard]] QString callOutputDeviceID() const {
return _callOutputDeviceID;
}
void setCallOutputDeviceID(const QString &value) {
_callOutputDeviceID = value;
}
[[nodiscard]] QString callInputDeviceID() const {
return _callInputDeviceID;
}
void setCallInputDeviceID(const QString &value) {
_callInputDeviceID = value;
}
[[nodiscard]] int callOutputVolume() const {
return _callOutputVolume;
}
void setCallOutputVolume(int value) {
_callOutputVolume = value;
}
[[nodiscard]] int callInputVolume() const {
return _callInputVolume;
}
void setCallInputVolume(int value) {
_callInputVolume = value;
}
[[nodiscard]] bool callAudioDuckingEnabled() const {
return _callAudioDuckingEnabled;
}
void setCallAudioDuckingEnabled(bool value) {
_callAudioDuckingEnabled = value;
} }
[[nodiscard]] Window::Theme::AccentColors &themesAccentColors() { [[nodiscard]] Window::Theme::AccentColors &themesAccentColors() {
return _variables.themesAccentColors; return _themesAccentColors;
}
void setThemesAccentColors(Window::Theme::AccentColors &&colors) {
_themesAccentColors = std::move(colors);
}
void setLastSeenWarningSeen(bool lastSeenWarningSeen) {
_lastSeenWarningSeen = lastSeenWarningSeen;
}
[[nodiscard]] bool lastSeenWarningSeen() const {
return _lastSeenWarningSeen;
}
void setSendFilesWay(SendFilesWay way) {
_sendFilesWay = way;
}
[[nodiscard]] SendFilesWay sendFilesWay() const {
return _sendFilesWay;
}
void setSendSubmitWay(Ui::InputSubmitSettings value) {
_sendSubmitWay = value;
}
[[nodiscard]] Ui::InputSubmitSettings sendSubmitWay() const {
return _sendSubmitWay;
}
void setSoundOverride(const QString &key, const QString &path) {
_soundOverrides.emplace(key, path);
}
void clearSoundOverrides() {
_soundOverrides.clear();
}
[[nodiscard]] QString getSoundPath(const QString &key) const;
[[nodiscard]] bool exeLaunchWarning() const {
return _exeLaunchWarning;
}
void setExeLaunchWarning(bool warning) {
_exeLaunchWarning = warning;
}
[[nodiscard]] bool loopAnimatedStickers() const {
return _loopAnimatedStickers;
}
void setLoopAnimatedStickers(bool value) {
_loopAnimatedStickers = value;
}
void setLargeEmoji(bool value) {
_largeEmoji = value;
}
[[nodiscard]] bool largeEmoji() const {
return _largeEmoji.current();
}
[[nodiscard]] rpl::producer<bool> largeEmojiValue() const {
return _largeEmoji.value();
}
[[nodiscard]] rpl::producer<bool> largeEmojiChanges() const {
return _largeEmoji.changes();
}
void setReplaceEmoji(bool value) {
_replaceEmoji = value;
}
[[nodiscard]] bool replaceEmoji() const {
return _replaceEmoji.current();
}
[[nodiscard]] rpl::producer<bool> replaceEmojiValue() const {
return _replaceEmoji.value();
}
[[nodiscard]] rpl::producer<bool> replaceEmojiChanges() const {
return _replaceEmoji.changes();
}
[[nodiscard]] bool suggestEmoji() const {
return _suggestEmoji;
}
void setSuggestEmoji(bool value) {
_suggestEmoji = value;
}
[[nodiscard]] bool suggestStickersByEmoji() const {
return _suggestStickersByEmoji;
}
void setSuggestStickersByEmoji(bool value) {
_suggestStickersByEmoji = value;
}
void setSpellcheckerEnabled(bool value) {
_spellcheckerEnabled = value;
}
bool spellcheckerEnabled() const {
return _spellcheckerEnabled.current();
}
rpl::producer<bool> spellcheckerEnabledValue() const {
return _spellcheckerEnabled.value();
}
rpl::producer<bool> spellcheckerEnabledChanges() const {
return _spellcheckerEnabled.changes();
}
void setDictionariesEnabled(std::vector<int> dictionaries) {
_dictionariesEnabled = std::move(dictionaries);
}
std::vector<int> dictionariesEnabled() const {
return _dictionariesEnabled.current();
}
rpl::producer<std::vector<int>> dictionariesEnabledChanges() const {
return _dictionariesEnabled.changes();
}
void setAutoDownloadDictionaries(bool value) {
_autoDownloadDictionaries = value;
}
bool autoDownloadDictionaries() const {
return _autoDownloadDictionaries.current();
}
rpl::producer<bool> autoDownloadDictionariesValue() const {
return _autoDownloadDictionaries.value();
}
rpl::producer<bool> autoDownloadDictionariesChanges() const {
return _autoDownloadDictionaries.changes();
}
[[nodiscard]] float64 videoPlaybackSpeed() const {
return _videoPlaybackSpeed.current();
}
void setVideoPlaybackSpeed(float64 speed) {
_videoPlaybackSpeed = speed;
}
[[nodiscard]] QByteArray videoPipGeometry() const {
return _videoPipGeometry;
}
void setVideoPipGeometry(QByteArray geometry) {
_videoPipGeometry = geometry;
}
[[nodiscard]] float64 rememberedSongVolume() const {
return _rememberedSongVolume;
}
void setRememberedSongVolume(float64 value) {
_rememberedSongVolume = value;
}
[[nodiscard]] bool rememberedSoundNotifyFromTray() const {
return _rememberedSoundNotifyFromTray;
}
void setRememberedSoundNotifyFromTray(bool value) {
_rememberedSoundNotifyFromTray = value;
}
[[nodiscard]] bool rememberedFlashBounceNotifyFromTray() const {
return _rememberedFlashBounceNotifyFromTray;
}
void setRememberedFlashBounceNotifyFromTray(bool value) {
_rememberedFlashBounceNotifyFromTray = value;
}
[[nodiscard]] static qint32 SerializePlaybackSpeed(float64 speed) {
return int(std::round(std::clamp(speed * 4., 2., 8.))) - 2;
}
[[nodiscard]] static float64 DeserializePlaybackSpeed(qint32 speed) {
return (std::clamp(speed, 0, 6) + 2) / 4.;
} }
private: private:
struct Variables { bool _adaptiveForWide = true;
Variables(); bool _moderateModeEnabled = false;
Window::Theme::AccentColors themesAccentColors; rpl::variable<float64> _songVolume = kDefaultVolume;
}; rpl::variable<float64> _videoVolume = kDefaultVolume;
Variables _variables; bool _askDownloadPath = false;
rpl::variable<QString> _downloadPath;
QByteArray _downloadPathBookmark;
bool _voiceMsgPlaybackDoubled = false;
bool _soundNotify = true;
bool _desktopNotify = true;
bool _flashBounceNotify = true;
DBINotifyView _notifyView = dbinvShowPreview;
bool _nativeNotifications = false;
int _notificationsCount = 3;
ScreenCorner _notificationsCorner = ScreenCorner::BottomRight;
bool _includeMutedCounter = true;
bool _countUnreadMessages = true;
rpl::variable<bool> _notifyAboutPinned = true;
int _autoLock = 3600;
QString _callOutputDeviceID = u"default"_q;
QString _callInputDeviceID = u"default"_q;
int _callOutputVolume = 100;
int _callInputVolume = 100;
bool _callAudioDuckingEnabled = true;
Window::Theme::AccentColors _themesAccentColors;
bool _lastSeenWarningSeen = false;
SendFilesWay _sendFilesWay;
Ui::InputSubmitSettings _sendSubmitWay;
base::flat_map<QString, QString> _soundOverrides;
bool _exeLaunchWarning = true;
bool _loopAnimatedStickers = true;
rpl::variable<bool> _largeEmoji = true;
rpl::variable<bool> _replaceEmoji = true;
bool _suggestEmoji = true;
bool _suggestStickersByEmoji = true;
rpl::variable<bool> _spellcheckerEnabled = true;
rpl::variable<float64> _videoPlaybackSpeed = 1.;
QByteArray _videoPipGeometry;
rpl::variable<std::vector<int>> _dictionariesEnabled;
rpl::variable<bool> _autoDownloadDictionaries = true;
float64 _rememberedSongVolume = kDefaultVolume;
bool _rememberedSoundNotifyFromTray = false;
bool _rememberedFlashBounceNotifyFromTray = false;
}; };
} // namespace Core } // namespace Core

View file

@ -16,7 +16,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/update_checker.h" #include "core/update_checker.h"
#include "core/sandbox.h" #include "core/sandbox.h"
#include "base/concurrent_timer.h" #include "base/concurrent_timer.h"
#include "facades.h"
namespace Core { namespace Core {
namespace { namespace {

View file

@ -59,9 +59,12 @@ bool JoinGroupByHash(
})); }));
}, [=](const MTPDchatInviteAlready &data) { }, [=](const MTPDchatInviteAlready &data) {
if (const auto chat = session->data().processChat(data.vchat())) { if (const auto chat = session->data().processChat(data.vchat())) {
App::wnd()->sessionController()->showPeerHistory( for (const auto controller : session->windows()) {
controller->showPeerHistory(
chat, chat,
Window::SectionShow::Way::Forward); Window::SectionShow::Way::Forward);
break;
}
} }
}); });
}, [=](const RPCError &error) { }, [=](const RPCError &error) {

View file

@ -17,7 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h" #include "mainwindow.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_accounts.h" #include "main/main_domain.h"
#include "info/info_memento.h" #include "info/info_memento.h"
#include "info/settings/info_settings_widget.h" #include "info/settings/info_settings_widget.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
@ -1392,7 +1392,7 @@ Updater::~Updater() {
UpdateChecker::UpdateChecker() UpdateChecker::UpdateChecker()
: _updater(GetUpdaterInstance()) { : _updater(GetUpdaterInstance()) {
if (IsAppLaunched() && Core::App().accounts().started()) { if (IsAppLaunched() && Core::App().domain().started()) {
const auto &account = Core::App().activeAccount(); const auto &account = Core::App().activeAccount();
if (account.sessionExists()) { if (account.sessionExists()) {
_updater->setMtproto(&account.session()); _updater->setMtproto(&account.session());

View file

@ -14,7 +14,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "inline_bots/inline_bot_layout_item.h" #include "inline_bots/inline_bot_layout_item.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "core/file_utilities.h" #include "core/file_utilities.h"
#include "core/mime_type.h" #include "core/mime_type.h"
@ -41,7 +40,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h" #include "mainwindow.h"
#include "core/application.h" #include "core/application.h"
#include "lottie/lottie_animation.h" #include "lottie/lottie_animation.h"
#include "facades.h"
#include "app.h" #include "app.h"
namespace { namespace {
@ -74,7 +72,7 @@ void LaunchWithWarning(
const auto warn = [&] { const auto warn = [&] {
if (!Data::IsExecutableName(name)) { if (!Data::IsExecutableName(name)) {
return false; return false;
} else if (!session->settings().exeLaunchWarning()) { } else if (!Core::App().settings().exeLaunchWarning()) {
return false; return false;
} else if (item && item->history()->peer->isVerified()) { } else if (item && item->history()->peer->isVerified()) {
return false; return false;
@ -86,13 +84,13 @@ void LaunchWithWarning(
return; return;
} }
const auto extension = '.' + Data::FileExtension(name); const auto extension = '.' + Data::FileExtension(name);
const auto callback = crl::guard(session, [=](bool checked) { const auto callback = [=](bool checked) {
if (checked) { if (checked) {
session->settings().setExeLaunchWarning(false); Core::App().settings().setExeLaunchWarning(false);
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
} }
File::Launch(name); File::Launch(name);
}); };
Ui::show(Box<ConfirmDontWarnBox>( Ui::show(Box<ConfirmDontWarnBox>(
tr::lng_launch_exe_warning( tr::lng_launch_exe_warning(
lt_extension, lt_extension,
@ -133,7 +131,7 @@ QString FileNameUnsafe(
bool savingAs, bool savingAs,
const QDir &dir) { const QDir &dir) {
name = base::FileNameFromUserString(name); name = base::FileNameFromUserString(name);
if (Global::AskDownloadPath() || savingAs) { if (Core::App().settings().askDownloadPath() || savingAs) {
if (!name.isEmpty() && name.at(0) == QChar::fromLatin1('.')) { if (!name.isEmpty() && name.at(0) == QChar::fromLatin1('.')) {
name = filedialogDefaultName(prefix, name); name = filedialogDefaultName(prefix, name);
} else if (dir.path() != qsl(".")) { } else if (dir.path() != qsl(".")) {
@ -177,14 +175,16 @@ QString FileNameUnsafe(
return filedialogGetSaveFile(name, title, fil, name) ? name : QString(); return filedialogGetSaveFile(name, title, fil, name) ? name : QString();
} }
QString path; auto path = [&] {
if (Global::DownloadPath().isEmpty()) { const auto path = Core::App().settings().downloadPath();
path = File::DefaultDownloadPath(session); if (path.isEmpty()) {
} else if (Global::DownloadPath() == qsl("tmp")) { return File::DefaultDownloadPath(session);
path = cTempDir(); } else if (path == qsl("tmp")) {
return cTempDir();
} else { } else {
path = Global::DownloadPath(); return path;
} }
}();
if (name.isEmpty()) name = qsl(".unknown"); if (name.isEmpty()) name = qsl(".unknown");
if (name.at(0) == QChar::fromLatin1('.')) { if (name.at(0) == QChar::fromLatin1('.')) {
if (!QDir().exists(path)) QDir().mkpath(path); if (!QDir().exists(path)) QDir().mkpath(path);
@ -1056,10 +1056,9 @@ void DocumentData::handleLoaderUpdates() {
// Sometimes FILE_REFERENCE_EXPIRED could not be handled. // Sometimes FILE_REFERENCE_EXPIRED could not be handled.
// //
//const auto openSettings = [=] { //const auto openSettings = [=] {
// Global::SetDownloadPath(QString()); // Core::App().settings().etDownloadPathBookmark(QByteArray());
// Global::SetDownloadPathBookmark(QByteArray()); // Core::App().settings().setDownloadPath(QString());
// Ui::show(Box<DownloadPathBox>()); // Ui::show(Box<DownloadPathBox>());
// Global::RefDownloadPathChanged().notify();
//}; //};
//Ui::show(Box<ConfirmBox>( //Ui::show(Box<ConfirmBox>(
// tr::lng_download_path_failed(tr::now), // tr::lng_download_path_failed(tr::now),
@ -1175,7 +1174,8 @@ bool DocumentData::saveFromData() {
bool DocumentData::saveFromDataSilent() { bool DocumentData::saveFromDataSilent() {
return !filepath(true).isEmpty() return !filepath(true).isEmpty()
|| (!Global::AskDownloadPath() && saveFromDataChecked()); || (!Core::App().settings().askDownloadPath()
&& saveFromDataChecked());
} }
bool DocumentData::saveFromDataChecked() { bool DocumentData::saveFromDataChecked() {

View file

@ -19,9 +19,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item.h" #include "history/history_item.h"
#include "history/history.h" #include "history/history.h"
#include "window/themes/window_theme_preview.h" #include "window/themes/window_theme_preview.h"
#include "core/core_settings.h"
#include "core/application.h"
#include "storage/file_download.h" #include "storage/file_download.h"
#include "ui/image/image.h" #include "ui/image/image.h"
#include "facades.h"
#include "app.h" #include "app.h"
#include <QtCore/QBuffer> #include <QtCore/QBuffer>
@ -259,7 +260,7 @@ void DocumentMedia::automaticLoad(
return; return;
} }
const auto toCache = _owner->saveToCache(); const auto toCache = _owner->saveToCache();
if (!toCache && Global::AskDownloadPath()) { if (!toCache && Core::App().settings().askDownloadPath()) {
// We need a filename, but we're supposed to ask user for it. // We need a filename, but we're supposed to ask user for it.
// No automatic download in this case. // No automatic download in this case.
return; return;

View file

@ -20,7 +20,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_account.h" #include "main/main_account.h"
//#include "storage/storage_feed_messages.h" // #feed //#include "storage/storage_feed_messages.h" // #feed
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "mtproto/mtproto_config.h" #include "mtproto/mtproto_config.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "mainwidget.h" #include "mainwidget.h"
@ -372,7 +371,7 @@ bool Folder::shouldBeInChatList() const {
int Folder::chatListUnreadCount() const { int Folder::chatListUnreadCount() const {
const auto state = chatListUnreadState(); const auto state = chatListUnreadState();
return state.marks return state.marks
+ (session().settings().countUnreadMessages() + (Core::App().settings().countUnreadMessages()
? state.messages ? state.messages
: state.chats); : state.chats);
} }

View file

@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h" #include "data/data_session.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "api/api_text_entities.h" #include "api/api_text_entities.h"
@ -2067,7 +2066,7 @@ int Session::unreadBadgeIgnoreOne(const Dialogs::Key &key) const {
} }
bool Session::unreadBadgeMutedIgnoreOne(const Dialogs::Key &key) const { bool Session::unreadBadgeMutedIgnoreOne(const Dialogs::Key &key) const {
if (!_session->settings().includeMutedCounter()) { if (!Core::App().settings().includeMutedCounter()) {
return false; return false;
} }
const auto remove = (key && key.entry()->inChatList()) const auto remove = (key && key.entry()->inChatList())
@ -2078,7 +2077,7 @@ bool Session::unreadBadgeMutedIgnoreOne(const Dialogs::Key &key) const {
int Session::unreadOnlyMutedBadge() const { int Session::unreadOnlyMutedBadge() const {
const auto state = _chatsList.unreadState(); const auto state = _chatsList.unreadState();
return _session->settings().countUnreadMessages() return Core::App().settings().countUnreadMessages()
? state.messagesMuted ? state.messagesMuted
: state.chatsMuted; : state.chatsMuted;
} }
@ -2092,20 +2091,20 @@ void Session::notifyUnreadBadgeChanged() {
} }
int Session::computeUnreadBadge(const Dialogs::UnreadState &state) const { int Session::computeUnreadBadge(const Dialogs::UnreadState &state) const {
const auto all = _session->settings().includeMutedCounter(); const auto all = Core::App().settings().includeMutedCounter();
return std::max(state.marks - (all ? 0 : state.marksMuted), 0) return std::max(state.marks - (all ? 0 : state.marksMuted), 0)
+ (_session->settings().countUnreadMessages() + (Core::App().settings().countUnreadMessages()
? std::max(state.messages - (all ? 0 : state.messagesMuted), 0) ? std::max(state.messages - (all ? 0 : state.messagesMuted), 0)
: std::max(state.chats - (all ? 0 : state.chatsMuted), 0)); : std::max(state.chats - (all ? 0 : state.chatsMuted), 0));
} }
bool Session::computeUnreadBadgeMuted( bool Session::computeUnreadBadgeMuted(
const Dialogs::UnreadState &state) const { const Dialogs::UnreadState &state) const {
if (!_session->settings().includeMutedCounter()) { if (!Core::App().settings().includeMutedCounter()) {
return false; return false;
} }
return (state.marksMuted >= state.marks) return (state.marksMuted >= state.marks)
&& (_session->settings().countUnreadMessages() && (Core::App().settings().countUnreadMessages()
? (state.messagesMuted >= state.messages) ? (state.messagesMuted >= state.messages)
: (state.chatsMuted >= state.chats)); : (state.chatsMuted >= state.chats));
} }

View file

@ -14,7 +14,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text_options.h" #include "ui/text_options.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "facades.h"
namespace { namespace {

View file

@ -18,8 +18,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item_components.h" #include "history/history_item_components.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "storage/storage_account.h" #include "storage/storage_account.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "mtproto/mtproto_config.h" #include "mtproto/mtproto_config.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "ui/image/image_location_factory.h" #include "ui/image/image_location_factory.h"
@ -1051,7 +1052,7 @@ std::vector<not_null<DocumentData*>> Stickers::getListByEmoji(
session().api().requestStickerSets(); session().api().requestStickerSets();
} }
if (session().settings().suggestStickersByEmoji()) { if (Core::App().settings().suggestStickersByEmoji()) {
const auto others = session().api().stickersByEmoji(original); const auto others = session().api().stickersByEmoji(original);
if (!others) { if (!others) {
return {}; return {};

View file

@ -49,7 +49,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/unread_badge.h" #include "ui/unread_badge.h"
#include "boxes/filters/edit_filter_box.h" #include "boxes/filters/edit_filter_box.h"
#include "api/api_chat_filters.h" #include "api/api_chat_filters.h"
#include "facades.h"
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
#include "styles/style_chat_helpers.h" #include "styles/style_chat_helpers.h"
#include "styles/style_window.h" #include "styles/style_window.h"

View file

@ -284,7 +284,7 @@ Widget::Widget(
updateControlsGeometry(); updateControlsGeometry();
}, lifetime()); }, lifetime());
_mainMenuToggle->setClickedCallback([=] { showMainMenu(); }); _mainMenuToggle->setClickedCallback([=] { showMainMenu(); });
_searchForNarrowFilters->setClickedCallback([=] { Ui::showChatsList(); }); _searchForNarrowFilters->setClickedCallback([=] { Ui::showChatsList(&session()); });
_chooseByDragTimer.setSingleShot(true); _chooseByDragTimer.setSingleShot(true);
connect(&_chooseByDragTimer, SIGNAL(timeout()), this, SLOT(onChooseByDrag())); connect(&_chooseByDragTimer, SIGNAL(timeout()), this, SLOT(onChooseByDrag()));

View file

@ -211,29 +211,28 @@ void showSettings() {
namespace Ui { namespace Ui {
void showPeerProfile(const PeerId &peer) { void showPeerProfile(not_null<PeerData*> peer) {
if (const auto window = App::wnd()) { if (const auto window = App::wnd()) { // multi good
if (const auto controller = window->sessionController()) { if (const auto controller = window->sessionController()) {
if (&controller->session() == &peer->session()) {
controller->showPeerInfo(peer); controller->showPeerInfo(peer);
} }
} }
} }
void showPeerProfile(const PeerData *peer) {
showPeerProfile(peer->id);
} }
void showPeerProfile(not_null<const History*> history) { void showPeerProfile(not_null<const History*> history) {
showPeerProfile(history->peer->id); showPeerProfile(history->peer);
} }
void showPeerHistory( void showChatsList(not_null<Main::Session*> session) {
const PeerId &peer,
MsgId msgId) {
if (const auto m = App::main()) { // multi good if (const auto m = App::main()) { // multi good
if (&m->session() == session) {
m->ui_showPeerHistory( m->ui_showPeerHistory(
peer, 0,
Window::SectionShow::Way::ClearStack, Window::SectionShow::Way::ClearStack,
msgId); 0);
}
} }
} }
@ -332,37 +331,11 @@ namespace Global {
namespace internal { namespace internal {
struct Data { struct Data {
bool ScreenIsLocked = false;
Adaptive::WindowLayout AdaptiveWindowLayout = Adaptive::WindowLayout::Normal; Adaptive::WindowLayout AdaptiveWindowLayout = Adaptive::WindowLayout::Normal;
Adaptive::ChatLayout AdaptiveChatLayout = Adaptive::ChatLayout::Normal; Adaptive::ChatLayout AdaptiveChatLayout = Adaptive::ChatLayout::Normal;
bool AdaptiveForWide = true;
base::Observable<void> AdaptiveChanged; base::Observable<void> AdaptiveChanged;
bool DialogsFiltersEnabled = false;
bool ModerateModeEnabled = false;
bool ScreenIsLocked = false;
float64 RememberedSongVolume = kDefaultVolume;
float64 SongVolume = kDefaultVolume;
base::Observable<void> SongVolumeChanged;
float64 VideoVolume = kDefaultVolume;
base::Observable<void> VideoVolumeChanged;
bool AskDownloadPath = false;
QString DownloadPath;
QByteArray DownloadPathBookmark;
base::Observable<void> DownloadPathChanged;
bool VoiceMsgPlaybackDoubled = false;
bool SoundNotify = true;
bool DesktopNotify = true;
bool FlashBounceNotify = true;
bool RestoreSoundNotifyFromTray = false;
bool RestoreFlashBounceNotifyFromTray = false;
DBINotifyView NotifyView = dbinvShowPreview;
bool NativeNotifications = false;
int NotificationsCount = 3;
Notify::ScreenCorner NotificationsCorner = Notify::ScreenCorner::BottomRight;
bool NotificationsDemoIsShown = false; bool NotificationsDemoIsShown = false;
bool TryIPv6 = !Platform::IsWindows(); bool TryIPv6 = !Platform::IsWindows();
@ -372,19 +345,12 @@ struct Data {
bool UseProxyForCalls = false; bool UseProxyForCalls = false;
base::Observable<void> ConnectionTypeChanged; base::Observable<void> ConnectionTypeChanged;
int AutoLock = 3600;
bool LocalPasscode = false; bool LocalPasscode = false;
base::Observable<void> LocalPasscodeChanged; base::Observable<void> LocalPasscodeChanged;
base::Variable<DBIWorkMode> WorkMode = { dbiwmWindowAndTray }; base::Variable<DBIWorkMode> WorkMode = { dbiwmWindowAndTray };
base::Observable<void> PeerChooseCancel; base::Observable<void> PeerChooseCancel;
QString CallOutputDeviceID = qsl("default");
QString CallInputDeviceID = qsl("default");
int CallOutputVolume = 100;
int CallInputVolume = 100;
bool CallAudioDuckingEnabled = true;
}; };
} // namespace internal } // namespace internal
@ -407,37 +373,11 @@ void finish() {
GlobalData = nullptr; GlobalData = nullptr;
} }
DefineVar(Global, bool, ScreenIsLocked);
DefineVar(Global, Adaptive::WindowLayout, AdaptiveWindowLayout); DefineVar(Global, Adaptive::WindowLayout, AdaptiveWindowLayout);
DefineVar(Global, Adaptive::ChatLayout, AdaptiveChatLayout); DefineVar(Global, Adaptive::ChatLayout, AdaptiveChatLayout);
DefineVar(Global, bool, AdaptiveForWide);
DefineRefVar(Global, base::Observable<void>, AdaptiveChanged); DefineRefVar(Global, base::Observable<void>, AdaptiveChanged);
DefineVar(Global, bool, DialogsFiltersEnabled);
DefineVar(Global, bool, ModerateModeEnabled);
DefineVar(Global, bool, ScreenIsLocked);
DefineVar(Global, float64, RememberedSongVolume);
DefineVar(Global, float64, SongVolume);
DefineRefVar(Global, base::Observable<void>, SongVolumeChanged);
DefineVar(Global, float64, VideoVolume);
DefineRefVar(Global, base::Observable<void>, VideoVolumeChanged);
DefineVar(Global, bool, AskDownloadPath);
DefineVar(Global, QString, DownloadPath);
DefineVar(Global, QByteArray, DownloadPathBookmark);
DefineRefVar(Global, base::Observable<void>, DownloadPathChanged);
DefineVar(Global, bool, VoiceMsgPlaybackDoubled);
DefineVar(Global, bool, SoundNotify);
DefineVar(Global, bool, DesktopNotify);
DefineVar(Global, bool, FlashBounceNotify);
DefineVar(Global, bool, RestoreSoundNotifyFromTray);
DefineVar(Global, bool, RestoreFlashBounceNotifyFromTray);
DefineVar(Global, DBINotifyView, NotifyView);
DefineVar(Global, bool, NativeNotifications);
DefineVar(Global, int, NotificationsCount);
DefineVar(Global, Notify::ScreenCorner, NotificationsCorner);
DefineVar(Global, bool, NotificationsDemoIsShown); DefineVar(Global, bool, NotificationsDemoIsShown);
DefineVar(Global, bool, TryIPv6); DefineVar(Global, bool, TryIPv6);
@ -447,7 +387,6 @@ DefineVar(Global, MTP::ProxyData::Settings, ProxySettings);
DefineVar(Global, bool, UseProxyForCalls); DefineVar(Global, bool, UseProxyForCalls);
DefineRefVar(Global, base::Observable<void>, ConnectionTypeChanged); DefineRefVar(Global, base::Observable<void>, ConnectionTypeChanged);
DefineVar(Global, int, AutoLock);
DefineVar(Global, bool, LocalPasscode); DefineVar(Global, bool, LocalPasscode);
DefineRefVar(Global, base::Observable<void>, LocalPasscodeChanged); DefineRefVar(Global, base::Observable<void>, LocalPasscodeChanged);
@ -455,10 +394,4 @@ DefineRefVar(Global, base::Variable<DBIWorkMode>, WorkMode);
DefineRefVar(Global, base::Observable<void>, PeerChooseCancel); DefineRefVar(Global, base::Observable<void>, PeerChooseCancel);
DefineVar(Global, QString, CallOutputDeviceID);
DefineVar(Global, QString, CallInputDeviceID);
DefineVar(Global, int, CallOutputVolume);
DefineVar(Global, int, CallInputVolume);
DefineVar(Global, bool, CallAudioDuckingEnabled);
} // namespace Global } // namespace Global

View file

@ -56,18 +56,13 @@ namespace Ui {
// Legacy global methods. // Legacy global methods.
void showPeerProfile(const PeerId &peer); void showPeerProfile(not_null<PeerData*> peer);
void showPeerProfile(const PeerData *peer);
void showPeerProfile(not_null<const History*> history); void showPeerProfile(not_null<const History*> history);
void showPeerHistory(const PeerId &peer, MsgId msgId);
void showPeerHistoryAtItem(not_null<const HistoryItem*> item); void showPeerHistoryAtItem(not_null<const HistoryItem*> item);
void showPeerHistory(not_null<const PeerData*> peer, MsgId msgId); void showPeerHistory(not_null<const PeerData*> peer, MsgId msgId);
void showPeerHistory(not_null<const History*> history, MsgId msgId); void showPeerHistory(not_null<const History*> history, MsgId msgId);
inline void showChatsList() { void showChatsList(not_null<Main::Session*> session);
showPeerHistory(PeerId(0), 0);
}
PeerData *getPeerForMouseAction(); PeerData *getPeerForMouseAction();
bool skipPaintEvent(QWidget *widget, QPaintEvent *event); bool skipPaintEvent(QWidget *widget, QPaintEvent *event);
@ -92,23 +87,6 @@ bool switchInlineBotButtonReceived(
UserData *samePeerBot = nullptr, UserData *samePeerBot = nullptr,
MsgId samePeerReplyTo = 0); MsgId samePeerReplyTo = 0);
void unreadCounterUpdated();
enum class ScreenCorner {
TopLeft = 0,
TopRight = 1,
BottomRight = 2,
BottomLeft = 3,
};
inline bool IsLeftCorner(ScreenCorner corner) {
return (corner == ScreenCorner::TopLeft) || (corner == ScreenCorner::BottomLeft);
}
inline bool IsTopCorner(ScreenCorner corner) {
return (corner == ScreenCorner::TopLeft) || (corner == ScreenCorner::TopRight);
}
} // namespace Notify } // namespace Notify
#define DeclareReadOnlyVar(Type, Name) const Type &Name(); #define DeclareReadOnlyVar(Type, Name) const Type &Name();
@ -139,43 +117,10 @@ void start();
void finish(); void finish();
DeclareVar(bool, ScreenIsLocked); DeclareVar(bool, ScreenIsLocked);
DeclareVar(Adaptive::WindowLayout, AdaptiveWindowLayout);
DeclareVar(Adaptive::ChatLayout, AdaptiveChatLayout); DeclareVar(Adaptive::ChatLayout, AdaptiveChatLayout);
DeclareVar(bool, AdaptiveForWide); DeclareVar(Adaptive::WindowLayout, AdaptiveWindowLayout);
DeclareRefVar(base::Observable<void>, AdaptiveChanged); DeclareRefVar(base::Observable<void>, AdaptiveChanged);
DeclareVar(bool, DialogsFiltersEnabled);
DeclareVar(bool, ModerateModeEnabled);
constexpr auto kDefaultVolume = 0.9;
DeclareVar(float64, RememberedSongVolume);
DeclareVar(float64, SongVolume);
DeclareRefVar(base::Observable<void>, SongVolumeChanged);
DeclareVar(float64, VideoVolume);
DeclareRefVar(base::Observable<void>, VideoVolumeChanged);
DeclareVar(bool, AskDownloadPath);
DeclareVar(QString, DownloadPath);
DeclareVar(QByteArray, DownloadPathBookmark);
DeclareRefVar(base::Observable<void>, DownloadPathChanged);
DeclareVar(bool, VoiceMsgPlaybackDoubled);
DeclareVar(bool, SoundNotify);
DeclareVar(bool, DesktopNotify);
DeclareVar(bool, FlashBounceNotify);
DeclareVar(bool, RestoreSoundNotifyFromTray);
DeclareVar(bool, RestoreFlashBounceNotifyFromTray);
DeclareVar(DBINotifyView, NotifyView);
DeclareVar(int, NotificationsCount);
DeclareVar(Notify::ScreenCorner, NotificationsCorner);
DeclareVar(QString, CallOutputDeviceID);
DeclareVar(QString, CallInputDeviceID);
DeclareVar(int, CallOutputVolume);
DeclareVar(int, CallInputVolume);
DeclareVar(bool, CallAudioDuckingEnabled);
DeclareVar(bool, NativeNotifications);
DeclareVar(bool, NotificationsDemoIsShown); DeclareVar(bool, NotificationsDemoIsShown);
DeclareVar(bool, TryIPv6); DeclareVar(bool, TryIPv6);
@ -185,7 +130,6 @@ DeclareVar(MTP::ProxyData::Settings, ProxySettings);
DeclareVar(bool, UseProxyForCalls); DeclareVar(bool, UseProxyForCalls);
DeclareRefVar(base::Observable<void>, ConnectionTypeChanged); DeclareRefVar(base::Observable<void>, ConnectionTypeChanged);
DeclareVar(int, AutoLock);
DeclareVar(bool, LocalPasscode); DeclareVar(bool, LocalPasscode);
DeclareRefVar(base::Observable<void>, LocalPasscodeChanged); DeclareRefVar(base::Observable<void>, LocalPasscodeChanged);
@ -213,13 +157,4 @@ inline bool ThreeColumn() {
return Global::AdaptiveWindowLayout() == WindowLayout::ThreeColumn; return Global::AdaptiveWindowLayout() == WindowLayout::ThreeColumn;
} }
inline bool ChatNormal() {
return !Global::AdaptiveForWide()
|| (Global::AdaptiveChatLayout() == ChatLayout::Normal);
}
inline bool ChatWide() {
return !ChatNormal();
}
} // namespace Adaptive } // namespace Adaptive

View file

@ -44,7 +44,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text_options.h" #include "ui/text_options.h"
#include "core/crash_reports.h" #include "core/crash_reports.h"
#include "base/unixtime.h" #include "base/unixtime.h"
#include "facades.h"
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
namespace { namespace {

View file

@ -391,7 +391,7 @@ void HistoryInner::enumerateItemsInHistory(History *history, int historytop, Met
} }
bool HistoryInner::canHaveFromUserpics() const { bool HistoryInner::canHaveFromUserpics() const {
if (_peer->isUser() && !_peer->isSelf() && !Adaptive::ChatWide()) { if (_peer->isUser() && !_peer->isSelf() && !Core::App().settings().chatWide()) {
return false; return false;
} else if (_peer->isChannel() && !_peer->isMegagroup()) { } else if (_peer->isChannel() && !_peer->isMegagroup()) {
return false; return false;
@ -2131,7 +2131,7 @@ void HistoryInner::recountHistoryGeometry() {
int32 descH = st::msgMargin.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom(); int32 descH = st::msgMargin.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom();
int32 descMaxWidth = _scroll->width(); int32 descMaxWidth = _scroll->width();
if (Adaptive::ChatWide()) { if (Core::App().settings().chatWide()) {
descMaxWidth = qMin(descMaxWidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); descMaxWidth = qMin(descMaxWidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
} }
int32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left(); int32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left();
@ -2329,7 +2329,7 @@ void HistoryInner::updateSize() {
if (_botAbout && _botAbout->height > 0) { if (_botAbout && _botAbout->height > 0) {
int32 descH = st::msgMargin.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom(); int32 descH = st::msgMargin.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom();
int32 descMaxWidth = _scroll->width(); int32 descMaxWidth = _scroll->width();
if (Adaptive::ChatWide()) { if (Core::App().settings().chatWide()) {
descMaxWidth = qMin(descMaxWidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); descMaxWidth = qMin(descMaxWidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
} }
int32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left(); int32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left();
@ -2680,7 +2680,7 @@ void HistoryInner::mouseActionUpdate() {
dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right(); dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right();
auto dateLeft = st::msgServiceMargin.left(); auto dateLeft = st::msgServiceMargin.left();
auto maxwidth = _contentWidth; auto maxwidth = _contentWidth;
if (Adaptive::ChatWide()) { if (Core::App().settings().chatWide()) {
maxwidth = qMin(maxwidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); maxwidth = qMin(maxwidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
} }
auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left(); auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();

View file

@ -27,7 +27,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/storage_shared_media.h" #include "storage/storage_shared_media.h"
//#include "storage/storage_feed_messages.h" // #feed //#include "storage/storage_feed_messages.h" // #feed
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "media/audio/media_audio.h" #include "media/audio/media_audio.h"
#include "core/application.h" #include "core/application.h"
@ -304,7 +303,7 @@ bool HistoryItem::isUnreadMention() const {
bool HistoryItem::mentionsMe() const { bool HistoryItem::mentionsMe() const {
if (Has<HistoryServicePinned>() if (Has<HistoryServicePinned>()
&& !history()->session().settings().notifyAboutPinned()) { && !Core::App().settings().notifyAboutPinned()) {
return false; return false;
} }
return _flags & MTPDmessage::Flag::f_mentioned; return _flags & MTPDmessage::Flag::f_mentioned;

View file

@ -506,7 +506,7 @@ HistoryWidget::HistoryWidget(
} }
}, lifetime()); }, lifetime());
session().settings().largeEmojiChanges( Core::App().settings().largeEmojiChanges(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
crl::on_main(this, [=] { crl::on_main(this, [=] {
updateHistoryGeometry(); updateHistoryGeometry();
@ -1554,7 +1554,7 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, U
if (h == _history) { if (h == _history) {
applyDraft(); applyDraft();
} else { } else {
Ui::showPeerHistory(toPeerId, ShowAtUnreadMsgId); Ui::showPeerHistory(h->peer, ShowAtUnreadMsgId);
} }
return true; return true;
} }
@ -2051,7 +2051,7 @@ void HistoryWidget::clearAllLoadRequests() {
void HistoryWidget::updateFieldSubmitSettings() { void HistoryWidget::updateFieldSubmitSettings() {
const auto settings = _isInlineBot const auto settings = _isInlineBot
? Ui::InputField::SubmitSettings::None ? Ui::InputField::SubmitSettings::None
: session().settings().sendSubmitWay(); : Core::App().settings().sendSubmitWay();
_field->setSubmitSettings(settings); _field->setSubmitSettings(settings);
} }
@ -5475,7 +5475,7 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) {
} }
if (!_canSendMessages) { if (!_canSendMessages) {
const auto submitting = Ui::InputField::ShouldSubmit( const auto submitting = Ui::InputField::ShouldSubmit(
session().settings().sendSubmitWay(), Core::App().settings().sendSubmitWay(),
e->modifiers()); e->modifiers());
if (submitting) { if (submitting) {
sendWithModifiers(e->modifiers()); sendWithModifiers(e->modifiers());

View file

@ -23,6 +23,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h" #include "main/main_session_settings.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "inline_bots/inline_results_widget.h" #include "inline_bots/inline_results_widget.h"
#include "facades.h" #include "facades.h"
#include "styles/style_history.h" #include "styles/style_history.h"
@ -207,7 +209,7 @@ void ComposeControls::init() {
void ComposeControls::initField() { void ComposeControls::initField() {
_field->setMaxHeight(st::historyComposeFieldMaxHeight); _field->setMaxHeight(st::historyComposeFieldMaxHeight);
_field->setSubmitSettings(_window->session().settings().sendSubmitWay()); _field->setSubmitSettings(Core::App().settings().sendSubmitWay());
//Ui::Connect(_field, &Ui::InputField::submitted, [=] { send(); }); //Ui::Connect(_field, &Ui::InputField::submitted, [=] { send(); });
Ui::Connect(_field, &Ui::InputField::cancelled, [=] { escape(); }); Ui::Connect(_field, &Ui::InputField::cancelled, [=] { escape(); });
//Ui::Connect(_field, &Ui::InputField::tabbed, [=] { fieldTabbed(); }); //Ui::Connect(_field, &Ui::InputField::tabbed, [=] { fieldTabbed(); });

View file

@ -16,15 +16,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/media/history_view_sticker.h" #include "history/view/media/history_view_sticker.h"
#include "history/view/media/history_view_large_emoji.h" #include "history/view/media/history_view_large_emoji.h"
#include "history/history.h" #include "history/history.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "chat_helpers/stickers_emoji_pack.h" #include "chat_helpers/stickers_emoji_pack.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_groups.h" #include "data/data_groups.h"
#include "data/data_media_types.h" #include "data/data_media_types.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "layout.h" #include "layout.h"
#include "facades.h"
#include "app.h" #include "app.h"
#include "styles/style_history.h" #include "styles/style_history.h"
@ -164,7 +164,7 @@ void UnreadBar::paint(Painter &p, int y, int w) const {
int left = st::msgServiceMargin.left(); int left = st::msgServiceMargin.left();
int maxwidth = w; int maxwidth = w;
if (Adaptive::ChatWide()) { if (Core::App().settings().chatWide()) {
maxwidth = qMin( maxwidth = qMin(
maxwidth, maxwidth,
st::msgMaxWidth st::msgMaxWidth
@ -363,7 +363,7 @@ void Element::refreshMedia(Element *replacing) {
if (const auto media = _data->media()) { if (const auto media = _data->media()) {
_media = media->createView(this, replacing); _media = media->createView(this, replacing);
} else if (_data->isIsolatedEmoji() } else if (_data->isIsolatedEmoji()
&& session->settings().largeEmoji()) { && Core::App().settings().largeEmoji()) {
const auto emoji = _data->isolatedEmoji(); const auto emoji = _data->isolatedEmoji();
const auto emojiStickers = &session->emojiStickersPack(); const auto emojiStickers = &session->emojiStickersPack();
if (const auto sticker = emojiStickers->stickerForEmoji(emoji)) { if (const auto sticker = emojiStickers->stickerForEmoji(emoji)) {

View file

@ -2168,7 +2168,7 @@ void ListWidget::mouseActionUpdate() {
dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right(); dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right();
auto dateLeft = st::msgServiceMargin.left(); auto dateLeft = st::msgServiceMargin.left();
auto maxwidth = view->width(); auto maxwidth = view->width();
if (Adaptive::ChatWide()) { if (Core::App().settings().chatWide()) {
maxwidth = qMin(maxwidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); maxwidth = qMin(maxwidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
} }
auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left(); auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();

View file

@ -13,6 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/media/history_view_media.h" #include "history/view/media/history_view_media.h"
#include "history/view/media/history_view_web_page.h" #include "history/view/media/history_view_web_page.h"
#include "history/history.h" #include "history/history.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/text/text_entity.h" #include "ui/text/text_entity.h"
@ -454,7 +456,7 @@ void Message::draw(
auto skipTail = isAttachedToNext() auto skipTail = isAttachedToNext()
|| (media && media->skipBubbleTail()) || (media && media->skipBubbleTail())
|| (keyboard != nullptr); || (keyboard != nullptr);
auto displayTail = skipTail ? RectPart::None : (outbg && !Adaptive::ChatWide()) ? RectPart::Right : RectPart::Left; auto displayTail = skipTail ? RectPart::None : (outbg && !Core::App().settings().chatWide()) ? RectPart::Right : RectPart::Left;
PaintBubble(p, g, width(), selected, outbg, displayTail); PaintBubble(p, g, width(), selected, outbg, displayTail);
// Entry page is always a bubble bottom. // Entry page is always a bubble bottom.
@ -796,7 +798,7 @@ bool Message::hasFromPhoto() const {
const auto item = message(); const auto item = message();
if (item->isPost() || item->isEmpty()) { if (item->isPost() || item->isEmpty()) {
return false; return false;
} else if (Adaptive::ChatWide()) { } else if (Core::App().settings().chatWide()) {
return true; return true;
} else if (item->history()->peer->isSelf()) { } else if (item->history()->peer->isSelf()) {
return item->Has<HistoryMessageForwarded>(); return item->Has<HistoryMessageForwarded>();
@ -1786,7 +1788,7 @@ QRect Message::countGeometry() const {
const auto availableWidth = width() const auto availableWidth = width()
- st::msgMargin.left() - st::msgMargin.left()
- st::msgMargin.right(); - st::msgMargin.right();
auto contentLeft = (outbg && !Adaptive::ChatWide()) auto contentLeft = (outbg && !Core::App().settings().chatWide())
? st::msgMargin.right() ? st::msgMargin.right()
: st::msgMargin.left(); : st::msgMargin.left();
auto contentWidth = availableWidth; auto contentWidth = availableWidth;
@ -1809,7 +1811,7 @@ QRect Message::countGeometry() const {
contentWidth = mediaWidth; contentWidth = mediaWidth;
} }
} }
if (contentWidth < availableWidth && outbg && !Adaptive::ChatWide()) { if (contentWidth < availableWidth && outbg && !Core::App().settings().chatWide()) {
contentLeft += availableWidth - contentWidth; contentLeft += availableWidth - contentWidth;
} }

View file

@ -16,10 +16,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_chat.h" #include "data/data_chat.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "ui/text_options.h" #include "ui/text_options.h"
#include "core/core_settings.h"
#include "core/application.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "layout.h" #include "layout.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "facades.h"
#include "app.h" #include "app.h"
#include "styles/style_history.h" #include "styles/style_history.h"
@ -164,7 +165,7 @@ void paintBubblePart(Painter &p, int x, int y, int width, int height, SideStyle
void paintPreparedDate(Painter &p, const QString &dateText, int dateTextWidth, int y, int w) { void paintPreparedDate(Painter &p, const QString &dateText, int dateTextWidth, int y, int w) {
int left = st::msgServiceMargin.left(); int left = st::msgServiceMargin.left();
int maxwidth = w; int maxwidth = w;
if (Adaptive::ChatWide()) { if (Core::App().settings().chatWide()) {
maxwidth = qMin(maxwidth, WideChatWidth()); maxwidth = qMin(maxwidth, WideChatWidth());
} }
w = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left(); w = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
@ -320,7 +321,7 @@ not_null<HistoryService*> Service::message() const {
QRect Service::countGeometry() const { QRect Service::countGeometry() const {
auto result = QRect(0, 0, width(), height()); auto result = QRect(0, 0, width(), height());
if (Adaptive::ChatWide()) { if (Core::App().settings().chatWide()) {
result.setWidth(qMin(result.width(), st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); result.setWidth(qMin(result.width(), st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
} }
return result.marginsRemoved(st::msgServiceMargin); return result.marginsRemoved(st::msgServiceMargin);
@ -343,7 +344,7 @@ QSize Service::performCountCurrentSize(int newWidth) {
item->_textHeight = 0; item->_textHeight = 0;
} else { } else {
auto contentWidth = newWidth; auto contentWidth = newWidth;
if (Adaptive::ChatWide()) { if (Core::App().settings().chatWide()) {
accumulate_min(contentWidth, st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()); accumulate_min(contentWidth, st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left());
} }
contentWidth -= st::msgServiceMargin.left() + st::msgServiceMargin.left(); // two small margins contentWidth -= st::msgServiceMargin.left() + st::msgServiceMargin.left(); // two small margins

View file

@ -13,8 +13,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item.h" #include "history/history_item.h"
#include "history/history_item_components.h" #include "history/history_item_components.h"
#include "lottie/lottie_single_player.h" #include "lottie/lottie_single_player.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "layout.h" #include "layout.h"
#include "facades.h"
#include "app.h" #include "app.h"
#include "styles/style_history.h" #include "styles/style_history.h"
@ -87,7 +88,7 @@ QSize UnwrappedMedia::countCurrentSize(int newWidth) {
} }
} }
auto newHeight = minHeight(); auto newHeight = minHeight();
if (_parent->hasOutLayout() && !Adaptive::ChatWide()) { if (_parent->hasOutLayout() && !Core::App().settings().chatWide()) {
// Add some height to isolated emoji for the timestamp info. // Add some height to isolated emoji for the timestamp info.
const auto infoHeight = st::msgDateImgPadding.y() * 2 const auto infoHeight = st::msgDateImgPadding.y() * 2
+ st::msgDateFont->height; + st::msgDateFont->height;
@ -109,7 +110,7 @@ void UnwrappedMedia::draw(
} }
bool selected = (selection == FullSelection); bool selected = (selection == FullSelection);
const auto rightAligned = _parent->hasOutLayout() && !Adaptive::ChatWide(); const auto rightAligned = _parent->hasOutLayout() && !Core::App().settings().chatWide();
const auto inWebPage = (_parent->media() != this); const auto inWebPage = (_parent->media() != this);
const auto item = _parent->data(); const auto item = _parent->data();
const auto via = inWebPage ? nullptr : item->Get<HistoryMessageVia>(); const auto via = inWebPage ? nullptr : item->Get<HistoryMessageVia>();
@ -177,7 +178,7 @@ void UnwrappedMedia::drawSurrounding(
const HistoryMessageVia *via, const HistoryMessageVia *via,
const HistoryMessageReply *reply, const HistoryMessageReply *reply,
const HistoryMessageForwarded *forwarded) const { const HistoryMessageForwarded *forwarded) const {
const auto rightAligned = _parent->hasOutLayout() && !Adaptive::ChatWide(); const auto rightAligned = _parent->hasOutLayout() && !Core::App().settings().chatWide();
const auto rightAction = _parent->displayRightAction(); const auto rightAction = _parent->displayRightAction();
const auto fullRight = calculateFullRight(inner); const auto fullRight = calculateFullRight(inner);
auto fullBottom = height(); auto fullBottom = height();
@ -236,7 +237,7 @@ PointState UnwrappedMedia::pointState(QPoint point) const {
return PointState::Outside; return PointState::Outside;
} }
const auto rightAligned = _parent->hasOutLayout() && !Adaptive::ChatWide(); const auto rightAligned = _parent->hasOutLayout() && !Core::App().settings().chatWide();
const auto inWebPage = (_parent->media() != this); const auto inWebPage = (_parent->media() != this);
const auto item = _parent->data(); const auto item = _parent->data();
const auto via = inWebPage ? nullptr : item->Get<HistoryMessageVia>(); const auto via = inWebPage ? nullptr : item->Get<HistoryMessageVia>();
@ -276,7 +277,7 @@ TextState UnwrappedMedia::textState(QPoint point, StateRequest request) const {
return result; return result;
} }
const auto rightAligned = _parent->hasOutLayout() && !Adaptive::ChatWide(); const auto rightAligned = _parent->hasOutLayout() && !Core::App().settings().chatWide();
const auto inWebPage = (_parent->media() != this); const auto inWebPage = (_parent->media() != this);
const auto item = _parent->data(); const auto item = _parent->data();
const auto via = inWebPage ? nullptr : item->Get<HistoryMessageVia>(); const auto via = inWebPage ? nullptr : item->Get<HistoryMessageVia>();
@ -387,7 +388,7 @@ std::unique_ptr<Lottie::SinglePlayer> UnwrappedMedia::stickerTakeLottie() {
} }
int UnwrappedMedia::calculateFullRight(const QRect &inner) const { int UnwrappedMedia::calculateFullRight(const QRect &inner) const {
const auto rightAligned = _parent->hasOutLayout() && !Adaptive::ChatWide(); const auto rightAligned = _parent->hasOutLayout() && !Core::App().settings().chatWide();
const auto infoWidth = _parent->infoWidth() const auto infoWidth = _parent->infoWidth()
+ st::msgDateImgPadding.x() * 2 + st::msgDateImgPadding.x() * 2
+ st::msgReplyPadding.left(); + st::msgReplyPadding.left();
@ -432,7 +433,7 @@ bool UnwrappedMedia::needInfoDisplay() const {
|| (_parent->displayRightAction()) || (_parent->displayRightAction())
|| (_parent->isLastAndSelfMessage()) || (_parent->isLastAndSelfMessage())
|| (_parent->hasOutLayout() || (_parent->hasOutLayout()
&& !Adaptive::ChatWide() && !Core::App().settings().chatWide()
&& _content->alwaysShowOutTimestamp()); && _content->alwaysShowOutTimestamp());
} }

View file

@ -17,8 +17,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/media/history_view_media_common.h" #include "history/view/media/history_view_media_common.h"
#include "ui/image/image.h" #include "ui/image/image.h"
#include "ui/emoji_config.h" #include "ui/emoji_config.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_app_config.h" #include "main/main_app_config.h"
#include "mainwindow.h" // App::wnd()->sessionController. #include "mainwindow.h" // App::wnd()->sessionController.
@ -190,7 +191,7 @@ void Sticker::paintLottie(Painter &p, const QRect &r, bool selected) {
: (_diceIndex == 0) : (_diceIndex == 0)
? false ? false
: (isEmojiSticker() : (isEmojiSticker()
|| !_data->session().settings().loopAnimatedStickers()); || !Core::App().settings().loopAnimatedStickers());
const auto count = _lottie->information().framesCount; const auto count = _lottie->information().framesCount;
_atTheEnd = (frame.index + 1 == count); _atTheEnd = (frame.index + 1 == count);
_nextLastDiceFrame = !paused _nextLastDiceFrame = !paused

View file

@ -15,6 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h" #include "main/main_session_settings.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
@ -26,7 +28,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_auto_download.h" #include "data/data_auto_download.h"
#include "window/window_controller.h" #include "window/window_controller.h"
#include "window/themes/window_theme.h" #include "window/themes/window_theme.h"
#include "facades.h"
#include "app.h" #include "app.h"
#include "styles/style_intro.h" #include "styles/style_intro.h"
#include "styles/style_window.h" #include "styles/style_window.h"
@ -39,11 +40,11 @@ void PrepareSupportMode(not_null<Main::Session*> session) {
using ::Data::AutoDownload::Full; using ::Data::AutoDownload::Full;
anim::SetDisabled(true); anim::SetDisabled(true);
Local::writeSettings(); Core::App().settings().setDesktopNotify(false);
Core::App().settings().setSoundNotify(false);
Core::App().settings().setFlashBounceNotify(false);
Core::App().saveSettings();
Global::SetDesktopNotify(false);
Global::SetSoundNotify(false);
Global::SetFlashBounceNotify(false);
session->settings().autoDownload() = Full::FullDisabled(); session->settings().autoDownload() = Full::FullDisabled();
session->saveSettings(); session->saveSettings();
} }

View file

@ -29,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_connecting_widget.h" #include "window/window_connecting_widget.h"
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
#include "api/api_text_entities.h" #include "api/api_text_entities.h"
#include "facades.h"
#include "app.h" #include "app.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_intro.h" #include "styles/style_intro.h"

View file

@ -14,7 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "core/application.h" #include "core/application.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_accounts.h" #include "main/main_domain.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "ui/wrap/padding_wrap.h" #include "ui/wrap/padding_wrap.h"
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
@ -158,7 +158,7 @@ Language ParseLanguage(const MTPLangPackLanguage &data) {
CloudManager::CloudManager(Instance &langpack) CloudManager::CloudManager(Instance &langpack)
: _langpack(langpack) { : _langpack(langpack) {
Core::App().accounts().activeValue( Core::App().domain().activeValue(
) | rpl::map([=](Main::Account *account) { ) | rpl::map([=](Main::Account *account) {
if (!account) { if (!account) {
_api.reset(); _api.reset();

View file

@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/launcher.h" #include "core/launcher.h"
#include "core/shortcuts.h" #include "core/shortcuts.h"
#include "storage/storage_account.h" #include "storage/storage_account.h"
#include "storage/storage_accounts.h" // Storage::StartResult. #include "storage/storage_domain.h" // Storage::StartResult.
#include "storage/serialize_common.h" #include "storage/serialize_common.h"
#include "storage/serialize_peer.h" #include "storage/serialize_peer.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "api/api_updates.h" #include "api/api_updates.h"
#include "main/main_app_config.h" #include "main/main_app_config.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_domain.h"
#include "main/main_session_settings.h" #include "main/main_session_settings.h"
#include "facades.h" #include "facades.h"
@ -45,8 +46,9 @@ namespace {
} // namespace } // namespace
Account::Account(const QString &dataName, int index) Account::Account(not_null<Domain*> domain, const QString &dataName, int index)
: _local(std::make_unique<Storage::Account>( : _domain(domain)
, _local(std::make_unique<Storage::Account>(
this, this,
ComposeDataString(dataName, index))) { ComposeDataString(dataName, index))) {
} }
@ -58,6 +60,10 @@ Account::~Account() {
destroySession(); destroySession();
} }
Storage::Domain &Account::domainLocal() const {
return _domain->local();
}
[[nodiscard]] Storage::StartResult Account::legacyStart( [[nodiscard]] Storage::StartResult Account::legacyStart(
const QByteArray &passcode) { const QByteArray &passcode) {
Expects(!_appConfig); Expects(!_appConfig);
@ -493,7 +499,7 @@ void Account::forcedLogOut() {
void Account::loggedOut() { void Account::loggedOut() {
_loggingOut = false; _loggingOut = false;
Media::Player::mixer()->stopAndClear(); Media::Player::mixer()->stopAndClear();
Global::SetVoiceMsgPlaybackDoubled(false); Core::App().settings().setVoiceMsgPlaybackDoubled(false); // #TODO multi properly reset settings
if (const auto window = Core::App().activeWindow()) { if (const auto window = Core::App().activeWindow()) {
window->tempDirDelete(Local::ClearManagerAll); window->tempDirDelete(Local::ClearManagerAll);
} }

View file

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Storage { namespace Storage {
class Account; class Account;
class Domain;
enum class StartResult : uchar; enum class StartResult : uchar;
} // namespace Storage } // namespace Storage
@ -23,17 +24,21 @@ class Config;
namespace Main { namespace Main {
class Domain;
class Session; class Session;
class SessionSettings; class SessionSettings;
class AppConfig; class AppConfig;
class Account final : public base::has_weak_ptr { class Account final : public base::has_weak_ptr {
public: public:
Account(const QString &dataName, int index); Account(not_null<Domain*> domain, const QString &dataName, int index);
~Account(); ~Account();
Account(const Account &other) = delete; [[nodiscard]] Domain &domain() const {
Account &operator=(const Account &other) = delete; return *_domain;
}
[[nodiscard]] Storage::Domain &domainLocal() const;
[[nodiscard]] Storage::StartResult legacyStart( [[nodiscard]] Storage::StartResult legacyStart(
const QByteArray &passcode); const QByteArray &passcode);
@ -100,6 +105,8 @@ public:
} }
private: private:
static constexpr auto kDefaultSaveDelay = crl::time(1000);
void startMtp(std::unique_ptr<MTP::Config> config); void startMtp(std::unique_ptr<MTP::Config> config);
void createSession( void createSession(
const MTPUser &user, const MTPUser &user,
@ -116,6 +123,7 @@ private:
void loggedOut(); void loggedOut();
const not_null<Domain*> _domain;
const std::unique_ptr<Storage::Account> _local; const std::unique_ptr<Storage::Account> _local;
std::unique_ptr<MTP::Instance> _mtp; std::unique_ptr<MTP::Instance> _mtp;

View file

@ -5,7 +5,7 @@ the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link: For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "main/main_accounts.h" #include "main/main_domain.h"
#include "core/application.h" #include "core/application.h"
#include "core/shortcuts.h" #include "core/shortcuts.h"
@ -14,24 +14,24 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h" #include "data/data_session.h"
#include "mtproto/mtproto_config.h" #include "mtproto/mtproto_config.h"
#include "mtproto/mtproto_dc_options.h" #include "mtproto/mtproto_dc_options.h"
#include "storage/storage_accounts.h" #include "storage/storage_domain.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "facades.h" #include "facades.h"
namespace Main { namespace Main {
Accounts::Accounts(const QString &dataName) Domain::Domain(const QString &dataName)
: _dataName(dataName) : _dataName(dataName)
, _local(std::make_unique<Storage::Accounts>(this, dataName)) { , _local(std::make_unique<Storage::Domain>(this, dataName)) {
} }
Accounts::~Accounts() = default; Domain::~Domain() = default;
bool Accounts::started() const { bool Domain::started() const {
return !_accounts.empty(); return !_accounts.empty();
} }
Storage::StartResult Accounts::start(const QByteArray &passcode) { Storage::StartResult Domain::start(const QByteArray &passcode) {
Expects(!started()); Expects(!started());
const auto result = _local->start(passcode); const auto result = _local->start(passcode);
@ -46,13 +46,13 @@ Storage::StartResult Accounts::start(const QByteArray &passcode) {
return result; return result;
} }
void Accounts::finish() { void Domain::finish() {
_activeIndex = -1; _activeIndex = -1;
_active = nullptr; _active = nullptr;
base::take(_accounts); base::take(_accounts);
} }
void Accounts::accountAddedInStorage( void Domain::accountAddedInStorage(
int index, int index,
std::unique_ptr<Account> account) { std::unique_ptr<Account> account) {
Expects(account != nullptr); Expects(account != nullptr);
@ -64,7 +64,7 @@ void Accounts::accountAddedInStorage(
_accounts.emplace(index, std::move(account)); _accounts.emplace(index, std::move(account));
}; };
void Accounts::resetWithForgottenPasscode() { void Domain::resetWithForgottenPasscode() {
if (_accounts.empty()) { if (_accounts.empty()) {
_local->startFromScratch(); _local->startFromScratch();
activateAfterStarting(); activateAfterStarting();
@ -75,7 +75,7 @@ void Accounts::resetWithForgottenPasscode() {
} }
} }
void Accounts::activateAfterStarting() { void Domain::activateAfterStarting() {
Expects(started()); Expects(started());
for (const auto &[index, account] : _accounts) { for (const auto &[index, account] : _accounts) {
@ -86,57 +86,57 @@ void Accounts::activateAfterStarting() {
removePasscodeIfEmpty(); removePasscodeIfEmpty();
} }
const base::flat_map<int, std::unique_ptr<Account>> &Accounts::list() const { const base::flat_map<int, std::unique_ptr<Account>> &Domain::accounts() const {
return _accounts; return _accounts;
} }
rpl::producer<Account*> Accounts::activeValue() const { rpl::producer<Account*> Domain::activeValue() const {
return _active.value(); return _active.value();
} }
int Accounts::activeIndex() const { int Domain::activeIndex() const {
Expects(_accounts.contains(_activeIndex)); Expects(_accounts.contains(_activeIndex));
return _activeIndex; return _activeIndex;
} }
Account &Accounts::active() const { Account &Domain::active() const {
Expects(!_accounts.empty()); Expects(!_accounts.empty());
Ensures(_active.current() != nullptr); Ensures(_active.current() != nullptr);
return *_active.current(); return *_active.current();
} }
rpl::producer<not_null<Account*>> Accounts::activeChanges() const { rpl::producer<not_null<Account*>> Domain::activeChanges() const {
return _active.changes() | rpl::map([](Account *value) { return _active.changes() | rpl::map([](Account *value) {
return not_null{ value }; return not_null{ value };
}); });
} }
rpl::producer<Session*> Accounts::activeSessionChanges() const { rpl::producer<Session*> Domain::activeSessionChanges() const {
return _activeSessions.events(); return _activeSessions.events();
} }
rpl::producer<Session*> Accounts::activeSessionValue() const { rpl::producer<Session*> Domain::activeSessionValue() const {
const auto current = (_accounts.empty() || !active().sessionExists()) const auto current = (_accounts.empty() || !active().sessionExists())
? nullptr ? nullptr
: &active().session(); : &active().session();
return rpl::single(current) | rpl::then(_activeSessions.events()); return rpl::single(current) | rpl::then(_activeSessions.events());
} }
int Accounts::unreadBadge() const { int Domain::unreadBadge() const {
return _unreadBadge; return _unreadBadge;
} }
bool Accounts::unreadBadgeMuted() const { bool Domain::unreadBadgeMuted() const {
return _unreadBadgeMuted; return _unreadBadgeMuted;
} }
rpl::producer<> Accounts::unreadBadgeChanges() const { rpl::producer<> Domain::unreadBadgeChanges() const {
return _unreadBadgeChanges.events(); return _unreadBadgeChanges.events();
} }
void Accounts::notifyUnreadBadgeChanged() { void Domain::notifyUnreadBadgeChanged() {
for (const auto &[index, account] : _accounts) { for (const auto &[index, account] : _accounts) {
if (account->sessionExists()) { if (account->sessionExists()) {
account->session().data().notifyUnreadBadgeChanged(); account->session().data().notifyUnreadBadgeChanged();
@ -144,7 +144,7 @@ void Accounts::notifyUnreadBadgeChanged() {
} }
} }
void Accounts::updateUnreadBadge() { void Domain::updateUnreadBadge() {
_unreadBadge = 0; _unreadBadge = 0;
_unreadBadgeMuted = true; _unreadBadgeMuted = true;
for (const auto &[index, account] : _accounts) { for (const auto &[index, account] : _accounts) {
@ -159,7 +159,7 @@ void Accounts::updateUnreadBadge() {
_unreadBadgeChanges.fire({}); _unreadBadgeChanges.fire({});
} }
void Accounts::scheduleUpdateUnreadBadge() { void Domain::scheduleUpdateUnreadBadge() {
if (_unreadBadgeUpdateScheduled) { if (_unreadBadgeUpdateScheduled) {
return; return;
} }
@ -170,7 +170,7 @@ void Accounts::scheduleUpdateUnreadBadge() {
})); }));
} }
int Accounts::add(MTP::Environment environment) { int Domain::add(MTP::Environment environment) {
Expects(_active.current() != nullptr); Expects(_active.current() != nullptr);
static const auto cloneConfig = [](const MTP::Config &config) { static const auto cloneConfig = [](const MTP::Config &config) {
@ -183,7 +183,7 @@ int Accounts::add(MTP::Environment environment) {
if (_active.current()->mtp().environment() == environment) { if (_active.current()->mtp().environment() == environment) {
return accountConfig(_active.current()); return accountConfig(_active.current());
} }
for (const auto &[index, account] : list()) { for (const auto &[index, account] : _accounts) {
if (account->mtp().environment() == environment) { if (account->mtp().environment() == environment) {
return accountConfig(account.get()); return accountConfig(account.get());
} }
@ -198,14 +198,14 @@ int Accounts::add(MTP::Environment environment) {
} }
const auto account = _accounts.emplace( const auto account = _accounts.emplace(
index, index,
std::make_unique<Account>(_dataName, index) std::make_unique<Account>(this, _dataName, index)
).first->second.get(); ).first->second.get();
_local->startAdded(account, std::move(config)); _local->startAdded(account, std::move(config));
watchSession(account); watchSession(account);
return index; return index;
} }
void Accounts::watchSession(not_null<Account*> account) { void Domain::watchSession(not_null<Account*> account) {
account->sessionValue( account->sessionValue(
) | rpl::filter([=](Session *session) { ) | rpl::filter([=](Session *session) {
return session != nullptr; return session != nullptr;
@ -230,7 +230,7 @@ void Accounts::watchSession(not_null<Account*> account) {
}, account->lifetime()); }, account->lifetime());
} }
void Accounts::activateAuthedAccount() { void Domain::activateAuthedAccount() {
Expects(started()); Expects(started());
if (_active.current()->sessionExists()) { if (_active.current()->sessionExists()) {
@ -244,7 +244,7 @@ void Accounts::activateAuthedAccount() {
} }
} }
bool Accounts::removePasscodeIfEmpty() { bool Domain::removePasscodeIfEmpty() {
if (_accounts.size() != 1 || _active.current()->sessionExists()) { if (_accounts.size() != 1 || _active.current()->sessionExists()) {
return false; return false;
} }
@ -258,7 +258,7 @@ bool Accounts::removePasscodeIfEmpty() {
return true; return true;
} }
void Accounts::removeRedundantAccounts() { void Domain::removeRedundantAccounts() {
Expects(started()); Expects(started());
const auto was = _accounts.size(); const auto was = _accounts.size();
@ -278,7 +278,7 @@ void Accounts::removeRedundantAccounts() {
} }
} }
void Accounts::checkForLastProductionConfig( void Domain::checkForLastProductionConfig(
not_null<Main::Account*> account) { not_null<Main::Account*> account) {
const auto mtp = &account->mtp(); const auto mtp = &account->mtp();
if (mtp->environment() != MTP::Environment::Production) { if (mtp->environment() != MTP::Environment::Production) {
@ -293,7 +293,7 @@ void Accounts::checkForLastProductionConfig(
Core::App().refreshFallbackProductionConfig(mtp->config()); Core::App().refreshFallbackProductionConfig(mtp->config());
} }
void Accounts::activate(int index) { void Domain::activate(int index) {
Expects(_accounts.contains(index)); Expects(_accounts.contains(index));
const auto changed = (_activeIndex != index); const auto changed = (_activeIndex != index);
@ -308,7 +308,7 @@ void Accounts::activate(int index) {
} }
} }
void Accounts::scheduleWriteAccounts() { void Domain::scheduleWriteAccounts() {
if (_writeAccountsScheduled) { if (_writeAccountsScheduled) {
return; return;
} }

View file

@ -7,8 +7,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#pragma once #pragma once
#include "base/timer.h"
namespace Storage { namespace Storage {
class Accounts; class Domain;
enum class StartResult : uchar; enum class StartResult : uchar;
} // namespace Storage } // namespace Storage
@ -21,21 +23,23 @@ namespace Main {
class Account; class Account;
class Session; class Session;
class Accounts final { class Domain final {
public: public:
explicit Accounts(const QString &dataName); static constexpr auto kMaxAccounts = 3;
~Accounts();
explicit Domain(const QString &dataName);
~Domain();
[[nodiscard]] bool started() const; [[nodiscard]] bool started() const;
[[nodiscard]] Storage::StartResult start(const QByteArray &passcode); [[nodiscard]] Storage::StartResult start(const QByteArray &passcode);
void resetWithForgottenPasscode(); void resetWithForgottenPasscode();
void finish(); void finish();
[[nodiscard]] Storage::Accounts &local() const { [[nodiscard]] Storage::Domain &local() const {
return *_local; return *_local;
} }
[[nodiscard]] auto list() const [[nodiscard]] auto accounts() const
-> const base::flat_map<int, std::unique_ptr<Account>> &; -> const base::flat_map<int, std::unique_ptr<Account>> &;
[[nodiscard]] rpl::producer<Account*> activeValue() const; [[nodiscard]] rpl::producer<Account*> activeValue() const;
@ -55,7 +59,7 @@ public:
[[nodiscard]] int add(MTP::Environment environment); [[nodiscard]] int add(MTP::Environment environment);
void activate(int index); void activate(int index);
// Interface for Storage::Accounts. // Interface for Storage::Domain.
void accountAddedInStorage(int index, std::unique_ptr<Account> account); void accountAddedInStorage(int index, std::unique_ptr<Account> account);
private: private:
@ -70,7 +74,7 @@ private:
void scheduleUpdateUnreadBadge(); void scheduleUpdateUnreadBadge();
const QString _dataName; const QString _dataName;
const std::unique_ptr<Storage::Accounts> _local; const std::unique_ptr<Storage::Domain> _local;
base::flat_map<int, std::unique_ptr<Account>> _accounts; base::flat_map<int, std::unique_ptr<Account>> _accounts;
rpl::variable<Account*> _active = nullptr; rpl::variable<Account*> _active = nullptr;

View file

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "api/api_updates.h" #include "api/api_updates.h"
#include "core/application.h" #include "core/application.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_domain.h"
#include "main/main_session_settings.h" #include "main/main_session_settings.h"
#include "mtproto/mtproto_config.h" #include "mtproto/mtproto_config.h"
#include "chat_helpers/stickers_emoji_pack.h" #include "chat_helpers/stickers_emoji_pack.h"
@ -42,7 +43,7 @@ namespace {
constexpr auto kLegacyCallsPeerToPeerNobody = 4; constexpr auto kLegacyCallsPeerToPeerNobody = 4;
[[nodiscard]] QString ValidatedInternalLinksDomain( [[nodiscard]] QString ValidatedInternalLinksDomain(
not_null<const Main::Session*> session) { not_null<const Session*> session) {
// This domain should start with 'http[s]://' and end with '/'. // This domain should start with 'http[s]://' and end with '/'.
// Like 'https://telegram.me/' or 'https://t.me/'. // Like 'https://telegram.me/' or 'https://t.me/'.
const auto &domain = session->serverConfig().internalLinksDomain; const auto &domain = session->serverConfig().internalLinksDomain;
@ -63,7 +64,7 @@ constexpr auto kLegacyCallsPeerToPeerNobody = 4;
} // namespace } // namespace
Session::Session( Session::Session(
not_null<Main::Account*> account, not_null<Account*> account,
const MTPUser &user, const MTPUser &user,
std::unique_ptr<SessionSettings> settings) std::unique_ptr<SessionSettings> settings)
: _account(account) : _account(account)
@ -140,7 +141,7 @@ Session::~Session() {
ClickHandler::unpressed(); ClickHandler::unpressed();
} }
Main::Account &Session::account() const { Account &Session::account() const {
return *_account; return *_account;
} }
@ -148,6 +149,14 @@ Storage::Account &Session::local() const {
return _account->local(); return _account->local();
} }
Domain &Session::domain() const {
return _account->domain();
}
Storage::Domain &Session::domainLocal() const {
return _account->domainLocal();
}
base::Observable<void> &Session::downloaderTaskFinished() { base::Observable<void> &Session::downloaderTaskFinished() {
return downloader().taskFinished(); return downloader().taskFinished();
} }
@ -172,10 +181,21 @@ bool Session::validateSelf(const MTPUser &user) {
return true; return true;
} }
void Session::saveSettings() {
local().writeSessionSettings();
}
void Session::saveSettingsDelayed(crl::time delay) { void Session::saveSettingsDelayed(crl::time delay) {
_saveSettingsTimer.callOnce(delay); _saveSettingsTimer.callOnce(delay);
} }
void Session::saveSettingsNowIfNeeded() {
if (_saveSettingsTimer.isActive()) {
_saveSettingsTimer.cancel();
saveSettings();
}
}
MTP::DcId Session::mainDcId() const { MTP::DcId Session::mainDcId() const {
return _account->mtp().mainDcId(); return _account->mtp().mainDcId();
} }
@ -227,17 +247,6 @@ Support::Templates& Session::supportTemplates() const {
return supportHelper().templates(); return supportHelper().templates();
} }
void Session::saveSettingsNowIfNeeded() {
if (_saveSettingsTimer.isActive()) {
_saveSettingsTimer.cancel();
saveSettings();
}
}
void Session::saveSettings() {
local().writeSessionSettings();
}
void Session::addWindow(not_null<Window::SessionController*> controller) { void Session::addWindow(not_null<Window::SessionController*> controller) {
_windows.emplace(controller); _windows.emplace(controller);
controller->lifetime().add([=] { controller->lifetime().add([=] {

View file

@ -38,6 +38,7 @@ class DownloadManagerMtproto;
class Uploader; class Uploader;
class Facade; class Facade;
class Account; class Account;
class Domain;
} // namespace Storage } // namespace Storage
namespace Window { namespace Window {
@ -59,6 +60,7 @@ class DicePacks;
namespace Main { namespace Main {
class Account; class Account;
class Domain;
class SessionSettings; class SessionSettings;
class Session final class Session final
@ -66,7 +68,7 @@ class Session final
, private base::Subscriber { , private base::Subscriber {
public: public:
Session( Session(
not_null<Main::Account*> account, not_null<Account*> account,
const MTPUser &user, const MTPUser &user,
std::unique_ptr<SessionSettings> settings); std::unique_ptr<SessionSettings> settings);
~Session(); ~Session();
@ -74,8 +76,10 @@ public:
Session(const Session &other) = delete; Session(const Session &other) = delete;
Session &operator=(const Session &other) = delete; Session &operator=(const Session &other) = delete;
[[nodiscard]] Main::Account &account() const; [[nodiscard]] Account &account() const;
[[nodiscard]] Storage::Account &local() const; [[nodiscard]] Storage::Account &local() const;
[[nodiscard]] Domain &domain() const;
[[nodiscard]] Storage::Domain &domainLocal() const;
[[nodiscard]] UserId userId() const; [[nodiscard]] UserId userId() const;
[[nodiscard]] PeerId userPeerId() const; [[nodiscard]] PeerId userPeerId() const;
@ -102,18 +106,19 @@ public:
[[nodiscard]] Stickers::DicePacks &diceStickersPacks() const { [[nodiscard]] Stickers::DicePacks &diceStickersPacks() const {
return *_diceStickersPacks; return *_diceStickersPacks;
} }
[[nodiscard]] Window::Notifications::System &notifications() { [[nodiscard]] Window::Notifications::System &notifications() const {
return *_notifications; return *_notifications;
} }
[[nodiscard]] Data::Changes &changes() { [[nodiscard]] Data::Changes &changes() const {
return *_changes; return *_changes;
} }
[[nodiscard]] Data::Session &data() { [[nodiscard]] Data::Session &data() const {
return *_data; return *_data;
} }
[[nodiscard]] SessionSettings &settings() { [[nodiscard]] SessionSettings &settings() const {
return *_settings; return *_settings;
} }
void saveSettings(); void saveSettings();
void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay); void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay);
void saveSettingsNowIfNeeded(); void saveSettingsNowIfNeeded();
@ -137,7 +142,6 @@ public:
void termsDeleteNow(); void termsDeleteNow();
void setInternalLinkDomain(const QString &domain) const;
[[nodiscard]] QString createInternalLink(const QString &query) const; [[nodiscard]] QString createInternalLink(const QString &query) const;
[[nodiscard]] QString createInternalLinkFull(const QString &query) const; [[nodiscard]] QString createInternalLinkFull(const QString &query) const;
@ -155,7 +159,7 @@ public:
private: private:
static constexpr auto kDefaultSaveDelay = crl::time(1000); static constexpr auto kDefaultSaveDelay = crl::time(1000);
const not_null<Main::Account*> _account; const not_null<Account*> _account;
const std::unique_ptr<SessionSettings> _settings; const std::unique_ptr<SessionSettings> _settings;
const std::unique_ptr<ApiWrap> _api; const std::unique_ptr<ApiWrap> _api;

View file

@ -13,6 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "support/support_common.h" #include "support/support_common.h"
#include "storage/serialize_common.h" #include "storage/serialize_common.h"
#include "boxes/send_files_box.h" #include "boxes/send_files_box.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
namespace Main { namespace Main {
@ -20,29 +22,19 @@ namespace {
constexpr auto kLegacyCallsPeerToPeerNobody = 4; constexpr auto kLegacyCallsPeerToPeerNobody = 4;
constexpr auto kVersionTag = -1; constexpr auto kVersionTag = -1;
constexpr auto kVersion = 1; constexpr auto kVersion = 2;
constexpr auto kMaxSavedPlaybackPositions = 16; constexpr auto kMaxSavedPlaybackPositions = 16;
[[nodiscard]] qint32 SerializePlaybackSpeed(float64 speed) {
return int(std::round(std::clamp(speed * 4., 2., 8.))) - 2;
}
float64 DeserializePlaybackSpeed(qint32 speed) {
return (std::clamp(speed, 0, 6) + 2) / 4.;
}
} // namespace } // namespace
SessionSettings::Variables::Variables() SessionSettings::SessionSettings()
: sendFilesWay(SendFilesWay::Album) : _selectorTab(ChatHelpers::SelectorTab::Emoji)
, selectorTab(ChatHelpers::SelectorTab::Emoji) , _floatPlayerColumn(Window::Column::Second)
, floatPlayerColumn(Window::Column::Second) , _floatPlayerCorner(RectPart::TopRight)
, floatPlayerCorner(RectPart::TopRight) , _dialogsWidthRatio(ThirdColumnByDefault()
, dialogsWidthRatio(ThirdColumnByDefault()
? kDefaultBigDialogsWidthRatio ? kDefaultBigDialogsWidthRatio
: kDefaultDialogsWidthRatio) : kDefaultDialogsWidthRatio)
, sendSubmitWay(Ui::InputSubmitSettings::Enter) , _supportSwitch(Support::SwitchSettings::Next) {
, supportSwitch(Support::SwitchSettings::Next) {
} }
bool SessionSettings::ThirdColumnByDefault() { bool SessionSettings::ThirdColumnByDefault() {
@ -50,16 +42,12 @@ bool SessionSettings::ThirdColumnByDefault() {
} }
QByteArray SessionSettings::serialize() const { QByteArray SessionSettings::serialize() const {
const auto autoDownload = _variables.autoDownload.serialize(); const auto autoDownload = _autoDownload.serialize();
auto size = sizeof(qint32) * 38; auto size = sizeof(qint32) * 38;
for (const auto &[key, value] : _variables.soundOverrides) { size += _groupStickersSectionHidden.size() * sizeof(quint64);
size += Serialize::stringSize(key) + Serialize::stringSize(value); size += _mediaLastPlaybackPosition.size() * 2 * sizeof(quint64);
}
size += _variables.groupStickersSectionHidden.size() * sizeof(quint64);
size += _variables.mediaLastPlaybackPosition.size() * 2 * sizeof(quint64);
size += Serialize::bytearraySize(autoDownload); size += Serialize::bytearraySize(autoDownload);
size += Serialize::bytearraySize(_variables.videoPipGeometry); size += sizeof(qint32) + _hiddenPinnedMessages.size() * (sizeof(quint64) + sizeof(qint32));
size += sizeof(qint32) + _variables.hiddenPinnedMessages.size() * (sizeof(quint64) + sizeof(qint32));
auto result = QByteArray(); auto result = QByteArray();
result.reserve(size); result.reserve(size);
@ -67,125 +55,98 @@ QByteArray SessionSettings::serialize() const {
QDataStream stream(&result, QIODevice::WriteOnly); QDataStream stream(&result, QIODevice::WriteOnly);
stream.setVersion(QDataStream::Qt_5_1); stream.setVersion(QDataStream::Qt_5_1);
stream << qint32(kVersionTag) << qint32(kVersion); stream << qint32(kVersionTag) << qint32(kVersion);
stream << static_cast<qint32>(_variables.selectorTab); stream << static_cast<qint32>(_selectorTab);
stream << qint32(_variables.lastSeenWarningSeen ? 1 : 0); stream << qint32(_tabbedSelectorSectionEnabled ? 1 : 0);
stream << qint32(_variables.tabbedSelectorSectionEnabled ? 1 : 0); stream << qint32(_floatPlayerColumn);
stream << qint32(_variables.soundOverrides.size()); stream << qint32(_floatPlayerCorner);
for (const auto &[key, value] : _variables.soundOverrides) { stream << qint32(_groupStickersSectionHidden.size());
stream << key << value; for (auto peerId : _groupStickersSectionHidden) {
}
stream << qint32(_variables.tabbedSelectorSectionTooltipShown);
stream << qint32(_variables.floatPlayerColumn);
stream << qint32(_variables.floatPlayerCorner);
stream << qint32(_variables.groupStickersSectionHidden.size());
for (auto peerId : _variables.groupStickersSectionHidden) {
stream << quint64(peerId); stream << quint64(peerId);
} }
stream << qint32(_variables.thirdSectionInfoEnabled ? 1 : 0); stream << qint32(_thirdSectionInfoEnabled ? 1 : 0);
stream << qint32(_variables.smallDialogsList ? 1 : 0); stream << qint32(_smallDialogsList ? 1 : 0);
stream << qint32(snap( stream << qint32(snap(
qRound(_variables.dialogsWidthRatio.current() * 1000000), qRound(_dialogsWidthRatio.current() * 1000000),
0, 0,
1000000)); 1000000));
stream << qint32(_variables.thirdColumnWidth.current()); stream << qint32(_thirdColumnWidth.current());
stream << qint32(_variables.thirdSectionExtendedBy); stream << qint32(_thirdSectionExtendedBy);
stream << qint32(_variables.sendFilesWay); stream << qint32(_supportSwitch);
stream << qint32(0);// LEGACY _variables.callsPeerToPeer.current()); stream << qint32(_supportFixChatsOrder ? 1 : 0);
stream << qint32(_variables.sendSubmitWay); stream << qint32(_supportTemplatesAutocomplete ? 1 : 0);
stream << qint32(_variables.supportSwitch); stream << qint32(_supportChatsTimeSlice.current());
stream << qint32(_variables.supportFixChatsOrder ? 1 : 0);
stream << qint32(_variables.supportTemplatesAutocomplete ? 1 : 0);
stream << qint32(_variables.supportChatsTimeSlice.current());
stream << qint32(_variables.includeMutedCounter ? 1 : 0);
stream << qint32(_variables.countUnreadMessages ? 1 : 0);
stream << qint32(_variables.exeLaunchWarning ? 1 : 0);
stream << autoDownload; stream << autoDownload;
stream << qint32(_variables.supportAllSearchResults.current() ? 1 : 0); stream << qint32(_supportAllSearchResults.current() ? 1 : 0);
stream << qint32(_variables.archiveCollapsed.current() ? 1 : 0); stream << qint32(_archiveCollapsed.current() ? 1 : 0);
stream << qint32(_variables.notifyAboutPinned.current() ? 1 : 0); stream << qint32(_archiveInMainMenu.current() ? 1 : 0);
stream << qint32(_variables.archiveInMainMenu.current() ? 1 : 0); stream << qint32(_skipArchiveInSearch.current() ? 1 : 0);
stream << qint32(_variables.skipArchiveInSearch.current() ? 1 : 0); stream << qint32(_mediaLastPlaybackPosition.size());
stream << qint32(0);// LEGACY _variables.autoplayGifs ? 1 : 0); for (const auto &[id, time] : _mediaLastPlaybackPosition) {
stream << qint32(_variables.loopAnimatedStickers ? 1 : 0);
stream << qint32(_variables.largeEmoji.current() ? 1 : 0);
stream << qint32(_variables.replaceEmoji.current() ? 1 : 0);
stream << qint32(_variables.suggestEmoji ? 1 : 0);
stream << qint32(_variables.suggestStickersByEmoji ? 1 : 0);
stream << qint32(_variables.spellcheckerEnabled.current() ? 1 : 0);
stream << qint32(_variables.mediaLastPlaybackPosition.size());
for (const auto &[id, time] : _variables.mediaLastPlaybackPosition) {
stream << quint64(id) << qint64(time); stream << quint64(id) << qint64(time);
} }
stream << qint32(SerializePlaybackSpeed(_variables.videoPlaybackSpeed.current())); stream << qint32(_hiddenPinnedMessages.size());
stream << _variables.videoPipGeometry; for (const auto &[key, value] : _hiddenPinnedMessages) {
stream << qint32(_variables.dictionariesEnabled.current().size());
for (const auto i : _variables.dictionariesEnabled.current()) {
stream << quint64(i);
}
stream << qint32(_variables.autoDownloadDictionaries.current() ? 1 : 0);
stream << qint32(_variables.hiddenPinnedMessages.size());
for (const auto &[key, value] : _variables.hiddenPinnedMessages) {
stream << quint64(key) << qint32(value); stream << quint64(key) << qint32(value);
} }
stream << qint32(_dialogsFiltersEnabled ? 1 : 0);
} }
return result; return result;
} }
std::unique_ptr<SessionSettings> SessionSettings::FromSerialized( void SessionSettings::addFromSerialized(const QByteArray &serialized) {
const QByteArray &serialized) {
if (serialized.isEmpty()) { if (serialized.isEmpty()) {
return nullptr; return;
} }
auto result = std::make_unique<SessionSettings>(); auto &app = Core::App().settings();
const auto variables = &result->_variables;
QDataStream stream(serialized); QDataStream stream(serialized);
stream.setVersion(QDataStream::Qt_5_1); stream.setVersion(QDataStream::Qt_5_1);
qint32 versionTag = 0; qint32 versionTag = 0;
qint32 version = 0; qint32 version = 0;
qint32 selectorTab = static_cast<qint32>(ChatHelpers::SelectorTab::Emoji); qint32 selectorTab = static_cast<qint32>(ChatHelpers::SelectorTab::Emoji);
qint32 lastSeenWarningSeen = 0; qint32 appLastSeenWarningSeen = app.lastSeenWarningSeen() ? 1 : 0;
qint32 tabbedSelectorSectionEnabled = 1; qint32 tabbedSelectorSectionEnabled = 1;
qint32 tabbedSelectorSectionTooltipShown = 0; qint32 legacyTabbedSelectorSectionTooltipShown = 0;
qint32 floatPlayerColumn = static_cast<qint32>(Window::Column::Second); qint32 floatPlayerColumn = static_cast<qint32>(Window::Column::Second);
qint32 floatPlayerCorner = static_cast<qint32>(RectPart::TopRight); qint32 floatPlayerCorner = static_cast<qint32>(RectPart::TopRight);
base::flat_map<QString, QString> soundOverrides; base::flat_map<QString, QString> appSoundOverrides;
base::flat_set<PeerId> groupStickersSectionHidden; base::flat_set<PeerId> groupStickersSectionHidden;
qint32 thirdSectionInfoEnabled = 0; qint32 thirdSectionInfoEnabled = 0;
qint32 smallDialogsList = 0; qint32 smallDialogsList = 0;
float64 dialogsWidthRatio = variables->dialogsWidthRatio.current(); float64 dialogsWidthRatio = _dialogsWidthRatio.current();
int thirdColumnWidth = variables->thirdColumnWidth.current(); int thirdColumnWidth = _thirdColumnWidth.current();
int thirdSectionExtendedBy = variables->thirdSectionExtendedBy; int thirdSectionExtendedBy = _thirdSectionExtendedBy;
qint32 sendFilesWay = static_cast<qint32>(variables->sendFilesWay); qint32 appSendFilesWay = static_cast<qint32>(app.sendFilesWay());
qint32 legacyCallsPeerToPeer = qint32(0); qint32 legacyCallsPeerToPeer = qint32(0);
qint32 sendSubmitWay = static_cast<qint32>(variables->sendSubmitWay); qint32 appSendSubmitWay = static_cast<qint32>(app.sendSubmitWay());
qint32 supportSwitch = static_cast<qint32>(variables->supportSwitch); qint32 supportSwitch = static_cast<qint32>(_supportSwitch);
qint32 supportFixChatsOrder = variables->supportFixChatsOrder ? 1 : 0; qint32 supportFixChatsOrder = _supportFixChatsOrder ? 1 : 0;
qint32 supportTemplatesAutocomplete = variables->supportTemplatesAutocomplete ? 1 : 0; qint32 supportTemplatesAutocomplete = _supportTemplatesAutocomplete ? 1 : 0;
qint32 supportChatsTimeSlice = variables->supportChatsTimeSlice.current(); qint32 supportChatsTimeSlice = _supportChatsTimeSlice.current();
qint32 includeMutedCounter = variables->includeMutedCounter ? 1 : 0; qint32 appIncludeMutedCounter = app.includeMutedCounter() ? 1 : 0;
qint32 countUnreadMessages = variables->countUnreadMessages ? 1 : 0; qint32 appCountUnreadMessages = app.countUnreadMessages() ? 1 : 0;
qint32 exeLaunchWarning = variables->exeLaunchWarning ? 1 : 0; qint32 appExeLaunchWarning = app.exeLaunchWarning() ? 1 : 0;
QByteArray autoDownload; QByteArray autoDownload;
qint32 supportAllSearchResults = variables->supportAllSearchResults.current() ? 1 : 0; qint32 supportAllSearchResults = _supportAllSearchResults.current() ? 1 : 0;
qint32 archiveCollapsed = variables->archiveCollapsed.current() ? 1 : 0; qint32 archiveCollapsed = _archiveCollapsed.current() ? 1 : 0;
qint32 notifyAboutPinned = variables->notifyAboutPinned.current() ? 1 : 0; qint32 appNotifyAboutPinned = app.notifyAboutPinned() ? 1 : 0;
qint32 archiveInMainMenu = variables->archiveInMainMenu.current() ? 1 : 0; qint32 archiveInMainMenu = _archiveInMainMenu.current() ? 1 : 0;
qint32 skipArchiveInSearch = variables->skipArchiveInSearch.current() ? 1 : 0; qint32 skipArchiveInSearch = _skipArchiveInSearch.current() ? 1 : 0;
qint32 autoplayGifs = 1; qint32 legacyAutoplayGifs = 1;
qint32 loopAnimatedStickers = variables->loopAnimatedStickers ? 1 : 0; qint32 appLoopAnimatedStickers = app.loopAnimatedStickers() ? 1 : 0;
qint32 largeEmoji = variables->largeEmoji.current() ? 1 : 0; qint32 appLargeEmoji = app.largeEmoji() ? 1 : 0;
qint32 replaceEmoji = variables->replaceEmoji.current() ? 1 : 0; qint32 appReplaceEmoji = app.replaceEmoji() ? 1 : 0;
qint32 suggestEmoji = variables->suggestEmoji ? 1 : 0; qint32 appSuggestEmoji = app.suggestEmoji() ? 1 : 0;
qint32 suggestStickersByEmoji = variables->suggestStickersByEmoji ? 1 : 0; qint32 appSuggestStickersByEmoji = app.suggestStickersByEmoji() ? 1 : 0;
qint32 spellcheckerEnabled = variables->spellcheckerEnabled.current() ? 1 : 0; qint32 appSpellcheckerEnabled = app.spellcheckerEnabled() ? 1 : 0;
std::vector<std::pair<DocumentId, crl::time>> mediaLastPlaybackPosition; std::vector<std::pair<DocumentId, crl::time>> mediaLastPlaybackPosition;
qint32 videoPlaybackSpeed = SerializePlaybackSpeed(variables->videoPlaybackSpeed.current()); qint32 appVideoPlaybackSpeed = Core::Settings::SerializePlaybackSpeed(app.videoPlaybackSpeed());
QByteArray videoPipGeometry = variables->videoPipGeometry; QByteArray appVideoPipGeometry = app.videoPipGeometry();
std::vector<int> dictionariesEnabled; std::vector<int> appDictionariesEnabled;
qint32 autoDownloadDictionaries = variables->autoDownloadDictionaries.current() ? 1 : 0; qint32 appAutoDownloadDictionaries = app.autoDownloadDictionaries() ? 1 : 0;
base::flat_map<PeerId, MsgId> hiddenPinnedMessages; base::flat_map<PeerId, MsgId> hiddenPinnedMessages;
qint32 dialogsFiltersEnabled = _dialogsFiltersEnabled ? 1 : 0;
stream >> versionTag; stream >> versionTag;
if (versionTag == kVersionTag) { if (versionTag == kVersionTag) {
@ -194,10 +155,13 @@ std::unique_ptr<SessionSettings> SessionSettings::FromSerialized(
} else { } else {
selectorTab = versionTag; selectorTab = versionTag;
} }
stream >> lastSeenWarningSeen; if (version < 2) {
stream >> appLastSeenWarningSeen;
}
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> tabbedSelectorSectionEnabled; stream >> tabbedSelectorSectionEnabled;
} }
if (version < 2) {
if (!stream.atEnd()) { if (!stream.atEnd()) {
auto count = qint32(0); auto count = qint32(0);
stream >> count; stream >> count;
@ -205,12 +169,13 @@ std::unique_ptr<SessionSettings> SessionSettings::FromSerialized(
for (auto i = 0; i != count; ++i) { for (auto i = 0; i != count; ++i) {
QString key, value; QString key, value;
stream >> key >> value; stream >> key >> value;
soundOverrides.emplace(key, value); appSoundOverrides.emplace(key, value);
} }
} }
} }
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> tabbedSelectorSectionTooltipShown; stream >> legacyTabbedSelectorSectionTooltipShown;
}
} }
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> floatPlayerColumn >> floatPlayerCorner; stream >> floatPlayerColumn >> floatPlayerCorner;
@ -241,14 +206,18 @@ std::unique_ptr<SessionSettings> SessionSettings::FromSerialized(
stream >> value; stream >> value;
thirdSectionExtendedBy = value; thirdSectionExtendedBy = value;
} }
if (version < 2) {
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> sendFilesWay; stream >> appSendFilesWay;
} }
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> legacyCallsPeerToPeer; stream >> legacyCallsPeerToPeer;
} }
}
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> sendSubmitWay; if (version < 2) {
stream >> appSendSubmitWay;
}
stream >> supportSwitch; stream >> supportSwitch;
stream >> supportFixChatsOrder; stream >> supportFixChatsOrder;
} }
@ -258,12 +227,14 @@ std::unique_ptr<SessionSettings> SessionSettings::FromSerialized(
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> supportChatsTimeSlice; stream >> supportChatsTimeSlice;
} }
if (version < 2) {
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> includeMutedCounter; stream >> appIncludeMutedCounter;
stream >> countUnreadMessages; stream >> appCountUnreadMessages;
} }
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> exeLaunchWarning; stream >> appExeLaunchWarning;
}
} }
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> autoDownload; stream >> autoDownload;
@ -274,8 +245,10 @@ std::unique_ptr<SessionSettings> SessionSettings::FromSerialized(
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> archiveCollapsed; stream >> archiveCollapsed;
} }
if (version < 2) {
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> notifyAboutPinned; stream >> appNotifyAboutPinned;
}
} }
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> archiveInMainMenu; stream >> archiveInMainMenu;
@ -283,16 +256,18 @@ std::unique_ptr<SessionSettings> SessionSettings::FromSerialized(
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> skipArchiveInSearch; stream >> skipArchiveInSearch;
} }
if (version < 2) {
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> autoplayGifs; stream >> legacyAutoplayGifs;
stream >> loopAnimatedStickers; stream >> appLoopAnimatedStickers;
stream >> largeEmoji; stream >> appLargeEmoji;
stream >> replaceEmoji; stream >> appReplaceEmoji;
stream >> suggestEmoji; stream >> appSuggestEmoji;
stream >> suggestStickersByEmoji; stream >> appSuggestStickersByEmoji;
} }
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> spellcheckerEnabled; stream >> appSpellcheckerEnabled;
}
} }
if (!stream.atEnd()) { if (!stream.atEnd()) {
auto count = qint32(0); auto count = qint32(0);
@ -306,11 +281,12 @@ std::unique_ptr<SessionSettings> SessionSettings::FromSerialized(
} }
} }
} }
if (version < 2) {
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> videoPlaybackSpeed; stream >> appVideoPlaybackSpeed;
} }
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> videoPipGeometry; stream >> appVideoPipGeometry;
} }
if (!stream.atEnd()) { if (!stream.atEnd()) {
auto count = qint32(0); auto count = qint32(0);
@ -319,12 +295,13 @@ std::unique_ptr<SessionSettings> SessionSettings::FromSerialized(
for (auto i = 0; i != count; ++i) { for (auto i = 0; i != count; ++i) {
qint64 langId; qint64 langId;
stream >> langId; stream >> langId;
dictionariesEnabled.emplace_back(langId); appDictionariesEnabled.emplace_back(langId);
} }
} }
} }
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> autoDownloadDictionaries; stream >> appAutoDownloadDictionaries;
}
} }
if (!stream.atEnd()) { if (!stream.atEnd()) {
auto count = qint32(0); auto count = qint32(0);
@ -338,20 +315,22 @@ std::unique_ptr<SessionSettings> SessionSettings::FromSerialized(
} }
} }
} }
if (!stream.atEnd()) {
stream >> dialogsFiltersEnabled;
}
if (stream.status() != QDataStream::Ok) { if (stream.status() != QDataStream::Ok) {
LOG(("App Error: " LOG(("App Error: "
"Bad data for Main::SessionSettings::FromSerialized()")); "Bad data for Main::SessionSettings::FromSerialized()"));
return nullptr; return;
} }
if (!autoDownload.isEmpty() if (!autoDownload.isEmpty()
&& !variables->autoDownload.setFromSerialized(autoDownload)) { && !_autoDownload.setFromSerialized(autoDownload)) {
return nullptr; return;
} }
if (!version) { if (!version) {
if (!autoplayGifs) { if (!legacyAutoplayGifs) {
using namespace Data::AutoDownload; using namespace Data::AutoDownload;
variables->autoDownload = WithDisabledAutoPlay( _autoDownload = WithDisabledAutoPlay(_autoDownload);
variables->autoDownload);
} }
} }
@ -359,106 +338,110 @@ std::unique_ptr<SessionSettings> SessionSettings::FromSerialized(
switch (uncheckedTab) { switch (uncheckedTab) {
case ChatHelpers::SelectorTab::Emoji: case ChatHelpers::SelectorTab::Emoji:
case ChatHelpers::SelectorTab::Stickers: case ChatHelpers::SelectorTab::Stickers:
case ChatHelpers::SelectorTab::Gifs: variables->selectorTab = uncheckedTab; break; case ChatHelpers::SelectorTab::Gifs: _selectorTab = uncheckedTab; break;
} }
variables->lastSeenWarningSeen = (lastSeenWarningSeen == 1); _tabbedSelectorSectionEnabled = (tabbedSelectorSectionEnabled == 1);
variables->tabbedSelectorSectionEnabled = (tabbedSelectorSectionEnabled == 1);
variables->soundOverrides = std::move(soundOverrides);
variables->tabbedSelectorSectionTooltipShown = tabbedSelectorSectionTooltipShown;
auto uncheckedColumn = static_cast<Window::Column>(floatPlayerColumn); auto uncheckedColumn = static_cast<Window::Column>(floatPlayerColumn);
switch (uncheckedColumn) { switch (uncheckedColumn) {
case Window::Column::First: case Window::Column::First:
case Window::Column::Second: case Window::Column::Second:
case Window::Column::Third: variables->floatPlayerColumn = uncheckedColumn; break; case Window::Column::Third: _floatPlayerColumn = uncheckedColumn; break;
} }
auto uncheckedCorner = static_cast<RectPart>(floatPlayerCorner); auto uncheckedCorner = static_cast<RectPart>(floatPlayerCorner);
switch (uncheckedCorner) { switch (uncheckedCorner) {
case RectPart::TopLeft: case RectPart::TopLeft:
case RectPart::TopRight: case RectPart::TopRight:
case RectPart::BottomLeft: case RectPart::BottomLeft:
case RectPart::BottomRight: variables->floatPlayerCorner = uncheckedCorner; break; case RectPart::BottomRight: _floatPlayerCorner = uncheckedCorner; break;
} }
variables->groupStickersSectionHidden = std::move(groupStickersSectionHidden); _groupStickersSectionHidden = std::move(groupStickersSectionHidden);
variables->thirdSectionInfoEnabled = thirdSectionInfoEnabled; _thirdSectionInfoEnabled = thirdSectionInfoEnabled;
variables->smallDialogsList = smallDialogsList; _smallDialogsList = smallDialogsList;
variables->dialogsWidthRatio = dialogsWidthRatio; _dialogsWidthRatio = dialogsWidthRatio;
variables->thirdColumnWidth = thirdColumnWidth; _thirdColumnWidth = thirdColumnWidth;
variables->thirdSectionExtendedBy = thirdSectionExtendedBy; _thirdSectionExtendedBy = thirdSectionExtendedBy;
if (variables->thirdSectionInfoEnabled) { if (_thirdSectionInfoEnabled) {
variables->tabbedSelectorSectionEnabled = false; _tabbedSelectorSectionEnabled = false;
}
auto uncheckedSendFilesWay = static_cast<SendFilesWay>(sendFilesWay);
switch (uncheckedSendFilesWay) {
case SendFilesWay::Album:
case SendFilesWay::Photos:
case SendFilesWay::Files: variables->sendFilesWay = uncheckedSendFilesWay; break;
}
auto uncheckedSendSubmitWay = static_cast<Ui::InputSubmitSettings>(
sendSubmitWay);
switch (uncheckedSendSubmitWay) {
case Ui::InputSubmitSettings::Enter:
case Ui::InputSubmitSettings::CtrlEnter: variables->sendSubmitWay = uncheckedSendSubmitWay; break;
} }
auto uncheckedSupportSwitch = static_cast<Support::SwitchSettings>( auto uncheckedSupportSwitch = static_cast<Support::SwitchSettings>(
supportSwitch); supportSwitch);
switch (uncheckedSupportSwitch) { switch (uncheckedSupportSwitch) {
case Support::SwitchSettings::None: case Support::SwitchSettings::None:
case Support::SwitchSettings::Next: case Support::SwitchSettings::Next:
case Support::SwitchSettings::Previous: variables->supportSwitch = uncheckedSupportSwitch; break; case Support::SwitchSettings::Previous: _supportSwitch = uncheckedSupportSwitch; break;
}
_supportFixChatsOrder = (supportFixChatsOrder == 1);
_supportTemplatesAutocomplete = (supportTemplatesAutocomplete == 1);
_supportChatsTimeSlice = supportChatsTimeSlice;
_hadLegacyCallsPeerToPeerNobody = (legacyCallsPeerToPeer == kLegacyCallsPeerToPeerNobody);
_supportAllSearchResults = (supportAllSearchResults == 1);
_archiveCollapsed = (archiveCollapsed == 1);
_archiveInMainMenu = (archiveInMainMenu == 1);
_skipArchiveInSearch = (skipArchiveInSearch == 1);
_mediaLastPlaybackPosition = std::move(mediaLastPlaybackPosition);
_hiddenPinnedMessages = std::move(hiddenPinnedMessages);
_dialogsFiltersEnabled = (dialogsFiltersEnabled == 1);
if (version < 2) {
app.setLastSeenWarningSeen(appLastSeenWarningSeen == 1);
for (const auto &[key, value] : appSoundOverrides) {
app.setSoundOverride(key, value);
}
auto uncheckedSendFilesWay = static_cast<SendFilesWay>(appSendFilesWay);
switch (uncheckedSendFilesWay) {
case SendFilesWay::Album:
case SendFilesWay::Photos:
case SendFilesWay::Files: app.setSendFilesWay(uncheckedSendFilesWay); break;
}
auto uncheckedSendSubmitWay = static_cast<Ui::InputSubmitSettings>(
appSendSubmitWay);
switch (uncheckedSendSubmitWay) {
case Ui::InputSubmitSettings::Enter:
case Ui::InputSubmitSettings::CtrlEnter: app.setSendSubmitWay(uncheckedSendSubmitWay); break;
}
app.setIncludeMutedCounter(appIncludeMutedCounter == 1);
app.setCountUnreadMessages(appCountUnreadMessages == 1);
app.setExeLaunchWarning(appExeLaunchWarning == 1);
app.setNotifyAboutPinned(appNotifyAboutPinned == 1);
app.setLoopAnimatedStickers(appLoopAnimatedStickers == 1);
app.setLargeEmoji(appLargeEmoji == 1);
app.setReplaceEmoji(appReplaceEmoji == 1);
app.setSuggestEmoji(appSuggestEmoji == 1);
app.setSuggestStickersByEmoji(appSuggestStickersByEmoji == 1);
app.setSpellcheckerEnabled(appSpellcheckerEnabled == 1);
app.setVideoPlaybackSpeed(Core::Settings::DeserializePlaybackSpeed(appVideoPlaybackSpeed));
app.setVideoPipGeometry(appVideoPipGeometry);
app.setDictionariesEnabled(std::move(appDictionariesEnabled));
app.setAutoDownloadDictionaries(appAutoDownloadDictionaries == 1);
} }
variables->supportFixChatsOrder = (supportFixChatsOrder == 1);
variables->supportTemplatesAutocomplete = (supportTemplatesAutocomplete == 1);
variables->supportChatsTimeSlice = supportChatsTimeSlice;
variables->hadLegacyCallsPeerToPeerNobody = (legacyCallsPeerToPeer == kLegacyCallsPeerToPeerNobody);
variables->includeMutedCounter = (includeMutedCounter == 1);
variables->countUnreadMessages = (countUnreadMessages == 1);
variables->exeLaunchWarning = (exeLaunchWarning == 1);
variables->supportAllSearchResults = (supportAllSearchResults == 1);
variables->archiveCollapsed = (archiveCollapsed == 1);
variables->notifyAboutPinned = (notifyAboutPinned == 1);
variables->archiveInMainMenu = (archiveInMainMenu == 1);
variables->skipArchiveInSearch = (skipArchiveInSearch == 1);
variables->loopAnimatedStickers = (loopAnimatedStickers == 1);
variables->largeEmoji = (largeEmoji == 1);
variables->replaceEmoji = (replaceEmoji == 1);
variables->suggestEmoji = (suggestEmoji == 1);
variables->suggestStickersByEmoji = (suggestStickersByEmoji == 1);
variables->spellcheckerEnabled = (spellcheckerEnabled == 1);
variables->mediaLastPlaybackPosition = std::move(mediaLastPlaybackPosition);
variables->videoPlaybackSpeed = DeserializePlaybackSpeed(videoPlaybackSpeed);
variables->videoPipGeometry = videoPipGeometry;
variables->dictionariesEnabled = std::move(dictionariesEnabled);
variables->autoDownloadDictionaries = (autoDownloadDictionaries == 1);
variables->hiddenPinnedMessages = std::move(hiddenPinnedMessages);
return result;
} }
void SessionSettings::setSupportChatsTimeSlice(int slice) { void SessionSettings::setSupportChatsTimeSlice(int slice) {
_variables.supportChatsTimeSlice = slice; _supportChatsTimeSlice = slice;
} }
int SessionSettings::supportChatsTimeSlice() const { int SessionSettings::supportChatsTimeSlice() const {
return _variables.supportChatsTimeSlice.current(); return _supportChatsTimeSlice.current();
} }
rpl::producer<int> SessionSettings::supportChatsTimeSliceValue() const { rpl::producer<int> SessionSettings::supportChatsTimeSliceValue() const {
return _variables.supportChatsTimeSlice.value(); return _supportChatsTimeSlice.value();
} }
void SessionSettings::setSupportAllSearchResults(bool all) { void SessionSettings::setSupportAllSearchResults(bool all) {
_variables.supportAllSearchResults = all; _supportAllSearchResults = all;
} }
bool SessionSettings::supportAllSearchResults() const { bool SessionSettings::supportAllSearchResults() const {
return _variables.supportAllSearchResults.current(); return _supportAllSearchResults.current();
} }
rpl::producer<bool> SessionSettings::supportAllSearchResultsValue() const { rpl::producer<bool> SessionSettings::supportAllSearchResultsValue() const {
return _variables.supportAllSearchResults.value(); return _supportAllSearchResults.value();
} }
void SessionSettings::setTabbedSelectorSectionEnabled(bool enabled) { void SessionSettings::setTabbedSelectorSectionEnabled(bool enabled) {
_variables.tabbedSelectorSectionEnabled = enabled; _tabbedSelectorSectionEnabled = enabled;
if (enabled) { if (enabled) {
setThirdSectionInfoEnabled(false); setThirdSectionInfoEnabled(false);
} }
@ -471,8 +454,8 @@ rpl::producer<bool> SessionSettings::tabbedReplacedWithInfoValue() const {
} }
void SessionSettings::setThirdSectionInfoEnabled(bool enabled) { void SessionSettings::setThirdSectionInfoEnabled(bool enabled) {
if (_variables.thirdSectionInfoEnabled != enabled) { if (_thirdSectionInfoEnabled != enabled) {
_variables.thirdSectionInfoEnabled = enabled; _thirdSectionInfoEnabled = enabled;
if (enabled) { if (enabled) {
setTabbedSelectorSectionEnabled(false); setTabbedSelectorSectionEnabled(false);
} }
@ -493,40 +476,32 @@ void SessionSettings::setTabbedReplacedWithInfo(bool enabled) {
} }
} }
QString SessionSettings::getSoundPath(const QString &key) const {
auto it = _variables.soundOverrides.find(key);
if (it != _variables.soundOverrides.end()) {
return it->second;
}
return qsl(":/sounds/") + key + qsl(".mp3");
}
void SessionSettings::setDialogsWidthRatio(float64 ratio) { void SessionSettings::setDialogsWidthRatio(float64 ratio) {
_variables.dialogsWidthRatio = ratio; _dialogsWidthRatio = ratio;
} }
float64 SessionSettings::dialogsWidthRatio() const { float64 SessionSettings::dialogsWidthRatio() const {
return _variables.dialogsWidthRatio.current(); return _dialogsWidthRatio.current();
} }
rpl::producer<float64> SessionSettings::dialogsWidthRatioChanges() const { rpl::producer<float64> SessionSettings::dialogsWidthRatioChanges() const {
return _variables.dialogsWidthRatio.changes(); return _dialogsWidthRatio.changes();
} }
void SessionSettings::setThirdColumnWidth(int width) { void SessionSettings::setThirdColumnWidth(int width) {
_variables.thirdColumnWidth = width; _thirdColumnWidth = width;
} }
int SessionSettings::thirdColumnWidth() const { int SessionSettings::thirdColumnWidth() const {
return _variables.thirdColumnWidth.current(); return _thirdColumnWidth.current();
} }
rpl::producer<int> SessionSettings::thirdColumnWidthChanges() const { rpl::producer<int> SessionSettings::thirdColumnWidthChanges() const {
return _variables.thirdColumnWidth.changes(); return _thirdColumnWidth.changes();
} }
void SessionSettings::setMediaLastPlaybackPosition(DocumentId id, crl::time time) { void SessionSettings::setMediaLastPlaybackPosition(DocumentId id, crl::time time) {
auto &map = _variables.mediaLastPlaybackPosition; auto &map = _mediaLastPlaybackPosition;
const auto i = ranges::find( const auto i = ranges::find(
map, map,
id, id,
@ -547,90 +522,46 @@ void SessionSettings::setMediaLastPlaybackPosition(DocumentId id, crl::time time
crl::time SessionSettings::mediaLastPlaybackPosition(DocumentId id) const { crl::time SessionSettings::mediaLastPlaybackPosition(DocumentId id) const {
const auto i = ranges::find( const auto i = ranges::find(
_variables.mediaLastPlaybackPosition, _mediaLastPlaybackPosition,
id, id,
&std::pair<DocumentId, crl::time>::first); &std::pair<DocumentId, crl::time>::first);
return (i != _variables.mediaLastPlaybackPosition.end()) ? i->second : 0; return (i != _mediaLastPlaybackPosition.end()) ? i->second : 0;
} }
void SessionSettings::setArchiveCollapsed(bool collapsed) { void SessionSettings::setArchiveCollapsed(bool collapsed) {
_variables.archiveCollapsed = collapsed; _archiveCollapsed = collapsed;
} }
bool SessionSettings::archiveCollapsed() const { bool SessionSettings::archiveCollapsed() const {
return _variables.archiveCollapsed.current(); return _archiveCollapsed.current();
} }
rpl::producer<bool> SessionSettings::archiveCollapsedChanges() const { rpl::producer<bool> SessionSettings::archiveCollapsedChanges() const {
return _variables.archiveCollapsed.changes(); return _archiveCollapsed.changes();
} }
void SessionSettings::setArchiveInMainMenu(bool inMainMenu) { void SessionSettings::setArchiveInMainMenu(bool inMainMenu) {
_variables.archiveInMainMenu = inMainMenu; _archiveInMainMenu = inMainMenu;
} }
bool SessionSettings::archiveInMainMenu() const { bool SessionSettings::archiveInMainMenu() const {
return _variables.archiveInMainMenu.current(); return _archiveInMainMenu.current();
} }
rpl::producer<bool> SessionSettings::archiveInMainMenuChanges() const { rpl::producer<bool> SessionSettings::archiveInMainMenuChanges() const {
return _variables.archiveInMainMenu.changes(); return _archiveInMainMenu.changes();
}
void SessionSettings::setNotifyAboutPinned(bool notify) {
_variables.notifyAboutPinned = notify;
}
bool SessionSettings::notifyAboutPinned() const {
return _variables.notifyAboutPinned.current();
}
rpl::producer<bool> SessionSettings::notifyAboutPinnedChanges() const {
return _variables.notifyAboutPinned.changes();
} }
void SessionSettings::setSkipArchiveInSearch(bool skip) { void SessionSettings::setSkipArchiveInSearch(bool skip) {
_variables.skipArchiveInSearch = skip; _skipArchiveInSearch = skip;
} }
bool SessionSettings::skipArchiveInSearch() const { bool SessionSettings::skipArchiveInSearch() const {
return _variables.skipArchiveInSearch.current(); return _skipArchiveInSearch.current();
} }
rpl::producer<bool> SessionSettings::skipArchiveInSearchChanges() const { rpl::producer<bool> SessionSettings::skipArchiveInSearchChanges() const {
return _variables.skipArchiveInSearch.changes(); return _skipArchiveInSearch.changes();
}
void SessionSettings::setLargeEmoji(bool value) {
_variables.largeEmoji = value;
}
bool SessionSettings::largeEmoji() const {
return _variables.largeEmoji.current();
}
rpl::producer<bool> SessionSettings::largeEmojiValue() const {
return _variables.largeEmoji.value();
}
rpl::producer<bool> SessionSettings::largeEmojiChanges() const {
return _variables.largeEmoji.changes();
}
void SessionSettings::setReplaceEmoji(bool value) {
_variables.replaceEmoji = value;
}
bool SessionSettings::replaceEmoji() const {
return _variables.replaceEmoji.current();
}
rpl::producer<bool> SessionSettings::replaceEmojiValue() const {
return _variables.replaceEmoji.value();
}
rpl::producer<bool> SessionSettings::replaceEmojiChanges() const {
return _variables.replaceEmoji.changes();
} }
} // namespace Main } // namespace Main

View file

@ -10,12 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_auto_download.h" #include "data/data_auto_download.h"
#include "ui/rect_part.h" #include "ui/rect_part.h"
enum class SendFilesWay;
namespace Ui {
enum class InputSubmitSettings;
} // namespace Ui
namespace Support { namespace Support {
enum class SwitchSettings; enum class SwitchSettings;
} // namespace Support } // namespace Support
@ -32,46 +26,28 @@ namespace Main {
class SessionSettings final { class SessionSettings final {
public: public:
[[nodiscard]] QByteArray serialize() const; SessionSettings();
[[nodiscard]] static std::unique_ptr<SessionSettings> FromSerialized(
const QByteArray &serialized);
void setLastSeenWarningSeen(bool lastSeenWarningSeen) { [[nodiscard]] QByteArray serialize() const;
_variables.lastSeenWarningSeen = lastSeenWarningSeen; [[nodiscard]] void addFromSerialized(const QByteArray &serialized);
}
[[nodiscard]] bool lastSeenWarningSeen() const {
return _variables.lastSeenWarningSeen;
}
void setSendFilesWay(SendFilesWay way) {
_variables.sendFilesWay = way;
}
[[nodiscard]] SendFilesWay sendFilesWay() const {
return _variables.sendFilesWay;
}
void setSendSubmitWay(Ui::InputSubmitSettings value) {
_variables.sendSubmitWay = value;
}
[[nodiscard]] Ui::InputSubmitSettings sendSubmitWay() const {
return _variables.sendSubmitWay;
}
void setSupportSwitch(Support::SwitchSettings value) { void setSupportSwitch(Support::SwitchSettings value) {
_variables.supportSwitch = value; _supportSwitch = value;
} }
[[nodiscard]] Support::SwitchSettings supportSwitch() const { [[nodiscard]] Support::SwitchSettings supportSwitch() const {
return _variables.supportSwitch; return _supportSwitch;
} }
void setSupportFixChatsOrder(bool fix) { void setSupportFixChatsOrder(bool fix) {
_variables.supportFixChatsOrder = fix; _supportFixChatsOrder = fix;
} }
[[nodiscard]] bool supportFixChatsOrder() const { [[nodiscard]] bool supportFixChatsOrder() const {
return _variables.supportFixChatsOrder; return _supportFixChatsOrder;
} }
void setSupportTemplatesAutocomplete(bool enabled) { void setSupportTemplatesAutocomplete(bool enabled) {
_variables.supportTemplatesAutocomplete = enabled; _supportTemplatesAutocomplete = enabled;
} }
[[nodiscard]] bool supportTemplatesAutocomplete() const { [[nodiscard]] bool supportTemplatesAutocomplete() const {
return _variables.supportTemplatesAutocomplete; return _supportTemplatesAutocomplete;
} }
void setSupportChatsTimeSlice(int slice); void setSupportChatsTimeSlice(int slice);
[[nodiscard]] int supportChatsTimeSlice() const; [[nodiscard]] int supportChatsTimeSlice() const;
@ -81,25 +57,25 @@ public:
[[nodiscard]] rpl::producer<bool> supportAllSearchResultsValue() const; [[nodiscard]] rpl::producer<bool> supportAllSearchResultsValue() const;
[[nodiscard]] ChatHelpers::SelectorTab selectorTab() const { [[nodiscard]] ChatHelpers::SelectorTab selectorTab() const {
return _variables.selectorTab; return _selectorTab;
} }
void setSelectorTab(ChatHelpers::SelectorTab tab) { void setSelectorTab(ChatHelpers::SelectorTab tab) {
_variables.selectorTab = tab; _selectorTab = tab;
} }
[[nodiscard]] bool tabbedSelectorSectionEnabled() const { [[nodiscard]] bool tabbedSelectorSectionEnabled() const {
return _variables.tabbedSelectorSectionEnabled; return _tabbedSelectorSectionEnabled;
} }
void setTabbedSelectorSectionEnabled(bool enabled); void setTabbedSelectorSectionEnabled(bool enabled);
[[nodiscard]] bool thirdSectionInfoEnabled() const { [[nodiscard]] bool thirdSectionInfoEnabled() const {
return _variables.thirdSectionInfoEnabled; return _thirdSectionInfoEnabled;
} }
void setThirdSectionInfoEnabled(bool enabled); void setThirdSectionInfoEnabled(bool enabled);
[[nodiscard]] rpl::producer<bool> thirdSectionInfoEnabledValue() const; [[nodiscard]] rpl::producer<bool> thirdSectionInfoEnabledValue() const;
[[nodiscard]] int thirdSectionExtendedBy() const { [[nodiscard]] int thirdSectionExtendedBy() const {
return _variables.thirdSectionExtendedBy; return _thirdSectionExtendedBy;
} }
void setThirdSectionExtendedBy(int savedValue) { void setThirdSectionExtendedBy(int savedValue) {
_variables.thirdSectionExtendedBy = savedValue; _thirdSectionExtendedBy = savedValue;
} }
[[nodiscard]] bool tabbedReplacedWithInfo() const { [[nodiscard]] bool tabbedReplacedWithInfo() const {
return _tabbedReplacedWithInfo; return _tabbedReplacedWithInfo;
@ -107,35 +83,22 @@ public:
void setTabbedReplacedWithInfo(bool enabled); void setTabbedReplacedWithInfo(bool enabled);
[[nodiscard]] rpl::producer<bool> tabbedReplacedWithInfoValue() const; [[nodiscard]] rpl::producer<bool> tabbedReplacedWithInfoValue() const;
void setSmallDialogsList(bool enabled) { void setSmallDialogsList(bool enabled) {
_variables.smallDialogsList = enabled; _smallDialogsList = enabled;
} }
[[nodiscard]] bool smallDialogsList() const { [[nodiscard]] bool smallDialogsList() const {
return _variables.smallDialogsList; return _smallDialogsList;
}
void setSoundOverride(const QString &key, const QString &path) {
_variables.soundOverrides.emplace(key, path);
}
void clearSoundOverrides() {
_variables.soundOverrides.clear();
}
[[nodiscard]] QString getSoundPath(const QString &key) const;
void setTabbedSelectorSectionTooltipShown(int shown) {
_variables.tabbedSelectorSectionTooltipShown = shown;
}
[[nodiscard]] int tabbedSelectorSectionTooltipShown() const {
return _variables.tabbedSelectorSectionTooltipShown;
} }
void setFloatPlayerColumn(Window::Column column) { void setFloatPlayerColumn(Window::Column column) {
_variables.floatPlayerColumn = column; _floatPlayerColumn = column;
} }
[[nodiscard]] Window::Column floatPlayerColumn() const { [[nodiscard]] Window::Column floatPlayerColumn() const {
return _variables.floatPlayerColumn; return _floatPlayerColumn;
} }
void setFloatPlayerCorner(RectPart corner) { void setFloatPlayerCorner(RectPart corner) {
_variables.floatPlayerCorner = corner; _floatPlayerCorner = corner;
} }
[[nodiscard]] RectPart floatPlayerCorner() const { [[nodiscard]] RectPart floatPlayerCorner() const {
return _variables.floatPlayerCorner; return _floatPlayerCorner;
} }
void setDialogsWidthRatio(float64 ratio); void setDialogsWidthRatio(float64 ratio);
[[nodiscard]] float64 dialogsWidthRatio() const; [[nodiscard]] float64 dialogsWidthRatio() const;
@ -145,23 +108,23 @@ public:
[[nodiscard]] rpl::producer<int> thirdColumnWidthChanges() const; [[nodiscard]] rpl::producer<int> thirdColumnWidthChanges() const;
void setGroupStickersSectionHidden(PeerId peerId) { void setGroupStickersSectionHidden(PeerId peerId) {
_variables.groupStickersSectionHidden.insert(peerId); _groupStickersSectionHidden.insert(peerId);
} }
[[nodiscard]] bool isGroupStickersSectionHidden(PeerId peerId) const { [[nodiscard]] bool isGroupStickersSectionHidden(PeerId peerId) const {
return _variables.groupStickersSectionHidden.contains(peerId); return _groupStickersSectionHidden.contains(peerId);
} }
void removeGroupStickersSectionHidden(PeerId peerId) { void removeGroupStickersSectionHidden(PeerId peerId) {
_variables.groupStickersSectionHidden.remove(peerId); _groupStickersSectionHidden.remove(peerId);
} }
void setMediaLastPlaybackPosition(DocumentId id, crl::time time); void setMediaLastPlaybackPosition(DocumentId id, crl::time time);
[[nodiscard]] crl::time mediaLastPlaybackPosition(DocumentId id) const; [[nodiscard]] crl::time mediaLastPlaybackPosition(DocumentId id) const;
[[nodiscard]] Data::AutoDownload::Full &autoDownload() { [[nodiscard]] Data::AutoDownload::Full &autoDownload() {
return _variables.autoDownload; return _autoDownload;
} }
[[nodiscard]] const Data::AutoDownload::Full &autoDownload() const { [[nodiscard]] const Data::AutoDownload::Full &autoDownload() const {
return _variables.autoDownload; return _autoDownload;
} }
void setArchiveCollapsed(bool collapsed); void setArchiveCollapsed(bool collapsed);
@ -172,191 +135,71 @@ public:
[[nodiscard]] bool archiveInMainMenu() const; [[nodiscard]] bool archiveInMainMenu() const;
[[nodiscard]] rpl::producer<bool> archiveInMainMenuChanges() const; [[nodiscard]] rpl::producer<bool> archiveInMainMenuChanges() const;
void setNotifyAboutPinned(bool notify);
[[nodiscard]] bool notifyAboutPinned() const;
[[nodiscard]] rpl::producer<bool> notifyAboutPinnedChanges() const;
void setSkipArchiveInSearch(bool skip); void setSkipArchiveInSearch(bool skip);
[[nodiscard]] bool skipArchiveInSearch() const; [[nodiscard]] bool skipArchiveInSearch() const;
[[nodiscard]] rpl::producer<bool> skipArchiveInSearchChanges() const; [[nodiscard]] rpl::producer<bool> skipArchiveInSearchChanges() const;
[[nodiscard]] bool hadLegacyCallsPeerToPeerNobody() const { [[nodiscard]] bool hadLegacyCallsPeerToPeerNobody() const {
return _variables.hadLegacyCallsPeerToPeerNobody; return _hadLegacyCallsPeerToPeerNobody;
}
[[nodiscard]] bool includeMutedCounter() const {
return _variables.includeMutedCounter;
}
void setIncludeMutedCounter(bool value) {
_variables.includeMutedCounter = value;
}
[[nodiscard]] bool countUnreadMessages() const {
return _variables.countUnreadMessages;
}
void setCountUnreadMessages(bool value) {
_variables.countUnreadMessages = value;
}
[[nodiscard]] bool exeLaunchWarning() const {
return _variables.exeLaunchWarning;
}
void setExeLaunchWarning(bool warning) {
_variables.exeLaunchWarning = warning;
}
[[nodiscard]] bool loopAnimatedStickers() const {
return _variables.loopAnimatedStickers;
}
void setLoopAnimatedStickers(bool value) {
_variables.loopAnimatedStickers = value;
}
void setLargeEmoji(bool value);
[[nodiscard]] bool largeEmoji() const;
[[nodiscard]] rpl::producer<bool> largeEmojiValue() const;
[[nodiscard]] rpl::producer<bool> largeEmojiChanges() const;
void setReplaceEmoji(bool value);
[[nodiscard]] bool replaceEmoji() const;
[[nodiscard]] rpl::producer<bool> replaceEmojiValue() const;
[[nodiscard]] rpl::producer<bool> replaceEmojiChanges() const;
[[nodiscard]] bool suggestEmoji() const {
return _variables.suggestEmoji;
}
void setSuggestEmoji(bool value) {
_variables.suggestEmoji = value;
}
[[nodiscard]] bool suggestStickersByEmoji() const {
return _variables.suggestStickersByEmoji;
}
void setSuggestStickersByEmoji(bool value) {
_variables.suggestStickersByEmoji = value;
}
void setSpellcheckerEnabled(bool value) {
_variables.spellcheckerEnabled = value;
}
bool spellcheckerEnabled() const {
return _variables.spellcheckerEnabled.current();
}
rpl::producer<bool> spellcheckerEnabledValue() const {
return _variables.spellcheckerEnabled.value();
}
rpl::producer<bool> spellcheckerEnabledChanges() const {
return _variables.spellcheckerEnabled.changes();
}
void setDictionariesEnabled(std::vector<int> dictionaries) {
_variables.dictionariesEnabled = std::move(dictionaries);
}
std::vector<int> dictionariesEnabled() const {
return _variables.dictionariesEnabled.current();
}
rpl::producer<std::vector<int>> dictionariesEnabledChanges() const {
return _variables.dictionariesEnabled.changes();
}
void setAutoDownloadDictionaries(bool value) {
_variables.autoDownloadDictionaries = value;
}
bool autoDownloadDictionaries() const {
return _variables.autoDownloadDictionaries.current();
}
rpl::producer<bool> autoDownloadDictionariesValue() const {
return _variables.autoDownloadDictionaries.value();
}
rpl::producer<bool> autoDownloadDictionariesChanges() const {
return _variables.autoDownloadDictionaries.changes();
}
[[nodiscard]] float64 videoPlaybackSpeed() const {
return _variables.videoPlaybackSpeed.current();
}
void setVideoPlaybackSpeed(float64 speed) {
_variables.videoPlaybackSpeed = speed;
}
[[nodiscard]] QByteArray videoPipGeometry() const {
return _variables.videoPipGeometry;
}
void setVideoPipGeometry(QByteArray geometry) {
_variables.videoPipGeometry = geometry;
} }
[[nodiscard]] MsgId hiddenPinnedMessageId(PeerId peerId) const { [[nodiscard]] MsgId hiddenPinnedMessageId(PeerId peerId) const {
const auto i = _variables.hiddenPinnedMessages.find(peerId); const auto i = _hiddenPinnedMessages.find(peerId);
return (i != end(_variables.hiddenPinnedMessages)) ? i->second : 0; return (i != end(_hiddenPinnedMessages)) ? i->second : 0;
} }
void setHiddenPinnedMessageId(PeerId peerId, MsgId msgId) { void setHiddenPinnedMessageId(PeerId peerId, MsgId msgId) {
if (msgId) { if (msgId) {
_variables.hiddenPinnedMessages[peerId] = msgId; _hiddenPinnedMessages[peerId] = msgId;
} else { } else {
_variables.hiddenPinnedMessages.remove(peerId); _hiddenPinnedMessages.remove(peerId);
} }
} }
[[nodiscard]] bool dialogsFiltersEnabled() const {
return _dialogsFiltersEnabled;
}
void setDialogsFiltersEnabled(bool value) {
_dialogsFiltersEnabled = value;
}
[[nodiscard]] static bool ThirdColumnByDefault(); [[nodiscard]] static bool ThirdColumnByDefault();
private: private:
struct Variables {
Variables();
static constexpr auto kDefaultDialogsWidthRatio = 5. / 14; static constexpr auto kDefaultDialogsWidthRatio = 5. / 14;
static constexpr auto kDefaultBigDialogsWidthRatio = 0.275; static constexpr auto kDefaultBigDialogsWidthRatio = 0.275;
static constexpr auto kDefaultThirdColumnWidth = 0; static constexpr auto kDefaultThirdColumnWidth = 0;
static constexpr auto kDefaultSupportChatsLimitSlice = 7 * 24 * 60 * 60;
bool lastSeenWarningSeen = false; ChatHelpers::SelectorTab _selectorTab; // per-window
SendFilesWay sendFilesWay; bool _tabbedSelectorSectionEnabled = false; // per-window
ChatHelpers::SelectorTab selectorTab; // per-window Window::Column _floatPlayerColumn; // per-window
bool tabbedSelectorSectionEnabled = false; // per-window RectPart _floatPlayerCorner; // per-window
int tabbedSelectorSectionTooltipShown = 0; base::flat_set<PeerId> _groupStickersSectionHidden;
base::flat_map<QString, QString> soundOverrides; bool _thirdSectionInfoEnabled = true; // per-window
Window::Column floatPlayerColumn; // per-window bool _smallDialogsList = false; // per-window
RectPart floatPlayerCorner; // per-window int _thirdSectionExtendedBy = -1; // per-window
base::flat_set<PeerId> groupStickersSectionHidden; rpl::variable<float64> _dialogsWidthRatio; // per-window
bool thirdSectionInfoEnabled = true; // per-window rpl::variable<int> _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w
bool smallDialogsList = false; // per-window bool _hadLegacyCallsPeerToPeerNobody = false;
int thirdSectionExtendedBy = -1; // per-window Data::AutoDownload::Full _autoDownload;
rpl::variable<float64> dialogsWidthRatio; // per-window rpl::variable<bool> _archiveCollapsed = false;
rpl::variable<int> thirdColumnWidth rpl::variable<bool> _archiveInMainMenu = false;
= kDefaultThirdColumnWidth; // per-window rpl::variable<bool> _skipArchiveInSearch = false;
Ui::InputSubmitSettings sendSubmitWay; std::vector<std::pair<DocumentId, crl::time>> _mediaLastPlaybackPosition;
bool hadLegacyCallsPeerToPeerNobody = false; base::flat_map<PeerId, MsgId> _hiddenPinnedMessages;
bool includeMutedCounter = true; bool _dialogsFiltersEnabled = false;
bool countUnreadMessages = true;
bool exeLaunchWarning = true;
Data::AutoDownload::Full autoDownload;
rpl::variable<bool> archiveCollapsed = false;
rpl::variable<bool> archiveInMainMenu = false;
rpl::variable<bool> notifyAboutPinned = true;
rpl::variable<bool> skipArchiveInSearch = false;
bool loopAnimatedStickers = true;
rpl::variable<bool> largeEmoji = true;
rpl::variable<bool> replaceEmoji = true;
bool suggestEmoji = true;
bool suggestStickersByEmoji = true;
rpl::variable<bool> spellcheckerEnabled = true;
std::vector<std::pair<DocumentId, crl::time>> mediaLastPlaybackPosition;
rpl::variable<float64> videoPlaybackSpeed = 1.;
QByteArray videoPipGeometry;
rpl::variable<std::vector<int>> dictionariesEnabled;
rpl::variable<bool> autoDownloadDictionaries = true;
base::flat_map<PeerId, MsgId> hiddenPinnedMessages;
static constexpr auto kDefaultSupportChatsLimitSlice Support::SwitchSettings _supportSwitch;
= 7 * 24 * 60 * 60; bool _supportFixChatsOrder = true;
bool _supportTemplatesAutocomplete = true;
Support::SwitchSettings supportSwitch; rpl::variable<int> _supportChatsTimeSlice
bool supportFixChatsOrder = true;
bool supportTemplatesAutocomplete = true;
rpl::variable<int> supportChatsTimeSlice
= kDefaultSupportChatsLimitSlice; = kDefaultSupportChatsLimitSlice;
rpl::variable<bool> supportAllSearchResults = false; rpl::variable<bool> _supportAllSearchResults = false;
};
rpl::event_stream<bool> _thirdSectionInfoEnabledValue; rpl::event_stream<bool> _thirdSectionInfoEnabledValue;
bool _tabbedReplacedWithInfo = false; bool _tabbedReplacedWithInfo = false;
rpl::event_stream<bool> _tabbedReplacedWithInfoValue; rpl::event_stream<bool> _tabbedReplacedWithInfoValue;
Variables _variables;
}; };
} // namespace Main } // namespace Main

View file

@ -872,7 +872,7 @@ bool MainWidget::insertBotCommand(const QString &cmd) {
void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) { void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) {
_dialogs->searchMessages(query, inChat); _dialogs->searchMessages(query, inChat);
if (Adaptive::OneColumn()) { if (Adaptive::OneColumn()) {
Ui::showChatsList(); Ui::showChatsList(&session());
} else { } else {
_dialogs->setInnerFocus(); _dialogs->setInnerFocus();
} }
@ -1353,8 +1353,10 @@ void MainWidget::viewsIncrementFail(const RPCError &error, mtpRequestId requestI
void MainWidget::choosePeer(PeerId peerId, MsgId showAtMsgId) { void MainWidget::choosePeer(PeerId peerId, MsgId showAtMsgId) {
if (selectingPeer()) { if (selectingPeer()) {
_hider->offerPeer(peerId); _hider->offerPeer(peerId);
} else if (peerId) {
Ui::showPeerHistory(session().data().peer(peerId), showAtMsgId);
} else { } else {
Ui::showPeerHistory(peerId, showAtMsgId); Ui::showChatsList(&session());
} }
} }
@ -2570,7 +2572,7 @@ void MainWidget::searchInChat(Dialogs::Key chat) {
} }
_dialogs->searchInChat(chat); _dialogs->searchInChat(chat);
if (Adaptive::OneColumn()) { if (Adaptive::OneColumn()) {
Ui::showChatsList(); Ui::showChatsList(&session());
} else { } else {
_dialogs->setInnerFocus(); _dialogs->setInnerFocus();
} }

View file

@ -133,7 +133,7 @@ void MainWindow::createTrayIconMenu() {
trayIconMenu = new QMenu(this); trayIconMenu = new QMenu(this);
#endif // else for Q_OS_WIN #endif // else for Q_OS_WIN
auto notificationActionText = Global::DesktopNotify() auto notificationActionText = Core::App().settings().desktopNotify()
? tr::lng_disable_notifications_from_tray(tr::now) ? tr::lng_disable_notifications_from_tray(tr::now)
: tr::lng_enable_notifications_from_tray(tr::now); : tr::lng_enable_notifications_from_tray(tr::now);
@ -620,7 +620,7 @@ void MainWindow::updateTrayMenu(bool force) {
: tr::lng_open_from_tray(tr::now)); : tr::lng_open_from_tray(tr::now));
} }
auto notificationAction = actions.at(Platform::IsLinux() && !Platform::IsWayland() ? 2 : 1); auto notificationAction = actions.at(Platform::IsLinux() && !Platform::IsWayland() ? 2 : 1);
auto notificationActionText = Global::DesktopNotify() auto notificationActionText = Core::App().settings().desktopNotify()
? tr::lng_disable_notifications_from_tray(tr::now) ? tr::lng_disable_notifications_from_tray(tr::now)
: tr::lng_enable_notifications_from_tray(tr::now); : tr::lng_enable_notifications_from_tray(tr::now);
notificationAction->setText(notificationActionText); notificationAction->setText(notificationActionText);
@ -781,33 +781,35 @@ void MainWindow::toggleDisplayNotifyFromTray() {
auto soundNotifyChanged = false; auto soundNotifyChanged = false;
auto flashBounceNotifyChanged = false; auto flashBounceNotifyChanged = false;
Global::SetDesktopNotify(!Global::DesktopNotify()); auto &settings = Core::App().settings();
if (Global::DesktopNotify()) { settings.setDesktopNotify(!settings.desktopNotify());
if (Global::RestoreSoundNotifyFromTray() && !Global::SoundNotify()) { if (settings.desktopNotify()) {
Global::SetSoundNotify(true); if (settings.rememberedSoundNotifyFromTray()
Global::SetRestoreSoundNotifyFromTray(false); && !settings.soundNotify()) {
settings.setSoundNotify(true);
settings.setRememberedSoundNotifyFromTray(false);
soundNotifyChanged = true; soundNotifyChanged = true;
} }
if (Global::RestoreFlashBounceNotifyFromTray() if (settings.rememberedFlashBounceNotifyFromTray()
&& !Global::FlashBounceNotify()) { && !settings.flashBounceNotify()) {
Global::SetFlashBounceNotify(true); settings.setFlashBounceNotify(true);
Global::SetRestoreFlashBounceNotifyFromTray(false); settings.setRememberedFlashBounceNotifyFromTray(false);
flashBounceNotifyChanged = true; flashBounceNotifyChanged = true;
} }
} else { } else {
if (Global::SoundNotify()) { if (settings.soundNotify()) {
Global::SetSoundNotify(false); settings.setSoundNotify(false);
Global::SetRestoreSoundNotifyFromTray(true); settings.setRememberedSoundNotifyFromTray(true);
soundNotifyChanged = true; soundNotifyChanged = true;
} else { } else {
Global::SetRestoreSoundNotifyFromTray(false); settings.setRememberedSoundNotifyFromTray(false);
} }
if (Global::FlashBounceNotify()) { if (settings.flashBounceNotify()) {
Global::SetFlashBounceNotify(false); settings.setFlashBounceNotify(false);
Global::SetRestoreFlashBounceNotifyFromTray(true); settings.setRememberedFlashBounceNotifyFromTray(true);
flashBounceNotifyChanged = true; flashBounceNotifyChanged = true;
} else { } else {
Global::SetRestoreFlashBounceNotifyFromTray(false); settings.setRememberedFlashBounceNotifyFromTray(false);
} }
} }
account().session().saveSettings(); account().session().saveSettings();

View file

@ -18,7 +18,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/platform_audio.h" #include "platform/platform_audio.h"
#include "core/application.h" #include "core/application.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "facades.h"
#include "app.h" #include "app.h"
#include <al.h> #include <al.h>
@ -575,12 +574,17 @@ Mixer::Mixer(not_null<Audio::Instance*> instance)
connect(this, SIGNAL(suppressSong()), _fader, SLOT(onSuppressSong())); connect(this, SIGNAL(suppressSong()), _fader, SLOT(onSuppressSong()));
connect(this, SIGNAL(unsuppressSong()), _fader, SLOT(onUnsuppressSong())); connect(this, SIGNAL(unsuppressSong()), _fader, SLOT(onUnsuppressSong()));
connect(this, SIGNAL(suppressAll(qint64)), _fader, SLOT(onSuppressAll(qint64))); connect(this, SIGNAL(suppressAll(qint64)), _fader, SLOT(onSuppressAll(qint64)));
subscribe(Global::RefSongVolumeChanged(), [this] {
Core::App().settings().songVolumeChanges(
) | rpl::start_with_next([=] {
QMetaObject::invokeMethod(_fader, "onSongVolumeChanged"); QMetaObject::invokeMethod(_fader, "onSongVolumeChanged");
}); }, _lifetime);
subscribe(Global::RefVideoVolumeChanged(), [this] {
Core::App().settings().videoVolumeChanges(
) | rpl::start_with_next([=] {
QMetaObject::invokeMethod(_fader, "onVideoVolumeChanged"); QMetaObject::invokeMethod(_fader, "onVideoVolumeChanged");
}); }, _lifetime);
connect(this, SIGNAL(loaderOnStart(const AudioMsgId&, qint64)), _loader, SLOT(onStart(const AudioMsgId&, qint64))); connect(this, SIGNAL(loaderOnStart(const AudioMsgId&, qint64)), _loader, SLOT(onStart(const AudioMsgId&, qint64)));
connect(this, SIGNAL(loaderOnCancel(const AudioMsgId&)), _loader, SLOT(onCancel(const AudioMsgId&))); connect(this, SIGNAL(loaderOnCancel(const AudioMsgId&)), _loader, SLOT(onCancel(const AudioMsgId&)));
connect(_loader, SIGNAL(needToCheck()), _fader, SLOT(onTimer())); connect(_loader, SIGNAL(needToCheck()), _fader, SLOT(onTimer()));
@ -756,8 +760,8 @@ void Mixer::play(
Expects(externalData != nullptr); Expects(externalData != nullptr);
Expects(audio.externalPlayId() != 0); Expects(audio.externalPlayId() != 0);
setSongVolume(Global::SongVolume()); setSongVolume(Core::App().settings().songVolume());
setVideoVolume(Global::VideoVolume()); setVideoVolume(Core::App().settings().videoVolume());
auto type = audio.type(); auto type = audio.type();
AudioMsgId stopped; AudioMsgId stopped;

View file

@ -126,7 +126,7 @@ struct TrackState {
bool waitingForData = false; bool waitingForData = false;
}; };
class Mixer : public QObject, private base::Subscriber { class Mixer final : public QObject {
Q_OBJECT Q_OBJECT
public: public:
@ -296,6 +296,8 @@ private:
Fader *_fader; Fader *_fader;
Loaders *_loader; Loaders *_loader;
rpl::lifetime _lifetime;
}; };
Mixer *mixer(); Mixer *mixer();

View file

@ -23,11 +23,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "core/shortcuts.h" #include "core/shortcuts.h"
#include "core/application.h" #include "core/application.h"
#include "main/main_accounts.h" // Accounts::activeSessionValue. #include "main/main_domain.h" // Domain::activeSessionValue.
#include "mainwindow.h" #include "mainwindow.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h" #include "main/main_session_settings.h"
#include "facades.h"
namespace Media { namespace Media {
namespace Player { namespace Player {
@ -115,7 +114,7 @@ Instance::Instance()
}); });
// While we have one Media::Player::Instance for all sessions we have to do this. // While we have one Media::Player::Instance for all sessions we have to do this.
Core::App().accounts().activeSessionValue( Core::App().domain().activeSessionValue(
) | rpl::start_with_next([=](Main::Session *session) { ) | rpl::start_with_next([=](Main::Session *session) {
if (session) { if (session) {
subscribe(session->calls().currentCallChanged(), [=](Calls::Call *call) { subscribe(session->calls().currentCallChanged(), [=](Calls::Call *call) {
@ -449,7 +448,7 @@ Streaming::PlaybackOptions Instance::streamingOptions(
: Streaming::Mode::Audio; : Streaming::Mode::Audio;
result.speed = (document result.speed = (document
&& (document->isVoiceMessage() || document->isVideoMessage()) && (document->isVoiceMessage() || document->isVideoMessage())
&& Global::VoiceMsgPlaybackDoubled()) && Core::App().settings().voiceMsgPlaybackDoubled())
? kVoicePlaybackSpeedMultiplier ? kVoicePlaybackSpeedMultiplier
: 1.; : 1.;
result.audioId = audioId; result.audioId = audioId;
@ -599,7 +598,7 @@ void Instance::cancelSeeking(AudioMsgId::Type type) {
void Instance::updateVoicePlaybackSpeed() { void Instance::updateVoicePlaybackSpeed() {
if (const auto data = getData(AudioMsgId::Type::Voice)) { if (const auto data = getData(AudioMsgId::Type::Voice)) {
if (const auto streamed = data->streamed.get()) { if (const auto streamed = data->streamed.get()) {
streamed->instance.setSpeed(Global::VoiceMsgPlaybackDoubled() streamed->instance.setSpeed(Core::App().settings().voiceMsgPlaybackDoubled()
? kVoicePlaybackSpeedMultiplier ? kVoicePlaybackSpeedMultiplier
: 1.); : 1.);
} }

View file

@ -16,7 +16,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h" #include "mainwindow.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "facades.h" #include "core/application.h"
#include "core/core_settings.h"
#include "app.h" #include "app.h"
#include "styles/style_media_player.h" #include "styles/style_media_player.h"
#include "styles/style_widgets.h" #include "styles/style_widgets.h"
@ -27,7 +28,7 @@ namespace Player {
VolumeController::VolumeController( VolumeController::VolumeController(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController*> controller) not_null<Window::SessionController*> controller)
: TWidget(parent) : RpWidget(parent)
, _slider(this, st::mediaPlayerPanelPlayback) { , _slider(this, st::mediaPlayerPanelPlayback) {
_slider->setMoveByWheel(true); _slider->setMoveByWheel(true);
_slider->setChangeProgressCallback([=](float64 volume) { _slider->setChangeProgressCallback([=](float64 volume) {
@ -35,17 +36,18 @@ VolumeController::VolumeController(
}); });
_slider->setChangeFinishedCallback([=](float64 volume) { _slider->setChangeFinishedCallback([=](float64 volume) {
if (volume > 0) { if (volume > 0) {
Global::SetRememberedSongVolume(volume); Core::App().settings().setRememberedSongVolume(volume);
} }
applyVolumeChange(volume); applyVolumeChange(volume);
controller->session().saveSettingsDelayed(); controller->session().saveSettingsDelayed();
}); });
subscribe(Global::RefSongVolumeChanged(), [this] { Core::App().settings().songVolumeChanges(
) | rpl::start_with_next([=](float64 volume) {
if (!_slider->isChanging()) { if (!_slider->isChanging()) {
_slider->setValue(Global::SongVolume()); _slider->setValue(volume);
} }
}); }, lifetime());
setVolume(Global::SongVolume()); setVolume(Core::App().settings().songVolume());
resize(st::mediaPlayerPanelVolumeWidth, 2 * st::mediaPlayerPanelPlaybackPadding + st::mediaPlayerPanelPlayback.width); resize(st::mediaPlayerPanelVolumeWidth, 2 * st::mediaPlayerPanelPlaybackPadding + st::mediaPlayerPanelPlayback.width);
} }
@ -63,16 +65,15 @@ void VolumeController::resizeEvent(QResizeEvent *e) {
void VolumeController::setVolume(float64 volume) { void VolumeController::setVolume(float64 volume) {
_slider->setValue(volume); _slider->setValue(volume);
if (volume > 0) { if (volume > 0) {
Global::SetRememberedSongVolume(volume); Core::App().settings().setRememberedSongVolume(volume);
} }
applyVolumeChange(volume); applyVolumeChange(volume);
} }
void VolumeController::applyVolumeChange(float64 volume) { void VolumeController::applyVolumeChange(float64 volume) {
if (volume != Global::SongVolume()) { if (volume != Core::App().settings().songVolume()) {
Global::SetSongVolume(volume); Core::App().settings().setSongVolume(volume);
mixer()->setSongVolume(Global::SongVolume()); mixer()->setSongVolume(Core::App().settings().songVolume());
Global::RefSongVolumeChanged().notify();
} }
} }

View file

@ -25,7 +25,7 @@ class SessionController;
namespace Media { namespace Media {
namespace Player { namespace Player {
class VolumeController : public TWidget, private base::Subscriber { class VolumeController : public Ui::RpWidget, private base::Subscriber {
public: public:
VolumeController( VolumeController(
QWidget *parent, QWidget *parent,

View file

@ -11,6 +11,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_document.h" #include "data/data_document.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_peer.h" #include "data/data_peer.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
#include "ui/widgets/continuous_sliders.h" #include "ui/widgets/continuous_sliders.h"
#include "ui/widgets/shadow.h" #include "ui/widgets/shadow.h"
@ -126,11 +128,16 @@ Widget::Widget(QWidget *parent, not_null<Main::Session*> session)
updateVolumeToggleIcon(); updateVolumeToggleIcon();
_volumeToggle->setClickedCallback([=] { _volumeToggle->setClickedCallback([=] {
Global::SetSongVolume((Global::SongVolume() > 0) ? 0. : Global::RememberedSongVolume()); const auto volume = (Core::App().settings().songVolume() > 0)
mixer()->setSongVolume(Global::SongVolume()); ? 0.
Global::RefSongVolumeChanged().notify(); : Core::App().settings().rememberedSongVolume();
Core::App().settings().setSongVolume(volume);
mixer()->setSongVolume(volume);
}); });
subscribe(Global::RefSongVolumeChanged(), [this] { updateVolumeToggleIcon(); }); Core::App().settings().songVolumeChanges(
) | rpl::start_with_next([=] {
updateVolumeToggleIcon();
}, lifetime());
updateRepeatTrackIcon(); updateRepeatTrackIcon();
_repeatTrack->setClickedCallback([=] { _repeatTrack->setClickedCallback([=] {
@ -139,11 +146,11 @@ Widget::Widget(QWidget *parent, not_null<Main::Session*> session)
updatePlaybackSpeedIcon(); updatePlaybackSpeedIcon();
_playbackSpeed->setClickedCallback([=] { _playbackSpeed->setClickedCallback([=] {
const auto doubled = !Global::VoiceMsgPlaybackDoubled(); const auto doubled = !Core::App().settings().voiceMsgPlaybackDoubled();
Global::SetVoiceMsgPlaybackDoubled(doubled); Core::App().settings().setVoiceMsgPlaybackDoubled(doubled);
instance()->updateVoicePlaybackSpeed(); instance()->updateVoicePlaybackSpeed();
updatePlaybackSpeedIcon(); updatePlaybackSpeedIcon();
_session->saveSettings(); Core::App().saveSettingsDelayed();
}); });
subscribe(instance()->repeatChangedNotifier(), [this](AudioMsgId::Type type) { subscribe(instance()->repeatChangedNotifier(), [this](AudioMsgId::Type type) {
@ -178,7 +185,7 @@ Widget::Widget(QWidget *parent, not_null<Main::Session*> session)
void Widget::updateVolumeToggleIcon() { void Widget::updateVolumeToggleIcon() {
auto icon = []() -> const style::icon * { auto icon = []() -> const style::icon * {
auto volume = Global::SongVolume(); auto volume = Core::App().settings().songVolume();
if (volume > 0) { if (volume > 0) {
if (volume < 1 / 3.) { if (volume < 1 / 3.) {
return &st::mediaPlayerVolumeIcon1; return &st::mediaPlayerVolumeIcon1;
@ -385,7 +392,7 @@ void Widget::updateRepeatTrackIcon() {
} }
void Widget::updatePlaybackSpeedIcon() { void Widget::updatePlaybackSpeedIcon() {
const auto doubled = Global::VoiceMsgPlaybackDoubled(); const auto doubled = Core::App().settings().voiceMsgPlaybackDoubled();
const auto isDefaultSpeed = !doubled; const auto isDefaultSpeed = !doubled;
_playbackSpeed->setIconOverride( _playbackSpeed->setIconOverride(
isDefaultSpeed ? &st::mediaPlayerSpeedDisabledIcon : nullptr, isDefaultSpeed ? &st::mediaPlayerSpeedDisabledIcon : nullptr,

View file

@ -49,7 +49,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
#include "base/unixtime.h" #include "base/unixtime.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_accounts.h" // Accounts::activeSessionValue. #include "main/main_domain.h" // Domain::activeSessionValue.
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h" #include "main/main_session_settings.h"
#include "layout.h" #include "layout.h"
@ -108,16 +108,16 @@ PipDelegate::PipDelegate(QWidget *parent, not_null<Main::Session*> session)
} }
void PipDelegate::pipSaveGeometry(QByteArray geometry) { void PipDelegate::pipSaveGeometry(QByteArray geometry) {
_session->settings().setVideoPipGeometry(geometry); Core::App().settings().setVideoPipGeometry(geometry);
_session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
} }
QByteArray PipDelegate::pipLoadGeometry() { QByteArray PipDelegate::pipLoadGeometry() {
return _session->settings().videoPipGeometry(); return Core::App().settings().videoPipGeometry();
} }
float64 PipDelegate::pipPlaybackSpeed() { float64 PipDelegate::pipPlaybackSpeed() {
return _session->settings().videoPlaybackSpeed(); return Core::App().settings().videoPlaybackSpeed();
} }
QWidget *PipDelegate::pipParentWidget() { QWidget *PipDelegate::pipParentWidget() {
@ -301,9 +301,9 @@ OverlayWidget::OverlayWidget()
, _dropdownShowTimer(this) { , _dropdownShowTimer(this) {
subscribe(Lang::Current().updated(), [this] { refreshLang(); }); subscribe(Lang::Current().updated(), [this] { refreshLang(); });
_lastPositiveVolume = (Global::VideoVolume() > 0.) _lastPositiveVolume = (Core::App().settings().videoVolume() > 0.)
? Global::VideoVolume() ? Core::App().settings().videoVolume()
: Global::kDefaultVolume; : Core::Settings::kDefaultVolume;
setWindowTitle(qsl("Media viewer")); setWindowTitle(qsl("Media viewer"));
@ -320,7 +320,7 @@ OverlayWidget::OverlayWidget()
connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(onScreenResized(int))); connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(onScreenResized(int)));
// While we have one mediaview for all sessions we have to do this. // While we have one mediaview for all sessions we have to do this.
Core::App().accounts().activeSessionValue( Core::App().domain().activeSessionValue(
) | rpl::start_with_next([=](Main::Session *session) { ) | rpl::start_with_next([=](Main::Session *session) {
if (!isHidden()) { if (!isHidden()) {
close(); close();
@ -1157,7 +1157,7 @@ void OverlayWidget::showSaveMsgFile() {
void OverlayWidget::updateMixerVideoVolume() const { void OverlayWidget::updateMixerVideoVolume() const {
if (_streamed) { if (_streamed) {
Player::mixer()->setVideoVolume(Global::VideoVolume()); Player::mixer()->setVideoVolume(Core::App().settings().videoVolume());
} }
} }
@ -1358,18 +1358,18 @@ void OverlayWidget::onDownload() {
if (!_photo && !_document) { if (!_photo && !_document) {
return; return;
} }
if (Global::AskDownloadPath()) { if (Core::App().settings().askDownloadPath()) {
return onSaveAs(); return onSaveAs();
} }
QString path; QString path;
const auto session = _photo ? &_photo->session() : &_document->session(); const auto session = _photo ? &_photo->session() : &_document->session();
if (Global::DownloadPath().isEmpty()) { if (Core::App().settings().downloadPath().isEmpty()) {
path = File::DefaultDownloadPath(session); path = File::DefaultDownloadPath(session);
} else if (Global::DownloadPath() == qsl("tmp")) { } else if (Core::App().settings().downloadPath() == qsl("tmp")) {
path = cTempDir(); path = cTempDir();
} else { } else {
path = Global::DownloadPath(); path = Core::App().settings().downloadPath();
} }
QString toName; QString toName;
if (_document) { if (_document) {
@ -2629,7 +2629,7 @@ void OverlayWidget::restartAtSeekPosition(crl::time position) {
options.mode = Streaming::Mode::Video; options.mode = Streaming::Mode::Video;
options.loop = true; options.loop = true;
} else { } else {
options.speed = _document->session().settings().videoPlaybackSpeed(); options.speed = Core::App().settings().videoPlaybackSpeed();
if (_pip) { if (_pip) {
_pip = nullptr; _pip = nullptr;
} }
@ -2664,25 +2664,24 @@ void OverlayWidget::playbackControlsSeekFinished(crl::time position) {
} }
void OverlayWidget::playbackControlsVolumeChanged(float64 volume) { void OverlayWidget::playbackControlsVolumeChanged(float64 volume) {
Global::SetVideoVolume(volume); Core::App().settings().setVideoVolume(volume);
updateMixerVideoVolume(); updateMixerVideoVolume();
Global::RefVideoVolumeChanged().notify();
if (_document) { if (_document) {
_document->session().saveSettingsDelayed(); _document->session().saveSettingsDelayed();
} }
} }
float64 OverlayWidget::playbackControlsCurrentVolume() { float64 OverlayWidget::playbackControlsCurrentVolume() {
return Global::VideoVolume(); return Core::App().settings().videoVolume();
} }
void OverlayWidget::playbackControlsVolumeToggled() { void OverlayWidget::playbackControlsVolumeToggled() {
const auto volume = Global::VideoVolume(); const auto volume = Core::App().settings().videoVolume();
playbackControlsVolumeChanged(volume ? 0. : _lastPositiveVolume); playbackControlsVolumeChanged(volume ? 0. : _lastPositiveVolume);
} }
void OverlayWidget::playbackControlsVolumeChangeFinished() { void OverlayWidget::playbackControlsVolumeChangeFinished() {
const auto volume = Global::VideoVolume(); const auto volume = Core::App().settings().videoVolume();
if (volume > 0.) { if (volume > 0.) {
_lastPositiveVolume = volume; _lastPositiveVolume = volume;
} }
@ -2692,8 +2691,8 @@ void OverlayWidget::playbackControlsSpeedChanged(float64 speed) {
DEBUG_LOG(("Media playback speed: change to %1.").arg(speed)); DEBUG_LOG(("Media playback speed: change to %1.").arg(speed));
if (_document) { if (_document) {
DEBUG_LOG(("Media playback speed: %1 to settings.").arg(speed)); DEBUG_LOG(("Media playback speed: %1 to settings.").arg(speed));
_document->session().settings().setVideoPlaybackSpeed(speed); Core::App().settings().setVideoPlaybackSpeed(speed);
_document->session().saveSettingsDelayed(); Core::App().saveSettingsDelayed();
} }
if (_streamed && !videoIsGifv()) { if (_streamed && !videoIsGifv()) {
DEBUG_LOG(("Media playback speed: %1 to _streamed.").arg(speed)); DEBUG_LOG(("Media playback speed: %1 to _streamed.").arg(speed));
@ -2702,12 +2701,8 @@ void OverlayWidget::playbackControlsSpeedChanged(float64 speed) {
} }
float64 OverlayWidget::playbackControlsCurrentSpeed() { float64 OverlayWidget::playbackControlsCurrentSpeed() {
const auto result = _document const auto result = Core::App().settings().videoPlaybackSpeed();
? _document->session().settings().videoPlaybackSpeed() DEBUG_LOG(("Media playback speed: now %1.").arg(result));
: 1.;
DEBUG_LOG(("Media playback speed: now %1 (doc %2)."
).arg(result
).arg(Logs::b(_document != nullptr)));
return result; return result;
} }

View file

@ -855,7 +855,6 @@ void Instance::Private::configLoadDone(const MTPConfig &result) {
if (const auto prefix = data.vautoupdate_url_prefix()) { if (const auto prefix = data.vautoupdate_url_prefix()) {
Local::writeAutoupdatePrefix(qs(*prefix)); Local::writeAutoupdatePrefix(qs(*prefix));
} }
Local::writeSettings();
_configExpiresAt = crl::now() _configExpiresAt = crl::now()
+ (data.vexpires().v - base::unixtime::now()) * crl::time(1000); + (data.vexpires().v - base::unixtime::now()) * crl::time(1000);

View file

@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/unixtime.h" #include "base/unixtime.h"
#include "base/openssl_help.h" #include "base/openssl_help.h"
#include "base/call_delayed.h" #include "base/call_delayed.h"
#include "facades.h"
#include <QtCore/QJsonDocument> #include <QtCore/QJsonDocument>
#include <QtCore/QJsonArray> #include <QtCore/QJsonArray>

View file

@ -17,7 +17,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "base/platform/base_platform_file_utilities.h" #include "base/platform/base_platform_file_utilities.h"
#include "base/call_delayed.h" #include "base/call_delayed.h"
#include "facades.h"
#include <QtCore/QProcess> #include <QtCore/QProcess>
#include <QtGui/QDesktopServices> #include <QtGui/QDesktopServices>

View file

@ -11,9 +11,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION #ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
#include "platform/linux/specific_linux.h" #include "platform/linux/specific_linux.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "history/history.h" #include "history/history.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "facades.h"
#include <QtCore/QVersionNumber> #include <QtCore/QVersionNumber>
#include <QtDBus/QDBusMessage> #include <QtDBus/QDBusMessage>
@ -71,7 +72,8 @@ void GetSupported() {
} }
Checked = true; Checked = true;
if (Global::NativeNotifications() && !Platform::IsWayland()) { if (Core::App().settings().nativeNotifications()
&& !Platform::IsWayland()) {
ComputeSupported(true); ComputeSupported(true);
} else { } else {
ComputeSupported(); ComputeSupported();
@ -271,7 +273,7 @@ NotificationData::NotificationData(
// suppress system sound if telegram sound activated, otherwise use system sound // suppress system sound if telegram sound activated, otherwise use system sound
if (capabilities.contains(qsl("sound"))) { if (capabilities.contains(qsl("sound"))) {
if (Global::SoundNotify()) { if (Core::App().settings().soundNotify()) {
_hints["suppress-sound"] = true; _hints["suppress-sound"] = true;
} else { } else {
// sound name according to http://0pointer.de/public/sound-naming-spec.html // sound name according to http://0pointer.de/public/sound-naming-spec.html
@ -475,7 +477,7 @@ std::unique_ptr<Window::Notifications::Manager> Create(
#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION #ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION
GetSupported(); GetSupported();
if ((Global::NativeNotifications() && Supported()) if ((Core::App().settings().nativeNotifications() && Supported())
|| Platform::IsWayland()) { || Platform::IsWayland()) {
return std::make_unique<Manager>(system); return std::make_unique<Manager>(system);
} }

View file

@ -18,7 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_widget.h" #include "history/history_widget.h"
#include "history/history_inner_widget.h" #include "history/history_inner_widget.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_accounts.h" // Accounts::activeSessionValue #include "main/main_domain.h" // Domain::activeSessionValue
#include "media/player/media_player_instance.h" #include "media/player/media_player_instance.h"
#include "media/audio/media_audio.h" #include "media/audio/media_audio.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
@ -196,7 +196,7 @@ private:
} }
- (void) darkModeChanged:(NSNotification *)aNotification { - (void) darkModeChanged:(NSNotification *)aNotification {
Core::App().accounts().notifyUnreadBadgeChanged(); Core::App().domain().notifyUnreadBadgeChanged();
} }
- (void) screenIsLocked:(NSNotification *)aNotification { - (void) screenIsLocked:(NSNotification *)aNotification {
@ -478,7 +478,7 @@ void MainWindow::initTouchBar() {
return; return;
} }
Core::App().accounts().activeSessionValue( Core::App().domain().activeSessionValue(
) | rpl::start_with_next([=](Main::Session *session) { ) | rpl::start_with_next([=](Main::Session *session) {
if (session) { if (session) {
// We need only common pinned dialogs. // We need only common pinned dialogs.

View file

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwidget.h" #include "mainwidget.h"
#include "core/sandbox.h" #include "core/sandbox.h"
#include "core/application.h" #include "core/application.h"
#include "core/core_settings.h"
#include "core/crash_reports.h" #include "core/crash_reports.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "media/audio/media_audio.h" #include "media/audio/media_audio.h"
@ -19,7 +20,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "base/timer.h" #include "base/timer.h"
#include "facades.h"
#include "styles/style_window.h" #include "styles/style_window.h"
#include <QtGui/QWindow> #include <QtGui/QWindow>
@ -422,12 +422,12 @@ void objc_downloadPathEnableAccess(const QByteArray &bookmark) {
} }
_downloadPathUrl = [url retain]; _downloadPathUrl = [url retain];
Global::SetDownloadPath(NS2QString([_downloadPathUrl path]) + '/'); Core::App().settings().setDownloadPath(NS2QString([_downloadPathUrl path]) + '/');
if (isStale) { if (isStale) {
NSData *data = [_downloadPathUrl bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope includingResourceValuesForKeys:nil relativeToURL:nil error:&error]; NSData *data = [_downloadPathUrl bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope includingResourceValuesForKeys:nil relativeToURL:nil error:&error];
if (data) { if (data) {
Global::SetDownloadPathBookmark(QByteArray::fromNSData(data)); Core::App().settings().setDownloadPathBookmark(QByteArray::fromNSData(data));
Local::writeUserSettings(); Local::writeSettings();
} }
} }
} }

View file

@ -20,7 +20,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/popup_menu.h" #include "ui/widgets/popup_menu.h"
#include "window/themes/window_theme.h" #include "window/themes/window_theme.h"
#include "history/history.h" #include "history/history.h"
#include "facades.h"
#include "app.h" #include "app.h"
#include <QtWidgets/QDesktopWidget> #include <QtWidgets/QDesktopWidget>

View file

@ -12,8 +12,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/win/windows_event_filter.h" #include "platform/win/windows_event_filter.h"
#include "platform/win/windows_dlls.h" #include "platform/win/windows_dlls.h"
#include "history/history.h" #include "history/history.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "facades.h"
#include <Shobjidl.h> #include <Shobjidl.h>
#include <shellapi.h> #include <shellapi.h>
@ -323,7 +324,7 @@ bool Supported() {
std::unique_ptr<Window::Notifications::Manager> Create(Window::Notifications::System *system) { std::unique_ptr<Window::Notifications::Manager> Create(Window::Notifications::System *system) {
#ifndef __MINGW32__ #ifndef __MINGW32__
if (Global::NativeNotifications() && Supported()) { if (Core::App().settings().nativeNotifications() && Supported()) {
auto result = std::make_unique<Manager>(system); auto result = std::make_unique<Manager>(system);
if (result->init()) { if (result->init()) {
return std::move(result); return std::move(result);

View file

@ -92,7 +92,7 @@ void GroupMembersWidget::removePeer(PeerData *selectedPeer) {
Ui::hideLayer(); Ui::hideLayer();
if (const auto chat = peer->asChat()) { if (const auto chat = peer->asChat()) {
chat->session().api().kickParticipant(chat, user); chat->session().api().kickParticipant(chat, user);
Ui::showPeerHistory(chat->id, ShowAtTheEndMsgId); Ui::showPeerHistory(chat, ShowAtTheEndMsgId);
} else if (const auto channel = peer->asChannel()) { } else if (const auto channel = peer->asChannel()) {
channel->session().api().kickParticipant( channel->session().api().kickParticipant(
channel, channel,

View file

@ -28,7 +28,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h" #include "data/data_session.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "mtproto/facade.h" #include "mtproto/facade.h"
#include "layout.h" #include "layout.h"
#include "facades.h" #include "facades.h"
@ -266,7 +265,7 @@ void SetupSpellchecker(
not_null<Ui::VerticalLayout*> container) { not_null<Ui::VerticalLayout*> container) {
#ifndef TDESKTOP_DISABLE_SPELLCHECK #ifndef TDESKTOP_DISABLE_SPELLCHECK
const auto session = &controller->session(); const auto session = &controller->session();
const auto settings = &session->settings(); const auto settings = &Core::App().settings();
const auto isSystem = Platform::Spellchecker::IsSystemSpellchecker(); const auto isSystem = Platform::Spellchecker::IsSystemSpellchecker();
const auto button = AddButton( const auto button = AddButton(
container, container,
@ -283,7 +282,7 @@ void SetupSpellchecker(
return (enabled != settings->spellcheckerEnabled()); return (enabled != settings->spellcheckerEnabled());
}) | rpl::start_with_next([=](bool enabled) { }) | rpl::start_with_next([=](bool enabled) {
settings->setSpellcheckerEnabled(enabled); settings->setSpellcheckerEnabled(enabled);
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
}, container->lifetime()); }, container->lifetime());
if (isSystem) { if (isSystem) {
@ -306,7 +305,7 @@ void SetupSpellchecker(
return (enabled != settings->autoDownloadDictionaries()); return (enabled != settings->autoDownloadDictionaries());
}) | rpl::start_with_next([=](bool enabled) { }) | rpl::start_with_next([=](bool enabled) {
settings->setAutoDownloadDictionaries(enabled); settings->setAutoDownloadDictionaries(enabled);
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
}, sliding->entity()->lifetime()); }, sliding->entity()->lifetime());
AddButtonWithLabel( AddButtonWithLabel(

View file

@ -23,6 +23,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_settings.h" #include "styles/style_settings.h"
#include "ui/widgets/continuous_sliders.h" #include "ui/widgets/continuous_sliders.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "calls/calls_instance.h" #include "calls/calls_instance.h"
#include "facades.h" #include "facades.h"
@ -72,32 +74,33 @@ void Calls::setupContent() {
return QString::fromStdString(device.displayName); return QString::fromStdString(device.displayName);
}; };
const auto &settings = Core::App().settings();
const auto currentOutputName = [&] { const auto currentOutputName = [&] {
if (Global::CallOutputDeviceID() == qsl("default")) { if (settings.callOutputDeviceID() == qsl("default")) {
return tr::lng_settings_call_device_default(tr::now); return tr::lng_settings_call_device_default(tr::now);
} }
const auto &list = VoIP::EnumerateAudioOutputs(); const auto &list = VoIP::EnumerateAudioOutputs();
const auto i = ranges::find( const auto i = ranges::find(
list, list,
Global::CallOutputDeviceID(), settings.callOutputDeviceID(),
getId); getId);
return (i != end(list)) return (i != end(list))
? getName(*i) ? getName(*i)
: Global::CallOutputDeviceID(); : settings.callOutputDeviceID();
}(); }();
const auto currentInputName = [&] { const auto currentInputName = [&] {
if (Global::CallInputDeviceID() == qsl("default")) { if (settings.callInputDeviceID() == qsl("default")) {
return tr::lng_settings_call_device_default(tr::now); return tr::lng_settings_call_device_default(tr::now);
} }
const auto &list = VoIP::EnumerateAudioInputs(); const auto &list = VoIP::EnumerateAudioInputs();
const auto i = ranges::find( const auto i = ranges::find(
list, list,
Global::CallInputDeviceID(), settings.callInputDeviceID(),
getId); getId);
return (i != end(list)) return (i != end(list))
? getName(*i) ? getName(*i)
: Global::CallInputDeviceID(); : settings.callInputDeviceID();
}(); }();
AddSkip(content); AddSkip(content);
@ -119,7 +122,7 @@ void Calls::setupContent() {
) | ranges::to_vector; ) | ranges::to_vector;
const auto i = ranges::find( const auto i = ranges::find(
devices, devices,
Global::CallOutputDeviceID(), Core::App().settings().callOutputDeviceID(),
getId); getId);
const auto currentOption = (i != end(devices)) const auto currentOption = (i != end(devices))
? int(i - begin(devices) + 1) ? int(i - begin(devices) + 1)
@ -129,7 +132,8 @@ void Calls::setupContent() {
const auto deviceId = option const auto deviceId = option
? devices[option - 1].id ? devices[option - 1].id
: "default"; : "default";
Global::SetCallOutputDeviceID(QString::fromStdString(deviceId)); Core::App().settings().setCallOutputDeviceID(
QString::fromStdString(deviceId));
_controller->session().saveSettingsDelayed(); _controller->session().saveSettingsDelayed();
if (const auto call = _controller->session().calls().currentCall()) { if (const auto call = _controller->session().calls().currentCall()) {
call->setCurrentAudioDevice(false, deviceId); call->setCurrentAudioDevice(false, deviceId);
@ -160,7 +164,7 @@ void Calls::setupContent() {
const auto updateOutputVolume = [=](int value) { const auto updateOutputVolume = [=](int value) {
_needWriteSettings = true; _needWriteSettings = true;
updateOutputLabel(value); updateOutputLabel(value);
Global::SetCallOutputVolume(value); Core::App().settings().setCallOutputVolume(value);
if (const auto call = _controller->session().calls().currentCall()) { if (const auto call = _controller->session().calls().currentCall()) {
call->setAudioVolume(false, value / 100.0f); call->setAudioVolume(false, value / 100.0f);
} }
@ -169,9 +173,9 @@ void Calls::setupContent() {
outputSlider->setPseudoDiscrete( outputSlider->setPseudoDiscrete(
201, 201,
[](int val) { return val; }, [](int val) { return val; },
Global::CallOutputVolume(), settings.callOutputVolume(),
updateOutputVolume); updateOutputVolume);
updateOutputLabel(Global::CallOutputVolume()); updateOutputLabel(Core::App().settings().callOutputVolume());
AddSkip(content); AddSkip(content);
AddDivider(content); AddDivider(content);
@ -194,7 +198,7 @@ void Calls::setupContent() {
) | ranges::to_vector; ) | ranges::to_vector;
const auto i = ranges::find( const auto i = ranges::find(
devices, devices,
Global::CallInputDeviceID(), Core::App().settings().callInputDeviceID(),
getId); getId);
const auto currentOption = (i != end(devices)) const auto currentOption = (i != end(devices))
? int(i - begin(devices) + 1) ? int(i - begin(devices) + 1)
@ -204,7 +208,8 @@ void Calls::setupContent() {
const auto deviceId = option const auto deviceId = option
? devices[option - 1].id ? devices[option - 1].id
: "default"; : "default";
Global::SetCallInputDeviceID(QString::fromStdString(deviceId)); Core::App().settings().setCallInputDeviceID(
QString::fromStdString(deviceId));
_controller->session().saveSettingsDelayed(); _controller->session().saveSettingsDelayed();
if (_micTester) { if (_micTester) {
stopTestingMicrophone(); stopTestingMicrophone();
@ -238,7 +243,7 @@ void Calls::setupContent() {
const auto updateInputVolume = [=](int value) { const auto updateInputVolume = [=](int value) {
_needWriteSettings = true; _needWriteSettings = true;
updateInputLabel(value); updateInputLabel(value);
Global::SetCallInputVolume(value); Core::App().settings().setCallInputVolume(value);
if (const auto call = _controller->session().calls().currentCall()) { if (const auto call = _controller->session().calls().currentCall()) {
call->setAudioVolume(true, value / 100.0f); call->setAudioVolume(true, value / 100.0f);
} }
@ -246,9 +251,9 @@ void Calls::setupContent() {
inputSlider->resize(st::settingsAudioVolumeSlider.seekSize); inputSlider->resize(st::settingsAudioVolumeSlider.seekSize);
inputSlider->setPseudoDiscrete(101, inputSlider->setPseudoDiscrete(101,
[](int val) { return val; }, [](int val) { return val; },
Global::CallInputVolume(), settings.callInputVolume(),
updateInputVolume); updateInputVolume);
updateInputLabel(Global::CallInputVolume()); updateInputLabel(settings.callInputVolume());
AddButton( AddButton(
content, content,
@ -350,7 +355,7 @@ void Calls::startTestingMicrophone() {
_micTestTextStream.fire(tr::lng_settings_call_stop_mic_test(tr::now)); _micTestTextStream.fire(tr::lng_settings_call_stop_mic_test(tr::now));
_levelUpdateTimer.callEach(50); _levelUpdateTimer.callEach(50);
_micTester = std::make_unique<tgvoip::AudioInputTester>( _micTester = std::make_unique<tgvoip::AudioInputTester>(
Global::CallInputDeviceID().toStdString()); Core::App().settings().callInputDeviceID().toStdString());
if (_micTester->Failed()) { if (_micTester->Failed()) {
stopTestingMicrophone(); stopTestingMicrophone();
Ui::show(Box<InformBox>(tr::lng_call_error_audio_io(tr::now))); Ui::show(Box<InformBox>(tr::lng_call_error_audio_io(tr::now)));

View file

@ -641,15 +641,6 @@ void ChooseFromFile(
crl::guard(parent, callback)); crl::guard(parent, callback));
} }
QString DownloadPathText() {
if (Global::DownloadPath().isEmpty()) {
return tr::lng_download_path_default(tr::now);
} else if (Global::DownloadPath() == qsl("tmp")) {
return tr::lng_download_path_temp(tr::now);
}
return QDir::toNativeSeparators(Global::DownloadPath());
}
void SetupStickersEmoji( void SetupStickersEmoji(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
not_null<Ui::VerticalLayout*> container) { not_null<Ui::VerticalLayout*> container) {
@ -686,42 +677,42 @@ void SetupStickersEmoji(
add( add(
tr::lng_settings_large_emoji(tr::now), tr::lng_settings_large_emoji(tr::now),
session->settings().largeEmoji(), Core::App().settings().largeEmoji(),
[=](bool checked) { [=](bool checked) {
session->settings().setLargeEmoji(checked); Core::App().settings().setLargeEmoji(checked);
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
}); });
add( add(
tr::lng_settings_replace_emojis(tr::now), tr::lng_settings_replace_emojis(tr::now),
session->settings().replaceEmoji(), Core::App().settings().replaceEmoji(),
[=](bool checked) { [=](bool checked) {
session->settings().setReplaceEmoji(checked); Core::App().settings().setReplaceEmoji(checked);
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
}); });
add( add(
tr::lng_settings_suggest_emoji(tr::now), tr::lng_settings_suggest_emoji(tr::now),
session->settings().suggestEmoji(), Core::App().settings().suggestEmoji(),
[=](bool checked) { [=](bool checked) {
session->settings().setSuggestEmoji(checked); Core::App().settings().setSuggestEmoji(checked);
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
}); });
add( add(
tr::lng_settings_suggest_by_emoji(tr::now), tr::lng_settings_suggest_by_emoji(tr::now),
session->settings().suggestStickersByEmoji(), Core::App().settings().suggestStickersByEmoji(),
[=](bool checked) { [=](bool checked) {
session->settings().setSuggestStickersByEmoji(checked); Core::App().settings().setSuggestStickersByEmoji(checked);
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
}); });
add( add(
tr::lng_settings_loop_stickers(tr::now), tr::lng_settings_loop_stickers(tr::now),
session->settings().loopAnimatedStickers(), Core::App().settings().loopAnimatedStickers(),
[=](bool checked) { [=](bool checked) {
session->settings().setLoopAnimatedStickers(checked); Core::App().settings().setLoopAnimatedStickers(checked);
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
}); });
AddButton( AddButton(
@ -769,7 +760,7 @@ void SetupMessages(
QMargins(0, skip, 0, skip))); QMargins(0, skip, 0, skip)));
const auto group = std::make_shared<Ui::RadioenumGroup<SendByType>>( const auto group = std::make_shared<Ui::RadioenumGroup<SendByType>>(
controller->session().settings().sendSubmitWay()); Core::App().settings().sendSubmitWay());
const auto add = [&](SendByType value, const QString &text) { const auto add = [&](SendByType value, const QString &text) {
inner->add( inner->add(
object_ptr<Ui::Radioenum<SendByType>>( object_ptr<Ui::Radioenum<SendByType>>(
@ -790,9 +781,9 @@ void SetupMessages(
: tr::lng_settings_send_ctrlenter(tr::now))); : tr::lng_settings_send_ctrlenter(tr::now)));
group->setChangedCallback([=](SendByType value) { group->setChangedCallback([=](SendByType value) {
controller->session().settings().setSendSubmitWay(value); Core::App().settings().setSendSubmitWay(value);
Core::App().saveSettingsDelayed();
controller->content()->ctrlEnterSubmitUpdated(); controller->content()->ctrlEnterSubmitUpdated();
controller->session().saveSettingsDelayed();
}); });
AddSkip(inner, st::settingsCheckboxesSkip); AddSkip(inner, st::settingsCheckboxesSkip);
@ -841,7 +832,7 @@ void SetupDataStorage(
container, container,
tr::lng_download_path_ask(), tr::lng_download_path_ask(),
st::settingsButton st::settingsButton
)->toggleOn(rpl::single(Global::AskDownloadPath())); )->toggleOn(rpl::single(Core::App().settings().askDownloadPath()));
#ifndef OS_WIN_STORE #ifndef OS_WIN_STORE
const auto showpath = Ui::CreateChild<rpl::event_stream<bool>>(ask); const auto showpath = Ui::CreateChild<rpl::event_stream<bool>>(ask);
@ -852,12 +843,14 @@ void SetupDataStorage(
container, container,
tr::lng_download_path(), tr::lng_download_path(),
st::settingsButton))); st::settingsButton)));
auto pathtext = rpl::single( auto pathtext = Core::App().settings().downloadPathValue(
rpl::empty_value() ) | rpl::map([](const QString &text) {
) | rpl::then(base::ObservableViewer( if (text.isEmpty()) {
Global::RefDownloadPathChanged() return tr::lng_download_path_default(tr::now);
)) | rpl::map([] { } else if (text == qsl("tmp")) {
return DownloadPathText(); return tr::lng_download_path_temp(tr::now);
}
return QDir::toNativeSeparators(text);
}); });
CreateRightLabel( CreateRightLabel(
path->entity(), path->entity(),
@ -872,10 +865,10 @@ void SetupDataStorage(
ask->toggledValue( ask->toggledValue(
) | rpl::filter([](bool checked) { ) | rpl::filter([](bool checked) {
return (checked != Global::AskDownloadPath()); return (checked != Core::App().settings().askDownloadPath());
}) | rpl::start_with_next([=](bool checked) { }) | rpl::start_with_next([=](bool checked) {
Global::SetAskDownloadPath(checked); Core::App().settings().setAskDownloadPath(checked);
controller->session().saveSettingsDelayed(); Core::App().saveSettingsDelayed();
#ifndef OS_WIN_STORE #ifndef OS_WIN_STORE
showpath->fire_copy(!checked); showpath->fire_copy(!checked);
@ -951,7 +944,7 @@ void SetupChatBackground(
object_ptr<Ui::Checkbox>( object_ptr<Ui::Checkbox>(
inner, inner,
tr::lng_settings_adaptive_wide(tr::now), tr::lng_settings_adaptive_wide(tr::now),
Global::AdaptiveForWide(), Core::App().settings().adaptiveForWide(),
st::settingsCheckbox), st::settingsCheckbox),
st::settingsSendTypePadding)); st::settingsSendTypePadding));
@ -981,9 +974,9 @@ void SetupChatBackground(
adaptive->entity()->checkedChanges( adaptive->entity()->checkedChanges(
) | rpl::start_with_next([=](bool checked) { ) | rpl::start_with_next([=](bool checked) {
Global::SetAdaptiveForWide(checked); Core::App().settings().setAdaptiveForWide(checked);
Core::App().saveSettingsDelayed();
Adaptive::Changed().notify(); Adaptive::Changed().notify();
controller->session().saveSettingsDelayed();
}, adaptive->lifetime()); }, adaptive->lifetime());
} }

View file

@ -13,9 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h" #include "mainwindow.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_accounts.h" #include "main/main_domain.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "lang/lang_cloud_manager.h" #include "lang/lang_cloud_manager.h"
#include "lang/lang_instance.h" #include "lang/lang_instance.h"
@ -30,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/audio/media_audio_track.h" #include "media/audio/media_audio_track.h"
#include "settings/settings_common.h" #include "settings/settings_common.h"
#include "api/api_updates.h" #include "api/api_updates.h"
#include "facades.h"
namespace Settings { namespace Settings {
namespace { namespace {
@ -63,13 +61,10 @@ auto GenerateCodes() {
Unexpected("Crashed in Settings!"); Unexpected("Crashed in Settings!");
}); });
codes.emplace(qsl("moderate"), [](SessionController *window) { codes.emplace(qsl("moderate"), [](SessionController *window) {
if (!window) { auto text = Core::App().settings().moderateModeEnabled() ? qsl("Disable moderate mode?") : qsl("Enable moderate mode?");
return;
}
auto text = Global::ModerateModeEnabled() ? qsl("Disable moderate mode?") : qsl("Enable moderate mode?");
Ui::show(Box<ConfirmBox>(text, [=] { Ui::show(Box<ConfirmBox>(text, [=] {
Global::SetModerateModeEnabled(!Global::ModerateModeEnabled()); Core::App().settings().setModerateModeEnabled(!Core::App().settings().moderateModeEnabled());
window->session().saveSettingsDelayed(); Core::App().saveSettingsDelayed();
Ui::hideLayer(); Ui::hideLayer();
})); }));
}); });
@ -97,7 +92,7 @@ auto GenerateCodes() {
})); }));
}); });
codes.emplace(qsl("endpoints"), [](SessionController *window) { codes.emplace(qsl("endpoints"), [](SessionController *window) {
if (!Core::App().accounts().started()) { if (!Core::App().domain().started()) {
return; return;
} }
const auto weak = window const auto weak = window
@ -113,7 +108,7 @@ auto GenerateCodes() {
if (const auto strong = weak.get()) { if (const auto strong = weak.get()) {
loadFor(strong); loadFor(strong);
} else { } else {
for (const auto &[index, account] : Core::App().accounts().list()) { for (const auto &[index, account] : Core::App().domain().accounts()) {
loadFor(account.get()); loadFor(account.get());
} }
} }
@ -130,10 +125,10 @@ auto GenerateCodes() {
crl::on_main(&Core::App(), [=] { crl::on_main(&Core::App(), [=] {
if (window if (window
&& !Core::App().locked() && !Core::App().locked()
&& Core::App().accounts().started() && Core::App().domain().started()
&& Core::App().accounts().list().size() < 3) { && Core::App().domain().accounts().size() < 3) {
Core::App().accounts().activate( Core::App().domain().activate(
Core::App().accounts().add(MTP::Environment::Production)); Core::App().domain().add(MTP::Environment::Production));
} }
}); });
}); });
@ -142,10 +137,10 @@ auto GenerateCodes() {
crl::on_main(&Core::App(), [=] { crl::on_main(&Core::App(), [=] {
if (window if (window
&& !Core::App().locked() && !Core::App().locked()
&& Core::App().accounts().started() && Core::App().domain().started()
&& Core::App().accounts().list().size() < 3) { && Core::App().domain().accounts().size() < 3) {
Core::App().accounts().activate( Core::App().domain().activate(
Core::App().accounts().add(MTP::Environment::Test)); Core::App().domain().add(MTP::Environment::Test));
} }
}); });
}); });
@ -154,11 +149,11 @@ auto GenerateCodes() {
codes.emplace(qsl("account%1").arg(i + 1), [=]( codes.emplace(qsl("account%1").arg(i + 1), [=](
SessionController *window) { SessionController *window) {
crl::on_main(&Core::App(), [=] { crl::on_main(&Core::App(), [=] {
const auto &list = Core::App().accounts().list(); const auto &list = Core::App().domain().accounts();
const auto j = list.find(i); const auto j = list.find(i);
if (j != list.end() && !Core::App().locked()) { if (j != list.end() && !Core::App().locked()) {
if (&Core::App().activeAccount() != j->second.get()) { if (&Core::App().activeAccount() != j->second.get()) {
Core::App().accounts().activate(i); Core::App().domain().activate(i);
} }
} }
}); });
@ -201,34 +196,27 @@ auto GenerateCodes() {
}; };
for (auto &key : audioKeys) { for (auto &key : audioKeys) {
codes.emplace(key, [=](SessionController *window) { codes.emplace(key, [=](SessionController *window) {
if (!window) { FileDialog::GetOpenPath(Core::App().getFileDialogParent(), "Open audio file", audioFilters, [=](const FileDialog::OpenResult &result) {
return; if (!result.paths.isEmpty()) {
}
const auto weak = base::make_weak(&window->session());
FileDialog::GetOpenPath(Core::App().getFileDialogParent(), "Open audio file", audioFilters, crl::guard(&window->session(), [=](const FileDialog::OpenResult &result) {
if (weak && !result.paths.isEmpty()) {
auto track = Media::Audio::Current().createTrack(); auto track = Media::Audio::Current().createTrack();
track->fillFromFile(result.paths.front()); track->fillFromFile(result.paths.front());
if (track->failed()) { if (track->failed()) {
Ui::show(Box<InformBox>( Ui::show(Box<InformBox>(
"Could not audio :( Errors in 'log.txt'.")); "Could not audio :( Errors in 'log.txt'."));
} else { } else {
weak->settings().setSoundOverride( Core::App().settings().setSoundOverride(
key, key,
result.paths.front()); result.paths.front());
weak->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
} }
} }
})); });
}); });
} }
codes.emplace(qsl("sounds_reset"), [](SessionController *window) { codes.emplace(qsl("sounds_reset"), [](SessionController *window) {
if (window) { Core::App().settings().clearSoundOverrides();
window->session().settings().clearSoundOverrides(); Core::App().saveSettingsDelayed();
window->session().saveSettingsDelayed();
Ui::show(Box<InformBox>("All sound overrides were reset.")); Ui::show(Box<InformBox>("All sound overrides were reset."));
}
}); });
return codes; return codes;

View file

@ -16,6 +16,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/popup_menu.h" #include "ui/widgets/popup_menu.h"
#include "ui/widgets/box_content_divider.h" #include "ui/widgets/box_content_divider.h"
#include "ui/special_buttons.h" #include "ui/special_buttons.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "chat_helpers/emoji_suggestions_widget.h" #include "chat_helpers/emoji_suggestions_widget.h"
#include "boxes/add_contact_box.h" #include "boxes/add_contact_box.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
@ -26,7 +28,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/profile/info_profile_values.h" #include "info/profile/info_profile_values.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "core/file_utilities.h" #include "core/file_utilities.h"
@ -397,7 +398,7 @@ BioManager SetupBio(
QObject::connect(bio, &Ui::InputField::changed, updated); QObject::connect(bio, &Ui::InputField::changed, updated);
bio->setInstantReplaces(Ui::InstantReplaces::Default()); bio->setInstantReplaces(Ui::InstantReplaces::Default());
bio->setInstantReplacesEnabled( bio->setInstantReplacesEnabled(
self->session().settings().replaceEmojiValue()); Core::App().settings().replaceEmojiValue());
Ui::Emoji::SuggestionsController::Init( Ui::Emoji::SuggestionsController::Init(
container->window(), container->window(),
bio, bio,

View file

@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_app_config.h" #include "main/main_app_config.h"
#include "apiwrap.h" #include "apiwrap.h"
@ -117,7 +118,7 @@ void SetupSections(
st::settingsSectionButton, st::settingsSectionButton,
&st::settingsIconFolders)))->setDuration(0); &st::settingsIconFolders)))->setDuration(0);
if (!controller->session().data().chatsFilters().list().empty() if (!controller->session().data().chatsFilters().list().empty()
|| Global::DialogsFiltersEnabled()) { || controller->session().settings().dialogsFiltersEnabled()) {
slided->show(anim::type::instant); slided->show(anim::type::instant);
preload(); preload();
} else { } else {

View file

@ -22,7 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h" #include "mainwindow.h"
#include "core/application.h" #include "core/application.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h" #include "main/main_domain.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "facades.h" #include "facades.h"
#include "app.h" #include "app.h"
@ -38,8 +38,11 @@ namespace {
constexpr auto kMaxNotificationsCount = 5; constexpr auto kMaxNotificationsCount = 5;
int CurrentCount() { [[nodiscard]] int CurrentCount() {
return snap(Global::NotificationsCount(), 1, kMaxNotificationsCount); return snap(
Core::App().settings().notificationsCount(),
1,
kMaxNotificationsCount);
} }
using ChangeType = Window::Notifications::ChangeType; using ChangeType = Window::Notifications::ChangeType;
@ -64,7 +67,7 @@ protected:
int resizeGetHeight(int newWidth) override; int resizeGetHeight(int newWidth) override;
private: private:
using ScreenCorner = Notify::ScreenCorner; using ScreenCorner = Core::Settings::ScreenCorner;
void setOverCorner(ScreenCorner corner); void setOverCorner(ScreenCorner corner);
void clearOverCorner(); void clearOverCorner();
@ -126,7 +129,7 @@ NotificationsCount::NotificationsCount(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController*> controller) not_null<Window::SessionController*> controller)
: _controller(controller) : _controller(controller)
, _chosenCorner(Global::NotificationsCorner()) , _chosenCorner(Core::App().settings().notificationsCorner())
, _oldCount(CurrentCount()) { , _oldCount(CurrentCount()) {
setMouseTracking(true); setMouseTracking(true);
@ -153,9 +156,9 @@ void NotificationsCount::paintEvent(QPaintEvent *e) {
st::notificationsBoxMonitor.paint(p, contentLeft, monitorTop, width()); st::notificationsBoxMonitor.paint(p, contentLeft, monitorTop, width());
for (int corner = 0; corner != 4; ++corner) { for (int corner = 0; corner != 4; ++corner) {
auto screenCorner = static_cast<Notify::ScreenCorner>(corner); auto screenCorner = static_cast<ScreenCorner>(corner);
auto isLeft = Notify::IsLeftCorner(screenCorner); auto isLeft = Core::Settings::IsLeftCorner(screenCorner);
auto isTop = Notify::IsTopCorner(screenCorner); auto isTop = Core::Settings::IsTopCorner(screenCorner);
auto sampleLeft = isLeft ? (screenRect.x() + st::notificationsSampleSkip) : (screenRect.x() + screenRect.width() - st::notificationsSampleSkip - st::notificationSampleSize.width()); auto sampleLeft = isLeft ? (screenRect.x() + st::notificationsSampleSkip) : (screenRect.x() + screenRect.width() - st::notificationsSampleSkip - st::notificationSampleSize.width());
auto sampleTop = isTop ? (screenRect.y() + st::notificationsSampleTopSkip) : (screenRect.y() + screenRect.height() - st::notificationsSampleBottomSkip - st::notificationSampleSize.height()); auto sampleTop = isTop ? (screenRect.y() + st::notificationsSampleTopSkip) : (screenRect.y() + screenRect.height() - st::notificationsSampleBottomSkip - st::notificationSampleSize.height());
if (corner == static_cast<int>(_chosenCorner)) { if (corner == static_cast<int>(_chosenCorner)) {
@ -185,11 +188,11 @@ void NotificationsCount::setCount(int count) {
_sampleOpacities[_oldCount + animatedDelta].start([this] { update(); }, from, to, st::notifyFastAnim); _sampleOpacities[_oldCount + animatedDelta].start([this] { update(); }, from, to, st::notifyFastAnim);
} }
if (count != Global::NotificationsCount()) { if (count != Core::App().settings().notificationsCount()) {
Global::SetNotificationsCount(count); Core::App().settings().setNotificationsCount(count);
Core::App().saveSettingsDelayed();
_controller->session().notifications().settingsChanged().notify( _controller->session().notifications().settingsChanged().notify(
ChangeType::MaxCount); ChangeType::MaxCount);
_controller->session().saveSettingsDelayed();
} }
} }
@ -324,13 +327,13 @@ void NotificationsCount::mouseMoveEvent(QMouseEvent *e) {
auto bottomRight = style::rtlrect(screenRect.x() + screenRect.width() - cornerWidth, screenRect.y() + screenRect.height() - cornerHeight, cornerWidth, cornerHeight, width()); auto bottomRight = style::rtlrect(screenRect.x() + screenRect.width() - cornerWidth, screenRect.y() + screenRect.height() - cornerHeight, cornerWidth, cornerHeight, width());
auto bottomLeft = style::rtlrect(screenRect.x(), screenRect.y() + screenRect.height() - cornerHeight, cornerWidth, cornerHeight, width()); auto bottomLeft = style::rtlrect(screenRect.x(), screenRect.y() + screenRect.height() - cornerHeight, cornerWidth, cornerHeight, width());
if (topLeft.contains(e->pos())) { if (topLeft.contains(e->pos())) {
setOverCorner(Notify::ScreenCorner::TopLeft); setOverCorner(ScreenCorner::TopLeft);
} else if (topRight.contains(e->pos())) { } else if (topRight.contains(e->pos())) {
setOverCorner(Notify::ScreenCorner::TopRight); setOverCorner(ScreenCorner::TopRight);
} else if (bottomRight.contains(e->pos())) { } else if (bottomRight.contains(e->pos())) {
setOverCorner(Notify::ScreenCorner::BottomRight); setOverCorner(ScreenCorner::BottomRight);
} else if (bottomLeft.contains(e->pos())) { } else if (bottomLeft.contains(e->pos())) {
setOverCorner(Notify::ScreenCorner::BottomLeft); setOverCorner(ScreenCorner::BottomLeft);
} else { } else {
clearOverCorner(); clearOverCorner();
} }
@ -340,7 +343,7 @@ void NotificationsCount::leaveEventHook(QEvent *e) {
clearOverCorner(); clearOverCorner();
} }
void NotificationsCount::setOverCorner(Notify::ScreenCorner corner) { void NotificationsCount::setOverCorner(ScreenCorner corner) {
if (_isOverCorner) { if (_isOverCorner) {
if (corner == _overCorner) { if (corner == _overCorner) {
return; return;
@ -366,8 +369,8 @@ void NotificationsCount::setOverCorner(Notify::ScreenCorner corner) {
} }
if (samplesNeeded > samplesLeave) { if (samplesNeeded > samplesLeave) {
auto r = psDesktopRect(); auto r = psDesktopRect();
auto isLeft = Notify::IsLeftCorner(_overCorner); auto isLeft = Core::Settings::IsLeftCorner(_overCorner);
auto isTop = Notify::IsTopCorner(_overCorner); auto isTop = Core::Settings::IsTopCorner(_overCorner);
auto sampleLeft = (isLeft == rtl()) ? (r.x() + r.width() - st::notifyWidth - st::notifyDeltaX) : (r.x() + st::notifyDeltaX); auto sampleLeft = (isLeft == rtl()) ? (r.x() + r.width() - st::notifyWidth - st::notifyDeltaX) : (r.x() + st::notifyDeltaX);
auto sampleTop = isTop ? (r.y() + st::notifyDeltaY) : (r.y() + r.height() - st::notifyDeltaY - st::notifyMinHeight); auto sampleTop = isTop ? (r.y() + st::notifyDeltaY) : (r.y() + r.height() - st::notifyDeltaY - st::notifyMinHeight);
for (int i = samplesLeave; i != samplesNeeded; ++i) { for (int i = samplesLeave; i != samplesNeeded; ++i) {
@ -412,11 +415,11 @@ void NotificationsCount::mouseReleaseEvent(QMouseEvent *e) {
_chosenCorner = _downCorner; _chosenCorner = _downCorner;
update(); update();
if (_chosenCorner != Global::NotificationsCorner()) { if (_chosenCorner != Core::App().settings().notificationsCorner()) {
Global::SetNotificationsCorner(_chosenCorner); Core::App().settings().setNotificationsCorner(_chosenCorner);
Core::App().saveSettingsDelayed();
_controller->session().notifications().settingsChanged().notify( _controller->session().notifications().settingsChanged().notify(
ChangeType::Corner); ChangeType::Corner);
_controller->session().saveSettingsDelayed();
} }
} }
} }
@ -562,25 +565,26 @@ void SetupNotificationsContent(
checkbox(label, checked), checkbox(label, checked),
st::settingsCheckboxPadding)); st::settingsCheckboxPadding));
}; };
const auto &settings = Core::App().settings();
const auto desktop = addCheckbox( const auto desktop = addCheckbox(
tr::lng_settings_desktop_notify(tr::now), tr::lng_settings_desktop_notify(tr::now),
Global::DesktopNotify()); settings.desktopNotify());
const auto name = addSlidingCheckbox( const auto name = addSlidingCheckbox(
tr::lng_settings_show_name(tr::now), tr::lng_settings_show_name(tr::now),
(Global::NotifyView() <= dbinvShowName)); (settings.notifyView() <= dbinvShowName));
const auto preview = addSlidingCheckbox( const auto preview = addSlidingCheckbox(
tr::lng_settings_show_preview(tr::now), tr::lng_settings_show_preview(tr::now),
(Global::NotifyView() <= dbinvShowPreview)); (settings.notifyView() <= dbinvShowPreview));
const auto sound = addCheckbox( const auto sound = addCheckbox(
tr::lng_settings_sound_notify(tr::now), tr::lng_settings_sound_notify(tr::now),
Global::SoundNotify()); settings.soundNotify());
const auto flashbounce = addCheckbox( const auto flashbounce = addCheckbox(
(Platform::IsWindows() (Platform::IsWindows()
? tr::lng_settings_alert_windows ? tr::lng_settings_alert_windows
: Platform::IsMac() : Platform::IsMac()
? tr::lng_settings_alert_mac ? tr::lng_settings_alert_mac
: tr::lng_settings_alert_linux)(tr::now), : tr::lng_settings_alert_linux)(tr::now),
Global::FlashBounceNotify()); settings.flashBounceNotify());
AddSkip(container, st::settingsCheckboxesSkip); AddSkip(container, st::settingsCheckboxesSkip);
AddDivider(container); AddDivider(container);
@ -589,10 +593,10 @@ void SetupNotificationsContent(
const auto muted = addCheckbox( const auto muted = addCheckbox(
tr::lng_settings_include_muted(tr::now), tr::lng_settings_include_muted(tr::now),
session->settings().includeMutedCounter()); settings.includeMutedCounter());
const auto count = addCheckbox( const auto count = addCheckbox(
tr::lng_settings_count_unread(tr::now), tr::lng_settings_count_unread(tr::now),
session->settings().countUnreadMessages()); settings.countUnreadMessages());
AddSkip(container, st::settingsCheckboxesSkip); AddSkip(container, st::settingsCheckboxesSkip);
AddDivider(container); AddDivider(container);
@ -616,17 +620,17 @@ void SetupNotificationsContent(
const auto pinned = addCheckbox( const auto pinned = addCheckbox(
tr::lng_settings_events_pinned(tr::now), tr::lng_settings_events_pinned(tr::now),
session->settings().notifyAboutPinned()); settings.notifyAboutPinned());
session->settings().notifyAboutPinnedChanges( settings.notifyAboutPinnedChanges(
) | rpl::start_with_next([=](bool notify) { ) | rpl::start_with_next([=](bool notify) {
pinned->setChecked(notify); pinned->setChecked(notify);
}, pinned->lifetime()); }, pinned->lifetime());
pinned->checkedChanges( pinned->checkedChanges(
) | rpl::filter([=](bool notify) { ) | rpl::filter([=](bool notify) {
return (notify != session->settings().notifyAboutPinned()); return (notify != Core::App().settings().notifyAboutPinned());
}) | rpl::start_with_next([=](bool notify) { }) | rpl::start_with_next([=](bool notify) {
session->settings().setNotifyAboutPinned(notify); Core::App().settings().setNotifyAboutPinned(notify);
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
}, joined->lifetime()); }, joined->lifetime());
const auto nativeText = [&] { const auto nativeText = [&] {
@ -648,7 +652,7 @@ void SetupNotificationsContent(
AddDivider(container); AddDivider(container);
AddSkip(container, st::settingsCheckboxesSkip); AddSkip(container, st::settingsCheckboxesSkip);
AddSubsectionTitle(container, tr::lng_settings_native_title()); AddSubsectionTitle(container, tr::lng_settings_native_title());
return addCheckbox(nativeText, Global::NativeNotifications()); return addCheckbox(nativeText, settings.nativeNotifications());
}(); }();
const auto advancedSlide = !Platform::IsMac10_8OrGreater() const auto advancedSlide = !Platform::IsMac10_8OrGreater()
@ -674,20 +678,20 @@ void SetupNotificationsContent(
name->hide(anim::type::instant); name->hide(anim::type::instant);
preview->hide(anim::type::instant); preview->hide(anim::type::instant);
} }
if (native && advancedSlide && Global::NativeNotifications()) { if (native && advancedSlide && settings.nativeNotifications()) {
advancedSlide->hide(anim::type::instant); advancedSlide->hide(anim::type::instant);
} }
using Change = Window::Notifications::ChangeType; using Change = Window::Notifications::ChangeType;
const auto changed = [=](Change change) { const auto changed = [=](Change change) {
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
session->notifications().settingsChanged().notify(change); session->notifications().settingsChanged().notify(change);
}; };
desktop->checkedChanges( desktop->checkedChanges(
) | rpl::filter([](bool checked) { ) | rpl::filter([](bool checked) {
return (checked != Global::DesktopNotify()); return (checked != Core::App().settings().desktopNotify());
}) | rpl::start_with_next([=](bool checked) { }) | rpl::start_with_next([=](bool checked) {
Global::SetDesktopNotify(checked); Core::App().settings().setDesktopNotify(checked);
changed(Change::DesktopEnabled); changed(Change::DesktopEnabled);
}, desktop->lifetime()); }, desktop->lifetime());
@ -700,9 +704,9 @@ void SetupNotificationsContent(
} }
return dbinvShowPreview; return dbinvShowPreview;
}) | rpl::filter([=](DBINotifyView value) { }) | rpl::filter([=](DBINotifyView value) {
return (value != Global::NotifyView()); return (value != Core::App().settings().notifyView());
}) | rpl::start_with_next([=](DBINotifyView value) { }) | rpl::start_with_next([=](DBINotifyView value) {
Global::SetNotifyView(value); Core::App().settings().setNotifyView(value);
changed(Change::ViewParams); changed(Change::ViewParams);
}, name->lifetime()); }, name->lifetime());
@ -715,41 +719,41 @@ void SetupNotificationsContent(
} }
return dbinvShowNothing; return dbinvShowNothing;
}) | rpl::filter([=](DBINotifyView value) { }) | rpl::filter([=](DBINotifyView value) {
return (value != Global::NotifyView()); return (value != Core::App().settings().notifyView());
}) | rpl::start_with_next([=](DBINotifyView value) { }) | rpl::start_with_next([=](DBINotifyView value) {
Global::SetNotifyView(value); Core::App().settings().setNotifyView(value);
changed(Change::ViewParams); changed(Change::ViewParams);
}, preview->lifetime()); }, preview->lifetime());
sound->checkedChanges( sound->checkedChanges(
) | rpl::filter([](bool checked) { ) | rpl::filter([](bool checked) {
return (checked != Global::SoundNotify()); return (checked != Core::App().settings().soundNotify());
}) | rpl::start_with_next([=](bool checked) { }) | rpl::start_with_next([=](bool checked) {
Global::SetSoundNotify(checked); Core::App().settings().setSoundNotify(checked);
changed(Change::SoundEnabled); changed(Change::SoundEnabled);
}, sound->lifetime()); }, sound->lifetime());
flashbounce->checkedChanges( flashbounce->checkedChanges(
) | rpl::filter([](bool checked) { ) | rpl::filter([](bool checked) {
return (checked != Global::FlashBounceNotify()); return (checked != Core::App().settings().flashBounceNotify());
}) | rpl::start_with_next([=](bool checked) { }) | rpl::start_with_next([=](bool checked) {
Global::SetFlashBounceNotify(checked); Core::App().settings().setFlashBounceNotify(checked);
changed(Change::FlashBounceEnabled); changed(Change::FlashBounceEnabled);
}, flashbounce->lifetime()); }, flashbounce->lifetime());
muted->checkedChanges( muted->checkedChanges(
) | rpl::filter([=](bool checked) { ) | rpl::filter([=](bool checked) {
return (checked != session->settings().includeMutedCounter()); return (checked != Core::App().settings().includeMutedCounter());
}) | rpl::start_with_next([=](bool checked) { }) | rpl::start_with_next([=](bool checked) {
session->settings().setIncludeMutedCounter(checked); Core::App().settings().setIncludeMutedCounter(checked);
changed(Change::IncludeMuted); changed(Change::IncludeMuted);
}, muted->lifetime()); }, muted->lifetime());
count->checkedChanges( count->checkedChanges(
) | rpl::filter([=](bool checked) { ) | rpl::filter([=](bool checked) {
return (checked != session->settings().countUnreadMessages()); return (checked != Core::App().settings().countUnreadMessages());
}) | rpl::start_with_next([=](bool checked) { }) | rpl::start_with_next([=](bool checked) {
session->settings().setCountUnreadMessages(checked); Core::App().settings().setCountUnreadMessages(checked);
changed(Change::CountMessages); changed(Change::CountMessages);
}, count->lifetime()); }, count->lifetime());
@ -757,32 +761,35 @@ void SetupNotificationsContent(
session->notifications().settingsChanged() session->notifications().settingsChanged()
) | rpl::start_with_next([=](Change change) { ) | rpl::start_with_next([=](Change change) {
if (change == Change::DesktopEnabled) { if (change == Change::DesktopEnabled) {
desktop->setChecked(Global::DesktopNotify()); desktop->setChecked(Core::App().settings().desktopNotify());
name->toggle(Global::DesktopNotify(), anim::type::normal); name->toggle(
Core::App().settings().desktopNotify(),
anim::type::normal);
preview->toggle( preview->toggle(
Global::DesktopNotify() && name->entity()->checked(), (Core::App().settings().desktopNotify()
&& name->entity()->checked()),
anim::type::normal); anim::type::normal);
} else if (change == Change::ViewParams) { } else if (change == Change::ViewParams) {
preview->toggle(name->entity()->checked(), anim::type::normal); preview->toggle(name->entity()->checked(), anim::type::normal);
} else if (change == Change::SoundEnabled) { } else if (change == Change::SoundEnabled) {
sound->setChecked(Global::SoundNotify()); sound->setChecked(Core::App().settings().soundNotify());
} else if (change == Change::FlashBounceEnabled) { } else if (change == Change::FlashBounceEnabled) {
flashbounce->setChecked(Global::FlashBounceNotify()); flashbounce->setChecked(Core::App().settings().flashBounceNotify());
} }
}, desktop->lifetime()); }, desktop->lifetime());
if (native) { if (native) {
native->checkedChanges( native->checkedChanges(
) | rpl::filter([](bool checked) { ) | rpl::filter([](bool checked) {
return (checked != Global::NativeNotifications()); return (checked != Core::App().settings().nativeNotifications());
}) | rpl::start_with_next([=](bool checked) { }) | rpl::start_with_next([=](bool checked) {
Global::SetNativeNotifications(checked); Core::App().settings().setNativeNotifications(checked);
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
session->notifications().createManager(); session->notifications().createManager();
if (advancedSlide) { if (advancedSlide) {
advancedSlide->toggle( advancedSlide->toggle(
!Global::NativeNotifications(), !Core::App().settings().nativeNotifications(),
anim::type::normal); anim::type::normal);
} }
}, native->lifetime()); }, native->lifetime());

View file

@ -12,10 +12,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h" #include "apiwrap.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "data/data_user.h" #include "data/data_user.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_changes.h" #include "data/data_changes.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "history/admin_log/history_admin_log_item.h" #include "history/admin_log/history_admin_log_item.h"
#include "history/view/history_view_element.h" #include "history/view/history_view_element.h"
#include "history/view/history_view_message.h" #include "history/view/history_view_message.h"
@ -252,8 +253,8 @@ void BlockedBoxController::loadMoreRows() {
void BlockedBoxController::rowClicked(not_null<PeerListRow*> row) { void BlockedBoxController::rowClicked(not_null<PeerListRow*> row) {
const auto peer = row->peer(); const auto peer = row->peer();
crl::on_main(&peer->session(), [peerId = peer->id] { crl::on_main(&peer->session(), [=] {
Ui::showPeerHistory(peerId, ShowAtUnreadMsgId); Ui::showPeerHistory(peer, ShowAtUnreadMsgId);
}); });
} }
@ -511,7 +512,7 @@ rpl::producer<QString> LastSeenPrivacyController::exceptionsDescription() {
void LastSeenPrivacyController::confirmSave( void LastSeenPrivacyController::confirmSave(
bool someAreDisallowed, bool someAreDisallowed,
FnMut<void()> saveCallback) { FnMut<void()> saveCallback) {
if (someAreDisallowed && !_session->settings().lastSeenWarningSeen()) { if (someAreDisallowed && !Core::App().settings().lastSeenWarningSeen()) {
const auto session = _session; const auto session = _session;
auto weakBox = std::make_shared<QPointer<ConfirmBox>>(); auto weakBox = std::make_shared<QPointer<ConfirmBox>>();
auto callback = [=, saveCallback = std::move(saveCallback)]() mutable { auto callback = [=, saveCallback = std::move(saveCallback)]() mutable {
@ -519,8 +520,8 @@ void LastSeenPrivacyController::confirmSave(
box->closeBox(); box->closeBox();
} }
saveCallback(); saveCallback();
session->settings().setLastSeenWarningSeen(true); Core::App().settings().setLastSeenWarningSeen(true);
session->saveSettingsDelayed(); Core::App().saveSettingsDelayed();
}; };
auto box = Box<ConfirmBox>( auto box = Box<ConfirmBox>(
tr::lng_edit_privacy_lastseen_warning(tr::now), tr::lng_edit_privacy_lastseen_warning(tr::now),

View file

@ -18,6 +18,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/sessions_box.h" #include "boxes/sessions_box.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "boxes/self_destruction_box.h" #include "boxes/self_destruction_box.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "ui/wrap/vertical_layout.h" #include "ui/wrap/vertical_layout.h"
#include "ui/wrap/slide_wrap.h" #include "ui/wrap/slide_wrap.h"
#include "ui/wrap/fade_wrap.h" #include "ui/wrap/fade_wrap.h"
@ -238,7 +240,7 @@ void SetupLocalPasscode(
: tr::lng_passcode_autolock_inactive; : tr::lng_passcode_autolock_inactive;
auto value = PasscodeChanges( auto value = PasscodeChanges(
) | rpl::map([] { ) | rpl::map([] {
const auto autolock = Global::AutoLock(); const auto autolock = Core::App().settings().autoLock();
return (autolock % 3600) return (autolock % 3600)
? tr::lng_passcode_autolock_minutes(tr::now, lt_count, autolock / 60) ? tr::lng_passcode_autolock_minutes(tr::now, lt_count, autolock / 60)
: tr::lng_passcode_autolock_hours(tr::now, lt_count, autolock / 3600); : tr::lng_passcode_autolock_hours(tr::now, lt_count, autolock / 3600);

View file

@ -85,7 +85,7 @@ bool ReadSetting(
stream >> serialized; stream >> serialized;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Core::App().settings().constructFromSerialized(serialized); Core::App().settings().addFromSerialized(serialized);
} break; } break;
case dbiChatSizeMaxOld: { case dbiChatSizeMaxOld: {
@ -234,13 +234,13 @@ bool ReadSetting(
anim::SetDisabled(disabled == 1); anim::SetDisabled(disabled == 1);
} break; } break;
case dbiSoundFlashBounceNotify: { case dbiSoundFlashBounceNotifyOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Global::SetSoundNotify((v & 0x01) == 0x01); Core::App().settings().setSoundNotify((v & 0x01) == 0x01);
Global::SetFlashBounceNotify((v & 0x02) == 0x00); Core::App().settings().setFlashBounceNotify((v & 0x02) == 0x00);
} break; } break;
case dbiAutoDownloadOld: { case dbiAutoDownloadOld: {
@ -302,20 +302,20 @@ bool ReadSetting(
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
} break; } break;
case dbiDialogsFilters: { case dbiDialogsFiltersOld: {
qint32 enabled; qint32 enabled;
stream >> enabled; stream >> enabled;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Global::SetDialogsFiltersEnabled(enabled == 1); context.sessionSettings().setDialogsFiltersEnabled(enabled == 1);
} break; } break;
case dbiModerateMode: { case dbiModerateModeOld: {
qint32 enabled; qint32 enabled;
stream >> enabled; stream >> enabled;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Global::SetModerateModeEnabled(enabled == 1); Core::App().settings().setModerateModeEnabled(enabled == 1);
} break; } break;
case dbiIncludeMutedOld: { case dbiIncludeMutedOld: {
@ -323,7 +323,7 @@ bool ReadSetting(
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
context.sessionSettings().setIncludeMutedCounter(v == 1); Core::App().settings().setIncludeMutedCounter(v == 1);
} break; } break;
case dbiShowingSavedGifsOld: { case dbiShowingSavedGifsOld: {
@ -332,12 +332,12 @@ bool ReadSetting(
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
} break; } break;
case dbiDesktopNotify: { case dbiDesktopNotifyOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Global::SetDesktopNotify(v == 1); Core::App().settings().setDesktopNotify(v == 1);
} break; } break;
case dbiWindowsNotificationsOld: { case dbiWindowsNotificationsOld: {
@ -346,28 +346,28 @@ bool ReadSetting(
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
} break; } break;
case dbiNativeNotifications: { case dbiNativeNotificationsOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Global::SetNativeNotifications(v == 1); Core::App().settings().setNativeNotifications(v == 1);
} break; } break;
case dbiNotificationsCount: { case dbiNotificationsCountOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Global::SetNotificationsCount((v > 0 ? v : 3)); Core::App().settings().setNotificationsCount((v > 0 ? v : 3));
} break; } break;
case dbiNotificationsCorner: { case dbiNotificationsCornerOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Global::SetNotificationsCorner(static_cast<Notify::ScreenCorner>((v >= 0 && v < 4) ? v : 2)); Core::App().settings().setNotificationsCorner(static_cast<Core::Settings::ScreenCorner>((v >= 0 && v < 4) ? v : 2));
} break; } break;
case dbiDialogsWidthRatioOld: { case dbiDialogsWidthRatioOld: {
@ -383,7 +383,7 @@ bool ReadSetting(
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
context.sessionSettings().setLastSeenWarningSeen(v == 1); Core::App().settings().setLastSeenWarningSeen(v == 1);
} break; } break;
case dbiSessionSettings: { case dbiSessionSettings: {
@ -391,8 +391,7 @@ bool ReadSetting(
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
context.sessionSettingsStorage context.sessionSettings().addFromSerialized(v);
= Main::SessionSettings::FromSerialized(v);
} break; } break;
case dbiWorkMode: { case dbiWorkMode: {
@ -720,7 +719,7 @@ bool ReadSetting(
&& unchecked != SendSettings::CtrlEnter) { && unchecked != SendSettings::CtrlEnter) {
return false; return false;
} }
context.sessionSettings().setSendSubmitWay(unchecked); Core::App().settings().setSendSubmitWay(unchecked);
} break; } break;
case dbiCatsAndDogs: { // deprecated case dbiCatsAndDogs: { // deprecated
@ -753,20 +752,20 @@ bool ReadSetting(
context.tileNight = (tileNight == 1); context.tileNight = (tileNight == 1);
} break; } break;
case dbiAdaptiveForWide: { case dbiAdaptiveForWideOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Global::SetAdaptiveForWide(v == 1); Core::App().settings().setAdaptiveForWide(v == 1);
} break; } break;
case dbiAutoLock: { case dbiAutoLockOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Global::SetAutoLock(v); Core::App().settings().setAutoLock(v);
Global::RefLocalPasscodeChanged().notify(); Global::RefLocalPasscodeChanged().notify();
} break; } break;
@ -775,7 +774,7 @@ bool ReadSetting(
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
context.sessionSettings().setReplaceEmoji(v == 1); Core::App().settings().setReplaceEmoji(v == 1);
} break; } break;
case dbiSuggestEmojiOld: { case dbiSuggestEmojiOld: {
@ -783,7 +782,7 @@ bool ReadSetting(
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
context.sessionSettings().setSuggestEmoji(v == 1); Core::App().settings().setSuggestEmoji(v == 1);
} break; } break;
case dbiSuggestStickersByEmojiOld: { case dbiSuggestStickersByEmojiOld: {
@ -791,7 +790,7 @@ bool ReadSetting(
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
context.sessionSettings().setSuggestStickersByEmoji(v == 1); Core::App().settings().setSuggestStickersByEmoji(v == 1);
} break; } break;
case dbiDefaultAttach: { case dbiDefaultAttach: {
@ -800,39 +799,38 @@ bool ReadSetting(
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
} break; } break;
case dbiNotifyView: { case dbiNotifyViewOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
switch (v) { switch (v) {
case dbinvShowNothing: Global::SetNotifyView(dbinvShowNothing); break; case dbinvShowNothing: Core::App().settings().setNotifyView(dbinvShowNothing); break;
case dbinvShowName: Global::SetNotifyView(dbinvShowName); break; case dbinvShowName: Core::App().settings().setNotifyView(dbinvShowName); break;
default: Global::SetNotifyView(dbinvShowPreview); break; default: Core::App().settings().setNotifyView(dbinvShowPreview); break;
} }
} break; } break;
case dbiAskDownloadPath: { case dbiAskDownloadPathOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Global::SetAskDownloadPath(v == 1); Core::App().settings().setAskDownloadPath(v == 1);
} break; } break;
case dbiDownloadPathOld: { case dbiDownloadPathOldOld: {
QString v; QString v;
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
#ifndef OS_WIN_STORE #ifndef OS_WIN_STORE
if (!v.isEmpty() && v != qstr("tmp") && !v.endsWith('/')) v += '/'; if (!v.isEmpty() && v != qstr("tmp") && !v.endsWith('/')) v += '/';
Global::SetDownloadPath(v); Core::App().settings().setDownloadPathBookmark(QByteArray());
Global::SetDownloadPathBookmark(QByteArray()); Core::App().settings().setDownloadPath(v);
Global::RefDownloadPathChanged().notify();
#endif // OS_WIN_STORE #endif // OS_WIN_STORE
} break; } break;
case dbiDownloadPath: { case dbiDownloadPathOld: {
QString v; QString v;
QByteArray bookmark; QByteArray bookmark;
stream >> v >> bookmark; stream >> v >> bookmark;
@ -840,19 +838,18 @@ bool ReadSetting(
#ifndef OS_WIN_STORE #ifndef OS_WIN_STORE
if (!v.isEmpty() && v != qstr("tmp") && !v.endsWith('/')) v += '/'; if (!v.isEmpty() && v != qstr("tmp") && !v.endsWith('/')) v += '/';
Global::SetDownloadPath(v); Core::App().settings().setDownloadPathBookmark(bookmark);
Global::SetDownloadPathBookmark(bookmark); Core::App().settings().setDownloadPath(v);
psDownloadPathEnableAccess(); psDownloadPathEnableAccess();
Global::RefDownloadPathChanged().notify();
#endif // OS_WIN_STORE #endif // OS_WIN_STORE
} break; } break;
case dbiCompressPastedImage: { case dbiCompressPastedImageOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
context.sessionSettings().setSendFilesWay((v == 1) Core::App().settings().setSendFilesWay((v == 1)
? SendFilesWay::Album ? SendFilesWay::Album
: SendFilesWay::Files); : SendFilesWay::Files);
} break; } break;
@ -976,36 +973,56 @@ bool ReadSetting(
cSetDialogLastPath(path); cSetDialogLastPath(path);
} break; } break;
case dbiSongVolume: { case dbiSongVolumeOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Global::SetSongVolume(snap(v / 1e6, 0., 1.)); Core::App().settings().setSongVolume(snap(v / 1e6, 0., 1.));
} break; } break;
case dbiVideoVolume: { case dbiVideoVolumeOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Global::SetVideoVolume(snap(v / 1e6, 0., 1.)); Core::App().settings().setVideoVolume(snap(v / 1e6, 0., 1.));
} break; } break;
case dbiPlaybackSpeed: { case dbiPlaybackSpeedOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Global::SetVoiceMsgPlaybackDoubled(v == 2); Core::App().settings().setVoiceMsgPlaybackDoubled(v == 2);
} break; } break;
case dbiCallSettings: { case dbiCallSettingsOld: {
QByteArray callSettings; QByteArray callSettings;
stream >> callSettings; stream >> callSettings;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
context.callSettings = callSettings; QDataStream settingsStream(&callSettings, QIODevice::ReadOnly);
settingsStream.setVersion(QDataStream::Qt_5_1);
QString outputDeviceID;
QString inputDeviceID;
qint32 outputVolume;
qint32 inputVolume;
qint32 duckingEnabled;
settingsStream >> outputDeviceID;
settingsStream >> outputVolume;
settingsStream >> inputDeviceID;
settingsStream >> inputVolume;
settingsStream >> duckingEnabled;
if (CheckStreamStatus(settingsStream)) {
auto &app = Core::App().settings();
app.setCallOutputDeviceID(outputDeviceID);
app.setCallOutputVolume(outputVolume);
app.setCallInputDeviceID(inputDeviceID);
app.setCallInputVolume(inputVolume);
app.setCallAudioDuckingEnabled(duckingEnabled);
}
} break; } break;
case dbiFallbackProductionConfig: { case dbiFallbackProductionConfig: {

View file

@ -54,8 +54,6 @@ struct ReadSettingsContext {
FileKey langPackKey = 0; FileKey langPackKey = 0;
FileKey languagesKey = 0; FileKey languagesKey = 0;
QByteArray callSettings;
QByteArray mtpAuthorization; QByteArray mtpAuthorization;
std::vector<std::shared_ptr<MTP::AuthKey>> mtpLegacyKeys; std::vector<std::shared_ptr<MTP::AuthKey>> mtpLegacyKeys;
qint32 mtpLegacyMainDcId = 0; qint32 mtpLegacyMainDcId = 0;
@ -82,10 +80,10 @@ enum {
dbiSendKeyOld = 0x05, dbiSendKeyOld = 0x05,
dbiAutoStart = 0x06, dbiAutoStart = 0x06,
dbiStartMinimized = 0x07, dbiStartMinimized = 0x07,
dbiSoundFlashBounceNotify = 0x08, dbiSoundFlashBounceNotifyOld = 0x08,
dbiWorkMode = 0x09, dbiWorkMode = 0x09,
dbiSeenTrayTooltip = 0x0a, dbiSeenTrayTooltip = 0x0a,
dbiDesktopNotify = 0x0b, dbiDesktopNotifyOld = 0x0b,
dbiAutoUpdate = 0x0c, dbiAutoUpdate = 0x0c,
dbiLastUpdateCheck = 0x0d, dbiLastUpdateCheck = 0x0d,
dbiWindowPosition = 0x0e, dbiWindowPosition = 0x0e,
@ -94,47 +92,47 @@ enum {
dbiDefaultAttach = 0x11, dbiDefaultAttach = 0x11,
dbiCatsAndDogs = 0x12, dbiCatsAndDogs = 0x12,
dbiReplaceEmojiOld = 0x13, dbiReplaceEmojiOld = 0x13,
dbiAskDownloadPath = 0x14, dbiAskDownloadPathOld = 0x14,
dbiDownloadPathOld = 0x15, dbiDownloadPathOldOld = 0x15,
dbiScaleOld = 0x16, dbiScaleOld = 0x16,
dbiEmojiTabOld = 0x17, dbiEmojiTabOld = 0x17,
dbiRecentEmojiOldOld = 0x18, dbiRecentEmojiOldOld = 0x18,
dbiLoggedPhoneNumberOld = 0x19, dbiLoggedPhoneNumberOld = 0x19,
dbiMutedPeersOld = 0x1a, dbiMutedPeersOld = 0x1a,
// 0x1b reserved // 0x1b reserved
dbiNotifyView = 0x1c, dbiNotifyViewOld = 0x1c,
dbiSendToMenu = 0x1d, dbiSendToMenu = 0x1d,
dbiCompressPastedImage = 0x1e, dbiCompressPastedImageOld = 0x1e,
dbiLangOld = 0x1f, dbiLangOld = 0x1f,
dbiLangFileOld = 0x20, dbiLangFileOld = 0x20,
dbiTileBackgroundOld = 0x21, dbiTileBackgroundOld = 0x21,
dbiAutoLock = 0x22, dbiAutoLockOld = 0x22,
dbiDialogLastPath = 0x23, dbiDialogLastPath = 0x23,
dbiRecentEmojiOld = 0x24, dbiRecentEmojiOld = 0x24,
dbiEmojiVariantsOld = 0x25, dbiEmojiVariantsOld = 0x25,
dbiRecentStickers = 0x26, dbiRecentStickers = 0x26,
dbiDcOptionOld = 0x27, dbiDcOptionOld = 0x27,
dbiTryIPv6 = 0x28, dbiTryIPv6 = 0x28,
dbiSongVolume = 0x29, dbiSongVolumeOld = 0x29,
dbiWindowsNotificationsOld = 0x30, dbiWindowsNotificationsOld = 0x30,
dbiIncludeMutedOld = 0x31, dbiIncludeMutedOld = 0x31,
dbiMegagroupSizeMaxOld = 0x32, dbiMegagroupSizeMaxOld = 0x32,
dbiDownloadPath = 0x33, dbiDownloadPathOld = 0x33,
dbiAutoDownloadOld = 0x34, dbiAutoDownloadOld = 0x34,
dbiSavedGifsLimitOld = 0x35, dbiSavedGifsLimitOld = 0x35,
dbiShowingSavedGifsOld = 0x36, dbiShowingSavedGifsOld = 0x36,
dbiAutoPlayOld = 0x37, dbiAutoPlayOld = 0x37,
dbiAdaptiveForWide = 0x38, dbiAdaptiveForWideOld = 0x38,
dbiHiddenPinnedMessagesOld = 0x39, dbiHiddenPinnedMessagesOld = 0x39,
dbiRecentEmoji = 0x3a, dbiRecentEmoji = 0x3a,
dbiEmojiVariants = 0x3b, dbiEmojiVariants = 0x3b,
dbiDialogsModeOld = 0x40, dbiDialogsModeOld = 0x40,
dbiModerateMode = 0x41, dbiModerateModeOld = 0x41,
dbiVideoVolume = 0x42, dbiVideoVolumeOld = 0x42,
dbiStickersRecentLimitOld = 0x43, dbiStickersRecentLimitOld = 0x43,
dbiNativeNotifications = 0x44, dbiNativeNotificationsOld = 0x44,
dbiNotificationsCount = 0x45, dbiNotificationsCountOld = 0x45,
dbiNotificationsCorner = 0x46, dbiNotificationsCornerOld = 0x46,
dbiThemeKeyOld = 0x47, dbiThemeKeyOld = 0x47,
dbiDialogsWidthRatioOld = 0x48, dbiDialogsWidthRatioOld = 0x48,
dbiUseExternalVideoPlayer = 0x49, dbiUseExternalVideoPlayer = 0x49,
@ -153,13 +151,13 @@ enum {
dbiCacheSettingsOld = 0x56, dbiCacheSettingsOld = 0x56,
dbiAnimationsDisabled = 0x57, dbiAnimationsDisabled = 0x57,
dbiScalePercent = 0x58, dbiScalePercent = 0x58,
dbiPlaybackSpeed = 0x59, dbiPlaybackSpeedOld = 0x59,
dbiLanguagesKey = 0x5a, dbiLanguagesKey = 0x5a,
dbiCallSettings = 0x5b, dbiCallSettingsOld = 0x5b,
dbiCacheSettings = 0x5c, dbiCacheSettings = 0x5c,
dbiTxtDomainStringOld = 0x5d, dbiTxtDomainStringOld = 0x5d,
dbiApplicationSettings = 0x5e, dbiApplicationSettings = 0x5e,
dbiDialogsFilters = 0x5f, dbiDialogsFiltersOld = 0x5f,
dbiFallbackProductionConfig = 0x60, dbiFallbackProductionConfig = 0x60,
dbiEncryptedWithSalt = 333, dbiEncryptedWithSalt = 333,

View file

@ -22,7 +22,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/crash_reports.h" #include "core/crash_reports.h"
#include "base/bytes.h" #include "base/bytes.h"
#include "base/openssl_help.h" #include "base/openssl_help.h"
#include "facades.h"
#include "app.h" #include "app.h"
namespace { namespace {

View file

@ -21,7 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mtproto/mtproto_config.h" #include "mtproto/mtproto_config.h"
#include "mtproto/mtproto_dc_options.h" #include "mtproto/mtproto_dc_options.h"
#include "core/application.h" #include "core/application.h"
#include "main/main_accounts.h" #include "main/main_domain.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "window/themes/window_theme.h" #include "window/themes/window_theme.h"
@ -98,15 +98,15 @@ bool CheckStreamStatus(QDataStream &stream) {
: nullptr; : nullptr;
}; };
const auto &app = Core::App(); const auto &app = Core::App();
const auto &accounts = app.accounts(); const auto &domain = app.domain();
const auto production = MTP::Environment::Production; const auto production = MTP::Environment::Production;
if (!accounts.started()) { if (!domain.started()) {
return app.fallbackProductionConfig(); return app.fallbackProductionConfig();
} }
if (const auto result = lookupConfig(&app.activeAccount())) { if (const auto result = lookupConfig(&app.activeAccount())) {
return *result; return *result;
} }
for (const auto &[_, account] : accounts.list()) { for (const auto &[_, account] : domain.accounts()) {
if (const auto result = lookupConfig(account.get())) { if (const auto result = lookupConfig(account.get())) {
return *result; return *result;
} }

Some files were not shown because too many files have changed in this diff Show more