[Improvement] Allow non-emoji auto-replaces with emoji replacements disabled
This commit is contained in:
parent
fa02051f18
commit
07e1dde871
8 changed files with 46 additions and 33 deletions
|
|
@ -467,9 +467,7 @@ void GroupInfoBox::prepare() {
|
|||
: tr::lng_dlg_new_group_name)(),
|
||||
_initialTitle);
|
||||
_title->setMaxLength(Ui::EditPeer::kMaxGroupChannelTitle);
|
||||
_title->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
_title->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
_title->setInstantReplaces(Core::App().settings().instantReplacesValue());
|
||||
Ui::Emoji::SuggestionsController::Init(
|
||||
getDelegate()->outerContainer(),
|
||||
_title,
|
||||
|
|
@ -483,9 +481,7 @@ void GroupInfoBox::prepare() {
|
|||
tr::lng_create_group_description());
|
||||
_description->show();
|
||||
_description->setMaxLength(Ui::EditPeer::kMaxChannelDescription);
|
||||
_description->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
_description->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
_description->setInstantReplaces(Core::App().settings().instantReplacesValue());
|
||||
_description->setSubmitSettings(
|
||||
Core::App().settings().sendSubmitWay());
|
||||
|
||||
|
|
|
|||
|
|
@ -162,9 +162,7 @@ void InitField(
|
|||
not_null<QWidget*> container,
|
||||
not_null<Ui::InputField*> field,
|
||||
not_null<Main::Session*> session) {
|
||||
field->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
field->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
field->setInstantReplaces(Core::App().settings().instantReplacesValue());
|
||||
auto options = Ui::Emoji::SuggestionsController::Options();
|
||||
options.suggestExactFirstWord = false;
|
||||
Ui::Emoji::SuggestionsController::Init(
|
||||
|
|
@ -845,9 +843,7 @@ not_null<Ui::InputField*> CreatePollBox::setupSolution(
|
|||
st::createPollFieldPadding);
|
||||
InitField(getDelegate()->outerContainer(), solution, session);
|
||||
solution->setMaxLength(kSolutionLimit + kErrorLimit);
|
||||
solution->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
solution->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
solution->setInstantReplaces(Core::App().settings().instantReplacesValue());
|
||||
solution->setMarkdownReplacesEnabled(rpl::single(true));
|
||||
solution->setEditLinkCallback(
|
||||
DefaultEditLinkCallback(
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/filters/edit_filter_chats_list.h"
|
||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/text/text_options.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/text/text_options.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
|
|
@ -642,12 +643,10 @@ void EditFilterBox(
|
|||
tr::lng_filters_new_name(),
|
||||
filter.title()),
|
||||
st::markdownLinkFieldPadding);
|
||||
name->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
name->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
if (!isLocal) {
|
||||
name->setMaxLength(kMaxFilterTitleLength);
|
||||
}
|
||||
name->setInstantReplaces(Core::App().settings().instantReplacesValue());
|
||||
Ui::Emoji::SuggestionsController::Init(
|
||||
box->getDelegate()->outerContainer(),
|
||||
name,
|
||||
|
|
|
|||
|
|
@ -476,9 +476,7 @@ object_ptr<Ui::RpWidget> Controller::createTitleEdit() {
|
|||
_peer->name()),
|
||||
st::editPeerTitleMargins);
|
||||
result->entity()->setMaxLength(Ui::EditPeer::kMaxGroupChannelTitle);
|
||||
result->entity()->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
result->entity()->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
result->entity()->setInstantReplaces(Core::App().settings().instantReplacesValue());
|
||||
Ui::Emoji::SuggestionsController::Init(
|
||||
_wrap->window(),
|
||||
result->entity(),
|
||||
|
|
@ -510,9 +508,7 @@ object_ptr<Ui::RpWidget> Controller::createDescriptionEdit() {
|
|||
_peer->about()),
|
||||
st::editPeerDescriptionMargins);
|
||||
result->entity()->setMaxLength(Ui::EditPeer::kMaxChannelDescription);
|
||||
result->entity()->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
result->entity()->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
result->entity()->setInstantReplaces(Core::App().settings().instantReplacesValue());
|
||||
result->entity()->setSubmitSettings(
|
||||
Core::App().settings().sendSubmitWay());
|
||||
Ui::Emoji::SuggestionsController::Init(
|
||||
|
|
|
|||
|
|
@ -139,9 +139,7 @@ void EditLinkBox(
|
|||
tr::lng_formatting_link_text(),
|
||||
startText),
|
||||
st::markdownLinkFieldPadding);
|
||||
text->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
text->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
text->setInstantReplaces(Core::App().settings().instantReplacesValue());
|
||||
Ui::Emoji::SuggestionsController::Init(
|
||||
box->getDelegate()->outerContainer(),
|
||||
text,
|
||||
|
|
@ -327,9 +325,7 @@ void InitMessageFieldHandlers(
|
|||
data,
|
||||
std::move(update));
|
||||
}, std::move(customEmojiPaused));
|
||||
field->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
field->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
field->setInstantReplaces(Core::App().settings().instantReplacesValue());
|
||||
field->setMarkdownReplacesEnabled(rpl::single(true));
|
||||
if (show) {
|
||||
field->setEditLinkCallback(
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "core/core_settings_proxy.h"
|
||||
#include "window/themes/window_themes_embedded.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
#include "ui/chat/attach/attach_send_files_way.h"
|
||||
#include "platform/platform_notifications_manager.h"
|
||||
#include "base/flags.h"
|
||||
|
|
@ -382,6 +383,9 @@ public:
|
|||
}
|
||||
void setReplaceEmoji(bool value) {
|
||||
_replaceEmoji = value;
|
||||
setInstantReplaces(value
|
||||
? Ui::InstantReplaces::Default()
|
||||
: Ui::InstantReplaces::Custom());
|
||||
}
|
||||
[[nodiscard]] bool replaceEmoji() const {
|
||||
return _replaceEmoji.current();
|
||||
|
|
@ -392,6 +396,34 @@ public:
|
|||
[[nodiscard]] rpl::producer<bool> replaceEmojiChanges() const {
|
||||
return _replaceEmoji.changes();
|
||||
}
|
||||
void setInstantReplaces(Ui::InstantReplaces replaces) {
|
||||
_instantReplaces = replaces;
|
||||
_instantReplacesSet = true;
|
||||
}
|
||||
[[nodiscard]] Ui::InstantReplaces instantReplaces() {
|
||||
if (!_instantReplacesSet) {
|
||||
setInstantReplaces(replaceEmoji()
|
||||
? Ui::InstantReplaces::Default()
|
||||
: Ui::InstantReplaces::Custom());
|
||||
}
|
||||
return _instantReplaces.current();
|
||||
}
|
||||
[[nodiscard]] rpl::producer<Ui::InstantReplaces> instantReplacesValue() {
|
||||
if (!_instantReplacesSet) {
|
||||
setInstantReplaces(replaceEmoji()
|
||||
? Ui::InstantReplaces::Default()
|
||||
: Ui::InstantReplaces::Custom());
|
||||
}
|
||||
return _instantReplaces.value();
|
||||
}
|
||||
[[nodiscard]] rpl::producer<Ui::InstantReplaces> instantReplacesChanges() {
|
||||
if (!_instantReplacesSet) {
|
||||
setInstantReplaces(replaceEmoji()
|
||||
? Ui::InstantReplaces::Default()
|
||||
: Ui::InstantReplaces::Custom());
|
||||
}
|
||||
return _instantReplaces.changes();
|
||||
}
|
||||
[[nodiscard]] bool suggestEmoji() const {
|
||||
return _suggestEmoji;
|
||||
}
|
||||
|
|
@ -779,6 +811,8 @@ private:
|
|||
bool _loopAnimatedStickers = true;
|
||||
rpl::variable<bool> _largeEmoji = true;
|
||||
rpl::variable<bool> _replaceEmoji = true;
|
||||
rpl::variable<Ui::InstantReplaces> _instantReplaces;
|
||||
bool _instantReplacesSet = false;
|
||||
bool _suggestEmoji = true;
|
||||
bool _suggestStickersByEmoji = true;
|
||||
bool _suggestAnimatedEmoji = true;
|
||||
|
|
|
|||
|
|
@ -564,9 +564,7 @@ void SetupBio(
|
|||
save();
|
||||
});
|
||||
QObject::connect(bio, &Ui::InputField::changed, updated);
|
||||
bio->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
bio->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
bio->setInstantReplaces(Core::App().settings().instantReplacesValue());
|
||||
Ui::Emoji::SuggestionsController::Init(
|
||||
container->window(),
|
||||
bio,
|
||||
|
|
|
|||
|
|
@ -83,9 +83,7 @@ EditInfoBox::EditInfoBox(
|
|||
_field->setMaxLength(kMaxSupportInfoLength);
|
||||
_field->setSubmitSettings(
|
||||
Core::App().settings().sendSubmitWay());
|
||||
_field->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
_field->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
_field->setInstantReplaces(Core::App().settings().instantReplacesValue());
|
||||
_field->setMarkdownReplacesEnabled(rpl::single(true));
|
||||
_field->setEditLinkCallback(
|
||||
DefaultEditLinkCallback(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue