Move focus from hiding selection mode bars to view

When a user exits selection mode for example by clicking the "Exit
Selection Mode" button, the bar is closed but the focus doesn't return
to the view which would be expected. This commit actively moves the
focus to the view in such a scenario.

BUG: 469621
This commit is contained in:
Felix Ernst 2023-06-23 19:07:10 +02:00 committed by Felix Ernst
parent ea56e1f75e
commit 0bf439833c

View file

@ -37,6 +37,7 @@
#include <KProtocolManager>
#include <KShell>
#include <QApplication>
#include <QDesktopServices>
#include <QDropEvent>
#include <QGridLayout>
@ -343,6 +344,9 @@ void DolphinViewContainer::setSelectionModeEnabled(bool enabled, KActionCollecti
}
Q_CHECK_PTR(m_selectionModeTopBar); // there is no point in disabling selectionMode when it wasn't even enabled once.
Q_CHECK_PTR(m_selectionModeBottomBar);
if (m_selectionModeTopBar->isAncestorOf(QApplication::focusWidget()) || m_selectionModeBottomBar->isAncestorOf(QApplication::focusWidget())) {
m_view->setFocus();
}
m_selectionModeTopBar->setVisible(false, WithAnimation);
m_selectionModeBottomBar->setVisible(false, WithAnimation);
Q_EMIT selectionModeChanged(false);