aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquicktextselection.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Set revision of new TextSelection features to 6.11Shawn Rutledge2025-09-231-9/+9
| | | | | | | Amends 13aa6fee41f8cf37a271309b8b9ebb158f8d066a Change-Id: If9cfa2f8df81d77ffeea06586f61928ff15e04b4 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Enable declared TextSelection instances to edit text programmaticallyShawn Rutledge2025-09-221-0/+249
| | | | | | | | | | | | | | | | | | | The first qml file in tests/auto/qmltest/textedit seems to determine the import version: switch to versionless imports on all of them so that we can use new properties in the new test. In the autotest, reset the url to planets.txt before each test case, now that we are loading a different file to test duplication of multiple blocks. This reverts commit 295953bfc791ee9a4b0660ee72f54c39e35a3973. [ChangeLog][QtQuick][TextEdit] In addition to TextEdit.cursorSelection, you can now create non-visual instances of TextSelection and use them to modify rich text programmatically. Change-Id: Ia121def3e033054c7cb117e53af877e2596d4e3a Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Set explicit default security level of all files with default securityJan Arve Sæther2025-09-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The files (folders) already processed are listed in each issue in epic QTBUG-134547 These files were processed half a year ago. In order to make it clear that all of these files are already processed, mark them with an explicit default security header. For the record, this was generated with this script: find -E . -regex ".*\.(cpp|h|hpp|mm|qml|js)$" | xargs python3 ~/bin/add-cra-header.py in the folders listed in each subtask of QTBUG-134547 (add-cra-header.py only exist at my desktop, but it simply adds the default security header if it doesn't already have any existing security header) QUIP: 23 Fixes: QTBUG-134547 Pick-to: 6.10 6.9 6.8 Change-Id: Ieb8c78ea6561fdbdd27c7b13185ece853eedf80f Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Doc: Replace \instantiates with \nativetypePaul Wicking2024-08-201-1/+1
| | | | | | | | | | | Since the implementation of the `\nativetype`-command in QDoc, the `\instantiates`-command is deprecated. Replace the use of the deprecated command in favor of its replacement. Pick-to: 6.8 Task-number: QTBUG-128216 Change-Id: I23d9f66d3f6db2e5f827d7868497a432bb9b0626 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Remove QQuickTextSelection::m_doc for nowShawn Rutledge2024-03-111-1/+0
| | | | | | | | | | | | This variable was unused, and was also causing a QQuickTextDocument to be created unnecessarily whenever QQuickTextEdit::cursorSelection() is accessed, because QQuickTextEdit::textDocument() does lazy init. Amends 045f9ce192d841f3cc36d514b5f238b46488b41e It may be needed again when we start using QQuickTextSelection for more purposes, but not right now. Pick-to: 6.7 Change-Id: Ib22f0ab9a1098cc9b9138699360dc42ec3ac60af Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Add TextSelection (Tech Preview)Shawn Rutledge2023-12-081-0/+188
In the Controls text editor example, DocumentHandler always sounded like a hack, just by its name. We don't expect to be able to handle multiple selections anytime soon; but if we realistically expect to have multi-seat support in Qt some day, then probably the multi-user experience should include support for multiple text cursors and selections. So we shouldn't paint ourselves into a corner. QQuickTextControl works with only one QTextCursor most of the time (but it's private, thus modifiable); and TextEdit has properties like selectionStart, selectionEnd, selectedText, etc. which seem to assume that there is only one selection. So probably if we needed to support multiple selections, we could add Q_PROPERTY(QQmlListProperty<QQuickTextSelection> selections ...), document that those legacy properties just work with the first selection, and/or deprecate them. So with that in mind, let's get started with a QQuickTextSelection object. We add TextEdit.cursorSelection which holds the single selection near the text cursor. It provides API needed for tracking and manipulating often-used properties of selected rich text (such as QTextCharFormat properties) so that DocumentHandler can be removed. The example now uses TextArea.cursorSelection to manipulate the selected text's format. It's not possible to be fully declarative with this API though; we need to call setFont (by assigning a font), but QFont is a value type, and is not as mergeable as QTextCharFormat is, for example. If we used a binding rather than Action.onTriggered, it would trigger reading the font for an entire span of selected text (which may have had multiple fonts), setting one attribute (like bold), then applying the font to the whole span. What we do now is almost like that; but instead of reading the font first, we start with a default-constructed QFont, set one attribute, and call QTextCursor::mergeCharFormat(), in the hope that it can merge only the features of QFont that have actually been set. Unfortunately this is not quite true either: if you toggle the bold button, it might change the font size too, and so on; so maybe we really need QTextCharFormat in QML (as a value type, presumably) to implement those feature-toggling toolbar buttons correctly. This API is in tech preview, because of such issues as described above; because we're just scratching the surface of what might be possible; because we should perhaps compare popular JavaScript text-editing APIs that might be found elsewhere, in the meantime get feedback from users during the tech preview phase, and keep iterating. [ChangeLog][QtQuick][TextEdit] TextEdit.cursorSelection is a TextSelection object, which provides properties to inspect and modify the formatting of the single selection that is currently supported. This API is in Tech Preview. [ChangeLog][Controls][TextArea] TextArea.cursorSelection is a TextSelection object, which provides properties to inspect and modify the formatting of the single selection that is currently supported. This API is in Tech Preview. Task-number: QTBUG-36521 Task-number: QTBUG-38830 Task-number: QTBUG-81022 Change-Id: Icea99f633694aa712d0b4730b77369077288540f Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>