Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PIM Messagelib
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PIM
PIM Messagelib
Commits
6fd82c8f
Commit
6fd82c8f
authored
Apr 26, 2016
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move in webengineviewer
parent
492d39c0
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
521 additions
and
9 deletions
+521
-9
CMakeLists.txt
CMakeLists.txt
+1
-1
messageviewer/src/CMakeLists.txt
messageviewer/src/CMakeLists.txt
+1
-1
webengineviewer/src/CMakeLists.txt
webengineviewer/src/CMakeLists.txt
+13
-1
webengineviewer/src/findbar/autotests/CMakeLists.txt
webengineviewer/src/findbar/autotests/CMakeLists.txt
+2
-2
webengineviewer/src/findbar/autotests/findbarbasetest.cpp
webengineviewer/src/findbar/autotests/findbarbasetest.cpp
+4
-4
webengineviewer/src/findbar/autotests/findbarbasetest.h
webengineviewer/src/findbar/autotests/findbarbasetest.h
+0
-0
webengineviewer/src/findbar/findbarbase.cpp
webengineviewer/src/findbar/findbarbase.cpp
+275
-0
webengineviewer/src/findbar/findbarbase.h
webengineviewer/src/findbar/findbarbase.h
+89
-0
webengineviewer/src/findbar/findbarwebengineview.cpp
webengineviewer/src/findbar/findbarwebengineview.cpp
+88
-0
webengineviewer/src/findbar/findbarwebengineview.h
webengineviewer/src/findbar/findbarwebengineview.h
+48
-0
No files found.
CMakeLists.txt
View file @
6fd82c8f
...
...
@@ -18,7 +18,7 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include
(
ECMQtDeclareLoggingCategory
)
include
(
ECMAddTests
)
set
(
MESSAGELIB_LIB_VERSION
"5.2.5
8
"
)
set
(
MESSAGELIB_LIB_VERSION
"5.2.5
9
"
)
set
(
KF5_VERSION
"5.19.0"
)
set
(
KDEPIMLIBS_LIB_VERSION
"5.2.40"
)
...
...
messageviewer/src/CMakeLists.txt
View file @
6fd82c8f
...
...
@@ -32,7 +32,7 @@ include_directories(${GPGME_INCLUDES})
if
(
BUILD_TESTING
)
add_subdirectory
(
scamdetection/autotests
)
add_subdirectory
(
findbar/autotests
)
#
add_subdirectory(findbar/autotests)
add_subdirectory
(
scamdetection/tests
)
add_subdirectory
(
viewerplugins/tests/
)
add_subdirectory
(
htmlwriter/autotests/
)
...
...
webengineviewer/src/CMakeLists.txt
View file @
6fd82c8f
...
...
@@ -5,6 +5,7 @@ if(BUILD_TESTING)
add_subdirectory
(
tests
)
add_subdirectory
(
autotests
)
add_subdirectory
(
webengineaccesskey/autotests
)
add_subdirectory
(
findbar/autotests
)
endif
()
...
...
@@ -25,10 +26,18 @@ set(libwebengineviewer_webengine_SRCS
webengineaccesskey/webengineaccesskeyanchor.cpp
webengineaccesskey/webengineaccesskeyutils.cpp
)
set
(
libwebengineviewer_findbar_SRCS
findbar/findbarbase.cpp
findbar/findbarwebengineview.cpp
)
set
(
libmessageviewer_web_LIB Qt5::WebEngineWidgets
)
set
(
libwebengineviewer_SRCS
${
libwebengineviewer_webengine_SRCS
}
${
libwebengineviewer_findbar_SRCS
}
)
qt5_add_resources
(
libwebengineviewer_webengine_SRCS jquery.qrc
)
...
...
@@ -36,7 +45,7 @@ qt5_add_resources(libwebengineviewer_webengine_SRCS jquery.qrc)
ecm_qt_declare_logging_category
(
libwebengineviewer_webengine_SRCS HEADER webengineviewer_debug.h IDENTIFIER WEBENGINEVIEWER_LOG CATEGORY_NAME log_webengineviewer
)
add_library
(
KF5WebEngineViewer
${
libwebengineviewer_webengine_SRCS
}
)
add_library
(
KF5WebEngineViewer
${
libwebengineviewer_
SRCS
}
${
libwebengineviewer_
webengine_SRCS
}
)
generate_export_header
(
KF5WebEngineViewer BASE_NAME webengineviewer
)
add_library
(
KF5::WebEngineViewer ALIAS KF5WebEngineViewer
)
...
...
@@ -49,6 +58,9 @@ target_link_libraries(KF5WebEngineViewer
PRIVATE
KF5::CoreAddons
KF5::XmlGui
KF5::Completion
KF5::I18n
KF5::PimCommon
)
set_target_properties
(
KF5WebEngineViewer PROPERTIES
...
...
messag
eviewer/src/findbar/autotests/CMakeLists.txt
→
webengin
eviewer/src/findbar/autotests/CMakeLists.txt
View file @
6fd82c8f
ecm_add_test
(
findbarbasetest.cpp ../findbarbase.cpp
TEST_NAME findbarbasetest
NAME_PREFIX
"
messag
eviewer-findbar-"
NAME_PREFIX
"
webengin
eviewer-findbar-"
LINK_LIBRARIES Qt5::Test Qt5::Widgets Qt5::Gui KF5::Completion KF5::I18n KF5::ConfigWidgets KF5::PimCommon
)
set_property
(
TARGET findbarbasetest PROPERTY INCLUDE_DIRECTORIES
${
CMAKE_SOURCE_DIR
}
/
messageviewer
${
CMAKE_BINARY_DIR
}
/messag
eviewer/src
)
set_property
(
TARGET findbarbasetest PROPERTY INCLUDE_DIRECTORIES
${
CMAKE_SOURCE_DIR
}
/
webengineviewer
${
CMAKE_BINARY_DIR
}
/webengin
eviewer/src
)
messag
eviewer/src/findbar/autotests/findbarbasetest.cpp
→
webengin
eviewer/src/findbar/autotests/findbarbasetest.cpp
View file @
6fd82c8f
...
...
@@ -38,7 +38,7 @@ FindBarBaseTest::~FindBarBaseTest()
void
FindBarBaseTest
::
shouldHaveDefaultValue
()
{
Messag
eViewer
::
FindBarBase
bar
;
WebEngin
eViewer
::
FindBarBase
bar
;
QLabel
*
status
=
bar
.
findChild
<
QLabel
*>
(
QStringLiteral
(
"status"
));
QVERIFY
(
status
);
QVERIFY
(
status
->
text
().
isEmpty
());
...
...
@@ -61,7 +61,7 @@ void FindBarBaseTest::shouldHaveDefaultValue()
void
FindBarBaseTest
::
shouldClearLineWhenClose
()
{
Messag
eViewer
::
FindBarBase
bar
;
WebEngin
eViewer
::
FindBarBase
bar
;
bar
.
show
();
QSignalSpy
spy
(
&
bar
,
SIGNAL
(
hideFindBar
()));
QTest
::
qWaitForWindowExposed
(
&
bar
);
...
...
@@ -79,7 +79,7 @@ void FindBarBaseTest::shouldClearLineWhenClose()
void
FindBarBaseTest
::
shouldEnableDisableNextPreviousButton
()
{
Messag
eViewer
::
FindBarBase
bar
;
WebEngin
eViewer
::
FindBarBase
bar
;
bar
.
show
();
QTest
::
qWaitForWindowExposed
(
&
bar
);
QPushButton
*
previous
=
bar
.
findChild
<
QPushButton
*>
(
QStringLiteral
(
"findprevious"
));
...
...
@@ -98,7 +98,7 @@ void FindBarBaseTest::shouldEnableDisableNextPreviousButton()
void
FindBarBaseTest
::
shouldClearAllWhenShowBar
()
{
Messag
eViewer
::
FindBarBase
bar
;
WebEngin
eViewer
::
FindBarBase
bar
;
bar
.
show
();
QTest
::
qWaitForWindowExposed
(
&
bar
);
QLabel
*
status
=
bar
.
findChild
<
QLabel
*>
(
QStringLiteral
(
"status"
));
...
...
messag
eviewer/src/findbar/autotests/findbarbasetest.h
→
webengin
eviewer/src/findbar/autotests/findbarbasetest.h
View file @
6fd82c8f
File moved
webengineviewer/src/findbar/findbarbase.cpp
0 → 100644
View file @
6fd82c8f
/* Copyright (C) 2010 Torgny Nyblom <nyblom@kde.org>
* Copyright (C) 2010-2016 Laurent Montel <montel@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "findbarbase.h"
#include "PimCommon/LineEditWithCompleter"
#include <qicon.h>
#include <KLocalizedString>
#include <klineedit.h>
#include <KColorScheme>
#include <QHBoxLayout>
#include <QPushButton>
#include <QTimer>
#include <QLabel>
#include <QMenu>
#include <QToolButton>
#include <QEvent>
#include <QKeyEvent>
using
namespace
WebEngineViewer
;
FindBarBase
::
FindBarBase
(
QWidget
*
parent
)
:
QWidget
(
parent
)
{
QHBoxLayout
*
lay
=
new
QHBoxLayout
(
this
);
lay
->
setMargin
(
2
);
QToolButton
*
closeBtn
=
new
QToolButton
(
this
);
closeBtn
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"dialog-close"
)));
closeBtn
->
setObjectName
(
QStringLiteral
(
"close"
));
closeBtn
->
setIconSize
(
QSize
(
16
,
16
));
closeBtn
->
setToolTip
(
i18n
(
"Close"
));
#ifndef QT_NO_ACCESSIBILITY
closeBtn
->
setAccessibleName
(
i18n
(
"Close"
));
#endif
closeBtn
->
setAutoRaise
(
true
);
lay
->
addWidget
(
closeBtn
);
QLabel
*
label
=
new
QLabel
(
i18nc
(
"Find text"
,
"F&ind:"
),
this
);
lay
->
addWidget
(
label
);
mSearch
=
new
PimCommon
::
LineEditWithCompleter
(
this
);
mSearch
->
setObjectName
(
QStringLiteral
(
"searchline"
));
mSearch
->
setToolTip
(
i18n
(
"Text to search for"
));
mSearch
->
setClearButtonShown
(
true
);
label
->
setBuddy
(
mSearch
);
lay
->
addWidget
(
mSearch
);
mFindNextBtn
=
new
QPushButton
(
QIcon
::
fromTheme
(
QStringLiteral
(
"go-down-search"
)),
i18nc
(
"Find and go to the next search match"
,
"Next"
),
this
);
mFindNextBtn
->
setToolTip
(
i18n
(
"Jump to next match"
));
mFindNextBtn
->
setObjectName
(
QStringLiteral
(
"findnext"
));
lay
->
addWidget
(
mFindNextBtn
);
mFindNextBtn
->
setEnabled
(
false
);
mFindPrevBtn
=
new
QPushButton
(
QIcon
::
fromTheme
(
QStringLiteral
(
"go-up-search"
)),
i18nc
(
"Find and go to the previous search match"
,
"Previous"
),
this
);
mFindPrevBtn
->
setToolTip
(
i18n
(
"Jump to previous match"
));
mFindPrevBtn
->
setObjectName
(
QStringLiteral
(
"findprevious"
));
lay
->
addWidget
(
mFindPrevBtn
);
mFindPrevBtn
->
setEnabled
(
false
);
QPushButton
*
optionsBtn
=
new
QPushButton
(
this
);
optionsBtn
->
setText
(
i18n
(
"Options"
));
optionsBtn
->
setToolTip
(
i18n
(
"Modify search behavior"
));
mOptionsMenu
=
new
QMenu
(
optionsBtn
);
mCaseSensitiveAct
=
mOptionsMenu
->
addAction
(
i18n
(
"Case sensitive"
));
mCaseSensitiveAct
->
setCheckable
(
true
);
optionsBtn
->
setMenu
(
mOptionsMenu
);
lay
->
addWidget
(
optionsBtn
);
connect
(
closeBtn
,
&
QToolButton
::
clicked
,
this
,
&
FindBarBase
::
closeBar
);
connect
(
mFindNextBtn
,
&
QPushButton
::
clicked
,
this
,
&
FindBarBase
::
findNext
);
connect
(
mFindPrevBtn
,
&
QPushButton
::
clicked
,
this
,
&
FindBarBase
::
findPrev
);
connect
(
mCaseSensitiveAct
,
&
QAction
::
toggled
,
this
,
&
FindBarBase
::
caseSensitivityChanged
);
connect
(
mSearch
,
&
KLineEdit
::
textChanged
,
this
,
&
FindBarBase
::
autoSearch
);
connect
(
mSearch
,
&
KLineEdit
::
clearButtonClicked
,
this
,
&
FindBarBase
::
slotClearSearch
);
mStatus
=
new
QLabel
;
mStatus
->
setObjectName
(
QStringLiteral
(
"status"
));
QFontMetrics
fm
(
mStatus
->
font
());
mNotFoundString
=
i18n
(
"Phrase not found"
);
mStatus
->
setFixedWidth
(
fm
.
width
(
mNotFoundString
));
lay
->
addWidget
(
mStatus
);
setSizePolicy
(
QSizePolicy
(
QSizePolicy
::
Preferred
,
QSizePolicy
::
Fixed
));
//lay->addStretch();
hide
();
}
FindBarBase
::~
FindBarBase
()
{
}
QMenu
*
FindBarBase
::
optionsMenu
()
{
return
mOptionsMenu
;
}
QString
FindBarBase
::
text
()
const
{
return
mSearch
->
text
();
}
void
FindBarBase
::
setText
(
const
QString
&
text
)
{
mSearch
->
setText
(
text
);
}
void
FindBarBase
::
focusAndSetCursor
()
{
setFocus
();
mStatus
->
clear
();
mSearch
->
selectAll
();
mSearch
->
setFocus
();
}
void
FindBarBase
::
slotClearSearch
()
{
clearSelections
();
}
void
FindBarBase
::
autoSearch
(
const
QString
&
str
)
{
const
bool
isNotEmpty
=
(
!
str
.
isEmpty
());
mFindPrevBtn
->
setEnabled
(
isNotEmpty
);
mFindNextBtn
->
setEnabled
(
isNotEmpty
);
if
(
isNotEmpty
)
{
QTimer
::
singleShot
(
0
,
this
,
SLOT
(
slotSearchText
()));
}
else
{
clearSelections
();
}
}
void
FindBarBase
::
slotSearchText
(
bool
backward
,
bool
isAutoSearch
)
{
searchText
(
backward
,
isAutoSearch
);
}
void
FindBarBase
::
setFoundMatch
(
bool
match
)
{
#ifndef QT_NO_STYLE_STYLESHEET
QString
styleSheet
;
if
(
!
mSearch
->
text
().
isEmpty
())
{
if
(
mNegativeBackground
.
isEmpty
())
{
KStatefulBrush
bgBrush
(
KColorScheme
::
View
,
KColorScheme
::
PositiveBackground
);
mPositiveBackground
=
QStringLiteral
(
"QLineEdit{ background-color:%1 }"
).
arg
(
bgBrush
.
brush
(
mSearch
).
color
().
name
());
bgBrush
=
KStatefulBrush
(
KColorScheme
::
View
,
KColorScheme
::
NegativeBackground
);
mNegativeBackground
=
QStringLiteral
(
"QLineEdit{ background-color:%1 }"
).
arg
(
bgBrush
.
brush
(
mSearch
).
color
().
name
());
}
if
(
match
)
{
styleSheet
=
mPositiveBackground
;
mStatus
->
clear
();
}
else
{
styleSheet
=
mNegativeBackground
;
mStatus
->
setText
(
mNotFoundString
);
}
}
mSearch
->
setStyleSheet
(
styleSheet
);
#endif
}
void
FindBarBase
::
searchText
(
bool
backward
,
bool
isAutoSearch
)
{
Q_UNUSED
(
backward
);
Q_UNUSED
(
isAutoSearch
);
}
void
FindBarBase
::
addToCompletion
(
const
QString
&
text
)
{
KCompletion
*
comp
=
mSearch
->
completionObject
();
comp
->
addItem
(
text
);
}
void
FindBarBase
::
findNext
()
{
searchText
(
false
,
false
);
addToCompletion
(
mLastSearchStr
);
}
void
FindBarBase
::
findPrev
()
{
searchText
(
true
,
false
);
addToCompletion
(
mLastSearchStr
);
}
void
FindBarBase
::
caseSensitivityChanged
(
bool
b
)
{
updateSensitivity
(
b
);
}
void
FindBarBase
::
updateSensitivity
(
bool
)
{
}
void
FindBarBase
::
slotHighlightAllChanged
(
bool
b
)
{
updateHighLight
(
b
);
}
void
FindBarBase
::
updateHighLight
(
bool
)
{
}
void
FindBarBase
::
clearSelections
()
{
setFoundMatch
(
false
);
}
void
FindBarBase
::
closeBar
()
{
// Make sure that all old searches are cleared
mSearch
->
clear
();
clearSelections
();
mSearch
->
clearFocus
();
Q_EMIT
hideFindBar
();
}
bool
FindBarBase
::
event
(
QEvent
*
e
)
{
// Close the bar when pressing Escape.
// Not using a QShortcut for this because it could conflict with
// window-global actions (e.g. Emil Sedgh binds Esc to "close tab").
// With a shortcut Q_DECL_OVERRIDE we can catch this before it gets to kactions.
const
bool
shortCutOverride
=
(
e
->
type
()
==
QEvent
::
ShortcutOverride
);
if
(
shortCutOverride
||
e
->
type
()
==
QEvent
::
KeyPress
)
{
QKeyEvent
*
kev
=
static_cast
<
QKeyEvent
*
>
(
e
);
if
(
kev
->
key
()
==
Qt
::
Key_Escape
)
{
if
(
shortCutOverride
)
{
e
->
accept
();
return
true
;
}
e
->
accept
();
closeBar
();
return
true
;
}
else
if
(
kev
->
key
()
==
Qt
::
Key_Enter
||
kev
->
key
()
==
Qt
::
Key_Return
)
{
e
->
accept
();
if
(
shortCutOverride
)
{
return
true
;
}
if
(
mSearch
->
text
().
isEmpty
())
{
return
true
;
}
if
(
kev
->
modifiers
()
&
Qt
::
ShiftModifier
)
{
findPrev
();
}
else
if
(
kev
->
modifiers
()
==
Qt
::
NoModifier
)
{
findNext
();
}
return
true
;
}
}
return
QWidget
::
event
(
e
);
}
webengineviewer/src/findbar/findbarbase.h
0 → 100644
View file @
6fd82c8f
/* Copyright (C) 2010 Torgny Nyblom <nyblom@kde.org>
* Copyright (C) 2010-2016 Laurent Montel <montel@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef FINDBARBASE_H
#define FINDBARBASE_H
#include <QWidget>
#include "webengineviewer_export.h"
class
QAction
;
class
QPushButton
;
class
QMenu
;
class
QLabel
;
namespace
PimCommon
{
class
LineEditWithCompleter
;
}
namespace
WebEngineViewer
{
class
WEBENGINEVIEWER_EXPORT
FindBarBase
:
public
QWidget
{
Q_OBJECT
public:
explicit
FindBarBase
(
QWidget
*
parent
=
Q_NULLPTR
);
virtual
~
FindBarBase
();
QString
text
()
const
;
void
setText
(
const
QString
&
text
);
void
focusAndSetCursor
();
protected:
bool
event
(
QEvent
*
e
)
Q_DECL_OVERRIDE
;
virtual
void
clearSelections
();
virtual
void
updateHighLight
(
bool
);
virtual
void
searchText
(
bool
backward
,
bool
isAutoSearch
);
virtual
void
updateSensitivity
(
bool
);
void
setFoundMatch
(
bool
match
);
QMenu
*
optionsMenu
();
public
Q_SLOTS
:
void
findNext
();
void
findPrev
();
void
autoSearch
(
const
QString
&
str
);
void
slotSearchText
(
bool
backward
=
false
,
bool
isAutoSearch
=
true
);
void
closeBar
();
Q_SIGNALS:
void
hideFindBar
();
protected
Q_SLOTS
:
void
caseSensitivityChanged
(
bool
);
void
slotHighlightAllChanged
(
bool
);
void
slotClearSearch
();
protected:
QString
mNotFoundString
;
QString
mPositiveBackground
;
QString
mNegativeBackground
;
QString
mLastSearchStr
;
PimCommon
::
LineEditWithCompleter
*
mSearch
;
QAction
*
mCaseSensitiveAct
;
QPushButton
*
mFindPrevBtn
;
QPushButton
*
mFindNextBtn
;
QMenu
*
mOptionsMenu
;
QLabel
*
mStatus
;
void
addToCompletion
(
const
QString
&
text
);
};
}
#endif
/* FINDBARBASE_H */
webengineviewer/src/findbar/findbarwebengineview.cpp
0 → 100644
View file @
6fd82c8f
/* Copyright (C) 2016 Laurent Montel <montel@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "findbarwebengineview.h"
#include "PimCommon/LineEditWithCompleter"
#include <QWebEngineView>
#include <QAction>
using
namespace
WebEngineViewer
;
class
WebEngineViewer
::
FindBarWebEngineViewPrivate
{
public:
FindBarWebEngineViewPrivate
()
:
mView
(
Q_NULLPTR
)
{
}
QWebEngineView
*
mView
;
};
FindBarWebEngineView
::
FindBarWebEngineView
(
QWebEngineView
*
view
,
QWidget
*
parent
)
:
FindBarBase
(
parent
),
d
(
new
WebEngineViewer
::
FindBarWebEngineViewPrivate
)
{
d
->
mView
=
view
;
}
FindBarWebEngineView
::~
FindBarWebEngineView
()
{
delete
d
;
}
void
FindBarWebEngineView
::
searchText
(
bool
backward
,
bool
isAutoSearch
)
{
QWebEnginePage
::
FindFlags
searchOptions
;
if
(
backward
)
{
searchOptions
|=
QWebEnginePage
::
FindBackward
;
}
if
(
mCaseSensitiveAct
->
isChecked
())
{
searchOptions
|=
QWebEnginePage
::
FindCaseSensitively
;
}
const
QString
searchWord
(
mSearch
->
text
());
if
(
!
isAutoSearch
&&
!
mLastSearchStr
.
contains
(
searchWord
,
Qt
::
CaseSensitive
))
{
clearSelections
();
}
d
->
mView
->
findText
(
QString
());
//Clear an existing highligh
mLastSearchStr
=
searchWord
;
d
->
mView
->
findText
(
mLastSearchStr
,
searchOptions
,
[
this
](
bool
found
)
{
setFoundMatch
(
found
);
});
}
void
FindBarWebEngineView
::
updateSensitivity
(
bool
sensitivity
)
{
QWebEnginePage
::
FindFlags
searchOptions
;
if
(
sensitivity
)
{
searchOptions
|=
QWebEnginePage
::
FindCaseSensitively
;
d
->
mView
->
findText
(
QString
());
//Clear an existing highligh
}
d
->
mView
->
findText
(
QString
(),
searchOptions
,
[
this
](
bool
found
)
{
setFoundMatch
(
found
);
});
}
void
FindBarWebEngineView
::
clearSelections
()
{
d
->
mView
->
findText
(
QString
());
mLastSearchStr
.
clear
();
FindBarBase
::
clearSelections
();
}
webengineviewer/src/findbar/findbarwebengineview.h
0 → 100644
View file @
6fd82c8f
/* Copyright (C) 2016 Laurent Montel <montel@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef WEBENGINEVIEWER_FINDBAR_MAILWEBENGINEVIEW_H
#define WEBENGINEVIEWER_FINDBAR_MAILWEBENGINEVIEW_H
#include "findbarbase.h"
#include "webengineviewer_export.h"
class
QWebEngineView
;
namespace
WebEngineViewer
{
class
FindBarWebEngineViewPrivate
;
class
WEBENGINEVIEWER_EXPORT
FindBarWebEngineView
:
public
FindBarBase
{
Q_OBJECT
public:
explicit
FindBarWebEngineView
(
QWebEngineView
*
view
,
QWidget
*
parent
=
Q_NULLPTR
);
~
FindBarWebEngineView
();
private:
void
clearSelections
()
Q_DECL_OVERRIDE
;
void
searchText
(
bool
backward
,
bool
isAutoSearch
)
Q_DECL_OVERRIDE
;
void
updateSensitivity
(
bool
sensitivity
)
Q_DECL_OVERRIDE
;
private:
FindBarWebEngineViewPrivate
*
const
d
;
};
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment