12#include <QWebEnginePage>
13#include <QWebEngineView>
34 QWebEngineView *
const WebView_;
35 QString PreviousFindText_;
58 static QWebEnginePage::FindFlags
ToPageFlags (FindFlags findFlags)
60 QWebEnginePage::FindFlags pageFlags;
61 auto check = [&pageFlags, findFlags] (
FindFlag ourFlag, QWebEnginePage::FindFlag pageFlag)
63 if (findFlags & ourFlag)
64 pageFlags |= pageFlag;
66 check (FindCaseSensitively, QWebEnginePage::FindCaseSensitively);
67 check (FindBackwards, QWebEnginePage::FindBackward);
71 void ClearFindResults ()
73 PreviousFindText_.clear ();
74 WebView_->page ()->findText ({});
77 void HandleNext (
const QString& text, FindFlags findFlags)
override
79 if (PreviousFindText_ != text)
82 PreviousFindText_ = text;
85 WebView_->page ()->findText (text, ToPageFlags (findFlags),
86 [
this] (
bool found) { SetSuccessful (found); });
91 FindNotification::Reject ();
A horizontal bar with typical widgets for text search.
A helper class to aid connecting FindNotification with QtWebEngine.
void HandleNext(const QString &text, FindFlags findFlags) override
Called each time the user requests a search.
static QWebEnginePage::FindFlags ToPageFlags(FindFlags findFlags)
Converts the given findFlags to WebKit find flags.
FindNotificationWE(const ICoreProxy_ptr &proxy, QWebEngineView *near)
Constructs the find notification using the given proxy and near widget.
std::shared_ptr< ICoreProxy > ICoreProxy_ptr