aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/items/qquicktextedit.cpp')
-rw-r--r--src/quick/items/qquicktextedit.cpp88
1 files changed, 71 insertions, 17 deletions
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 3ab7f358ff..9b23abc877 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -1,31 +1,37 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -328,6 +334,8 @@ QString QQuickTextEdit::text() const
insert() and remove() methods provide more fine-grained control and
remarkably better performance for modifying especially large rich text
content.
+
+ \sa clear()
*/
void QQuickTextEdit::setText(const QString &text)
{
@@ -351,6 +359,19 @@ void QQuickTextEdit::setText(const QString &text)
}
/*!
+ \qmlproperty string QtQuick::TextEdit::preeditText
+ \readonly
+ \since 5.7
+
+ This property contains partial text input from an input method.
+*/
+QString QQuickTextEdit::preeditText() const
+{
+ Q_D(const QQuickTextEdit);
+ return d->control->preeditText();
+}
+
+/*!
\qmlproperty enumeration QtQuick::TextEdit::textFormat
The way the text property should be displayed.
@@ -487,7 +508,7 @@ void QQuickTextEdit::setFont(const QFont &font)
updateSize();
updateWholeDocument();
#ifndef QT_NO_IM
- updateInputMethod(Qt::ImCursorRectangle | Qt::ImFont);
+ updateInputMethod(Qt::ImCursorRectangle | Qt::ImAnchorRectangle | Qt::ImFont);
#endif
}
emit fontChanged(d->sourceFont);
@@ -1513,8 +1534,7 @@ void QQuickTextEdit::setReadOnly(bool r)
if (!r)
flags = flags | Qt::TextEditable;
d->control->setTextInteractionFlags(flags);
- if (!r)
- d->control->moveCursor(QTextCursor::End);
+ d->control->moveCursor(QTextCursor::End);
#ifndef QT_NO_IM
updateInputMethod(Qt::ImEnabled);
@@ -1650,6 +1670,7 @@ void QQuickTextEdit::select(int start, int end)
// QTBUG-11100
updateSelection();
+ updateInputMethod();
}
/*!
@@ -1821,8 +1842,15 @@ QVariant QQuickTextEdit::inputMethodQuery(Qt::InputMethodQuery property, QVarian
case Qt::ImHints:
v = (int)d->effectiveInputMethodHints();
break;
+ case Qt::ImInputItemClipRectangle:
+ v = QQuickItem::inputMethodQuery(property);
+ break;
default:
+ if (property == Qt::ImCursorPosition && !argument.isNull())
+ argument = QVariant(argument.toPointF() - QPointF(d->xoff, d->yoff));
v = d->control->inputMethodQuery(property, argument);
+ if (property == Qt::ImCursorRectangle || property == Qt::ImAnchorRectangle)
+ v = QVariant(v.toRectF().translated(d->xoff, d->yoff));
break;
}
return v;
@@ -2166,6 +2194,7 @@ void QQuickTextEditPrivate::init()
qmlobject_connect(control, QQuickTextControl, SIGNAL(linkActivated(QString)), q, QQuickTextEdit, SIGNAL(linkActivated(QString)));
qmlobject_connect(control, QQuickTextControl, SIGNAL(linkHovered(QString)), q, QQuickTextEdit, SIGNAL(linkHovered(QString)));
qmlobject_connect(control, QQuickTextControl, SIGNAL(textChanged()), q, QQuickTextEdit, SLOT(q_textChanged()));
+ qmlobject_connect(control, QQuickTextControl, SIGNAL(preeditTextChanged()), q, QQuickTextEdit, SIGNAL(preeditTextChanged()));
#ifndef QT_NO_CLIPBOARD
qmlobject_connect(QGuiApplication::clipboard(), QClipboard, SIGNAL(dataChanged()), q, QQuickTextEdit, SLOT(q_canPasteChanged()));
#endif
@@ -2183,6 +2212,13 @@ void QQuickTextEditPrivate::init()
q->updateSize();
}
+void QQuickTextEditPrivate::resetInputMethod()
+{
+ Q_Q(QQuickTextEdit);
+ if (!q->isReadOnly() && q->hasActiveFocus() && qGuiApp)
+ QGuiApplication::inputMethod()->reset();
+}
+
void QQuickTextEdit::q_textChanged()
{
Q_D(QQuickTextEdit);
@@ -2938,4 +2974,22 @@ void QQuickTextEdit::resetBottomPadding()
d->setBottomPadding(0, true);
}
+/*!
+ \qmlmethod QtQuick::TextEdit::clear()
+ \since 5.7
+
+ Clears the contents of the text edit
+ and resets partial text input from an input method.
+
+ Use this method instead of setting the \l text property to an empty string.
+
+ \sa QInputMethod::reset()
+*/
+void QQuickTextEdit::clear()
+{
+ Q_D(QQuickTextEdit);
+ d->resetInputMethod();
+ d->control->clear();
+}
+
QT_END_NAMESPACE