diff options
| author | Méven Car <[email protected]> | 2021-04-19 05:10:11 +0000 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2021-04-19 05:10:11 +0000 |
| commit | 5a0da4a9c8d10dc1921077d84bdabf05d20150b0 (patch) | |
| tree | f80eeabb2a24b1da2a0adf248f43fa1db64b623b /src/kitemviews/private/kitemlistroleeditor.cpp | |
| parent | a27b4c5c608174e0164a02275749238b423d01a5 (diff) | |
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
Diffstat (limited to 'src/kitemviews/private/kitemlistroleeditor.cpp')
| -rw-r--r-- | src/kitemviews/private/kitemlistroleeditor.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
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); } } |
