From: Chinmoy Ranjan Pradhan Date: Sun, 5 May 2019 13:00:19 +0000 (+0530) Subject: [Inline Rename] Move cursor to correct position on pressing Home and End X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/d7555d8e11311c16f6dadc14abd9b3fb9a03a085 [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 --- 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; }