12#include <QWebEnginePage>
13#include <QWebEngineView>
14#if QT_VERSION_MAJOR >= 6
15#include <QWebEngineFindTextResult>
37 QWebEngineView *
const WebView_;
38 QString PreviousFindText_;
61 static QWebEnginePage::FindFlags
ToPageFlags (FindFlags findFlags)
63 QWebEnginePage::FindFlags pageFlags;
64 auto check = [&pageFlags, findFlags] (
FindFlag ourFlag, QWebEnginePage::FindFlag pageFlag)
66 if (findFlags & ourFlag)
67 pageFlags |= pageFlag;
74 void ClearFindResults ()
76 PreviousFindText_.clear ();
77 WebView_->page ()->findText ({});
80 void HandleNext (
const QString& text, FindFlags findFlags)
override
82 if (PreviousFindText_ != text)
85 PreviousFindText_ = text;
88#if QT_VERSION_MAJOR >= 6
89 WebView_->page ()->findText (text,
ToPageFlags (findFlags),
90 [
this] (
const QWebEngineFindTextResult& found) {
SetSuccessful (found.numberOfMatches ()); });
92 WebView_->page ()->findText (text,
ToPageFlags (findFlags),
FindNotification(const ICoreProxy_ptr &proxy, QWidget *near)
Creates the search widget in parent layout of near.
void SetSuccessful(bool successful)
Updates the widget to show whether the search has been successful.
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