Keep the find bar working after ESC is pressed in PageView

Instead of directly killing the search in the core, emit a signal
caught by FindBar to tell its SearchLineEdit to reset the search
operation.
In this way, SearchLineEdit can set m_changed, and next time a new
search operation will be started, instead of attempting to use the
old one.
This commit is contained in:
Fabio D'Urso 2012-07-12 20:46:24 +02:00
parent beffbf10ff
commit 76b7982f57
7 changed files with 23 additions and 1 deletions

View file

@ -440,6 +440,7 @@ m_cliPresentation(false), m_embedMode(detectEmbedMode(parentWidget, parent, args
connect( m_findBar, SIGNAL(forwardKeyPressEvent(QKeyEvent*)), m_pageView, SLOT(externalKeyPressEvent(QKeyEvent*)));
connect( m_miniBar, SIGNAL(forwardKeyPressEvent(QKeyEvent*)), m_pageView, SLOT(externalKeyPressEvent(QKeyEvent*)));
connect( m_pageView, SIGNAL(escPressed()), m_findBar, SLOT(resetSearch()) );
connect( m_pageNumberTool, SIGNAL(forwardKeyPressEvent(QKeyEvent*)), m_pageView, SLOT(externalKeyPressEvent(QKeyEvent*)));
connect( m_reviewsWidget, SIGNAL(openAnnotationWindow(Okular::Annotation*,int)),

View file

@ -149,6 +149,11 @@ void FindBar::findPrev()
m_search->lineEdit()->findPrev();
}
void FindBar::resetSearch()
{
m_search->lineEdit()->resetSearch();
}
void FindBar::caseSensitivityChanged()
{
m_search->lineEdit()->setSearchCaseSensitivity( m_caseSensitiveAct->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive );

View file

@ -40,6 +40,7 @@ class FindBar
public slots:
void findNext();
void findPrev();
void resetSearch();
private slots:
void caseSensitivityChanged();

View file

@ -1642,7 +1642,7 @@ void PageView::keyPressEvent( QKeyEvent * e )
horizontalScrollBar()->triggerAction( QScrollBar::SliderSingleStepAdd );
break;
case Qt::Key_Escape:
d->document->resetSearch( PART_SEARCH_ID );
emit escPressed();
selectionClear( d->tableDividersGuessed ? ClearOnlyDividers : ClearAllSelection );
d->mousePressPos = QPoint();
if ( d->aPrevAction )

View file

@ -131,6 +131,7 @@ Q_OBJECT
signals:
void urlDropped( const KUrl& );
void rightClick( const Okular::Page *, const QPoint & );
void escPressed();
protected:
void resizeEvent( QResizeEvent* );

View file

@ -90,6 +90,19 @@ void SearchLineEdit::setSearchFromStart( bool fromStart )
m_fromStart = fromStart;
}
void SearchLineEdit::resetSearch()
{
// Stop the currently running search, if any
stopSearch();
// Clear highlights
if ( m_id != -1 )
m_document->resetSearch( m_id );
// Make sure that the search will be reset at the next one
m_changed = true;
}
bool SearchLineEdit::isSearchRunning() const
{
return m_searchRunning;

View file

@ -36,6 +36,7 @@ class SearchLineEdit : public KLineEdit
void setSearchColor( const QColor &color );
void setSearchMoveViewport( bool move );
void setSearchFromStart( bool fromStart );
void resetSearch();
bool isSearchRunning() const;