aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoni Poikelin <joni.poikelin@theqtcompany.com>2016-02-18 13:18:33 +0200
committerJoni Poikelin <joni.poikelin@theqtcompany.com>2016-03-07 05:04:07 +0000
commit443ba99b1ef825e198fe1999c34ee44547135797 (patch)
tree3a334c71d19c606693802a67db5aa9c67f2fe998
parentf8a6b3b9ab967c65708e9b72a2557f564d22a8ea (diff)
Prevent cutting in non-Normal echoMode of TextInput
Cutting the text in Password mode led to the text being deleted. Cut and copy operations should not be allowed when echoMode is set to a mode other than Normal. Task-number: QTBUG-51231 Change-Id: If75cdaedac7478ecc1a5126ad4a5ecbf32acd1ab Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
-rw-r--r--src/quick/items/qquicktextinput.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index ba7142856b..ffc94dfd46 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -1886,11 +1886,15 @@ bool QQuickTextInput::isRightToLeft(int start, int end)
\qmlmethod QtQuick::TextInput::cut()
Moves the currently selected text to the system clipboard.
+
+ \note If the echo mode is set to a mode other than Normal then cut
+ will not work. This is to prevent using cut as a method of bypassing
+ password features of the line control.
*/
void QQuickTextInput::cut()
{
Q_D(QQuickTextInput);
- if (!d->m_readOnly) {
+ if (!d->m_readOnly && d->m_echoMode == QQuickTextInput::Normal) {
d->copy();
d->del();
}
@@ -1900,6 +1904,10 @@ void QQuickTextInput::cut()
\qmlmethod QtQuick::TextInput::copy()
Copies the currently selected text to the system clipboard.
+
+ \note If the echo mode is set to a mode other than Normal then copy
+ will not work. This is to prevent using copy as a method of bypassing
+ password features of the line control.
*/
void QQuickTextInput::copy()
{
@@ -4251,10 +4259,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event)
}
}
else if (event == QKeySequence::Cut) {
- if (!m_readOnly) {
- copy();
- del();
- }
+ q->cut();
}
else if (event == QKeySequence::DeleteEndOfLine) {
if (!m_readOnly)