mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-27 06:47:02 -05:00
Allow Enter key to select recent DB on OS X
* Override `keyPressEvent`on WelcomeWidget on OS X to `openDatabaseFromFile`. openDatabaseFromFile is already invoked via the QListWidget::itemActivated signal, but this signal doesn't fire on OS X for Enter. QListWidget::itemActivated activates on an OS specific activation key. [1] On Windows/X11, this is Enter, which lets the user easily navigate with just the keyboard. On OS X, this is Ctrl+O, which is already bound to Open Database. This means that itemActivated cannot fire via the keyboard. Per StackOverflow [2], the recommended solution is to catch the enter/return key press manually. This seems like a common problem with Qt. [3] [4] [1] https://doc.qt.io/archives/qt-4.8/qlistwidget.html#itemActivated [2] https://stackoverflow.com/questions/31650780/when-does-a-qtreeview-emit-the-activated-signal-on-mac [3] https://forum.qt.io/topic/36147/pyside-itemactivated-not-triggered-on-mac-os-x-with-return-key [4] https://github.com/dolphin-emu/dolphin/pull/6099
This commit is contained in:
parent
c34b0069ff
commit
b1ff346f63
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include "WelcomeWidget.h"
|
||||
#include "ui_WelcomeWidget.h"
|
||||
|
||||
@ -76,3 +77,11 @@ void WelcomeWidget::refreshLastDatabases()
|
||||
m_ui->recentListWidget->addItem(itm);
|
||||
}
|
||||
}
|
||||
|
||||
void WelcomeWidget::keyPressEvent(QKeyEvent *event) {
|
||||
if (m_ui->recentListWidget->hasFocus() && (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)) {
|
||||
openDatabaseFromFile(m_ui->recentListWidget->currentItem());
|
||||
}
|
||||
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
@ -43,6 +43,9 @@ signals:
|
||||
void importKeePass1Database();
|
||||
void importCsv();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void openDatabaseFromFile(QListWidgetItem* item);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user