mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-27 03:30:20 +00:00
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:
parent
beffbf10ff
commit
76b7982f57
1
part.cpp
1
part.cpp
|
@ -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)),
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -40,6 +40,7 @@ class FindBar
|
|||
public slots:
|
||||
void findNext();
|
||||
void findPrev();
|
||||
void resetSearch();
|
||||
|
||||
private slots:
|
||||
void caseSensitivityChanged();
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -131,6 +131,7 @@ Q_OBJECT
|
|||
signals:
|
||||
void urlDropped( const KUrl& );
|
||||
void rightClick( const Okular::Page *, const QPoint & );
|
||||
void escPressed();
|
||||
|
||||
protected:
|
||||
void resizeEvent( QResizeEvent* );
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue