From affff20b494965ccd4eee72230d7cb2d1a585d4f Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Sat, 1 Oct 2022 11:57:47 -0400 Subject: [PATCH] Fix focus traps * Fix focus issues with new PasswordWidget * Fix focus wrapping when DatabaseTabWidget is not showing the tab bar * Fix focus wrapping in EditWidget views to move between category list and contents. This is not a perfect fix, but Qt has a mind of its own with these complex widgets. This will be fixed in future Ui improvements that move away from the category widget. --- src/gui/DatabaseOpenWidget.cpp | 7 +---- src/gui/DatabaseOpenWidget.h | 1 - src/gui/DatabaseOpenWidget.ui | 26 +++++++++---------- src/gui/DatabaseTabWidget.cpp | 2 ++ src/gui/DatabaseWidget.cpp | 2 +- src/gui/EditWidget.ui | 14 ++++++++++ src/gui/PasswordGeneratorWidget.ui | 9 ++++--- src/gui/databasekey/PasswordEditWidget.ui | 22 ++++++++-------- src/gui/entry/EditEntryWidgetMain.ui | 20 +++++++------- src/keeshare/group/EditGroupWidgetKeeShare.ui | 12 ++++----- 10 files changed, 64 insertions(+), 51 deletions(-) diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index 4d313dd35..aff418627 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -213,6 +213,7 @@ void DatabaseOpenWidget::clearForms() m_ui->editPassword->setShowPassword(false); m_ui->keyFileLineEdit->clear(); m_ui->keyFileLineEdit->setShowPassword(false); + m_ui->keyFileLineEdit->setClearButtonEnabled(true); m_ui->challengeResponseCombo->clear(); m_ui->centralStack->setCurrentIndex(0); m_db.reset(); @@ -442,12 +443,6 @@ void DatabaseOpenWidget::browseKeyFile() } } -void DatabaseOpenWidget::clearKeyFileText() -{ - m_ui->keyFileLineEdit->clear(); - m_ui->keyFileLineEdit->setShowPassword(false); -} - void DatabaseOpenWidget::pollHardwareKey() { if (m_pollingHardwareKey) { diff --git a/src/gui/DatabaseOpenWidget.h b/src/gui/DatabaseOpenWidget.h index 756234c57..cf7579efe 100644 --- a/src/gui/DatabaseOpenWidget.h +++ b/src/gui/DatabaseOpenWidget.h @@ -70,7 +70,6 @@ protected slots: private slots: void browseKeyFile(); - void clearKeyFileText(); void pollHardwareKey(); void hardwareKeyResponse(bool found); void openHardwareKeyHelp(); diff --git a/src/gui/DatabaseOpenWidget.ui b/src/gui/DatabaseOpenWidget.ui index 7cd4f281e..ad4d4af7a 100644 --- a/src/gui/DatabaseOpenWidget.ui +++ b/src/gui/DatabaseOpenWidget.ui @@ -145,13 +145,13 @@ - + + + Qt::StrongFocus + Password field - - QLineEdit::Password - @@ -380,22 +380,19 @@ 0 - + - + 0 0 + + Qt::StrongFocus + Key file to unlock the database - - QLineEdit::Password - - - true - @@ -463,6 +460,9 @@ + + Qt::StrongFocus + QDialogButtonBox::Close|QDialogButtonBox::Ok @@ -618,7 +618,7 @@ PasswordWidget - QLineEdit + QWidget
gui/PasswordWidget.h
1
diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index 8437a701b..8d95aaef1 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -76,9 +76,11 @@ void DatabaseTabWidget::toggleTabbar() { if (count() > 1) { tabBar()->show(); + setFocusPolicy(Qt::StrongFocus); emit tabVisibilityChanged(true); } else { tabBar()->hide(); + setFocusPolicy(Qt::NoFocus); emit tabVisibilityChanged(false); } } diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 7f9d06fe4..e5e6e4847 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -1641,7 +1641,7 @@ bool DatabaseWidget::focusNextPrevChild(bool next) // Find the next visible element in the sequence and set the focus while (idx >= 0 && idx < sequence.size()) { widget = sequence[idx]; - if (widget && widget->isVisible() && widget->height() > 0 && widget->width() > 0) { + if (widget && widget->isVisible() && widget->isEnabled() && widget->height() > 0 && widget->width() > 0) { widget->setFocus(); return widget; } diff --git a/src/gui/EditWidget.ui b/src/gui/EditWidget.ui index 8bbec46bc..96aac0d36 100644 --- a/src/gui/EditWidget.ui +++ b/src/gui/EditWidget.ui @@ -66,10 +66,16 @@ 0 + + Qt::TabFocus +
+ + Qt::TabFocus + -1 @@ -84,6 +90,9 @@ + + Qt::TabFocus + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -107,6 +116,11 @@ 1 + + categoryList + stackedWidget + buttonBox + diff --git a/src/gui/PasswordGeneratorWidget.ui b/src/gui/PasswordGeneratorWidget.ui index 19cb0bef3..642129de6 100644 --- a/src/gui/PasswordGeneratorWidget.ui +++ b/src/gui/PasswordGeneratorWidget.ui @@ -87,9 +87,9 @@ - + - + 0 0 @@ -100,6 +100,9 @@ 0 + + Qt::StrongFocus + Generated password @@ -991,7 +994,7 @@ QProgressBar::chunk { PasswordWidget - QLineEdit + QWidget
gui/PasswordWidget.h
1
diff --git a/src/gui/databasekey/PasswordEditWidget.ui b/src/gui/databasekey/PasswordEditWidget.ui index e3b1679e1..e191968f8 100644 --- a/src/gui/databasekey/PasswordEditWidget.ui +++ b/src/gui/databasekey/PasswordEditWidget.ui @@ -31,9 +31,9 @@
- + - + 0 0 @@ -44,12 +44,12 @@ 0 + + Qt::StrongFocus + Password field - - QLineEdit::Password - @@ -60,9 +60,9 @@
- + - + 0 0 @@ -73,12 +73,12 @@ 0 + + Qt::StrongFocus + Repeat password field - - QLineEdit::Password - @@ -86,7 +86,7 @@ PasswordWidget - QLineEdit + QWidget
gui/PasswordWidget.h
1
diff --git a/src/gui/entry/EditEntryWidgetMain.ui b/src/gui/entry/EditEntryWidgetMain.ui index 894f56115..19dbf31fd 100644 --- a/src/gui/entry/EditEntryWidgetMain.ui +++ b/src/gui/entry/EditEntryWidgetMain.ui @@ -243,13 +243,13 @@
- + + + Qt::StrongFocus + Password field - - QLineEdit::Password - @@ -296,12 +296,6 @@ - - PasswordWidget - QLineEdit -
gui/PasswordWidget.h
- 1 -
TagsEdit QWidget @@ -314,6 +308,12 @@
gui/URLEdit.h
1
+ + PasswordWidget + QWidget +
gui/PasswordWidget.h
+ 1 +
titleEdit diff --git a/src/keeshare/group/EditGroupWidgetKeeShare.ui b/src/keeshare/group/EditGroupWidgetKeeShare.ui index 4f655ee4d..857ba61c8 100644 --- a/src/keeshare/group/EditGroupWidgetKeeShare.ui +++ b/src/keeshare/group/EditGroupWidgetKeeShare.ui @@ -51,9 +51,9 @@
- + - + 0 0 @@ -64,12 +64,12 @@ 0 + + Qt::StrongFocus + Password field - - QLineEdit::Password - @@ -191,7 +191,7 @@ PasswordWidget - QLineEdit + QWidget
gui/PasswordWidget.h
1