mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-27 11:40:07 +00:00
Implement continuous search
Show non-intrusive info messages whenever the search start over from the beginning or the bottom of the document, instead of asking the user if s/he wants to continue the search. This is consistent with search in KWrite/Kate and with web browsers. Based on work of and reviewed by Elvis Angelaccio
This commit is contained in:
parent
f6424adcaa
commit
ef7c9c67bf
|
@ -1609,13 +1609,15 @@ void DocumentPrivate::doContinueDirectionMatchSearch(void *doContinueDirectionMa
|
|||
if (search->pagesDone < pageCount)
|
||||
{
|
||||
doContinue = true;
|
||||
if ( searchStruct->currentPage >= pageCount || searchStruct->currentPage < 0 )
|
||||
if ( searchStruct->currentPage >= pageCount )
|
||||
{
|
||||
doContinue = false;
|
||||
search->isCurrentlySearching = false;
|
||||
search->continueOnPage = forward ? 0 : pageCount - 1;
|
||||
search->continueOnMatch = RegularAreaRect();
|
||||
emit m_parent->searchFinished ( searchStruct->searchID, Document::EndOfDocumentReached );
|
||||
searchStruct->currentPage = 0;
|
||||
emit m_parent->notice(i18n("Continuing search from beginning"), 3000);
|
||||
}
|
||||
else if ( searchStruct->currentPage < 0 )
|
||||
{
|
||||
searchStruct->currentPage = pageCount - 1;
|
||||
emit m_parent->notice(i18n("Continuing search from bottom"), 3000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -608,12 +608,13 @@ class OKULARCORE_EXPORT Document : public QObject
|
|||
/**
|
||||
* Describes how search ended
|
||||
*/
|
||||
// TODO remove EndOfDocumentReached when we break API
|
||||
enum SearchStatus
|
||||
{
|
||||
MatchFound, ///< Any match was found
|
||||
NoMatchFound, ///< No match was found
|
||||
SearchCancelled, ///< The search was cancelled
|
||||
EndOfDocumentReached ///< The end of document was reached without any match @since 0.20 (KDE 4.14)
|
||||
EndOfDocumentReached ///< This is not ever emitted since 1.3. The end of document was reached without any match @since 0.20 (KDE 4.14)
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -271,15 +271,6 @@ void SearchLineEdit::searchFinished( int id, Okular::Document::SearchStatus endS
|
|||
setPalette( pal );
|
||||
}
|
||||
|
||||
if ( endStatus == Okular::Document::EndOfDocumentReached ) {
|
||||
const bool forward = m_searchType == Okular::Document::NextMatch;
|
||||
const QString question = forward ? i18n("End of document reached.\nContinue from the beginning?") : i18n("Beginning of document reached.\nContinue from the bottom?");
|
||||
if ( KMessageBox::questionYesNo(window(), question, QString(), KStandardGuiItem::cont(), KStandardGuiItem::cancel()) == KMessageBox::Yes ) {
|
||||
m_document->continueSearch( m_id, m_searchType );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_searchRunning = false;
|
||||
emit searchStopped();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue