Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2022-08-19 05:18:01 +0300
committerJonathan White <support@dmapps.us>2022-09-22 13:49:07 +0300
commit64dda095657c8ba5193c2cb61b95eb8016ad6d48 (patch)
treeb52d0f3ddf299af6d1b68ebaf225c05decf885fc
parentde168959a59120bb8352ee97e4eecf2b967bfe2b (diff)
Fix tabbing around database widget
Fixes #8352
-rw-r--r--src/gui/DatabaseWidget.cpp49
1 files changed, 23 insertions, 26 deletions
diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp
index 4618ef3fa..09f1b9f21 100644
--- a/src/gui/DatabaseWidget.cpp
+++ b/src/gui/DatabaseWidget.cpp
@@ -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)
@@ -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);
}