mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-03 12:06:25 -04: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
3 changed files with 20 additions and 10 deletions
|
@ -155,9 +155,9 @@ MainWindow::MainWindow()
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
// Setup the search widget in the toolbar
|
// Setup the search widget in the toolbar
|
||||||
auto* search = new SearchWidget();
|
m_searchWidget = new SearchWidget();
|
||||||
search->connectSignals(m_actionMultiplexer);
|
m_searchWidget->connectSignals(m_actionMultiplexer);
|
||||||
m_searchWidgetAction = m_ui->toolBar->addWidget(search);
|
m_searchWidgetAction = m_ui->toolBar->addWidget(m_searchWidget);
|
||||||
m_searchWidgetAction->setEnabled(false);
|
m_searchWidgetAction->setEnabled(false);
|
||||||
|
|
||||||
m_countDefaultAttributes = m_ui->menuEntryCopyAttribute->actions().size();
|
m_countDefaultAttributes = m_ui->menuEntryCopyAttribute->actions().size();
|
||||||
|
@ -253,7 +253,9 @@ MainWindow::MainWindow()
|
||||||
m_ui->actionEntryCopyURL->setShortcutVisibleInContextMenu(true);
|
m_ui->actionEntryCopyURL->setShortcutVisibleInContextMenu(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
connect(m_ui->menuEntries, SIGNAL(aboutToShow()), SLOT(obtainContextFocusLock()));
|
||||||
connect(m_ui->menuEntries, SIGNAL(aboutToHide()), SLOT(releaseContextFocusLock()));
|
connect(m_ui->menuEntries, SIGNAL(aboutToHide()), SLOT(releaseContextFocusLock()));
|
||||||
|
connect(m_ui->menuGroups, SIGNAL(aboutToShow()), SLOT(obtainContextFocusLock()));
|
||||||
connect(m_ui->menuGroups, SIGNAL(aboutToHide()), SLOT(releaseContextFocusLock()));
|
connect(m_ui->menuGroups, SIGNAL(aboutToHide()), SLOT(releaseContextFocusLock()));
|
||||||
|
|
||||||
// Control window state
|
// Control window state
|
||||||
|
@ -308,9 +310,9 @@ MainWindow::MainWindow()
|
||||||
// Notify search when the active database changes or gets locked
|
// Notify search when the active database changes or gets locked
|
||||||
connect(m_ui->tabWidget,
|
connect(m_ui->tabWidget,
|
||||||
SIGNAL(activateDatabaseChanged(DatabaseWidget*)),
|
SIGNAL(activateDatabaseChanged(DatabaseWidget*)),
|
||||||
search,
|
m_searchWidget,
|
||||||
SLOT(databaseChanged(DatabaseWidget*)));
|
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(tabNameChanged()), SLOT(updateWindowTitle()));
|
||||||
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)), SLOT(updateWindowTitle()));
|
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)), SLOT(updateWindowTitle()));
|
||||||
|
@ -545,9 +547,10 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case DatabaseWidget::Mode::ViewMode: {
|
case DatabaseWidget::Mode::ViewMode: {
|
||||||
// bool inSearch = dbWidget->isInSearchMode();
|
bool hasFocus = m_contextMenuFocusLock || menuBar()->hasFocus() || m_searchWidget->hasFocus()
|
||||||
bool singleEntrySelected = dbWidget->numberOfSelectedEntries() == 1 && (m_contextMenuFocusLock || dbWidget->currentEntryHasFocus());
|
|| dbWidget->currentEntryHasFocus();
|
||||||
bool entriesSelected = dbWidget->numberOfSelectedEntries() > 0 && (m_contextMenuFocusLock || dbWidget->currentEntryHasFocus());
|
bool singleEntrySelected = dbWidget->numberOfSelectedEntries() == 1 && hasFocus;
|
||||||
|
bool entriesSelected = dbWidget->numberOfSelectedEntries() > 0 && hasFocus;
|
||||||
bool groupSelected = dbWidget->isGroupSelected();
|
bool groupSelected = dbWidget->isGroupSelected();
|
||||||
bool recycleBinSelected = dbWidget->isRecycleBinSelected();
|
bool recycleBinSelected = dbWidget->isRecycleBinSelected();
|
||||||
|
|
||||||
|
@ -990,6 +993,11 @@ void MainWindow::updateTrayIcon()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::obtainContextFocusLock()
|
||||||
|
{
|
||||||
|
m_contextMenuFocusLock = true;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::releaseContextFocusLock()
|
void MainWindow::releaseContextFocusLock()
|
||||||
{
|
{
|
||||||
m_contextMenuFocusLock = false;
|
m_contextMenuFocusLock = false;
|
||||||
|
@ -997,13 +1005,11 @@ void MainWindow::releaseContextFocusLock()
|
||||||
|
|
||||||
void MainWindow::showEntryContextMenu(const QPoint& globalPos)
|
void MainWindow::showEntryContextMenu(const QPoint& globalPos)
|
||||||
{
|
{
|
||||||
m_contextMenuFocusLock = true;
|
|
||||||
m_ui->menuEntries->popup(globalPos);
|
m_ui->menuEntries->popup(globalPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showGroupContextMenu(const QPoint& globalPos)
|
void MainWindow::showGroupContextMenu(const QPoint& globalPos)
|
||||||
{
|
{
|
||||||
m_contextMenuFocusLock = true;
|
|
||||||
m_ui->menuGroups->popup(globalPos);
|
m_ui->menuGroups->popup(globalPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace Ui
|
||||||
}
|
}
|
||||||
|
|
||||||
class InactivityTimer;
|
class InactivityTimer;
|
||||||
|
class SearchWidget;
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
|
@ -117,6 +118,7 @@ private slots:
|
||||||
void selectPreviousDatabaseTab();
|
void selectPreviousDatabaseTab();
|
||||||
void togglePasswordsHidden();
|
void togglePasswordsHidden();
|
||||||
void toggleUsernamesHidden();
|
void toggleUsernamesHidden();
|
||||||
|
void obtainContextFocusLock();
|
||||||
void releaseContextFocusLock();
|
void releaseContextFocusLock();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -144,6 +146,7 @@ private:
|
||||||
int m_countDefaultAttributes;
|
int m_countDefaultAttributes;
|
||||||
QSystemTrayIcon* m_trayIcon;
|
QSystemTrayIcon* m_trayIcon;
|
||||||
ScreenLockListener* m_screenLockListener;
|
ScreenLockListener* m_screenLockListener;
|
||||||
|
QPointer<SearchWidget> m_searchWidget;
|
||||||
|
|
||||||
Q_DISABLE_COPY(MainWindow)
|
Q_DISABLE_COPY(MainWindow)
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ SearchWidget::SearchWidget(QWidget* parent)
|
||||||
, m_clearSearchTimer(new QTimer(this))
|
, m_clearSearchTimer(new QTimer(this))
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
setFocusProxy(m_ui->searchEdit);
|
||||||
|
|
||||||
m_helpWidget = new PopupHelpWidget(m_ui->searchEdit);
|
m_helpWidget = new PopupHelpWidget(m_ui->searchEdit);
|
||||||
m_helpWidget->setOffset(QPoint(0, 1));
|
m_helpWidget->setOffset(QPoint(0, 1));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue