Commit f6f4bc1e authored by Laurent Montel's avatar Laurent Montel 😁

implement scrollup/scrolldown

parent 102c2c96
......@@ -80,6 +80,16 @@ MailWebEngineView::~MailWebEngineView()
delete d;
}
void MailWebEngineView::scrollUp(int pixels)
{
page()->runJavaScript(MessageViewer::WebEngineScript::scrollUp(pixels));
}
void MailWebEngineView::scrollDown(int pixels)
{
page()->runJavaScript(MessageViewer::WebEngineScript::scrollDown(pixels));
}
void MailWebEngineView::selectAll()
{
page()->triggerAction(QWebEnginePage::SelectAll);
......
......@@ -30,6 +30,10 @@ public:
explicit MailWebEngineView(KActionCollection *ac, QWidget *parent = Q_NULLPTR);
~MailWebEngineView();
void scrollUp(int pixels);
void scrollDown(int pixels);
void selectAll();
void scamCheck();
......
......@@ -124,6 +124,19 @@ QString WebEngineScript::searchElementPosition(const QString &elementStr)
return source;
}
QString WebEngineScript::scrollUp(int 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);
return source;
}
QString WebEngineScript::scrollToPosition(const QPoint &pos)
{
const QString source = QString::fromLatin1("window.scrollTo(%1, %2); [window.scrollX, window.scrollY];").arg(pos.x()).arg(pos.y());
......
......@@ -33,6 +33,8 @@ MESSAGEVIEWER_EXPORT QString searchElementPosition(const QString &elementStr);
MESSAGEVIEWER_EXPORT QString scrollToPosition(const QPoint &pos);
MESSAGEVIEWER_EXPORT QString setElementByIdVisible(const QString &elementStr, bool visibility);
MESSAGEVIEWER_EXPORT QString setStyleToElement(const QString &elementStr, const QString &style);
MESSAGEVIEWER_EXPORT QString scrollDown(int pixel);
MESSAGEVIEWER_EXPORT QString scrollUp(int pixel);
}
}
#endif // WEBENGINESCRIPT_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment