diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index 8870d947b..06d17191b 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -268,6 +268,8 @@ EditCaptionBox::EditCaptionBox( _field->setEditLinkCallback( DefaultEditLinkCallback(&_controller->session(), _field)); + _spelling = InitSpellchecker(&_controller->session(), _field); + auto r = object_ptr>( this, object_ptr( diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.h b/Telegram/SourceFiles/boxes/edit_caption_box.h index 14e7cd5c3..825bc8aeb 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.h +++ b/Telegram/SourceFiles/boxes/edit_caption_box.h @@ -24,6 +24,10 @@ namespace Data { class Media; } // namespace Data +namespace Spellchecker { +class SpellingHighlighter; +} // namespace Spellchecker + namespace Ui { class InputField; class EmojiButton; @@ -99,6 +103,7 @@ private: object_ptr _emojiToggle = { nullptr }; base::unique_qptr _emojiPanel; base::unique_qptr _emojiFilter; + base::unique_qptr _spelling; int _thumbx = 0; int _thumbw = 0; diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 2a458900e..cb0a589fd 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -1679,6 +1679,8 @@ void SendFilesBox::setupCaption() { _caption, &_controller->session()); + _spelling = InitSpellchecker(&_controller->session(), _caption); + updateCaptionPlaceholder(); setupEmojiPanel(); } diff --git a/Telegram/SourceFiles/boxes/send_files_box.h b/Telegram/SourceFiles/boxes/send_files_box.h index 23f741295..716f5e739 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.h +++ b/Telegram/SourceFiles/boxes/send_files_box.h @@ -40,6 +40,10 @@ namespace Window { class SessionController; } // namespace Window +namespace Spellchecker { +class SpellingHighlighter; +} // namespace Spellchecker + enum class SendMenuType; enum class SendFilesWay { @@ -150,6 +154,7 @@ private: object_ptr _emojiToggle = { nullptr }; base::unique_qptr _emojiPanel; base::unique_qptr _emojiFilter; + base::unique_qptr _spelling; object_ptr> _sendAlbum = { nullptr }; object_ptr> _sendPhotos = { nullptr }; diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index 82fea368f..9d234ff89 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -207,6 +207,7 @@ void ShareBox::prepareCommentField() { field->setEditLinkCallback( DefaultEditLinkCallback(&_navigation->session(), field)); + _spelling = InitSpellchecker(&_navigation->session(), field); Ui::SendPendingMoveResizeEvents(_comment); } diff --git a/Telegram/SourceFiles/boxes/share_box.h b/Telegram/SourceFiles/boxes/share_box.h index 55d223c04..00e9e3d7a 100644 --- a/Telegram/SourceFiles/boxes/share_box.h +++ b/Telegram/SourceFiles/boxes/share_box.h @@ -36,6 +36,10 @@ namespace Notify { struct PeerUpdate; } // namespace Notify +namespace Spellchecker { +class SpellingHighlighter; +} // namespace Spellchecker + namespace Ui { class MultiSelect; class InputField; @@ -113,6 +117,7 @@ private: object_ptr _select; object_ptr> _comment; + base::unique_qptr _spelling; class Inner; QPointer _inner; diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index 43fb29500..0987915cf 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -78,6 +78,7 @@ private: QString _startLink; Fn _callback; Fn _setInnerFocus; + base::unique_qptr _spelling; }; @@ -127,6 +128,7 @@ void EditLinkBox::prepare() { getDelegate()->outerContainer(), text, _session); + _spelling = InitSpellchecker(_session, text); const auto url = content->add( object_ptr( @@ -273,6 +275,17 @@ void InitMessageField( DefaultEditLinkCallback(&controller->session(), field)); } +base::unique_qptr InitSpellchecker( + not_null session, + not_null field) { + auto s = base::make_unique_q( + field->rawTextEdit(), + session->settings().spellcheckerEnabledValue(), + field->documentContentsChanges()); + field->setExtendedContextMenu(s->contextMenuCreated()); + return s; +} + bool HasSendText(not_null field) { const auto &text = field->getTextWithTags().text; for (const auto ch : text) { diff --git a/Telegram/SourceFiles/chat_helpers/message_field.h b/Telegram/SourceFiles/chat_helpers/message_field.h index 8077c032b..e327327d1 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.h +++ b/Telegram/SourceFiles/chat_helpers/message_field.h @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once +#include "spellcheck/spelling_highlighter.h" #include "ui/widgets/input_fields.h" #include "base/timer.h" #include "base/qt_connection.h" @@ -34,6 +35,9 @@ Fn controller, not_null field); +base::unique_qptr InitSpellchecker( + not_null session, + not_null field); bool HasSendText(not_null field); struct InlineBotQuery { diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index af5bf73b7..d11525600 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -411,6 +411,7 @@ HistoryWidget::HistoryWidget( } Unexpected("action in MimeData hook."); }); + _spelling = InitSpellchecker(&controller->session(), _field); const auto suggestions = Ui::Emoji::SuggestionsController::Init( this, diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index df9eb8c98..48706e9ff 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -86,6 +86,10 @@ class ContactStatus; class Element; } // namespace HistoryView +namespace Spellchecker { +class SpellingHighlighter; +} // namespace Spellchecker + class DragArea; class SendFilesBox; class BotKeyboard; @@ -741,6 +745,7 @@ private: object_ptr _scheduled = { nullptr }; bool _cmdStartShown = false; object_ptr _field; + base::unique_qptr _spelling; bool _recording = false; bool _inField = false; bool _inReplyEditForward = false;