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

Enhance Tags / Saved Searches #8435

Merged
merged 5 commits into from
Sep 8, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix tabbing around database widget
Fixes #8352
  • Loading branch information
droidmonkey committed Sep 7, 2022
commit a202980c0de474a232d9e28a7b9514ee067a783d
49 changes: 23 additions & 26 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,11 +559,7 @@ void DatabaseWidget::deleteEntries(QList<Entry*> selectedEntries, bool confirm)

void DatabaseWidget::setFocus(Qt::FocusReason reason)
{
if (reason == Qt::BacktabFocusReason) {
m_previewView->setFocus();
} else {
m_groupView->setFocus();
}
focusNextPrevChild(reason == Qt::TabFocusReason);
}

void DatabaseWidget::focusOnEntries(bool editIfFocused)
Expand Down Expand Up @@ -1617,31 +1613,32 @@ void DatabaseWidget::showEvent(QShowEvent* event)
bool DatabaseWidget::focusNextPrevChild(bool next)
{
// [parent] <-> GroupView <-> TagView <-> EntryView <-> EntryPreview <-> [parent]
if (next) {
if (m_groupView->hasFocus()) {
m_tagView->setFocus();
return true;
} else if (m_tagView->hasFocus()) {
m_entryView->setFocus();
return true;
} else if (m_entryView->hasFocus()) {
m_previewView->setFocus();
return true;
}
QList<QWidget*> sequence = {m_groupView, m_tagView, m_entryView, m_previewView};
auto widget = qApp->focusWidget();

int idx;
do {
idx = sequence.indexOf(widget);
widget = widget->parentWidget();
} while (idx == -1 && widget);

if (idx == -1) {
idx = next ? 0 : sequence.size() - 1;
} else {
if (m_previewView->hasFocus()) {
m_entryView->setFocus();
return true;
} else if (m_entryView->hasFocus()) {
m_tagView->setFocus();
return true;
} else if (m_tagView->hasFocus()) {
m_groupView->setFocus();
return true;
idx = next ? idx + 1 : idx - 1;
}

// Find the next visible element in the sequence and set the focus
while (idx >= 0 && idx < sequence.size()) {
widget = sequence[idx];
if (widget->isVisible() && widget->height() > 0 && widget->width() > 0) {
widget->setFocus();
return widget;
}
idx = next ? idx + 1 : idx - 1;
}

// Defer to the parent widget to make a decision
// Ran out of options, defer to the parent widget
return QStackedWidget::focusNextPrevChild(next);
}

Expand Down