diff --git a/ui/searchlineedit.cpp b/ui/searchlineedit.cpp index baefce2db..6d344b28e 100644 --- a/ui/searchlineedit.cpp +++ b/ui/searchlineedit.cpp @@ -37,6 +37,7 @@ SearchLineEdit::SearchLineEdit( QWidget * parent, Okular::Document * document ) this, SLOT( startSearch() ) ); connect(this, SIGNAL( textChanged(const QString &) ), this, SLOT( slotTextChanged(const QString &) )); + connect(this, SIGNAL( returnPressed(const QString &) ), this, SLOT( slotReturnPressed(const QString &) )); connect(document, SIGNAL( searchFinished(int, Okular::Document::SearchStatus) ), this, SLOT( searchFinished(int, Okular::Document::SearchStatus) )); } @@ -143,9 +144,15 @@ void SearchLineEdit::findPrev() } void SearchLineEdit::slotTextChanged( const QString & text ) +{ + prepareLineEditForSearch(); + restartSearch(); +} + +void SearchLineEdit::prepareLineEditForSearch() { QPalette pal = palette(); - const int textLength = text.length(); + const int textLength = text().length(); if ( textLength > 0 && textLength < m_minLength ) { const KColorScheme scheme( QPalette::Active, KColorScheme::View ); @@ -159,7 +166,13 @@ void SearchLineEdit::slotTextChanged( const QString & text ) pal.setColor( QPalette::Text, qAppPalette.color( QPalette::Text ) ); } setPalette( pal ); - restartSearch(); +} + +void SearchLineEdit::slotReturnPressed( const QString &text ) +{ + m_inputDelayTimer->stop(); + prepareLineEditForSearch(); + findNext(); } void SearchLineEdit::startSearch() diff --git a/ui/searchlineedit.h b/ui/searchlineedit.h index 96120d9fa..b23fe71e2 100644 --- a/ui/searchlineedit.h +++ b/ui/searchlineedit.h @@ -50,6 +50,8 @@ class SearchLineEdit : public KLineEdit void findPrev(); private: + void prepareLineEditForSearch(); + Okular::Document * m_document; QTimer * m_inputDelayTimer; int m_minLength; @@ -64,6 +66,7 @@ class SearchLineEdit : public KLineEdit private slots: void slotTextChanged( const QString & text ); + void slotReturnPressed( const QString &text ); void startSearch(); void searchFinished( int id, Okular::Document::SearchStatus endStatus ); };