From d7555d8e11311c16f6dadc14abd9b3fb9a03a085 Mon Sep 17 00:00:00 2001 From: Chinmoy Ranjan Pradhan Date: Sun, 5 May 2019 18:30:19 +0530 Subject: [Inline Rename] Move cursor to correct position on pressing Home and End Summary: When pressing home or end key on a wrapped file name the cursor should move to beginning or end of the whole file name instead of the last line (which is the default behaviour of any textedit widget). BUG: 363179 Reviewers: #dolphin, elvisangelaccio Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D21031 --- src/kitemviews/private/kitemlistroleeditor.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/kitemviews/private/kitemlistroleeditor.cpp b/src/kitemviews/private/kitemlistroleeditor.cpp index e79a9f9d1..eb6f1de76 100644 --- a/src/kitemviews/private/kitemlistroleeditor.cpp +++ b/src/kitemviews/private/kitemlistroleeditor.cpp @@ -107,6 +107,23 @@ void KItemListRoleEditor::keyPressEvent(QKeyEvent* event) } break; } + case Qt::Key_Home: + case Qt::Key_End: { + if (event->modifiers() == Qt::NoModifier || event->modifiers() == Qt::ShiftModifier) { + const QTextCursor::MoveOperation op = event->key() == Qt::Key_Home + ? QTextCursor::Start + : QTextCursor::End; + const QTextCursor::MoveMode mode = event->modifiers() == Qt::NoModifier + ? QTextCursor::MoveAnchor + : QTextCursor::KeepAnchor; + QTextCursor cursor = textCursor(); + cursor.movePosition(op, mode); + setTextCursor(cursor); + event->accept(); + return; + } + break; + } default: break; } -- cgit v1.3