Added SpellingHighlighter to InputField in HistoryWidget and some boxes.

This commit is contained in:
23rd 2019-10-18 16:54:26 +03:00 committed by John Preston
parent 6e95cfc24d
commit 4be178c75f
10 changed files with 43 additions and 0 deletions

View file

@ -268,6 +268,8 @@ EditCaptionBox::EditCaptionBox(
_field->setEditLinkCallback(
DefaultEditLinkCallback(&_controller->session(), _field));
_spelling = InitSpellchecker(&_controller->session(), _field);
auto r = object_ptr<Ui::SlideWrap<Ui::Checkbox>>(
this,
object_ptr<Ui::Checkbox>(

View file

@ -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<Ui::EmojiButton> _emojiToggle = { nullptr };
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
base::unique_qptr<QObject> _emojiFilter;
base::unique_qptr<Spellchecker::SpellingHighlighter> _spelling;
int _thumbx = 0;
int _thumbw = 0;

View file

@ -1679,6 +1679,8 @@ void SendFilesBox::setupCaption() {
_caption,
&_controller->session());
_spelling = InitSpellchecker(&_controller->session(), _caption);
updateCaptionPlaceholder();
setupEmojiPanel();
}

View file

@ -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<Ui::EmojiButton> _emojiToggle = { nullptr };
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
base::unique_qptr<QObject> _emojiFilter;
base::unique_qptr<Spellchecker::SpellingHighlighter> _spelling;
object_ptr<Ui::Radioenum<SendFilesWay>> _sendAlbum = { nullptr };
object_ptr<Ui::Radioenum<SendFilesWay>> _sendPhotos = { nullptr };

View file

@ -207,6 +207,7 @@ void ShareBox::prepareCommentField() {
field->setEditLinkCallback(
DefaultEditLinkCallback(&_navigation->session(), field));
_spelling = InitSpellchecker(&_navigation->session(), field);
Ui::SendPendingMoveResizeEvents(_comment);
}

View file

@ -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<Ui::MultiSelect> _select;
object_ptr<Ui::SlideWrap<Ui::InputField>> _comment;
base::unique_qptr<Spellchecker::SpellingHighlighter> _spelling;
class Inner;
QPointer<Inner> _inner;

View file

@ -78,6 +78,7 @@ private:
QString _startLink;
Fn<void(QString, QString)> _callback;
Fn<void()> _setInnerFocus;
base::unique_qptr<Spellchecker::SpellingHighlighter> _spelling;
};
@ -127,6 +128,7 @@ void EditLinkBox::prepare() {
getDelegate()->outerContainer(),
text,
_session);
_spelling = InitSpellchecker(_session, text);
const auto url = content->add(
object_ptr<Ui::InputField>(
@ -273,6 +275,17 @@ void InitMessageField(
DefaultEditLinkCallback(&controller->session(), field));
}
base::unique_qptr<Spellchecker::SpellingHighlighter> InitSpellchecker(
not_null<Main::Session*> session,
not_null<Ui::InputField*> field) {
auto s = base::make_unique_q<Spellchecker::SpellingHighlighter>(
field->rawTextEdit(),
session->settings().spellcheckerEnabledValue(),
field->documentContentsChanges());
field->setExtendedContextMenu(s->contextMenuCreated());
return s;
}
bool HasSendText(not_null<const Ui::InputField*> field) {
const auto &text = field->getTextWithTags().text;
for (const auto ch : text) {

View file

@ -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<bool(
void InitMessageField(
not_null<Window::SessionController*> controller,
not_null<Ui::InputField*> field);
base::unique_qptr<Spellchecker::SpellingHighlighter> InitSpellchecker(
not_null<Main::Session*> session,
not_null<Ui::InputField*> field);
bool HasSendText(not_null<const Ui::InputField*> field);
struct InlineBotQuery {

View file

@ -411,6 +411,7 @@ HistoryWidget::HistoryWidget(
}
Unexpected("action in MimeData hook.");
});
_spelling = InitSpellchecker(&controller->session(), _field);
const auto suggestions = Ui::Emoji::SuggestionsController::Init(
this,

View file

@ -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<Ui::IconButton> _scheduled = { nullptr };
bool _cmdStartShown = false;
object_ptr<Ui::InputField> _field;
base::unique_qptr<Spellchecker::SpellingHighlighter> _spelling;
bool _recording = false;
bool _inField = false;
bool _inReplyEditForward = false;