From 5a0da4a9c8d10dc1921077d84bdabf05d20150b0 Mon Sep 17 00:00:00 2001 From: Méven Car Date: Mon, 19 Apr 2021 05:10:11 +0000 Subject: When renaming files, move to next file using tab key or up/down To rename previous file: Up or Shift-Tab To rename next file: Down or Tab Credit goes to msciubidlo FEATURE: 403931 FEATURE: 269987 BUG: 334533 FIXED-IN: 21.08 --- src/kitemviews/private/kitemlistroleeditor.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/kitemviews/private/kitemlistroleeditor.cpp') diff --git a/src/kitemviews/private/kitemlistroleeditor.cpp b/src/kitemviews/private/kitemlistroleeditor.cpp index df142a456..cc10bd58a 100644 --- a/src/kitemviews/private/kitemlistroleeditor.cpp +++ b/src/kitemviews/private/kitemlistroleeditor.cpp @@ -40,6 +40,11 @@ QByteArray KItemListRoleEditor::role() const return m_role; } +void KItemListRoleEditor::setAllowUpDownKeyChainEdit(bool allowChainEdit) +{ + m_allowUpDownKeyChainEdit = allowChainEdit; +} + bool KItemListRoleEditor::eventFilter(QObject* watched, QEvent* event) { if (watched == parentWidget() && event->type() == QEvent::Resize) { @@ -78,6 +83,20 @@ void KItemListRoleEditor::keyPressEvent(QKeyEvent* event) emitRoleEditingFinished(); event->accept(); return; + case Qt::Key_Tab: + case Qt::Key_Down: + if (m_allowUpDownKeyChainEdit || event->key() == Qt::Key_Tab) { + emitRoleEditingFinished(EditNext); + event->accept(); + return; + } + case Qt::Key_Backtab: + case Qt::Key_Up: + if (m_allowUpDownKeyChainEdit || event->key() == Qt::Key_Backtab) { + emitRoleEditingFinished(EditPrevious); + event->accept(); + return; + } case Qt::Key_Left: case Qt::Key_Right: { QTextCursor cursor = textCursor(); @@ -143,10 +162,13 @@ void KItemListRoleEditor::autoAdjustSize() } } -void KItemListRoleEditor::emitRoleEditingFinished() +void KItemListRoleEditor::emitRoleEditingFinished(EditResultDirection direction) { + QVariant ret; + ret.setValue(EditResult {KIO::encodeFileName(toPlainText()), direction}); + if (!m_blockFinishedSignal) { - Q_EMIT roleEditingFinished(m_role, KIO::encodeFileName(toPlainText())); + Q_EMIT roleEditingFinished(m_role, ret); } } -- cgit v1.3