In save dialogs the keyboard navigation would escape during file
highlighting, since the fileHighlight sets the focus for fileName bar
for mouse operations.
This makes sure the user has to press Tab to explicitly escape the
keyboard navigation mode. For clicking the items, it should not affect
at all.
CCBUG: 466206
FIXED-IN: 6.14
(cherry picked from commit
8e4e84f045b7459c0b02b1b1b51a9df73cea068a)
Gbp-Pq: Name upstream_719e0b00_KFileWidget-Fix-key-navigation-escaping-in-save-dialogs.patch
bool m_showOpenWithActions = false;
bool m_isTouchEvent = false;
bool m_isTouchDrag = false;
+ bool m_keyNavigation = false;
QList<QUrl> m_itemsToBeSetAsCurrent;
QStringList m_supportedSchemes;
d->m_showOpenWithActions = enable;
}
+bool KDirOperator::usingKeyNavigation()
+{
+ return d->m_keyNavigation;
+}
+
void KDirOperator::changeEvent(QEvent *event)
{
QWidget::changeEvent(event);
return true;
}
}
+ // Only use tab key to escape the view navigation
+ if (evt->key() == Qt::Key_Tab) {
+ d->m_keyNavigation = false;
+ d->slotSelectionChanged();
+ // When saving we need to return here,
+ // otherwise we skip over the next item with our tab press
+ // since we focus on that item in slotSelectionChanged
+ if (d->m_isSaving) {
+ return true;
+ }
+ } else {
+ d->m_keyNavigation = true;
+ }
break;
}
case QEvent::Resize: {
QApplication::restoreOverrideCursor();
Q_EMIT fileSelected(item);
+ d->m_keyNavigation = false;
}
void KDirOperator::highlightFile(const KFileItem &item)
}
Q_EMIT fileHighlighted(item);
+ d->m_keyNavigation = false;
}
void KDirOperator::setCurrentItem(const QUrl &url)
*/
void showOpenWithActions(bool enable);
+ /*!
+ * @returns true if the user was using keys to navigate.
+ *
+ * \since 6.14
+ */
+ bool usingKeyNavigation();
+
protected:
/**
* A view factory for creating predefined fileviews. Called internally by setView,
void enterUrl(const QString &);
void locationAccepted(const QString &);
void slotFilterChanged();
- void fileHighlighted(const KFileItem &);
+ void fileHighlighted(const KFileItem &, bool);
void fileSelected(const KFileItem &);
void slotLoadingFinished();
void togglePlacesPanel(bool show, QObject *sender = nullptr);
d->m_ops->close();
}
-void KFileWidgetPrivate::fileHighlighted(const KFileItem &i)
+void KFileWidgetPrivate::fileHighlighted(const KFileItem &i, bool isKeyNavigation)
{
if ((m_locationEdit->hasFocus() && !m_locationEdit->currentText().isEmpty())) { // don't disturb
return;
// rename it if desired
// Note that double-clicking will override this and overwrite regardless of
// single/double click mouse setting (see slotViewDoubleClicked() )
- if (m_operationMode == KFileWidget::Saving) {
+ if (!isKeyNavigation && m_operationMode == KFileWidget::Saving) {
m_locationEdit->setFocus();
}
}
urlEntered(url);
});
q->connect(m_ops, &KDirOperator::fileHighlighted, q, [this](const KFileItem &item) {
- fileHighlighted(item);
+ fileHighlighted(item, m_ops->usingKeyNavigation());
});
q->connect(m_ops, &KDirOperator::fileSelected, q, [this](const KFileItem &item) {
fileSelected(item);