LeechCraft
0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
Toggle main menu visibility
Loading...
Searching...
No Matches
findnotificationwe.h
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#pragma once
10
11
#include "
findnotification.h
"
12
#include <QWebEnginePage>
13
#include <QWebEngineView>
14
#include <QWebEngineFindTextResult>
15
16
namespace
LC::Util
17
{
33
class
UTIL_GUI_API
FindNotificationWE
:
public
FindNotification
34
{
35
QWebEngineView *
const
WebView_;
36
QString PreviousFindText_;
37
public
:
47
FindNotificationWE
(
const
ICoreProxy_ptr
& proxy, QWebEngineView *near)
48
:
FindNotification
{ proxy, near }
49
, WebView_ { near }
50
{
51
}
52
59
static
QWebEnginePage::FindFlags
ToPageFlags
(FindFlags findFlags)
60
{
61
QWebEnginePage::FindFlags pageFlags;
62
auto
check = [&pageFlags, findFlags] (
FindFlag
ourFlag, QWebEnginePage::FindFlag pageFlag)
63
{
64
if
(findFlags & ourFlag)
65
pageFlags |= pageFlag;
66
};
67
check (
FindCaseSensitively
, QWebEnginePage::FindCaseSensitively);
68
check (
FindBackwards
, QWebEnginePage::FindBackward);
69
return
pageFlags;
70
}
71
private
:
72
void
ClearFindResults ()
73
{
74
PreviousFindText_.clear ();
75
WebView_->page ()->findText ({});
76
}
77
protected
:
78
void
HandleNext
(
const
QString& text, FindFlags findFlags)
override
79
{
80
if
(PreviousFindText_ != text)
81
{
82
ClearFindResults ();
83
PreviousFindText_ = text;
84
}
85
86
WebView_->page ()->findText (text,
ToPageFlags
(findFlags),
87
[
this
] (
const
QWebEngineFindTextResult& found) {
SetSuccessful
(found.numberOfMatches ()); });
88
}
89
90
void
Reject
()
override
91
{
92
FindNotification::Reject
();
93
ClearFindResults ();
94
}
95
};
96
}
LC::Util::FindNotification::FindFlag
FindFlag
Definition
findnotification.h:69
LC::Util::FindNotification::FindCaseSensitively
@ FindCaseSensitively
Definition
findnotification.h:76
LC::Util::FindNotification::FindBackwards
@ FindBackwards
Definition
findnotification.h:80
LC::Util::FindNotification::Reject
virtual void Reject()
Definition
findnotification.cpp:132
LC::Util::FindNotification::FindNotification
FindNotification(const ICoreProxy_ptr &proxy, QWidget *near)
Creates the search widget in parent layout of near.
Definition
findnotification.cpp:19
LC::Util::FindNotification::SetSuccessful
void SetSuccessful(bool successful)
Updates the widget to show whether the search has been successful.
Definition
findnotification.cpp:83
LC::Util::FindNotificationWE::HandleNext
void HandleNext(const QString &text, FindFlags findFlags) override
Called each time the user requests a search.
Definition
findnotificationwe.h:78
LC::Util::FindNotificationWE::ToPageFlags
static QWebEnginePage::FindFlags ToPageFlags(FindFlags findFlags)
Converts the given findFlags to WebKit find flags.
Definition
findnotificationwe.h:59
LC::Util::FindNotificationWE::FindNotificationWE
FindNotificationWE(const ICoreProxy_ptr &proxy, QWebEngineView *near)
Constructs the find notification using the given proxy and near widget.
Definition
findnotificationwe.h:47
LC::Util::FindNotificationWE::Reject
void Reject() override
Definition
findnotificationwe.h:90
findnotification.h
UTIL_GUI_API
#define UTIL_GUI_API
Definition
guiconfig.h:16
ICoreProxy_ptr
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition
icoreproxy.h:177
LC::Util
Definition
icoreproxy.h:34
src
util
gui
findnotificationwe.h
Generated by
1.17.0