mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
parent
9a415bf40a
commit
d8682ff51d
@ -1,6 +1,6 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - QtWebEngine based browser
|
* QupZilla - QtWebEngine based browser
|
||||||
* Copyright (C) 2015 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2015-2016 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -81,7 +81,8 @@ WebHitTestResult::WebHitTestResult(const WebPage *page, const QPoint &pos)
|
|||||||
"})()");
|
"})()");
|
||||||
|
|
||||||
WebPage *p = const_cast<WebPage*>(page);
|
WebPage *p = const_cast<WebPage*>(page);
|
||||||
const QString &js = source.arg(pos.x()).arg(pos.y());
|
m_viewportPos = p->mapToViewport(m_pos);
|
||||||
|
const QString &js = source.arg(m_viewportPos.x()).arg(m_viewportPos.y());
|
||||||
init(page->url(), p->execJavaScript(js).toMap());
|
init(page->url(), p->execJavaScript(js).toMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,6 +146,11 @@ QPoint WebHitTestResult::pos() const
|
|||||||
return m_pos;
|
return m_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPoint WebHitTestResult::viewportPos() const
|
||||||
|
{
|
||||||
|
return m_viewportPos;
|
||||||
|
}
|
||||||
|
|
||||||
QString WebHitTestResult::tagName() const
|
QString WebHitTestResult::tagName() const
|
||||||
{
|
{
|
||||||
return m_tagName;
|
return m_tagName;
|
||||||
|
@ -44,6 +44,7 @@ public:
|
|||||||
bool mediaPaused() const;
|
bool mediaPaused() const;
|
||||||
bool mediaMuted() const;
|
bool mediaMuted() const;
|
||||||
QPoint pos() const;
|
QPoint pos() const;
|
||||||
|
QPoint viewportPos() const;
|
||||||
QString tagName() const;
|
QString tagName() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -61,6 +62,7 @@ private:
|
|||||||
bool m_mediaPaused;
|
bool m_mediaPaused;
|
||||||
bool m_mediaMuted;
|
bool m_mediaMuted;
|
||||||
QPoint m_pos;
|
QPoint m_pos;
|
||||||
|
QPoint m_viewportPos;
|
||||||
QString m_tagName;
|
QString m_tagName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -126,6 +126,11 @@ QVariant WebPage::execJavaScript(const QString &scriptSource, int timeout)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPoint WebPage::mapToViewport(const QPoint &pos) const
|
||||||
|
{
|
||||||
|
return QPoint(pos.x() / zoomFactor(), pos.y() / zoomFactor());
|
||||||
|
}
|
||||||
|
|
||||||
WebHitTestResult WebPage::hitTestContent(const QPoint &pos) const
|
WebHitTestResult WebPage::hitTestContent(const QPoint &pos) const
|
||||||
{
|
{
|
||||||
return WebHitTestResult(this, pos);
|
return WebHitTestResult(this, pos);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2015 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2016 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -43,6 +43,7 @@ public:
|
|||||||
|
|
||||||
QVariant execJavaScript(const QString &scriptSource, int timeout = 500);
|
QVariant execJavaScript(const QString &scriptSource, int timeout = 500);
|
||||||
|
|
||||||
|
QPoint mapToViewport(const QPoint &pos) const;
|
||||||
WebHitTestResult hitTestContent(const QPoint &pos) const;
|
WebHitTestResult hitTestContent(const QPoint &pos) const;
|
||||||
|
|
||||||
void scroll(int x, int y);
|
void scroll(int x, int y);
|
||||||
|
@ -222,6 +222,11 @@ void WebView::setZoomLevel(int level)
|
|||||||
applyZoom();
|
applyZoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPoint WebView::mapToViewport(const QPoint &pos) const
|
||||||
|
{
|
||||||
|
return page()->mapToViewport(pos);
|
||||||
|
}
|
||||||
|
|
||||||
void WebView::restoreHistory(const QByteArray &data)
|
void WebView::restoreHistory(const QByteArray &data)
|
||||||
{
|
{
|
||||||
QDataStream stream(data);
|
QDataStream stream(data);
|
||||||
@ -814,7 +819,6 @@ void WebView::createSelectedTextContextMenu(QMenu* menu, const WebHitTestResult
|
|||||||
|
|
||||||
void WebView::createMediaContextMenu(QMenu *menu, const WebHitTestResult &hitTest)
|
void WebView::createMediaContextMenu(QMenu *menu, const WebHitTestResult &hitTest)
|
||||||
{
|
{
|
||||||
m_clickedPos = hitTest.pos();
|
|
||||||
bool paused = hitTest.mediaPaused();
|
bool paused = hitTest.mediaPaused();
|
||||||
bool muted = hitTest.mediaMuted();
|
bool muted = hitTest.mediaMuted();
|
||||||
|
|
||||||
@ -829,10 +833,10 @@ void WebView::createMediaContextMenu(QMenu *menu, const WebHitTestResult &hitTes
|
|||||||
|
|
||||||
void WebView::checkForForm(QAction *action, const QPoint &pos)
|
void WebView::checkForForm(QAction *action, const QPoint &pos)
|
||||||
{
|
{
|
||||||
m_clickedPos = pos;
|
m_clickedPos = mapToViewport(pos);
|
||||||
QPointer<QAction> act = action;
|
QPointer<QAction> act = action;
|
||||||
|
|
||||||
page()->runJavaScript(Scripts::getFormData(pos), [this, act](const QVariant &res) {
|
page()->runJavaScript(Scripts::getFormData(m_clickedPos), [this, act](const QVariant &res) {
|
||||||
const QVariantMap &map = res.toMap();
|
const QVariantMap &map = res.toMap();
|
||||||
if (!act || map.isEmpty())
|
if (!act || map.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2016 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -55,6 +55,8 @@ public:
|
|||||||
int zoomLevel() const;
|
int zoomLevel() const;
|
||||||
void setZoomLevel(int level);
|
void setZoomLevel(int level);
|
||||||
|
|
||||||
|
QPoint mapToViewport(const QPoint &pos) const;
|
||||||
|
|
||||||
void restoreHistory(const QByteArray &data);
|
void restoreHistory(const QByteArray &data);
|
||||||
|
|
||||||
void addNotification(QWidget* notif);
|
void addNotification(QWidget* notif);
|
||||||
|
Loading…
Reference in New Issue
Block a user