Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
PIM Messagelib
Commits
b51a413f
Commit
b51a413f
authored
Mar 27, 2016
by
Laurent Montel
😁
Browse files
Add test application for scroll up/scroll down
parent
f6f4bc1e
Changes
3
Hide whitespace changes
Inline
Side-by-side
messageviewer/src/webengine/tests/testmailwebengine.cpp
View file @
b51a413f
...
...
@@ -15,10 +15,13 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "testmailwebengine.h"
#include "webengine/webenginescript.h"
#include <KActionCollection>
#include <QApplication>
#include <QPushButton>
#include <QVBoxLayout>
#include <QWebEngineSettings>
#include <viewer/webengine/mailwebengineview.h>
...
...
@@ -28,7 +31,19 @@ TestMailWebEngine::TestMailWebEngine(QWidget *parent)
{
QVBoxLayout
*
vbox
=
new
QVBoxLayout
(
this
);
mTestWebEngine
=
new
MessageViewer
::
MailWebEngineView
(
new
KActionCollection
(
this
),
this
);
mTestWebEngine
->
load
(
QUrl
(
QStringLiteral
(
"http://www.kde.org"
)));
mTestWebEngine
->
settings
()
->
setAttribute
(
QWebEngineSettings
::
JavascriptEnabled
,
true
);
vbox
->
addWidget
(
mTestWebEngine
);
QHBoxLayout
*
hButtonBox
=
new
QHBoxLayout
;
vbox
->
addLayout
(
hButtonBox
);
QPushButton
*
scrollUp
=
new
QPushButton
(
QStringLiteral
(
"scrollUp 10px"
),
this
);
connect
(
scrollUp
,
&
QPushButton
::
clicked
,
this
,
&
TestMailWebEngine
::
slotScrollUp
);
hButtonBox
->
addWidget
(
scrollUp
);
QPushButton
*
scrollDown
=
new
QPushButton
(
QStringLiteral
(
"scrollDown 10px"
),
this
);
connect
(
scrollDown
,
&
QPushButton
::
clicked
,
this
,
&
TestMailWebEngine
::
slotScrollDown
);
hButtonBox
->
addWidget
(
scrollDown
);
}
TestMailWebEngine
::~
TestMailWebEngine
()
...
...
@@ -36,6 +51,16 @@ TestMailWebEngine::~TestMailWebEngine()
}
void
TestMailWebEngine
::
slotScrollDown
()
{
mTestWebEngine
->
page
()
->
runJavaScript
(
MessageViewer
::
WebEngineScript
::
scrollDown
(
10
));
}
void
TestMailWebEngine
::
slotScrollUp
()
{
mTestWebEngine
->
page
()
->
runJavaScript
(
MessageViewer
::
WebEngineScript
::
scrollUp
(
10
));
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
messageviewer/src/webengine/tests/testmailwebengine.h
View file @
b51a413f
...
...
@@ -31,6 +31,10 @@ class TestMailWebEngine : public QWidget
public:
explicit
TestMailWebEngine
(
QWidget
*
parent
=
Q_NULLPTR
);
~
TestMailWebEngine
();
private
Q_SLOTS
:
void
slotScrollUp
();
void
slotScrollDown
();
private:
MessageViewer
::
MailWebEngineView
*
mTestWebEngine
;
};
...
...
messageviewer/src/webengine/webenginescript.cpp
View file @
b51a413f
...
...
@@ -126,13 +126,13 @@ QString WebEngineScript::searchElementPosition(const QString &elementStr)
QString
WebEngineScript
::
scrollUp
(
int
pixel
)
{
const
QString
source
=
QString
::
fromLatin1
(
"window.scrollBy(0, %1"
).
arg
(
pixel
);
const
QString
source
=
QString
::
fromLatin1
(
"window.scrollBy(0, %1
);
"
).
arg
(
-
pixel
);
return
source
;
}
QString
WebEngineScript
::
scrollDown
(
int
pixel
)
{
const
QString
source
=
QString
::
fromLatin1
(
"window.scrollBy(0, %1"
).
arg
(
-
pixel
);
const
QString
source
=
QString
::
fromLatin1
(
"window.scrollBy(0, %1
);
"
).
arg
(
pixel
);
return
source
;
}
...
...
Write
Preview
Supports
Markdown
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