QtQuick support in Sonnet
Open, Needs TriagePublic

Description

Spellchecking is something we might want in QtQuick application too. NeoChat would be very interested in it but generally spellchecking in chat applications is really helpful.

I looked in the code a bit and the highlighting stuff can be shared between QtQuick and QtWidgets, but the rest I'm not so sure about. Probably needs more thinking :p

Related Objects

StatusAssignedTask
OpenNone
OpenNone
ognarb created this task.Feb 27 2021, 9:34 PM
krop renamed this task from QtQuick supports in Sonnect to QtQuick supports in Sonnet.Mar 15 2021, 9:23 AM
nicolasfella renamed this task from QtQuick supports in Sonnet to QtQuick support in Sonnet.Mar 15 2021, 12:26 PM
ervin moved this task from Needs Input to In Discussion on the KF6 board.Mar 28 2021, 2:35 PM
ervin moved this task from In Discussion to Backlog on the KF6 board.Mar 28 2021, 3:35 PM
ognarb claimed this task.Jun 9 2021, 9:45 PM

I implemented something in the private api of qqc2-desktop-style: https://invent.kde.org/frameworks/qqc2-desktop-style/-/merge_requests/74 :)

Current problem is that this might be a bit too much to add spell checking on every TextArea in QML/Kirigami, so qqc2-desktop-style might not be the right place for this.

Current alternatives are:

  1. Adding a Kirigami.TextArea with a context menu and port apps to use it. In Kirigami Addons, extends Kirigami.TextArea and add the Sonnet integration. This would allow for apps to opt-in into this feature but also means we would need to replace every QQC2.textArea with either Kirigami.TextArea or KirigamiAddons.SpellcheckedTextArea :(
  2. Doing things with input methods, but this will need to make changes in Qt to expose the QTextDocument to Input Methods otherwise we won't get syntax highlighting
  3. Doing things as I did in NeoChat and copy the TextArea from qqc2-desktop-style and extend it with spellchecking. Work for now and make users happy but this is not a long-term solution.
ognarb removed ognarb as the assignee of this task.Jun 10 2021, 11:12 AM

What's the problem that we are facing that we need to copy textArea? You probably encountered some issue that makes just adding the spellchecker ( which would also provide the menu ) to the textarea/input not feasible?

What's the problem that we are facing that we need to copy textArea? You probably encountered some issue that makes just adding the spellchecker ( which would also provide the menu ) to the textarea/input not feasible?

The problem is that it could theoretically break applications. For example, a text editor already has its own syntax highlighting and adding the one from Sonnet on top won't work.

Oh I think we are thinking of different things. I think during the spring the idea was to provide a object that one could use in order to opt into spell checking

TextArea {
  SonnetHighlighter {
      target: TextArea
  }
}

Or something like that.

Oh I think we are thinking of different things. I think during the spring the idea was to provide a object that one could use in order to opt into spell checking

TextArea {
  SonnetHighlighter {
      target: TextArea
  }
}

Or something like that.

The problem with that is that for the suggestions we would need to access the context menu from qqc2-desktop-style to add a few more entry items. We could depends on qqc2-desktop-style and do hacky things to make it work, but we would then loose the ability to switch the qqc2 style for android and plasma mobile :(

For android we likely want to use the system spellchecking or do we also want sonnet there?

Maybe we can do it the other way around then:

  • our Highlighter /has/ to be the parent
  • qqc2-desktop-style can look for the Highlighter in the children and integrate the suggestions into its own menu
  • with other styles SonnetHighlighter shows its own menu

Different behavior per style could be implemented with file selectors
https://doc.qt.io/qt-5/qtquickcontrols2-fileselectors.html

Another option would be to add a new input method hint to Qt so that we can still use a simple TextArea and get SyntaxHighlighting just by adding the hint. This would also make it easier to ifdef sonnet from the Android build for example.

https://doc.qt.io/qt-5/qml-qtquick-textinput.html#inputMethodHints-prop

ognarb added a comment.EditedJul 1 2021, 3:11 PM

Ok this is now mostly done! ๐ŸŽ‰

Ping, who is up to review it? :)

ognarb moved this task from Backlog to Done on the KF6 board.Oct 4 2021, 9:02 PM

Merged :D