Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix remaining issues with menu keyboard navigation #3248

Merged
merged 2 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -990,20 +993,23 @@ void MainWindow::updateTrayIcon()
}
}

void MainWindow::obtainContextFocusLock()
{
m_contextMenuFocusLock = true;
}

void MainWindow::releaseContextFocusLock()
{
m_contextMenuFocusLock = false;
}

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);
}

Expand Down
3 changes: 3 additions & 0 deletions src/gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace Ui
}

class InactivityTimer;
class SearchWidget;

class MainWindow : public QMainWindow
{
Expand Down Expand Up @@ -117,6 +118,7 @@ private slots:
void selectPreviousDatabaseTab();
void togglePasswordsHidden();
void toggleUsernamesHidden();
void obtainContextFocusLock();
void releaseContextFocusLock();

private:
Expand Down Expand Up @@ -144,6 +146,7 @@ private slots:
int m_countDefaultAttributes;
QSystemTrayIcon* m_trayIcon;
ScreenLockListener* m_screenLockListener;
QPointer<SearchWidget> m_searchWidget;

Q_DISABLE_COPY(MainWindow)

Expand Down
1 change: 1 addition & 0 deletions src/gui/SearchWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down