mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Unite settings_chat and settings_chat_builder into settings/sections/settings_chat.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1548,12 +1548,12 @@ PRIVATE
|
||||
settings/settings_active_sessions.h
|
||||
settings/sections/settings_advanced.cpp
|
||||
settings/sections/settings_advanced.h
|
||||
settings/sections/settings_chat.cpp
|
||||
settings/sections/settings_chat.h
|
||||
settings/settings_blocked_peers.cpp
|
||||
settings/settings_blocked_peers.h
|
||||
settings/settings_business.cpp
|
||||
settings/settings_business.h
|
||||
settings/settings_chat.cpp
|
||||
settings/settings_chat.h
|
||||
settings/settings_calls.cpp
|
||||
settings/settings_calls.h
|
||||
settings/settings_codes.cpp
|
||||
@@ -1582,8 +1582,6 @@ PRIVATE
|
||||
settings/settings_search.h
|
||||
settings/builder/settings_builder.cpp
|
||||
settings/builder/settings_builder.h
|
||||
settings/builder/settings_chat_builder.cpp
|
||||
settings/builder/settings_chat_builder.h
|
||||
settings/builder/settings_notifications_builder.cpp
|
||||
settings/builder/settings_notifications_builder.h
|
||||
settings/builder/settings_privacy_security_builder.cpp
|
||||
|
||||
@@ -43,7 +43,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "settings/settings_blocked_peers.h"
|
||||
#include "settings/settings_business.h"
|
||||
#include "settings/settings_calls.h"
|
||||
#include "settings/settings_chat.h"
|
||||
#include "settings/sections/settings_chat.h"
|
||||
#include "settings/settings_passkeys.h"
|
||||
#include "data/components/passkeys.h"
|
||||
#include "calls/calls_box_controller.h"
|
||||
|
||||
@@ -64,7 +64,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "settings/sections/settings_main.h"
|
||||
#include "settings/settings_privacy_controllers.h"
|
||||
#include "settings/settings_privacy_security.h"
|
||||
#include "settings/settings_chat.h"
|
||||
#include "settings/sections/settings_chat.h"
|
||||
#include "settings/settings_premium.h"
|
||||
#include "storage/storage_account.h"
|
||||
#include "mainwidget.h"
|
||||
|
||||
@@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "info/info_memento.h"
|
||||
#include "info/info_top_bar.h"
|
||||
#include "settings/cloud_password/settings_cloud_password_email_confirm.h"
|
||||
#include "settings/settings_chat.h"
|
||||
#include "settings/sections/settings_chat.h"
|
||||
#include "settings/settings_information.h"
|
||||
#include "settings/sections/settings_main.h"
|
||||
#include "settings/settings_premium.h"
|
||||
|
||||
@@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "info/userpic/info_userpic_color_circle_button.h"
|
||||
|
||||
#include "settings/settings_chat.h" // Settings::PaintRoundColorButton.
|
||||
#include "settings/sections/settings_chat.h" // Settings::PaintRoundColorButton.
|
||||
#include "ui/painter.h"
|
||||
|
||||
namespace UserpicBuilder {
|
||||
|
||||
@@ -1,542 +0,0 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "settings/builder/settings_chat_builder.h"
|
||||
|
||||
#include "base/timer_rpl.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "settings/builder/settings_builder.h"
|
||||
#include "settings/sections/settings_advanced.h"
|
||||
#include "settings/settings_chat.h"
|
||||
#include "settings/settings_experimental.h"
|
||||
#include "settings/sections/settings_main.h"
|
||||
#include "settings/settings_privacy_security.h"
|
||||
#include "settings/settings_shortcuts.h"
|
||||
#include "support/support_common.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/vertical_list.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "styles/style_menu_icons.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
namespace Settings::Builder {
|
||||
namespace {
|
||||
|
||||
void BuildThemeOptionsSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto highlights = builder.highlights();
|
||||
|
||||
builder.add([controller, highlights](const WidgetContext &ctx) {
|
||||
SetupThemeOptions(controller, ctx.container.get(), highlights);
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/themes"_q,
|
||||
.title = tr::lng_settings_themes(tr::now),
|
||||
.keywords = { u"themes"_q, u"appearance"_q, u"dark"_q, u"light"_q },
|
||||
.icon = { &st::menuIconPalette },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/themes-edit"_q,
|
||||
.title = tr::lng_settings_theme_accent_title(tr::now),
|
||||
.keywords = { u"accent"_q, u"color"_q, u"customize"_q },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildThemeSettingsSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto highlights = builder.highlights();
|
||||
|
||||
builder.add([controller, highlights](const WidgetContext &ctx) {
|
||||
SetupThemeSettings(controller, ctx.container.get(), highlights);
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/peer-color"_q,
|
||||
.title = tr::lng_settings_theme_settings(tr::now),
|
||||
.keywords = { u"color"_q, u"profile"_q, u"name"_q },
|
||||
.icon = { &st::menuIconChangeColors },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/auto-night-mode"_q,
|
||||
.title = tr::lng_settings_auto_night_mode(tr::now),
|
||||
.keywords = { u"night"_q, u"dark"_q, u"auto"_q, u"system"_q },
|
||||
.icon = { &st::menuIconNightMode },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/font"_q,
|
||||
.title = tr::lng_settings_font_family(tr::now),
|
||||
.keywords = { u"font"_q, u"family"_q, u"text"_q },
|
||||
.icon = { &st::menuIconFont },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildCloudThemesSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto highlights = builder.highlights();
|
||||
|
||||
builder.add([controller, highlights](const WidgetContext &ctx) {
|
||||
SetupCloudThemes(controller, ctx.container.get(), highlights);
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/cloud-themes"_q,
|
||||
.title = tr::lng_settings_bg_cloud_themes(tr::now),
|
||||
.keywords = { u"cloud"_q, u"themes"_q, u"online"_q },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildChatBackgroundSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto highlights = builder.highlights();
|
||||
|
||||
builder.add([controller, highlights](const WidgetContext &ctx) {
|
||||
SetupChatBackground(controller, ctx.container.get(), highlights);
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/wallpapers"_q,
|
||||
.title = tr::lng_settings_section_background(tr::now),
|
||||
.keywords = { u"background"_q, u"wallpaper"_q, u"image"_q },
|
||||
.icon = { &st::menuIconPhoto },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/wallpapers-set"_q,
|
||||
.title = tr::lng_settings_bg_from_gallery(tr::now),
|
||||
.keywords = { u"gallery"_q, u"wallpaper"_q },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/wallpapers-choose-photo"_q,
|
||||
.title = tr::lng_settings_bg_from_file(tr::now),
|
||||
.keywords = { u"file"_q, u"photo"_q, u"upload"_q },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/adaptive-layout"_q,
|
||||
.title = tr::lng_settings_adaptive_wide(tr::now),
|
||||
.keywords = { u"adaptive"_q, u"wide"_q, u"layout"_q },
|
||||
.checkIcon = Core::App().settings().adaptiveForWide()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildChatListQuickActionSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
|
||||
builder.add([controller](const WidgetContext &ctx) {
|
||||
SetupChatListQuickAction(controller, ctx.container.get());
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/quick-dialog-action"_q,
|
||||
.title = tr::lng_settings_quick_dialog_action_title(tr::now),
|
||||
.keywords = { u"swipe"_q, u"quick"_q, u"action"_q, u"dialog"_q },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildStickersEmojiSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto highlights = builder.highlights();
|
||||
|
||||
builder.add([controller, highlights](const WidgetContext &ctx) {
|
||||
SetupStickersEmoji(controller, ctx.container.get(), highlights);
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/stickers-emoji"_q,
|
||||
.title = tr::lng_settings_stickers_emoji(tr::now),
|
||||
.keywords = { u"stickers"_q, u"emoji"_q },
|
||||
.icon = { &st::menuIconStickers },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/large-emoji"_q,
|
||||
.title = tr::lng_settings_large_emoji(tr::now),
|
||||
.keywords = { u"large"_q, u"emoji"_q, u"big"_q },
|
||||
.checkIcon = Core::App().settings().largeEmoji()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/replace-emoji"_q,
|
||||
.title = tr::lng_settings_replace_emojis(tr::now),
|
||||
.keywords = { u"replace"_q, u"emoji"_q, u"convert"_q },
|
||||
.checkIcon = Core::App().settings().replaceEmoji()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/suggest-emoji"_q,
|
||||
.title = tr::lng_settings_suggest_emoji(tr::now),
|
||||
.keywords = { u"suggest"_q, u"emoji"_q, u"autocomplete"_q },
|
||||
.checkIcon = Core::App().settings().suggestEmoji()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/suggest-animated-emoji"_q,
|
||||
.title = tr::lng_settings_suggest_animated_emoji(tr::now),
|
||||
.keywords = { u"animated"_q, u"emoji"_q, u"premium"_q },
|
||||
.checkIcon = Core::App().settings().suggestAnimatedEmoji()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/suggest-by-emoji"_q,
|
||||
.title = tr::lng_settings_suggest_by_emoji(tr::now),
|
||||
.keywords = { u"suggest"_q, u"stickers"_q, u"emoji"_q },
|
||||
.checkIcon = Core::App().settings().suggestStickersByEmoji()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/loop-stickers"_q,
|
||||
.title = tr::lng_settings_loop_stickers(tr::now),
|
||||
.keywords = { u"loop"_q, u"stickers"_q, u"animated"_q },
|
||||
.checkIcon = Core::App().settings().loopAnimatedStickers()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/my-stickers"_q,
|
||||
.title = tr::lng_stickers_you_have(tr::now),
|
||||
.keywords = { u"stickers"_q, u"manage"_q, u"installed"_q },
|
||||
.icon = { &st::menuIconStickers },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/emoji-sets"_q,
|
||||
.title = tr::lng_emoji_manage_sets(tr::now),
|
||||
.keywords = { u"emoji"_q, u"sets"_q, u"manage"_q },
|
||||
.icon = { &st::menuIconEmoji },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildMessagesSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto highlights = builder.highlights();
|
||||
|
||||
builder.add([controller, highlights](const WidgetContext &ctx) {
|
||||
SetupMessages(controller, ctx.container.get(), highlights);
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/messages"_q,
|
||||
.title = tr::lng_settings_messages(tr::now),
|
||||
.keywords = { u"messages"_q, u"send"_q, u"enter"_q },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/send-enter"_q,
|
||||
.title = tr::lng_settings_send_enter(tr::now),
|
||||
.keywords = { u"send"_q, u"enter"_q, u"keyboard"_q },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/quick-reaction"_q,
|
||||
.title = tr::lng_settings_chat_quick_action_react(tr::now),
|
||||
.keywords = { u"quick"_q, u"reaction"_q, u"double"_q, u"click"_q },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/corner-reaction"_q,
|
||||
.title = tr::lng_settings_chat_corner_reaction(tr::now),
|
||||
.keywords = { u"corner"_q, u"reaction"_q },
|
||||
.checkIcon = Core::App().settings().cornerReaction()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildSensitiveContentSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto highlights = builder.highlights();
|
||||
|
||||
builder.add([controller, highlights](const WidgetContext &ctx) {
|
||||
auto updateOnTick = rpl::single(
|
||||
) | rpl::then(base::timer_each(60 * crl::time(1000)));
|
||||
Ui::AddDivider(ctx.container.get());
|
||||
SetupSensitiveContent(
|
||||
controller,
|
||||
ctx.container.get(),
|
||||
std::move(updateOnTick),
|
||||
highlights);
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/sensitive-content"_q,
|
||||
.title = tr::lng_settings_sensitive_title(tr::now),
|
||||
.keywords = { u"sensitive"_q, u"content"_q, u"nsfw"_q, u"adult"_q },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildArchiveSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto showOther = builder.showOther();
|
||||
const auto session = builder.session();
|
||||
|
||||
builder.addSkip();
|
||||
|
||||
builder.addButton({
|
||||
.id = u"chat/shortcuts"_q,
|
||||
.title = tr::lng_settings_shortcuts(),
|
||||
.icon = { &st::menuIconShortcut },
|
||||
.onClick = [showOther] { showOther(Shortcuts::Id()); },
|
||||
.keywords = { u"shortcuts"_q, u"keyboard"_q, u"hotkeys"_q },
|
||||
});
|
||||
|
||||
if (controller) {
|
||||
PreloadArchiveSettings(session);
|
||||
}
|
||||
|
||||
builder.addButton({
|
||||
.id = u"chat/archive-settings"_q,
|
||||
.title = tr::lng_context_archive_settings(),
|
||||
.icon = { &st::menuIconArchive },
|
||||
.onClick = [=] {
|
||||
if (controller) {
|
||||
controller->show(
|
||||
Box<Ui::GenericBox>(ArchiveSettingsBox, controller));
|
||||
}
|
||||
},
|
||||
.keywords = { u"archive"_q, u"settings"_q, u"folder"_q },
|
||||
});
|
||||
}
|
||||
|
||||
void BuildSupportSection(SectionBuilder &builder) {
|
||||
const auto session = builder.session();
|
||||
if (!session->supportMode()) {
|
||||
return;
|
||||
}
|
||||
const auto controller = builder.controller();
|
||||
|
||||
builder.addSkip();
|
||||
builder.addSubsectionTitle({
|
||||
.id = u"chat/support"_q,
|
||||
.title = rpl::single(u"Support settings"_q),
|
||||
.keywords = { u"support"_q },
|
||||
});
|
||||
builder.addSkip(st::settingsSendTypeSkip);
|
||||
|
||||
using SwitchType = Support::SwitchSettings;
|
||||
|
||||
builder.add([controller](const WidgetContext &ctx) {
|
||||
const auto container = ctx.container.get();
|
||||
auto wrap = object_ptr<Ui::VerticalLayout>(container);
|
||||
const auto inner = wrap.data();
|
||||
|
||||
const auto group = std::make_shared<Ui::RadioenumGroup<SwitchType>>(
|
||||
controller->session().settings().supportSwitch());
|
||||
|
||||
const auto addRadio = [&](SwitchType value, const QString &label) {
|
||||
inner->add(
|
||||
object_ptr<Ui::Radioenum<SwitchType>>(
|
||||
inner,
|
||||
group,
|
||||
value,
|
||||
label,
|
||||
st::settingsSendType),
|
||||
st::settingsSendTypePadding);
|
||||
};
|
||||
addRadio(SwitchType::None, "Just send the reply");
|
||||
addRadio(SwitchType::Next, "Send and switch to next");
|
||||
addRadio(SwitchType::Previous, "Send and switch to previous");
|
||||
|
||||
group->setChangedCallback([=](SwitchType value) {
|
||||
controller->session().settings().setSupportSwitch(value);
|
||||
controller->session().saveSettingsDelayed();
|
||||
});
|
||||
|
||||
return SectionBuilder::WidgetToAdd{ .widget = std::move(wrap) };
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/support/switch"_q,
|
||||
.title = u"Send and switch behavior"_q,
|
||||
.keywords = { u"switch"_q, u"next"_q, u"previous"_q, u"reply"_q },
|
||||
};
|
||||
});
|
||||
|
||||
builder.addSkip(st::settingsCheckboxesSkip);
|
||||
|
||||
const auto templatesAutocomplete = builder.addCheckbox({
|
||||
.id = u"chat/support/templates"_q,
|
||||
.title = rpl::single(u"Enable templates autocomplete"_q),
|
||||
.checked = session->settings().supportTemplatesAutocomplete(),
|
||||
.keywords = { u"templates"_q, u"autocomplete"_q },
|
||||
});
|
||||
if (templatesAutocomplete) {
|
||||
templatesAutocomplete->checkedChanges(
|
||||
) | rpl::on_next([=](bool checked) {
|
||||
controller->session().settings().setSupportTemplatesAutocomplete(
|
||||
checked);
|
||||
controller->session().saveSettingsDelayed();
|
||||
}, templatesAutocomplete->lifetime());
|
||||
}
|
||||
|
||||
const auto allSilent = builder.addCheckbox({
|
||||
.id = u"chat/support/silent"_q,
|
||||
.title = rpl::single(u"Send all messages without sound"_q),
|
||||
.checked = session->settings().supportAllSilent(),
|
||||
.keywords = { u"silent"_q, u"sound"_q, u"mute"_q },
|
||||
});
|
||||
if (allSilent) {
|
||||
allSilent->checkedChanges(
|
||||
) | rpl::on_next([=](bool checked) {
|
||||
controller->session().settings().setSupportAllSilent(checked);
|
||||
controller->session().saveSettingsDelayed();
|
||||
}, allSilent->lifetime());
|
||||
}
|
||||
|
||||
builder.addSkip(st::settingsCheckboxesSkip);
|
||||
builder.addSubsectionTitle({
|
||||
.id = u"chat/support/chats-period"_q,
|
||||
.title = rpl::single(u"Load chats for a period"_q),
|
||||
.keywords = { u"period"_q, u"days"_q },
|
||||
});
|
||||
|
||||
builder.add([controller](const WidgetContext &ctx) {
|
||||
constexpr auto kDayDuration = 24 * 60 * 60;
|
||||
struct Option {
|
||||
int days = 0;
|
||||
QString label;
|
||||
};
|
||||
const auto options = std::vector<Option>{
|
||||
{ 1, "1 day" },
|
||||
{ 7, "1 week" },
|
||||
{ 30, "1 month" },
|
||||
{ 365, "1 year" },
|
||||
{ 0, "All of them" },
|
||||
};
|
||||
const auto current = controller->session().settings().supportChatsTimeSlice();
|
||||
const auto days = current / kDayDuration;
|
||||
const auto best = ranges::min_element(
|
||||
options,
|
||||
std::less<>(),
|
||||
[&](const Option &option) { return std::abs(option.days - days); });
|
||||
|
||||
const auto container = ctx.container.get();
|
||||
auto wrap = object_ptr<Ui::VerticalLayout>(container);
|
||||
const auto inner = wrap.data();
|
||||
|
||||
const auto group = std::make_shared<Ui::RadiobuttonGroup>(best->days);
|
||||
for (const auto &option : options) {
|
||||
inner->add(
|
||||
object_ptr<Ui::Radiobutton>(
|
||||
inner,
|
||||
group,
|
||||
option.days,
|
||||
option.label,
|
||||
st::settingsSendType),
|
||||
st::settingsSendTypePadding);
|
||||
}
|
||||
group->setChangedCallback([=](int days) {
|
||||
controller->session().settings().setSupportChatsTimeSlice(
|
||||
days * kDayDuration);
|
||||
controller->session().saveSettingsDelayed();
|
||||
});
|
||||
|
||||
return SectionBuilder::WidgetToAdd{ .widget = std::move(wrap) };
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/support/chats-period/options"_q,
|
||||
.title = u"Chat loading period options"_q,
|
||||
.keywords = { u"week"_q, u"month"_q, u"year"_q },
|
||||
};
|
||||
});
|
||||
|
||||
builder.addSkip(st::settingsCheckboxesSkip);
|
||||
builder.addSkip();
|
||||
}
|
||||
|
||||
void BuildChatSectionContent(SectionBuilder &builder) {
|
||||
BuildThemeOptionsSection(builder);
|
||||
BuildThemeSettingsSection(builder);
|
||||
BuildCloudThemesSection(builder);
|
||||
BuildChatBackgroundSection(builder);
|
||||
BuildChatListQuickActionSection(builder);
|
||||
BuildStickersEmojiSection(builder);
|
||||
BuildMessagesSection(builder);
|
||||
BuildSensitiveContentSection(builder);
|
||||
BuildArchiveSection(builder);
|
||||
BuildSupportSection(builder);
|
||||
}
|
||||
|
||||
const auto kMeta = BuildHelper({
|
||||
.id = Chat::Id(),
|
||||
.parentId = Main::Id(),
|
||||
.title = &tr::lng_settings_section_chat_settings,
|
||||
.icon = &st::menuIconChatBubble,
|
||||
}, [](SectionBuilder &builder) {
|
||||
BuildChatSectionContent(builder);
|
||||
});
|
||||
|
||||
} // namespace
|
||||
|
||||
SectionBuildMethod ChatSection = kMeta.build;
|
||||
|
||||
} // namespace Settings::Builder
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
|
||||
namespace Ui {
|
||||
class VerticalLayout;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace Settings::Builder {
|
||||
|
||||
extern SectionBuildMethod ChatSection;
|
||||
|
||||
} // namespace Settings::Builder
|
||||
@@ -35,7 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "platform/platform_specific.h"
|
||||
#include "settings/builder/settings_builder.h"
|
||||
#include "settings/sections/settings_main.h"
|
||||
#include "settings/settings_chat.h"
|
||||
#include "settings/sections/settings_chat.h"
|
||||
#include "settings/settings_experimental.h"
|
||||
#include "settings/settings_power_saving.h"
|
||||
#include "settings/settings_privacy_security.h"
|
||||
|
||||
+604
-97
@@ -5,11 +5,12 @@ the official desktop application for the Telegram messaging service.
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "settings/settings_chat.h"
|
||||
#include "settings/sections/settings_chat.h"
|
||||
|
||||
#include "base/timer_rpl.h"
|
||||
#include "settings/builder/settings_chat_builder.h"
|
||||
#include "settings/builder/settings_builder.h"
|
||||
#include "settings/sections/settings_advanced.h"
|
||||
#include "settings/sections/settings_main.h"
|
||||
#include "settings/settings_privacy_security.h"
|
||||
#include "settings/settings_experimental.h"
|
||||
#include "settings/settings_shortcuts.h"
|
||||
@@ -63,6 +64,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "storage/localstorage.h"
|
||||
#include "core/file_utilities.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_cloud_themes.h"
|
||||
#include "data/data_file_origin.h"
|
||||
@@ -89,6 +91,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
namespace Settings {
|
||||
namespace {
|
||||
|
||||
using namespace Builder;
|
||||
|
||||
const auto kSchemesList = Window::Theme::EmbeddedThemes();
|
||||
constexpr auto kCustomColorButtonParts = 7;
|
||||
|
||||
@@ -400,32 +404,6 @@ void ColorsPalette::updateInnerGeometry() {
|
||||
inner->resize(inner->width(), y + size + st::defaultVerticalListSkip);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void PaintRoundColorButton(
|
||||
QPainter &p,
|
||||
int size,
|
||||
QBrush brush,
|
||||
float64 selected) {
|
||||
const auto rect = QRect(0, 0, size, size);
|
||||
|
||||
p.setBrush(brush);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawEllipse(rect);
|
||||
|
||||
if (selected > 0.) {
|
||||
const auto startSkip = -st::settingsAccentColorLine / 2.;
|
||||
const auto endSkip = float64(st::settingsAccentColorSkip);
|
||||
const auto skip = startSkip + (endSkip - startSkip) * selected;
|
||||
auto pen = st::boxBg->p;
|
||||
pen.setWidth(st::settingsAccentColorLine);
|
||||
p.setBrush(Qt::NoBrush);
|
||||
p.setPen(pen);
|
||||
p.setOpacity(selected);
|
||||
p.drawEllipse(QRectF(rect).marginsRemoved({ skip, skip, skip, skip }));
|
||||
}
|
||||
}
|
||||
|
||||
class BackgroundRow : public Ui::RpWidget {
|
||||
public:
|
||||
BackgroundRow(
|
||||
@@ -736,6 +714,599 @@ void ChooseFromFile(
|
||||
crl::guard(parent, callback));
|
||||
}
|
||||
|
||||
void SetupSupportSwitchSettings(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container) {
|
||||
using SwitchType = Support::SwitchSettings;
|
||||
const auto group = std::make_shared<Ui::RadioenumGroup<SwitchType>>(
|
||||
controller->session().settings().supportSwitch());
|
||||
const auto add = [&](SwitchType value, const QString &label) {
|
||||
container->add(
|
||||
object_ptr<Ui::Radioenum<SwitchType>>(
|
||||
container,
|
||||
group,
|
||||
value,
|
||||
label,
|
||||
st::settingsSendType),
|
||||
st::settingsSendTypePadding);
|
||||
};
|
||||
add(SwitchType::None, "Just send the reply");
|
||||
add(SwitchType::Next, "Send and switch to next");
|
||||
add(SwitchType::Previous, "Send and switch to previous");
|
||||
group->setChangedCallback([=](SwitchType value) {
|
||||
controller->session().settings().setSupportSwitch(value);
|
||||
controller->session().saveSettingsDelayed();
|
||||
});
|
||||
}
|
||||
|
||||
void SetupSupportChatsLimitSlice(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container) {
|
||||
constexpr auto kDayDuration = 24 * 60 * 60;
|
||||
struct Option {
|
||||
int days = 0;
|
||||
QString label;
|
||||
};
|
||||
const auto options = std::vector<Option>{
|
||||
{ 1, "1 day" },
|
||||
{ 7, "1 week" },
|
||||
{ 30, "1 month" },
|
||||
{ 365, "1 year" },
|
||||
{ 0, "All of them" },
|
||||
};
|
||||
const auto current = controller->session().settings().supportChatsTimeSlice();
|
||||
const auto days = current / kDayDuration;
|
||||
const auto best = ranges::min_element(
|
||||
options,
|
||||
std::less<>(),
|
||||
[&](const Option &option) { return std::abs(option.days - days); });
|
||||
|
||||
const auto group = std::make_shared<Ui::RadiobuttonGroup>(best->days);
|
||||
for (const auto &option : options) {
|
||||
container->add(
|
||||
object_ptr<Ui::Radiobutton>(
|
||||
container,
|
||||
group,
|
||||
option.days,
|
||||
option.label,
|
||||
st::settingsSendType),
|
||||
st::settingsSendTypePadding);
|
||||
}
|
||||
group->setChangedCallback([=](int days) {
|
||||
controller->session().settings().setSupportChatsTimeSlice(
|
||||
days * kDayDuration);
|
||||
controller->session().saveSettingsDelayed();
|
||||
});
|
||||
}
|
||||
|
||||
void BuildThemeOptionsSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto highlights = builder.highlights();
|
||||
|
||||
builder.add([controller, highlights](const WidgetContext &ctx) {
|
||||
SetupThemeOptions(controller, ctx.container.get(), highlights);
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/themes"_q,
|
||||
.title = tr::lng_settings_themes(tr::now),
|
||||
.keywords = { u"themes"_q, u"appearance"_q, u"dark"_q, u"light"_q },
|
||||
.icon = { &st::menuIconPalette },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/themes-edit"_q,
|
||||
.title = tr::lng_settings_theme_accent_title(tr::now),
|
||||
.keywords = { u"accent"_q, u"color"_q, u"customize"_q },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildThemeSettingsSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto highlights = builder.highlights();
|
||||
|
||||
builder.add([controller, highlights](const WidgetContext &ctx) {
|
||||
SetupThemeSettings(controller, ctx.container.get(), highlights);
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/peer-color"_q,
|
||||
.title = tr::lng_settings_theme_settings(tr::now),
|
||||
.keywords = { u"color"_q, u"profile"_q, u"name"_q },
|
||||
.icon = { &st::menuIconChangeColors },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/auto-night-mode"_q,
|
||||
.title = tr::lng_settings_auto_night_mode(tr::now),
|
||||
.keywords = { u"night"_q, u"dark"_q, u"auto"_q, u"system"_q },
|
||||
.icon = { &st::menuIconNightMode },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/font"_q,
|
||||
.title = tr::lng_settings_font_family(tr::now),
|
||||
.keywords = { u"font"_q, u"family"_q, u"text"_q },
|
||||
.icon = { &st::menuIconFont },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildCloudThemesSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto highlights = builder.highlights();
|
||||
|
||||
builder.add([controller, highlights](const WidgetContext &ctx) {
|
||||
SetupCloudThemes(controller, ctx.container.get(), highlights);
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/cloud-themes"_q,
|
||||
.title = tr::lng_settings_bg_cloud_themes(tr::now),
|
||||
.keywords = { u"cloud"_q, u"themes"_q, u"online"_q },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildChatBackgroundSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto highlights = builder.highlights();
|
||||
|
||||
builder.add([controller, highlights](const WidgetContext &ctx) {
|
||||
SetupChatBackground(controller, ctx.container.get(), highlights);
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/wallpapers"_q,
|
||||
.title = tr::lng_settings_section_background(tr::now),
|
||||
.keywords = { u"background"_q, u"wallpaper"_q, u"image"_q },
|
||||
.icon = { &st::menuIconPhoto },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/wallpapers-set"_q,
|
||||
.title = tr::lng_settings_bg_from_gallery(tr::now),
|
||||
.keywords = { u"gallery"_q, u"wallpaper"_q },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/wallpapers-choose-photo"_q,
|
||||
.title = tr::lng_settings_bg_from_file(tr::now),
|
||||
.keywords = { u"file"_q, u"photo"_q, u"upload"_q },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/adaptive-layout"_q,
|
||||
.title = tr::lng_settings_adaptive_wide(tr::now),
|
||||
.keywords = { u"adaptive"_q, u"wide"_q, u"layout"_q },
|
||||
.checkIcon = Core::App().settings().adaptiveForWide()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildChatListQuickActionSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
|
||||
builder.add([controller](const WidgetContext &ctx) {
|
||||
SetupChatListQuickAction(controller, ctx.container.get());
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/quick-dialog-action"_q,
|
||||
.title = tr::lng_settings_quick_dialog_action_title(tr::now),
|
||||
.keywords = { u"swipe"_q, u"quick"_q, u"action"_q, u"dialog"_q },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildStickersEmojiSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto highlights = builder.highlights();
|
||||
|
||||
builder.add([controller, highlights](const WidgetContext &ctx) {
|
||||
SetupStickersEmoji(controller, ctx.container.get(), highlights);
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/stickers-emoji"_q,
|
||||
.title = tr::lng_settings_stickers_emoji(tr::now),
|
||||
.keywords = { u"stickers"_q, u"emoji"_q },
|
||||
.icon = { &st::menuIconStickers },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/large-emoji"_q,
|
||||
.title = tr::lng_settings_large_emoji(tr::now),
|
||||
.keywords = { u"large"_q, u"emoji"_q, u"big"_q },
|
||||
.checkIcon = Core::App().settings().largeEmoji()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/replace-emoji"_q,
|
||||
.title = tr::lng_settings_replace_emojis(tr::now),
|
||||
.keywords = { u"replace"_q, u"emoji"_q, u"convert"_q },
|
||||
.checkIcon = Core::App().settings().replaceEmoji()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/suggest-emoji"_q,
|
||||
.title = tr::lng_settings_suggest_emoji(tr::now),
|
||||
.keywords = { u"suggest"_q, u"emoji"_q, u"autocomplete"_q },
|
||||
.checkIcon = Core::App().settings().suggestEmoji()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/suggest-animated-emoji"_q,
|
||||
.title = tr::lng_settings_suggest_animated_emoji(tr::now),
|
||||
.keywords = { u"animated"_q, u"emoji"_q, u"premium"_q },
|
||||
.checkIcon = Core::App().settings().suggestAnimatedEmoji()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/suggest-by-emoji"_q,
|
||||
.title = tr::lng_settings_suggest_by_emoji(tr::now),
|
||||
.keywords = { u"suggest"_q, u"stickers"_q, u"emoji"_q },
|
||||
.checkIcon = Core::App().settings().suggestStickersByEmoji()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/loop-stickers"_q,
|
||||
.title = tr::lng_settings_loop_stickers(tr::now),
|
||||
.keywords = { u"loop"_q, u"stickers"_q, u"animated"_q },
|
||||
.checkIcon = Core::App().settings().loopAnimatedStickers()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/my-stickers"_q,
|
||||
.title = tr::lng_stickers_you_have(tr::now),
|
||||
.keywords = { u"stickers"_q, u"manage"_q, u"installed"_q },
|
||||
.icon = { &st::menuIconStickers },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/emoji-sets"_q,
|
||||
.title = tr::lng_emoji_manage_sets(tr::now),
|
||||
.keywords = { u"emoji"_q, u"sets"_q, u"manage"_q },
|
||||
.icon = { &st::menuIconEmoji },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildMessagesSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto highlights = builder.highlights();
|
||||
|
||||
builder.add([controller, highlights](const WidgetContext &ctx) {
|
||||
SetupMessages(controller, ctx.container.get(), highlights);
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/messages"_q,
|
||||
.title = tr::lng_settings_messages(tr::now),
|
||||
.keywords = { u"messages"_q, u"send"_q, u"enter"_q },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/send-enter"_q,
|
||||
.title = tr::lng_settings_send_enter(tr::now),
|
||||
.keywords = { u"send"_q, u"enter"_q, u"keyboard"_q },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/quick-reaction"_q,
|
||||
.title = tr::lng_settings_chat_quick_action_react(tr::now),
|
||||
.keywords = { u"quick"_q, u"reaction"_q, u"double"_q, u"click"_q },
|
||||
};
|
||||
});
|
||||
|
||||
builder.add(nullptr, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/corner-reaction"_q,
|
||||
.title = tr::lng_settings_chat_corner_reaction(tr::now),
|
||||
.keywords = { u"corner"_q, u"reaction"_q },
|
||||
.checkIcon = Core::App().settings().cornerReaction()
|
||||
? SearchEntryCheckIcon::Checked
|
||||
: SearchEntryCheckIcon::Unchecked,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildSensitiveContentSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto highlights = builder.highlights();
|
||||
|
||||
builder.add([controller, highlights](const WidgetContext &ctx) {
|
||||
auto updateOnTick = rpl::single(
|
||||
) | rpl::then(base::timer_each(60 * crl::time(1000)));
|
||||
Ui::AddDivider(ctx.container.get());
|
||||
SetupSensitiveContent(
|
||||
controller,
|
||||
ctx.container.get(),
|
||||
std::move(updateOnTick),
|
||||
highlights);
|
||||
return SectionBuilder::WidgetToAdd{};
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/sensitive-content"_q,
|
||||
.title = tr::lng_settings_sensitive_title(tr::now),
|
||||
.keywords = { u"sensitive"_q, u"content"_q, u"nsfw"_q, u"adult"_q },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void BuildArchiveSection(SectionBuilder &builder) {
|
||||
const auto controller = builder.controller();
|
||||
const auto showOther = builder.showOther();
|
||||
const auto session = builder.session();
|
||||
|
||||
builder.addSkip();
|
||||
|
||||
builder.addButton({
|
||||
.id = u"chat/shortcuts"_q,
|
||||
.title = tr::lng_settings_shortcuts(),
|
||||
.icon = { &st::menuIconShortcut },
|
||||
.onClick = [showOther] { showOther(Shortcuts::Id()); },
|
||||
.keywords = { u"shortcuts"_q, u"keyboard"_q, u"hotkeys"_q },
|
||||
});
|
||||
|
||||
if (controller) {
|
||||
PreloadArchiveSettings(session);
|
||||
}
|
||||
|
||||
builder.addButton({
|
||||
.id = u"chat/archive-settings"_q,
|
||||
.title = tr::lng_context_archive_settings(),
|
||||
.icon = { &st::menuIconArchive },
|
||||
.onClick = [=] {
|
||||
if (controller) {
|
||||
controller->show(
|
||||
Box<Ui::GenericBox>(ArchiveSettingsBox, controller));
|
||||
}
|
||||
},
|
||||
.keywords = { u"archive"_q, u"settings"_q, u"folder"_q },
|
||||
});
|
||||
}
|
||||
|
||||
void BuildSupportSection(SectionBuilder &builder) {
|
||||
const auto session = builder.session();
|
||||
if (!session->supportMode()) {
|
||||
return;
|
||||
}
|
||||
const auto controller = builder.controller();
|
||||
|
||||
builder.addSkip();
|
||||
builder.addSubsectionTitle({
|
||||
.id = u"chat/support"_q,
|
||||
.title = rpl::single(u"Support settings"_q),
|
||||
.keywords = { u"support"_q },
|
||||
});
|
||||
builder.addSkip(st::settingsSendTypeSkip);
|
||||
|
||||
using SwitchType = Support::SwitchSettings;
|
||||
|
||||
builder.add([controller](const WidgetContext &ctx) {
|
||||
const auto container = ctx.container.get();
|
||||
auto wrap = object_ptr<Ui::VerticalLayout>(container);
|
||||
const auto inner = wrap.data();
|
||||
|
||||
const auto group = std::make_shared<Ui::RadioenumGroup<SwitchType>>(
|
||||
controller->session().settings().supportSwitch());
|
||||
|
||||
const auto addRadio = [&](SwitchType value, const QString &label) {
|
||||
inner->add(
|
||||
object_ptr<Ui::Radioenum<SwitchType>>(
|
||||
inner,
|
||||
group,
|
||||
value,
|
||||
label,
|
||||
st::settingsSendType),
|
||||
st::settingsSendTypePadding);
|
||||
};
|
||||
addRadio(SwitchType::None, "Just send the reply");
|
||||
addRadio(SwitchType::Next, "Send and switch to next");
|
||||
addRadio(SwitchType::Previous, "Send and switch to previous");
|
||||
|
||||
group->setChangedCallback([=](SwitchType value) {
|
||||
controller->session().settings().setSupportSwitch(value);
|
||||
controller->session().saveSettingsDelayed();
|
||||
});
|
||||
|
||||
return SectionBuilder::WidgetToAdd{ .widget = std::move(wrap) };
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/support/switch"_q,
|
||||
.title = u"Send and switch behavior"_q,
|
||||
.keywords = { u"switch"_q, u"next"_q, u"previous"_q, u"reply"_q },
|
||||
};
|
||||
});
|
||||
|
||||
builder.addSkip(st::settingsCheckboxesSkip);
|
||||
|
||||
const auto templatesAutocomplete = builder.addCheckbox({
|
||||
.id = u"chat/support/templates"_q,
|
||||
.title = rpl::single(u"Enable templates autocomplete"_q),
|
||||
.checked = session->settings().supportTemplatesAutocomplete(),
|
||||
.keywords = { u"templates"_q, u"autocomplete"_q },
|
||||
});
|
||||
if (templatesAutocomplete) {
|
||||
templatesAutocomplete->checkedChanges(
|
||||
) | rpl::on_next([=](bool checked) {
|
||||
controller->session().settings().setSupportTemplatesAutocomplete(
|
||||
checked);
|
||||
controller->session().saveSettingsDelayed();
|
||||
}, templatesAutocomplete->lifetime());
|
||||
}
|
||||
|
||||
const auto allSilent = builder.addCheckbox({
|
||||
.id = u"chat/support/silent"_q,
|
||||
.title = rpl::single(u"Send all messages without sound"_q),
|
||||
.checked = session->settings().supportAllSilent(),
|
||||
.keywords = { u"silent"_q, u"sound"_q, u"mute"_q },
|
||||
});
|
||||
if (allSilent) {
|
||||
allSilent->checkedChanges(
|
||||
) | rpl::on_next([=](bool checked) {
|
||||
controller->session().settings().setSupportAllSilent(checked);
|
||||
controller->session().saveSettingsDelayed();
|
||||
}, allSilent->lifetime());
|
||||
}
|
||||
|
||||
builder.addSkip(st::settingsCheckboxesSkip);
|
||||
builder.addSubsectionTitle({
|
||||
.id = u"chat/support/chats-period"_q,
|
||||
.title = rpl::single(u"Load chats for a period"_q),
|
||||
.keywords = { u"period"_q, u"days"_q },
|
||||
});
|
||||
|
||||
builder.add([controller](const WidgetContext &ctx) {
|
||||
constexpr auto kDayDuration = 24 * 60 * 60;
|
||||
struct Option {
|
||||
int days = 0;
|
||||
QString label;
|
||||
};
|
||||
const auto options = std::vector<Option>{
|
||||
{ 1, "1 day" },
|
||||
{ 7, "1 week" },
|
||||
{ 30, "1 month" },
|
||||
{ 365, "1 year" },
|
||||
{ 0, "All of them" },
|
||||
};
|
||||
const auto current = controller->session().settings().supportChatsTimeSlice();
|
||||
const auto days = current / kDayDuration;
|
||||
const auto best = ranges::min_element(
|
||||
options,
|
||||
std::less<>(),
|
||||
[&](const Option &option) { return std::abs(option.days - days); });
|
||||
|
||||
const auto container = ctx.container.get();
|
||||
auto wrap = object_ptr<Ui::VerticalLayout>(container);
|
||||
const auto inner = wrap.data();
|
||||
|
||||
const auto group = std::make_shared<Ui::RadiobuttonGroup>(best->days);
|
||||
for (const auto &option : options) {
|
||||
inner->add(
|
||||
object_ptr<Ui::Radiobutton>(
|
||||
inner,
|
||||
group,
|
||||
option.days,
|
||||
option.label,
|
||||
st::settingsSendType),
|
||||
st::settingsSendTypePadding);
|
||||
}
|
||||
group->setChangedCallback([=](int days) {
|
||||
controller->session().settings().setSupportChatsTimeSlice(
|
||||
days * kDayDuration);
|
||||
controller->session().saveSettingsDelayed();
|
||||
});
|
||||
|
||||
return SectionBuilder::WidgetToAdd{ .widget = std::move(wrap) };
|
||||
}, [] {
|
||||
return SearchEntry{
|
||||
.id = u"chat/support/chats-period/options"_q,
|
||||
.title = u"Chat loading period options"_q,
|
||||
.keywords = { u"week"_q, u"month"_q, u"year"_q },
|
||||
};
|
||||
});
|
||||
|
||||
builder.addSkip(st::settingsCheckboxesSkip);
|
||||
builder.addSkip();
|
||||
}
|
||||
|
||||
void BuildChatSectionContent(SectionBuilder &builder) {
|
||||
BuildThemeOptionsSection(builder);
|
||||
BuildThemeSettingsSection(builder);
|
||||
BuildCloudThemesSection(builder);
|
||||
BuildChatBackgroundSection(builder);
|
||||
BuildChatListQuickActionSection(builder);
|
||||
BuildStickersEmojiSection(builder);
|
||||
BuildMessagesSection(builder);
|
||||
BuildSensitiveContentSection(builder);
|
||||
BuildArchiveSection(builder);
|
||||
BuildSupportSection(builder);
|
||||
}
|
||||
|
||||
const auto kMeta = BuildHelper({
|
||||
.id = Chat::Id(),
|
||||
.parentId = Main::Id(),
|
||||
.title = &tr::lng_settings_section_chat_settings,
|
||||
.icon = &st::menuIconChatBubble,
|
||||
}, [](SectionBuilder &builder) {
|
||||
BuildChatSectionContent(builder);
|
||||
});
|
||||
|
||||
} // namespace
|
||||
|
||||
void PaintRoundColorButton(
|
||||
QPainter &p,
|
||||
int size,
|
||||
QBrush brush,
|
||||
float64 selected) {
|
||||
const auto rect = QRect(0, 0, size, size);
|
||||
|
||||
p.setBrush(brush);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawEllipse(rect);
|
||||
|
||||
if (selected > 0.) {
|
||||
const auto startSkip = -st::settingsAccentColorLine / 2.;
|
||||
const auto endSkip = float64(st::settingsAccentColorSkip);
|
||||
const auto skip = startSkip + (endSkip - startSkip) * selected;
|
||||
auto pen = st::boxBg->p;
|
||||
pen.setWidth(st::settingsAccentColorLine);
|
||||
p.setBrush(Qt::NoBrush);
|
||||
p.setPen(pen);
|
||||
p.setOpacity(selected);
|
||||
p.drawEllipse(QRectF(rect).marginsRemoved({ skip, skip, skip, skip }));
|
||||
}
|
||||
}
|
||||
|
||||
void SetupStickersEmoji(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
@@ -1782,10 +2353,6 @@ void SetupDefaultThemes(
|
||||
palette->selected(
|
||||
) | rpl::on_next([=](QColor color) {
|
||||
if (Background()->editingTheme()) {
|
||||
// We don't remember old accent color to revert it properly
|
||||
// in Window::Theme::Revert which is called by Editor.
|
||||
//
|
||||
// So we check here, before we change the saved accent color.
|
||||
window->show(Ui::MakeInformBox(
|
||||
tr::lng_theme_editor_cant_change_theme()));
|
||||
return;
|
||||
@@ -2017,71 +2584,6 @@ void SetupThemeSettings(
|
||||
Ui::AddSkip(container, st::settingsCheckboxesSkip);
|
||||
}
|
||||
|
||||
void SetupSupportSwitchSettings(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container) {
|
||||
using SwitchType = Support::SwitchSettings;
|
||||
const auto group = std::make_shared<Ui::RadioenumGroup<SwitchType>>(
|
||||
controller->session().settings().supportSwitch());
|
||||
const auto add = [&](SwitchType value, const QString &label) {
|
||||
container->add(
|
||||
object_ptr<Ui::Radioenum<SwitchType>>(
|
||||
container,
|
||||
group,
|
||||
value,
|
||||
label,
|
||||
st::settingsSendType),
|
||||
st::settingsSendTypePadding);
|
||||
};
|
||||
add(SwitchType::None, "Just send the reply");
|
||||
add(SwitchType::Next, "Send and switch to next");
|
||||
add(SwitchType::Previous, "Send and switch to previous");
|
||||
group->setChangedCallback([=](SwitchType value) {
|
||||
controller->session().settings().setSupportSwitch(value);
|
||||
controller->session().saveSettingsDelayed();
|
||||
});
|
||||
}
|
||||
|
||||
void SetupSupportChatsLimitSlice(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container) {
|
||||
constexpr auto kDayDuration = 24 * 60 * 60;
|
||||
struct Option {
|
||||
int days = 0;
|
||||
QString label;
|
||||
};
|
||||
const auto options = std::vector<Option>{
|
||||
{ 1, "1 day" },
|
||||
{ 7, "1 week" },
|
||||
{ 30, "1 month" },
|
||||
{ 365, "1 year" },
|
||||
{ 0, "All of them" },
|
||||
};
|
||||
const auto current = controller->session().settings().supportChatsTimeSlice();
|
||||
const auto days = current / kDayDuration;
|
||||
const auto best = ranges::min_element(
|
||||
options,
|
||||
std::less<>(),
|
||||
[&](const Option &option) { return std::abs(option.days - days); });
|
||||
|
||||
const auto group = std::make_shared<Ui::RadiobuttonGroup>(best->days);
|
||||
for (const auto &option : options) {
|
||||
container->add(
|
||||
object_ptr<Ui::Radiobutton>(
|
||||
container,
|
||||
group,
|
||||
option.days,
|
||||
option.label,
|
||||
st::settingsSendType),
|
||||
st::settingsSendTypePadding);
|
||||
}
|
||||
group->setChangedCallback([=](int days) {
|
||||
controller->session().settings().setSupportChatsTimeSlice(
|
||||
days * kDayDuration);
|
||||
controller->session().saveSettingsDelayed();
|
||||
});
|
||||
}
|
||||
|
||||
void SetupSupport(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container) {
|
||||
@@ -2171,4 +2673,9 @@ void Chat::setupContent() {
|
||||
Ui::ResizeFitChild(this, content);
|
||||
}
|
||||
|
||||
namespace Builder {
|
||||
|
||||
SectionBuildMethod ChatSection = kMeta.build;
|
||||
|
||||
} // namespace Builder
|
||||
} // namespace Settings
|
||||
+11
@@ -8,11 +8,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common_session.h"
|
||||
#include "settings/settings_type.h"
|
||||
|
||||
namespace Window {
|
||||
class Controller;
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace Ui {
|
||||
class VerticalLayout;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Settings {
|
||||
|
||||
void SetupDataStorage(
|
||||
@@ -98,4 +104,9 @@ private:
|
||||
|
||||
};
|
||||
|
||||
namespace Builder {
|
||||
|
||||
extern SectionBuildMethod ChatSection;
|
||||
|
||||
} // namespace Builder
|
||||
} // namespace Settings
|
||||
@@ -44,7 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "settings/sections/settings_advanced.h"
|
||||
#include "settings/settings_business.h"
|
||||
#include "settings/settings_calls.h"
|
||||
#include "settings/settings_chat.h"
|
||||
#include "settings/sections/settings_chat.h"
|
||||
#include "settings/settings_codes.h"
|
||||
#include "settings/settings_credits.h"
|
||||
#include "settings/settings_folders.h"
|
||||
|
||||
@@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "settings/settings_common_session.h"
|
||||
|
||||
#include "settings/cloud_password/settings_cloud_password_email_confirm.h"
|
||||
#include "settings/settings_chat.h"
|
||||
#include "settings/sections/settings_chat.h"
|
||||
#include "settings/sections/settings_main.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
@@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "settings/sections/settings_advanced.h"
|
||||
#include "settings/sections/settings_main.h"
|
||||
#include "settings/settings_chat.h"
|
||||
#include "settings/sections/settings_chat.h"
|
||||
#include "settings/settings_codes.h"
|
||||
#include "ui/basic_click_handlers.h"
|
||||
#include "ui/wrap/fade_wrap.h"
|
||||
|
||||
Reference in New Issue
Block a user