Falkon Develop
Cross-platform Qt-based web browser
qmlwebhittestresult.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2018 Anmol Gautam <tarptaeya@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#include "qmlwebhittestresult.h"
19#include <QQmlEngine>
20
21QmlWebHitTestResult::QmlWebHitTestResult(const WebHitTestResult &webHitTestResult, QObject *parent)
22 : QObject(parent)
23 , m_webHitTestResult(webHitTestResult)
24{
25 QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership);
26}
27
29{
30 return !m_webHitTestResult.imageUrl().isEmpty();
31}
32
34{
35 return m_webHitTestResult.isContentEditable();
36}
37
39{
40 return m_webHitTestResult.isContentSelected();
41}
42
44{
45 return m_webHitTestResult.isNull();
46}
47
49{
50 return !m_webHitTestResult.linkUrl().isEmpty();
51}
52
54{
55 return !m_webHitTestResult.mediaUrl().isEmpty();
56}
57
59{
60 return m_webHitTestResult.mediaPaused();
61}
62
64{
65 return m_webHitTestResult.mediaMuted();
66}
67
69{
70 return m_webHitTestResult.tagName();
71}
72
74{
75 const QUrl base = m_webHitTestResult.baseUrl();
76 return QString::fromUtf8(base.toEncoded());
77}
78
80{
81 return m_webHitTestResult.linkTitle();
82}
83
85{
86 const QUrl link = m_webHitTestResult.linkUrl();
87 return QString::fromUtf8(link.toEncoded());
88}
89
91{
92 const QUrl image = m_webHitTestResult.imageUrl();
93 return QString::fromUtf8(image.toEncoded());
94}
95
97{
98 const QUrl media = m_webHitTestResult.mediaUrl();
99 return QString::fromUtf8(media.toEncoded());
100}
101
103{
104 return m_webHitTestResult.pos();
105}
106
108{
109 return m_webHitTestResult.viewportPos();
110}
QString imageUrl
Gets the url of image on which the context menu is requested.
Q_INVOKABLE bool mediaPaused() const
Checks if the context menu requested on media element is paused.
Q_INVOKABLE bool isLink() const
Checks if the context menu is requested on a link.
QmlWebHitTestResult(const WebHitTestResult &webHitTestResult, QObject *parent=nullptr)
QString linkUrl
Gets the link url on which the context menu is requested.
QString baseUrl
Gets the base url on which the context menu is requested.
QString linkTitle
Gets the link title on which the context menu is requested.
Q_INVOKABLE bool isNull() const
Checks if the context menu is requested on null element.
Q_INVOKABLE bool isMedia() const
Checks if the context menu is requested on a media element.
QPointF viewportPos
Gets the viewport position at which the context menu is requested.
QPoint pos
Gets the position at which the context menu is requested.
QString tagName
Gets the tagName of the element on which the context menu is requested.
Q_INVOKABLE bool isImage() const
Checks if the context menu is requested on image.
Q_INVOKABLE bool mediaMuted() const
Checks if the context menu requested on media element is muted.
QString mediaUrl
Gets the url of media on which the context menu is requested.
Q_INVOKABLE bool isContentEditable() const
Checks if the context menu is requested on editable content.
Q_INVOKABLE bool isContentSelected() const
Checks if the context menu is requested on the selected content.
QPointF viewportPos() const
QString linkTitle() const
bool isContentSelected() const
QPoint pos() const
bool mediaPaused() const
bool mediaMuted() const
QString tagName() const
bool isContentEditable() const