Commit 7e36e64c authored by Laurent Montel's avatar Laurent Montel 😁

Start to implement scroll percentage

parent b51a413f
......@@ -200,3 +200,25 @@ void MailWebEngineView::handleScrollToAnchor(const QVariant &result)
}
}
}
void MailWebEngineView::scrollPageDown(int 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
}
void MailWebEngineView::scrollPageUp(int percent)
{
#if 0
scrollPageDown(-percent);
#endif
}
......@@ -44,6 +44,8 @@ public:
bool removeAttachmentMarking(const QString &id);
void markAttachment(const QString &id, const QString &style);
void scrollToAnchor(const QString &anchor);
void scrollPageDown(int percent);
void scrollPageUp(int percent);
public Q_SLOTS:
void slotZoomChanged(qreal zoom);
......
......@@ -124,6 +124,12 @@ QString WebEngineScript::searchElementPosition(const QString &elementStr)
return source;
}
QString WebEngineScript::scrollPercentage(int percent)
{
//TODO
return QString();
}
QString WebEngineScript::scrollUp(int pixel)
{
const QString source = QString::fromLatin1("window.scrollBy(0, %1);").arg(-pixel);
......
......@@ -35,6 +35,7 @@ MESSAGEVIEWER_EXPORT QString setElementByIdVisible(const QString &elementStr, bo
MESSAGEVIEWER_EXPORT QString setStyleToElement(const QString &elementStr, const QString &style);
MESSAGEVIEWER_EXPORT QString scrollDown(int pixel);
MESSAGEVIEWER_EXPORT QString scrollUp(int pixel);
MESSAGEVIEWER_EXPORT QString scrollPercentage(int percent);
}
}
#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