File indexing completed on 2024-12-22 04:41:14
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2018 Anmol Gautam <tarptaeya@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #pragma once 0019 0020 #include "webhittestresult.h" 0021 #include <QObject> 0022 0023 /** 0024 * @brief The class exposing result of WebHitTest to QML 0025 */ 0026 class QmlWebHitTestResult : public QObject 0027 { 0028 Q_OBJECT 0029 /** 0030 * @brief Gets the tagName of the element on which the context menu is requested. 0031 */ 0032 Q_PROPERTY(QString tagName READ tagName CONSTANT) 0033 /** 0034 * @brief Gets the base url on which the context menu is requested. 0035 */ 0036 Q_PROPERTY(QString baseUrl READ baseUrl CONSTANT) 0037 /** 0038 * @brief Gets the link title on which the context menu is requested. 0039 */ 0040 Q_PROPERTY(QString linkTitle READ linkTitle CONSTANT) 0041 /** 0042 * @brief Gets the link url on which the context menu is requested. 0043 */ 0044 Q_PROPERTY(QString linkUrl READ linkUrl CONSTANT) 0045 /** 0046 * @brief Gets the url of image on which the context menu is requested. 0047 */ 0048 Q_PROPERTY(QString imageUrl READ imageUrl CONSTANT) 0049 /** 0050 * @brief Gets the url of media on which the context menu is requested. 0051 */ 0052 Q_PROPERTY(QString mediaUrl READ mediaUrl CONSTANT) 0053 /** 0054 * @brief Gets the position at which the context menu is requested. 0055 */ 0056 Q_PROPERTY(QPoint pos READ pos CONSTANT) 0057 /** 0058 * @brief Gets the viewport position at which the context menu is requested. 0059 */ 0060 Q_PROPERTY(QPointF viewportPos READ viewportPos CONSTANT) 0061 public: 0062 explicit QmlWebHitTestResult(const WebHitTestResult &webHitTestResult, QObject *parent = nullptr); 0063 /** 0064 * @brief Checks if the context menu is requested on image. 0065 * @return true if image, else false 0066 */ 0067 Q_INVOKABLE bool isImage() const; 0068 /** 0069 * @brief Checks if the context menu is requested on editable content. 0070 * @return true if the content is editable, else false 0071 */ 0072 Q_INVOKABLE bool isContentEditable() const; 0073 /** 0074 * @brief Checks if the context menu is requested on the selected content. 0075 * @return true if content is selected, else false. 0076 */ 0077 Q_INVOKABLE bool isContentSelected() const; 0078 /** 0079 * @brief Checks if the context menu is requested on null element. 0080 * @return true if the element is null, else false 0081 */ 0082 Q_INVOKABLE bool isNull() const; 0083 /** 0084 * @brief Checks if the context menu is requested on a link. 0085 * @return true if the element is link, else false 0086 */ 0087 Q_INVOKABLE bool isLink() const; 0088 /** 0089 * @brief Checks if the context menu is requested on a media element. 0090 * @return true if the element is media, else false 0091 */ 0092 Q_INVOKABLE bool isMedia() const; 0093 /** 0094 * @brief Checks if the context menu requested on media element is paused. 0095 * @return true if media is paused, else false 0096 */ 0097 Q_INVOKABLE bool mediaPaused() const; 0098 /** 0099 * @brief Checks if the context menu requested on media element is muted. 0100 * @return true if media is muted, else false 0101 */ 0102 Q_INVOKABLE bool mediaMuted() const; 0103 QString tagName() const; 0104 QString baseUrl() const; 0105 QString linkTitle() const; 0106 QString linkUrl() const; 0107 QString imageUrl() const; 0108 QString mediaUrl() const; 0109 QPoint pos() const; 0110 QPointF viewportPos() const; 0111 0112 private: 0113 WebHitTestResult m_webHitTestResult; 0114 };