From 0843ee2dada57255c29425f7b598ab3b258e4641 Mon Sep 17 00:00:00 2001 From: Mike Skec Date: Tue, 9 Feb 2021 17:49:07 +1100 Subject: Search box: better reimplementation This was necessary to fix a bug, where the URL bar becomes unusable while search box is visible. --- src/widgets/searchbox.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/widgets/searchbox.cpp (limited to 'src/widgets/searchbox.cpp') diff --git a/src/widgets/searchbox.cpp b/src/widgets/searchbox.cpp new file mode 100644 index 0000000..67e48f9 --- /dev/null +++ b/src/widgets/searchbox.cpp @@ -0,0 +1,31 @@ +#include "searchbox.hpp" + +#include +#include + +SearchBox::SearchBox(QWidget * parent) : QLineEdit(parent) +{} + +void SearchBox::keyPressEvent(QKeyEvent *event) +{ + if(event->key() == Qt::Key_Return || event->key() == Qt::Key_F3) { + if (event->modifiers() == Qt::ShiftModifier) { + emit searchPrev(); + } + else { + emit searchNext(); + } + } else { + QLineEdit::keyPressEvent(event); + } +} + +void SearchBox::keyReleaseEvent(QKeyEvent *event) +{ + if(event->key() == Qt::Key_Return) { + // Eat the event + } else { + QLineEdit::keyReleaseEvent(event); + } +} + -- cgit v1.2.3