mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-13 08:19:50 -05:00
Fix remaining issues with menu keyboard navigation (#3248)
* Fix remaining issues with menu keyboard navigation * Entry menu now locks focus on entry when used from menubar * When using keyboard navigation to select menubar menus, do not lose focus on selected entry (fixes #3246) * Enable all entry keyboard shortcuts while in search (fixes #3034) * When the search text edit has focus, retain selected entry keyboard shortcuts and button pressing capability
This commit is contained in:
parent
fbf8cb3d6f
commit
6d449aca49
@ -155,9 +155,9 @@ MainWindow::MainWindow()
|
||||
setAcceptDrops(true);
|
||||
|
||||
// Setup the search widget in the toolbar
|
||||
auto* search = new SearchWidget();
|
||||
search->connectSignals(m_actionMultiplexer);
|
||||
m_searchWidgetAction = m_ui->toolBar->addWidget(search);
|
||||
m_searchWidget = new SearchWidget();
|
||||
m_searchWidget->connectSignals(m_actionMultiplexer);
|
||||
m_searchWidgetAction = m_ui->toolBar->addWidget(m_searchWidget);
|
||||
m_searchWidgetAction->setEnabled(false);
|
||||
|
||||
m_countDefaultAttributes = m_ui->menuEntryCopyAttribute->actions().size();
|
||||
@ -253,7 +253,9 @@ MainWindow::MainWindow()
|
||||
m_ui->actionEntryCopyURL->setShortcutVisibleInContextMenu(true);
|
||||
#endif
|
||||
|
||||
connect(m_ui->menuEntries, SIGNAL(aboutToShow()), SLOT(obtainContextFocusLock()));
|
||||
connect(m_ui->menuEntries, SIGNAL(aboutToHide()), SLOT(releaseContextFocusLock()));
|
||||
connect(m_ui->menuGroups, SIGNAL(aboutToShow()), SLOT(obtainContextFocusLock()));
|
||||
connect(m_ui->menuGroups, SIGNAL(aboutToHide()), SLOT(releaseContextFocusLock()));
|
||||
|
||||
// Control window state
|
||||
@ -308,9 +310,9 @@ MainWindow::MainWindow()
|
||||
// Notify search when the active database changes or gets locked
|
||||
connect(m_ui->tabWidget,
|
||||
SIGNAL(activateDatabaseChanged(DatabaseWidget*)),
|
||||
search,
|
||||
m_searchWidget,
|
||||
SLOT(databaseChanged(DatabaseWidget*)));
|
||||
connect(m_ui->tabWidget, SIGNAL(databaseLocked(DatabaseWidget*)), search, SLOT(databaseChanged()));
|
||||
connect(m_ui->tabWidget, SIGNAL(databaseLocked(DatabaseWidget*)), m_searchWidget, SLOT(databaseChanged()));
|
||||
|
||||
connect(m_ui->tabWidget, SIGNAL(tabNameChanged()), SLOT(updateWindowTitle()));
|
||||
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)), SLOT(updateWindowTitle()));
|
||||
@ -545,9 +547,10 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
||||
|
||||
switch (mode) {
|
||||
case DatabaseWidget::Mode::ViewMode: {
|
||||
// bool inSearch = dbWidget->isInSearchMode();
|
||||
bool singleEntrySelected = dbWidget->numberOfSelectedEntries() == 1 && (m_contextMenuFocusLock || dbWidget->currentEntryHasFocus());
|
||||
bool entriesSelected = dbWidget->numberOfSelectedEntries() > 0 && (m_contextMenuFocusLock || dbWidget->currentEntryHasFocus());
|
||||
bool hasFocus = m_contextMenuFocusLock || menuBar()->hasFocus() || m_searchWidget->hasFocus()
|
||||
|| dbWidget->currentEntryHasFocus();
|
||||
bool singleEntrySelected = dbWidget->numberOfSelectedEntries() == 1 && hasFocus;
|
||||
bool entriesSelected = dbWidget->numberOfSelectedEntries() > 0 && hasFocus;
|
||||
bool groupSelected = dbWidget->isGroupSelected();
|
||||
bool recycleBinSelected = dbWidget->isRecycleBinSelected();
|
||||
|
||||
@ -990,6 +993,11 @@ void MainWindow::updateTrayIcon()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::obtainContextFocusLock()
|
||||
{
|
||||
m_contextMenuFocusLock = true;
|
||||
}
|
||||
|
||||
void MainWindow::releaseContextFocusLock()
|
||||
{
|
||||
m_contextMenuFocusLock = false;
|
||||
@ -997,13 +1005,11 @@ void MainWindow::releaseContextFocusLock()
|
||||
|
||||
void MainWindow::showEntryContextMenu(const QPoint& globalPos)
|
||||
{
|
||||
m_contextMenuFocusLock = true;
|
||||
m_ui->menuEntries->popup(globalPos);
|
||||
}
|
||||
|
||||
void MainWindow::showGroupContextMenu(const QPoint& globalPos)
|
||||
{
|
||||
m_contextMenuFocusLock = true;
|
||||
m_ui->menuGroups->popup(globalPos);
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ namespace Ui
|
||||
}
|
||||
|
||||
class InactivityTimer;
|
||||
class SearchWidget;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
@ -117,6 +118,7 @@ private slots:
|
||||
void selectPreviousDatabaseTab();
|
||||
void togglePasswordsHidden();
|
||||
void toggleUsernamesHidden();
|
||||
void obtainContextFocusLock();
|
||||
void releaseContextFocusLock();
|
||||
|
||||
private:
|
||||
@ -144,6 +146,7 @@ private:
|
||||
int m_countDefaultAttributes;
|
||||
QSystemTrayIcon* m_trayIcon;
|
||||
ScreenLockListener* m_screenLockListener;
|
||||
QPointer<SearchWidget> m_searchWidget;
|
||||
|
||||
Q_DISABLE_COPY(MainWindow)
|
||||
|
||||
|
@ -35,6 +35,7 @@ SearchWidget::SearchWidget(QWidget* parent)
|
||||
, m_clearSearchTimer(new QTimer(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setFocusProxy(m_ui->searchEdit);
|
||||
|
||||
m_helpWidget = new PopupHelpWidget(m_ui->searchEdit);
|
||||
m_helpWidget->setOffset(QPoint(0, 1));
|
||||
|
Loading…
Reference in New Issue
Block a user