mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Support animated emoji in caption edit fields.
This commit is contained in:
parent
00d1828fbe
commit
806c5ddf29
8 changed files with 60 additions and 64 deletions
|
@ -241,20 +241,19 @@ void EditCaptionBox::rebuildPreview() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditCaptionBox::setupField() {
|
void EditCaptionBox::setupField() {
|
||||||
const auto show = std::make_shared<Window::Show>(_controller);
|
InitMessageFieldHandlers(
|
||||||
const auto session = &_controller->session();
|
_controller,
|
||||||
|
_field.get(),
|
||||||
|
Window::GifPauseReason::Layer);
|
||||||
|
Ui::Emoji::SuggestionsController::Init(
|
||||||
|
getDelegate()->outerContainer(),
|
||||||
|
_field,
|
||||||
|
&_controller->session());
|
||||||
|
|
||||||
_field->setSubmitSettings(
|
_field->setSubmitSettings(
|
||||||
Core::App().settings().sendSubmitWay());
|
Core::App().settings().sendSubmitWay());
|
||||||
_field->setInstantReplaces(Ui::InstantReplaces::Default());
|
|
||||||
_field->setInstantReplacesEnabled(
|
|
||||||
Core::App().settings().replaceEmojiValue());
|
|
||||||
_field->setMarkdownReplacesEnabled(rpl::single(true));
|
|
||||||
_field->setEditLinkCallback(
|
|
||||||
DefaultEditLinkCallback(show, session, _field));
|
|
||||||
_field->setMaxHeight(st::confirmCaptionArea.heightMax);
|
_field->setMaxHeight(st::confirmCaptionArea.heightMax);
|
||||||
|
|
||||||
InitSpellchecker(show, session, _field);
|
|
||||||
|
|
||||||
connect(_field, &Ui::InputField::submitted, [=] { save(); });
|
connect(_field, &Ui::InputField::submitted, [=] { save(); });
|
||||||
connect(_field, &Ui::InputField::cancelled, [=] { closeBox(); });
|
connect(_field, &Ui::InputField::cancelled, [=] { closeBox(); });
|
||||||
connect(_field, &Ui::InputField::resized, [=] { captionResized(); });
|
connect(_field, &Ui::InputField::resized, [=] { captionResized(); });
|
||||||
|
@ -273,10 +272,6 @@ void EditCaptionBox::setupField() {
|
||||||
}
|
}
|
||||||
Unexpected("Action in MimeData hook.");
|
Unexpected("Action in MimeData hook.");
|
||||||
});
|
});
|
||||||
Ui::Emoji::SuggestionsController::Init(
|
|
||||||
getDelegate()->outerContainer(),
|
|
||||||
_field,
|
|
||||||
&_controller->session());
|
|
||||||
|
|
||||||
auto cursor = _field->textCursor();
|
auto cursor = _field->textCursor();
|
||||||
cursor.movePosition(QTextCursor::End);
|
cursor.movePosition(QTextCursor::End);
|
||||||
|
|
|
@ -672,9 +672,19 @@ void SendFilesBox::updateSendWayControlsVisibility() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendFilesBox::setupCaption() {
|
void SendFilesBox::setupCaption() {
|
||||||
_caption->setMaxLength(kMaxMessageLength);
|
InitMessageFieldHandlers(
|
||||||
|
_controller,
|
||||||
|
_caption.data(),
|
||||||
|
Window::GifPauseReason::Layer);
|
||||||
|
Ui::Emoji::SuggestionsController::Init(
|
||||||
|
getDelegate()->outerContainer(),
|
||||||
|
_caption,
|
||||||
|
&_controller->session());
|
||||||
|
|
||||||
_caption->setSubmitSettings(
|
_caption->setSubmitSettings(
|
||||||
Core::App().settings().sendSubmitWay());
|
Core::App().settings().sendSubmitWay());
|
||||||
|
_caption->setMaxLength(kMaxMessageLength);
|
||||||
|
|
||||||
connect(_caption, &Ui::InputField::resized, [=] {
|
connect(_caption, &Ui::InputField::resized, [=] {
|
||||||
captionResized();
|
captionResized();
|
||||||
});
|
});
|
||||||
|
@ -696,21 +706,6 @@ void SendFilesBox::setupCaption() {
|
||||||
}
|
}
|
||||||
Unexpected("action in MimeData hook.");
|
Unexpected("action in MimeData hook.");
|
||||||
});
|
});
|
||||||
const auto show = std::make_shared<Window::Show>(_controller);
|
|
||||||
const auto session = &_controller->session();
|
|
||||||
|
|
||||||
_caption->setInstantReplaces(Ui::InstantReplaces::Default());
|
|
||||||
_caption->setInstantReplacesEnabled(
|
|
||||||
Core::App().settings().replaceEmojiValue());
|
|
||||||
_caption->setMarkdownReplacesEnabled(rpl::single(true));
|
|
||||||
_caption->setEditLinkCallback(
|
|
||||||
DefaultEditLinkCallback(show, session, _caption));
|
|
||||||
Ui::Emoji::SuggestionsController::Init(
|
|
||||||
getDelegate()->outerContainer(),
|
|
||||||
_caption,
|
|
||||||
session);
|
|
||||||
|
|
||||||
InitSpellchecker(show, session, _caption);
|
|
||||||
|
|
||||||
updateCaptionPlaceholder();
|
updateCaptionPlaceholder();
|
||||||
setupEmojiPanel();
|
setupEmojiPanel();
|
||||||
|
|
|
@ -286,12 +286,12 @@ Fn<bool(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitMessageField(
|
void InitMessageFieldHandlers(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<Ui::InputField*> field) {
|
not_null<Ui::InputField*> field,
|
||||||
field->setMinHeight(
|
Window::GifPauseReason pauseReasonLevel) {
|
||||||
st::historySendSize.height() - 2 * st::historySendPadding);
|
const auto show = std::make_shared<Window::Show>(controller);
|
||||||
field->setMaxHeight(st::historyComposeFieldMaxHeight);
|
const auto session = &controller->session();
|
||||||
|
|
||||||
field->setTagMimeProcessor(FieldTagMimeProcessor(controller));
|
field->setTagMimeProcessor(FieldTagMimeProcessor(controller));
|
||||||
field->setCustomEmojiFactory([=](QStringView data, Fn<void()> update) {
|
field->setCustomEmojiFactory([=](QStringView data, Fn<void()> update) {
|
||||||
|
@ -299,23 +299,36 @@ void InitMessageField(
|
||||||
data,
|
data,
|
||||||
std::move(update));
|
std::move(update));
|
||||||
}, [=] {
|
}, [=] {
|
||||||
return controller->isGifPausedAtLeastFor(
|
return controller->isGifPausedAtLeastFor(pauseReasonLevel);
|
||||||
Window::GifPauseReason::Any);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
field->document()->setDocumentMargin(4.);
|
|
||||||
field->setAdditionalMargin(style::ConvertScale(4) - 4);
|
|
||||||
|
|
||||||
field->customTab(true);
|
|
||||||
field->setInstantReplaces(Ui::InstantReplaces::Default());
|
field->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||||
field->setInstantReplacesEnabled(
|
field->setInstantReplacesEnabled(
|
||||||
Core::App().settings().replaceEmojiValue());
|
Core::App().settings().replaceEmojiValue());
|
||||||
field->setMarkdownReplacesEnabled(rpl::single(true));
|
field->setMarkdownReplacesEnabled(rpl::single(true));
|
||||||
field->setEditLinkCallback(
|
field->setEditLinkCallback(
|
||||||
DefaultEditLinkCallback(
|
DefaultEditLinkCallback(show, session, field));
|
||||||
std::make_shared<Window::Show>(controller),
|
|
||||||
&controller->session(),
|
InitSpellchecker(
|
||||||
field));
|
std::make_shared<Window::Show>(controller),
|
||||||
|
session,
|
||||||
|
field);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitMessageFieldGeometry(not_null<Ui::InputField*> field) {
|
||||||
|
field->setMinHeight(
|
||||||
|
st::historySendSize.height() - 2 * st::historySendPadding);
|
||||||
|
field->setMaxHeight(st::historyComposeFieldMaxHeight);
|
||||||
|
|
||||||
|
field->document()->setDocumentMargin(4.);
|
||||||
|
field->setAdditionalMargin(style::ConvertScale(4) - 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitMessageField(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::InputField*> field) {
|
||||||
|
InitMessageFieldHandlers(controller, field, Window::GifPauseReason::Any);
|
||||||
|
InitMessageFieldGeometry(field);
|
||||||
|
field->customTab(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitSpellchecker(
|
void InitSpellchecker(
|
||||||
|
@ -339,15 +352,6 @@ void InitSpellchecker(
|
||||||
#endif // TDESKTOP_DISABLE_SPELLCHECK
|
#endif // TDESKTOP_DISABLE_SPELLCHECK
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitSpellchecker(
|
|
||||||
not_null<Window::SessionController*> controller,
|
|
||||||
not_null<Ui::InputField*> field) {
|
|
||||||
InitSpellchecker(
|
|
||||||
std::make_shared<Window::Show>(controller),
|
|
||||||
&controller->session(),
|
|
||||||
field);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HasSendText(not_null<const Ui::InputField*> field) {
|
bool HasSendText(not_null<const Ui::InputField*> field) {
|
||||||
const auto &text = field->getTextWithTags().text;
|
const auto &text = field->getTextWithTags().text;
|
||||||
for (const auto &ch : text) {
|
for (const auto &ch : text) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ class Session;
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
class SessionController;
|
class SessionController;
|
||||||
|
enum class GifPauseReason;
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -43,6 +44,10 @@ Fn<bool(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
not_null<Ui::InputField*> field,
|
not_null<Ui::InputField*> field,
|
||||||
const style::InputField *fieldStyle = nullptr);
|
const style::InputField *fieldStyle = nullptr);
|
||||||
|
void InitMessageFieldHandlers(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::InputField*> field,
|
||||||
|
Window::GifPauseReason pauseReasonLevel);
|
||||||
void InitMessageField(
|
void InitMessageField(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<Ui::InputField*> field);
|
not_null<Ui::InputField*> field);
|
||||||
|
@ -52,9 +57,6 @@ void InitSpellchecker(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
not_null<Ui::InputField*> field,
|
not_null<Ui::InputField*> field,
|
||||||
bool skipDictionariesManager = false);
|
bool skipDictionariesManager = false);
|
||||||
void InitSpellchecker(
|
|
||||||
not_null<Window::SessionController*> controller,
|
|
||||||
not_null<Ui::InputField*> field);
|
|
||||||
|
|
||||||
bool HasSendText(not_null<const Ui::InputField*> field);
|
bool HasSendText(not_null<const Ui::InputField*> field);
|
||||||
|
|
||||||
|
|
|
@ -221,9 +221,11 @@ void MentionNameClickHandler::onClick(ClickContext context) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto MentionNameClickHandler::getTextEntity() const -> TextEntity {
|
auto MentionNameClickHandler::getTextEntity() const -> TextEntity {
|
||||||
const auto data = QString::number(_userId.bare)
|
const auto data = TextUtilities::MentionNameDataFromFields({
|
||||||
+ '.'
|
.selfId = _session->userId().bare,
|
||||||
+ QString::number(_accessHash);
|
.userId = _userId.bare,
|
||||||
|
.accessHash = _accessHash,
|
||||||
|
});
|
||||||
return { EntityType::MentionName, data };
|
return { EntityType::MentionName, data };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -473,7 +473,6 @@ HistoryWidget::HistoryWidget(
|
||||||
}
|
}
|
||||||
Unexpected("action in MimeData hook.");
|
Unexpected("action in MimeData hook.");
|
||||||
});
|
});
|
||||||
InitSpellchecker(controller, _field);
|
|
||||||
|
|
||||||
const auto suggestions = Ui::Emoji::SuggestionsController::Init(
|
const auto suggestions = Ui::Emoji::SuggestionsController::Init(
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -1426,7 +1426,6 @@ void ComposeControls::initField() {
|
||||||
_field,
|
_field,
|
||||||
&_window->session());
|
&_window->session());
|
||||||
_raiseEmojiSuggestions = [=] { suggestions->raise(); };
|
_raiseEmojiSuggestions = [=] { suggestions->raise(); };
|
||||||
InitSpellchecker(_window, _field);
|
|
||||||
|
|
||||||
const auto rawTextEdit = _field->rawTextEdit().get();
|
const auto rawTextEdit = _field->rawTextEdit().get();
|
||||||
rpl::merge(
|
rpl::merge(
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6bd7518109850d650a174b74e5582367555390da
|
Subproject commit 0b829240fd3ade757aa4e957c17d84a81ef1c3ff
|
Loading…
Add table
Reference in a new issue