Commit d8a837e0 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Try to fix scroll to page

parent d637f854
...@@ -47,8 +47,8 @@ namespace MessageViewer ...@@ -47,8 +47,8 @@ namespace MessageViewer
class TeeHtmlWriter : public MimeTreeParser::HtmlWriter class TeeHtmlWriter : public MimeTreeParser::HtmlWriter
{ {
public: public:
explicit TeeHtmlWriter(HtmlWriter *writer1 = 0, explicit TeeHtmlWriter(HtmlWriter *writer1 = Q_NULLPTR,
MimeTreeParser::HtmlWriter *writer2 = 0); MimeTreeParser::HtmlWriter *writer2 = Q_NULLPTR);
virtual ~TeeHtmlWriter(); virtual ~TeeHtmlWriter();
void addHtmlWriter(HtmlWriter *writer); void addHtmlWriter(HtmlWriter *writer);
......
...@@ -238,17 +238,6 @@ void MailWebEngineView::handleScrollToAnchor(const QVariant &result) ...@@ -238,17 +238,6 @@ void MailWebEngineView::handleScrollToAnchor(const QVariant &result)
void MailWebEngineView::scrollPageDown(int percent) void MailWebEngineView::scrollPageDown(int percent)
{ {
page()->runJavaScript(MessageViewer::WebEngineScript::scrollPercentage(percent)); page()->runJavaScript(MessageViewer::WebEngineScript::scrollPercentage(percent));
qDebug()<<" void MailWebEngineView::scrollPageDown(int percent) not implemented";
#if 0
const qint64 height = page()->viewportSize().height();
const qint64 current = page()->mainFrame()->scrollBarValue(Qt::Vertical);
// do arithmetic in higher precision, and check for overflow:
const qint64 newPosition = current + height * percent / 100;
if (newPosition > std::numeric_limits<int>::max()) {
qCWarning(MESSAGEVIEWER_LOG) << "new position" << newPosition << "exceeds range of 'int'!";
}
page()->mainFrame()->setScrollBarValue(Qt::Vertical, newPosition);
#endif
} }
void MailWebEngineView::scrollPageUp(int percent) void MailWebEngineView::scrollPageUp(int percent)
......
...@@ -125,8 +125,24 @@ QString WebEngineScript::searchElementPosition(const QString &elementStr) ...@@ -125,8 +125,24 @@ QString WebEngineScript::searchElementPosition(const QString &elementStr)
QString WebEngineScript::scrollPercentage(int percent) QString WebEngineScript::scrollPercentage(int percent)
{ {
const QString source = QString::fromLatin1("var current = document.body.scrollTop;"
"var height = document.height;"
"var newPosition = current + height * %1 / 100;"
"window.scrollTo(window.scrollX, newPostion); [window.scrollX, window.scrollY];").arg(percent);
#if 0
const qint64 height = page()->viewportSize().height();
const qint64 current = page()->mainFrame()->scrollBarValue(Qt::Vertical);
// do arithmetic in higher precision, and check for overflow:
const qint64 newPosition = current + height * percent / 100;
if (newPosition > std::numeric_limits<int>::max()) {
qCWarning(MESSAGEVIEWER_LOG) << "new position" << newPosition << "exceeds range of 'int'!";
}
page()->mainFrame()->setScrollBarValue(Qt::Vertical, newPosition);
#endif
qDebug() << "QString WebEngineScript::scrollPercentage(int percent) "<<source;
//TODO //TODO
return QString(); return source;
} }
QString WebEngineScript::scrollUp(int pixel) QString WebEngineScript::scrollUp(int pixel)
......
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