Skip to content

Commit

Permalink
Ignore focus when checking toolbar state
Browse files Browse the repository at this point in the history
  • Loading branch information
ba32107 committed Nov 17, 2019
1 parent 39af47f commit 79860d6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,9 +1517,9 @@ bool DatabaseWidget::isGroupSelected() const
return m_groupView->currentGroup();
}

bool DatabaseWidget::currentEntryHasFocus()
bool DatabaseWidget::atLeastOneEntrySelected()
{
return m_entryView->numberOfSelectedEntries() > 0 && m_entryView->hasFocus();
return m_entryView->numberOfSelectedEntries() > 0;
}

bool DatabaseWidget::currentEntryHasTitle()
Expand Down
2 changes: 1 addition & 1 deletion src/gui/DatabaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class DatabaseWidget : public QStackedWidget
bool isPasswordsHidden() const;
void setPasswordsHidden(bool hide);
void clearAllWidgets();
bool currentEntryHasFocus();
bool atLeastOneEntrySelected();
bool currentEntryHasTitle();
bool currentEntryHasUsername();
bool currentEntryHasPassword();
Expand Down
8 changes: 3 additions & 5 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,8 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)

switch (mode) {
case DatabaseWidget::Mode::ViewMode: {
bool hasFocus = m_contextMenuFocusLock || menuBar()->hasFocus() || m_searchWidget->hasFocus()
|| dbWidget->currentEntryHasFocus();
bool singleEntrySelected = dbWidget->numberOfSelectedEntries() == 1 && hasFocus;
bool entriesSelected = dbWidget->numberOfSelectedEntries() > 0 && hasFocus;
bool singleEntrySelected = dbWidget->numberOfSelectedEntries() == 1;
bool entriesSelected = dbWidget->atLeastOneEntrySelected();
bool groupSelected = dbWidget->isGroupSelected();
bool currentGroupHasChildren = dbWidget->currentGroup()->hasChildren();
bool currentGroupHasEntries = !dbWidget->currentGroup()->entries().isEmpty();
Expand Down Expand Up @@ -1129,7 +1127,7 @@ void MainWindow::showEntryContextMenu(const QPoint& globalPos)
bool entrySelected = false;
auto dbWidget = m_ui->tabWidget->currentDatabaseWidget();
if (dbWidget) {
entrySelected = dbWidget->currentEntryHasFocus();
entrySelected = dbWidget->atLeastOneEntrySelected();
}

if (entrySelected) {
Expand Down

0 comments on commit 79860d6

Please sign in to comment.