This reverts commit e5824ea91b.
Reason for revert: dfcde3ea4d, which this
requires, causes a regression: QTBUG-134903. The feature will be post-poned
to 6.10 instead.
Also amends da064518e4 in order to keep
it working after a small conflict.
Change-Id: I339e1afc77b11bf446d04aad5aae933c8c1f6b45
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
When a user activates the boldAction for example, the code was replacing
QTextCharFormat's font with a default-constructed font that has the bold
attribute set, which meant that it could not be bold, italic, underlined
struck out, and with a custom size and color at the same time. On the
other hand, when we do it the current way:
textArea.cursorSelection.font.bold = checked
we call QQuickTextSelection::font(), QFont::setBold(), and then
QQuickTextSelection::setFont(). (QFont is a QML value type, so it's the
only way.) Perhaps at some point, something was going wrong with that,
but it seems to work now.
Amends 045f9ce192
Fixes: QTBUG-136250
Pick-to: 6.8
Change-Id: I268e5814e7aa52aeb5aaec2d1a8fbfbc0d670236
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
(cherry picked from commit 17a225f09a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Since 3b598b6f75 TextArea comes with a built-in
context menu. Here we demonstrate how to add extra menu items to the end.
Task-number: QTBUG-35598
Task-number: QTBUG-134903
Change-Id: I1e3d8c044939521aaa076486630e3b879130dfd1
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit 64063946db)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
- text formatting includes alignment, not just font properties
- update links in example.md
- update texteditor.html: don't mention Qt Labs Platform, but
link to some recent new stuff
- if ToolButton.action is bound, enabled is redundant (the Action
already has it)
- don't include QApplication
Amends 6217408799 and
21b3c4741e
Change-Id: Ie4565829f02d8ee1541ba4af9d64bd044739179f
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
We also move ScrollBar to make explanation easier.
Pick-to: 6.7 6.7.0
Change-Id: If65de335f840382b5e236d8a04db382b0b7aee6a
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
I'm not sure why the example was written with so much repetition,
but there must have been limitations back then. It's better to have
Action as the encapsulation for an operation, and simply bind it to
all the places where it's used (menubar, toolbar and context menu).
It would be even better if an Action could be added directly to a
Menu or ToolBar, but so far there's not a declarative way to do that
(only by using addAction(), which is only in Menu, not ToolBar).
We now use TapHandler instead of MouseArea to open the context menu.
It works fine either way, but at least we don't need anchors.fill.
Pick-to: 6.7 6.7.0
Change-Id: I74900ec49b57b616ffacddcf81c5aea12d4fefe6
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Update docs after b46d6a75ac,
fdbacf2d5c etc.
Pick-to: 6.7
Change-Id: Ieb49d6876f0a86031fb0ffe970f695e5acbe4c43
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
The size policy of item updated as part of task QTBUG-117597. This
patch update existing examples and manual tests that depends on quick
layout to embrace size policy change.
Task-number: QTBUG-117597
Pick-to: 6.7
Change-Id: I68469a3bba3c4d3e5ed4b6eae0fd765b5206efc0
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Catch up with recent changes in the default texteditor.qml file:
- TextDocument.status is new; the error signal is gone. Update as in
bec8df96b7 and
1e6cb2462e
- 3bae41faac changed the mapping of the
"OK" checkmark in fontello.ttf
- use Actions to show and change cursorSelection styling, as in
045f9ce192
- set a default window size; it doesn't matter on a mobile device that
runs everything fullscreen, but it's easier to test on desktop with
the -touch flag
Fixes: QTBUG-121840
Task-number: QTBUG-121946
Pick-to: 6.7
Change-Id: If678b92efe4e1824022fa0ee9106c0c3b0b9f194
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Computed properties make it possible to use scoped enum values as
object property names. Amends bec8df96b7
Also remove semicolons for consistency.
Pick-to: 6.7
Task-number: QTBUG-121946
Change-Id: I1ee354722d9f0e065637731d1b535389a9cb0032
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Amends 5647b6900b in which the error
signal was removed and replaced with a status property.
Pick-to: 6.7
Change-Id: I433987fe4c480c910c98c8fd3714c2e426e49c0f
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This depends on the plan to have the Controls MenuBar and context Menu
"go native" on platforms that support it.
Task-number: QTBUG-119988
Task-number: QTBUG-106782
Change-Id: Ib8354b44bde385717431534d0260182715d66f16
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
...and fix a couple of minor issues that remained.
Fixes: QTBUG-81022
Change-Id: I5fc1547fb09caef5a9e24d95c2ca7b8d78ee104a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
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>
Since QTBUG-92155 is not done, we need an easy way to load and save text
into and out of a QTextDocument in QML. This patch follows the pattern
from Image and other types: add a `source` property, a URL from which
the file is to be loaded.
When it comes to saving, the pattern is not set: so far the only file
writing that has been available from QML is ItemGrabResult.saveToFile().
Since we need to save in specific formats, it makes sense to continue
that pattern: the text document knows how to do its own serialization,
so this is not suitable for generic data file I/O, even if we did have a
QML API for that. We add invokable functions save() and saveAs() for the
usual use cases in word processors and such. The URL extension
determines the file format.
Setting QQuickTextDocument's source is not allowed if the document has
unsaved changes. The user (app author) needs to call save() or override
modified to false first.
[ChangeLog][QtQuick][TextEdit] TextEdit.textDocument now has a source
property for loading files; save() and saveAs() functions for writing;
a modified property which tracks QTextDocument::modified; and an error
signal in case any of these operations fail. Setting the source
property is allowed only if the document is in unmodified state.
This API is in Tech Preview.
[ChangeLog][Controls][TextArea] TextArea.textDocument now has a source
property for loading files; save() and saveAs() functions for writing;
a modified property which tracks QTextDocument::modified; and an error
signal in case any of these operations fail. Setting the source
property is allowed only if the document is in unmodified state.
This API is in Tech Preview.
Change-Id: I687318523c7a520e02244e47224d067da55318b5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Qt Quick Controls 2 was named that way because it was a follow-up to
Qt Quick Controls 1.x. Now that Qt Quick Controls 1 is no longer
supported, we don't need to have "2" in the name. Work on this was
already started for the documentation in
1abdfe5d5a.
By doing this renaming a few weeks before feature freeze, it won't
affect the release but still results in as little time possible spent
manually fixing conflicts in cherry-picks from non-LTS releases as a
result of the renaming.
This patch does the following:
- Renames directories.
- Adapts CMakeLists.txt and other files to account for the new paths.
A follow-up patch will handle documentation.
It does not touch library names or other user-facing stuff, as that
will have to be done in Qt 7.
Task-number: QTBUG-95413
Change-Id: I170d8db19033ee71e495ff0c5c1a517a41ed7634
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>