aboutsummaryrefslogtreecommitdiff
path: root/src/widgets/searchbox.cpp
blob: 67e48f9322ad6a8f891f135541daf98c1529a29f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "searchbox.hpp"

#include <QKeyEvent>
#include <QDebug>

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);
    }
}