From 95517128d2b5ed6b3e993df3276c012199ec8ab9 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 5 Sep 2017 21:15:13 +0200 Subject: Update the cursor rectangle when select all is triggered MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When select all is triggered then the cursor rectangle should be updated to ensure that the selection handles are visible if they are displayed on a given platform. For instance, on iOS the loupe handles should appear in this case. This also has the added effect that when using Backspace on the iOS keyboard, it will delete the selected text as opposed to just a single character as it will handle that situation correctly. The tst_qquicktextedit::inputMethodUpdate() test is modified to account for the extra event sent now when selectAll() is called. Task-number: QTBUG-63835 Change-Id: I94fb0576b286c006dd12c65d0b322d712ed2a96f Reviewed-by: Tor Arne Vestbø --- src/quick/items/qquicktextcontrol.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/quick/items/qquicktextcontrol.cpp') diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index 2e23d69e5b..874c02fc99 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -432,6 +432,7 @@ void QQuickTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged / #endif emit q->selectionChanged(); } + q->updateCursorRectangle(true); } void QQuickTextControlPrivate::_q_updateCurrentCharFormatAndSelection() @@ -1150,7 +1151,6 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou if (interactionFlags & Qt::TextEditable) { if (cursor.position() != oldCursorPos) { emit q->cursorPositionChanged(); - q->updateCursorRectangle(true); } _q_updateCurrentCharFormatAndSelection(); #if QT_CONFIG(im) @@ -1159,7 +1159,6 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou #endif } else if (cursor.position() != oldCursorPos) { emit q->cursorPositionChanged(); - q->updateCursorRectangle(true); } selectionChanged(true); repaintOldAndNewSelection(oldSelection); -- cgit v1.2.3 From 499ec43937e926e4f2fa57a9baa455fcb3862262 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 21 Feb 2018 10:41:54 +0100 Subject: use nullptr consistently (clang-tidy) From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann --- src/quick/items/qquicktextcontrol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/quick/items/qquicktextcontrol.cpp') diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index 874c02fc99..e3080dfe48 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -95,7 +95,7 @@ static QTextLine currentTextLine(const QTextCursor &cursor) } QQuickTextControlPrivate::QQuickTextControlPrivate() - : doc(0), + : doc(nullptr), #if QT_CONFIG(im) preeditCursor(0), #endif -- cgit v1.2.3 From 9ef0d2da99f4593d50c16912d00bef121bb76f9b Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 26 Apr 2018 13:53:54 +0200 Subject: Fix for input method commit that ends with newline If the input method event contains a commit text that ends with a newline, text, the commit string is inserted first. This changes the current block. This change makes sure that we apply the formatting changes (including removing the old preedit text) to the old block in this specific case. This is a copy of change 6cece0f43a18dc8c9dbf5bc49ce515714f090725 in qtbase, since the code is duplicated. Task-number: QTBUG-67836 Change-Id: I531d3f1dce51d840acc0ef7fda9e7affb3192327 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/quick/items/qquicktextcontrol.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/quick/items/qquicktextcontrol.cpp') diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index e3080dfe48..1cb12235c1 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -1304,8 +1304,12 @@ void QQuickTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) cursor.removeSelectedText(); } + QTextBlock block; + // insert commit string if (!e->commitString().isEmpty() || e->replacementLength()) { + if (e->commitString().endsWith(QChar::LineFeed)) + block = cursor.block(); // Remember the block where the preedit text is QTextCursor c = cursor; c.setPosition(c.position() + e->replacementStart()); c.setPosition(c.position() + e->replacementLength(), QTextCursor::KeepAnchor); @@ -1324,7 +1328,9 @@ void QQuickTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) } } - QTextBlock block = cursor.block(); + if (!block.isValid()) + block = cursor.block(); + QTextLayout *layout = block.layout(); if (isGettingInput) { layout->setPreeditArea(cursor.position() - block.position(), e->preeditString()); -- cgit v1.2.3 From 23f9dd17b5f999b6a4c78f7513ea1c5a20d1208e Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 25 Jun 2018 09:41:27 +0200 Subject: Build without the draganddrop feature Change-Id: I5e3a3ebd36d49fdf649eec5a3fb0a8fdb048ce0d Reviewed-by: Mitch Curtis --- src/quick/items/qquicktextcontrol.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/quick/items/qquicktextcontrol.cpp') diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index 1cb12235c1..38ca7283b4 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From ede9a8285858873e644083bbad9a71da26276dce Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 8 Jan 2019 15:27:34 +0100 Subject: Fix QFont-related deprecation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace QFontMetrics::width() by horizontalAdvance(), fixing: items/qquicktextcontrol.cpp:1001:80: warning: ‘int QFontMetrics::width(QChar) const’ is deprecated: Use QFont::horizontalAdvance [-Wdeprecated-declarations] items/qquicktextinput.cpp:880:60: warning: ‘int QFontMetrics::width(QChar) const’ is deprecated: Use QFont::horizontalAdvance [-Wdeprecated-declarations] items/qquicktextinput.cpp:1380:60: warning: ‘int QFontMetrics::width(QChar) const’ is deprecated: Use QFont::horizontalAdvance [-Wdeprecated-declarations] items/context2d/qquickcontext2d.cpp:2980:57: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFont::horizontalAdvance [-Wdeprecated-declarations] items/context2d/qquickcontext2d.cpp:4060:36: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFont::horizontalAdvance [-Wdeprecated-declarations] items/context2d/qquickcontext2d.cpp:4063:36: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFont::horizontalAdvance [-Wdeprecated-declarations] Change-Id: Ie97be4a6cf1ce087caeb4d83fe016fa1a471f3ec Reviewed-by: Ulf Hermann --- src/quick/items/qquicktextcontrol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/quick/items/qquicktextcontrol.cpp') diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index 38ca7283b4..a7a90c9134 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -998,7 +998,7 @@ QRectF QQuickTextControlPrivate::rectForPosition(int position) const if (relativePos < line.textLength() - line.textStart()) w = line.cursorToX(relativePos + 1) - x; else - w = QFontMetrics(block.layout()->font()).width(QLatin1Char(' ')); // in sync with QTextLine::draw() + w = QFontMetrics(block.layout()->font()).horizontalAdvance(QLatin1Char(' ')); // in sync with QTextLine::draw() } r = QRectF(layoutPos.x() + x, layoutPos.y() + line.y(), textCursorWidth + w, line.height()); } else { -- cgit v1.2.3