1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00
This commit is contained in:
Anmol Gautam 2018-08-05 22:44:34 +05:30
parent de0cb89dda
commit 87230c4a77
46 changed files with 662 additions and 762 deletions

View File

@ -16,13 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "qmltesthelper.h"
#include "qml/qmlplugins.h"
#include <QQmlComponent>
#include <QDebug>
QmlTestHelper::QmlTestHelper()
{
qmlRegisterType<QmlTestItem>("org.kde.falkon.test", 1, 0, "TestItem");
QmlPlugins::registerQmlTypes();
qmlRegisterType<QmlTestItem>("org.kde.falkon.test", 1, 0, "TestItem");
QQmlComponent component(&engine);
component.setData("import org.kde.falkon 1.0 as Falkon\n"
"import org.kde.falkon.test 1.0 as FalkonTest\n"

View File

@ -9,3 +9,7 @@
/* Disable DBus support */
#cmakedefine DISABLE_DBUS
if (LibIntl_FOUND)
target_compile_definitions(FalkonPrivate PRIVATE LibIntl_FOUND=1)
endif()

View File

@ -37,14 +37,13 @@ Plugins::Plugins(QObject* parent)
: QObject(parent)
, m_pluginsLoaded(false)
, m_speedDial(new SpeedDial(this))
, m_qmlSupportLoaded(false)
{
loadSettings();
if (!MainApplication::isTestModeEnabled()) {
loadPythonSupport();
}
loadQmlSupport();
}
QList<Plugins::Plugin> Plugins::getAvailablePlugins()
@ -292,6 +291,7 @@ void Plugins::loadPythonSupport()
void Plugins::loadQmlSupport()
{
QmlPlugins::registerQmlTypes();
m_qmlSupportLoaded = true;
}
Plugins::Plugin Plugins::loadPlugin(const QString &id)
@ -397,6 +397,10 @@ Plugins::Plugin Plugins::loadPythonPlugin(const QString &name)
Plugins::Plugin Plugins::loadQmlPlugin(const QString &name)
{
if (!m_qmlSupportLoaded) {
loadQmlSupport();
}
QString fullPath;
if (QFileInfo(name).isAbsolute()) {
fullPath = name;

View File

@ -147,6 +147,7 @@ private:
QList<PluginInterface*> m_internalPlugins;
QLibrary *m_pythonPlugin = nullptr;
bool m_qmlSupportLoaded;
};
Q_DECLARE_METATYPE(Plugins::Plugin)

View File

@ -89,80 +89,36 @@ BookmarkItem *QmlBookmarks::getBookmarkItem(QObject *object) const
return item;
}
/**
* @brief Checks if the url is bookmarked
* @param String representing the url to check
* @return true if bookmarked, else false
*/
bool QmlBookmarks::isBookmarked(const QString &url) const
{
return mApp->bookmarks()->isBookmarked(QUrl::fromEncoded(url.toUtf8()));
}
/**
* @brief Get the root bookmark item
* @return Root boomkark item
*/
QmlBookmarkTreeNode *QmlBookmarks::rootItem() const
{
return bookmarkTreeNodeData->get(mApp->bookmarks()->rootItem());
}
/**
* @brief Get the bookmarks toolbar
* @return Bookmarks toolbar
*/
QmlBookmarkTreeNode *QmlBookmarks::toolbarFolder() const
{
return bookmarkTreeNodeData->get(mApp->bookmarks()->toolbarFolder());
}
/**
* @brief Get the bookmarks menu folder
* @return Bookmarks menu folder
*/
QmlBookmarkTreeNode *QmlBookmarks::menuFolder() const
{
return bookmarkTreeNodeData->get(mApp->bookmarks()->menuFolder());
}
/**
* @brief Get the unsorted bookmarks folder
* @return Unsorted bookmarks folder
*/
QmlBookmarkTreeNode *QmlBookmarks::unsortedFolder() const
{
return bookmarkTreeNodeData->get(mApp->bookmarks()->unsortedFolder());
}
/**
* @brief Get the last used bookmarks folder
* @return Last used bookmarks folder
*/
QmlBookmarkTreeNode *QmlBookmarks::lastUsedFolder() const
{
return bookmarkTreeNodeData->get(mApp->bookmarks()->lastUsedFolder());
}
/**
* @brief Creates a bookmark item
* @param A JavaScript object containing
* - parent:
* Object of type [QmlBookmarkTreeNode](@ref QmlBookmarkTreeNode), representing
* the parent of the new bookmark item. This is required field.
* - title:
* String representing the title of the new bookmark item. Defaults to empty string
* - url:
* String representing the url of the new bookmark item. Defaults to empty string
* - description
* String representing the description of the new bookmark item. Defaults to empty string
* - type:
* [Type](@ref QmlBookmarkTreeNode::Type) representing the type of the new bookmark item.
* Defaults to [Url](@ref QmlBookmarkTreeNode::Url) if url is provided, else
* [Folder](@ref QmlBookmarkTreeNode::Folder) if title is provided, else
* [Invalid](@ref QmlBookmarkTreeNode::Invalid)
* @return true if the bookmark it created, else false
*/
bool QmlBookmarks::create(const QVariantMap &map) const
{
if (!map.contains(QSL("parent"))) {
@ -200,12 +156,6 @@ bool QmlBookmarks::create(const QVariantMap &map) const
return true;
}
/**
* @brief Removes a bookmark item
* @param treeNode:
* Object of type [QmlBookmarkTreeNode](@ref QmlBookmarkTreeNode) to be removed
* @return true if the bookmark is removed, else false
*/
bool QmlBookmarks::remove(QmlBookmarkTreeNode *treeNode) const
{
auto item = getBookmarkItem(treeNode);
@ -216,16 +166,6 @@ bool QmlBookmarks::remove(QmlBookmarkTreeNode *treeNode) const
return mApp->bookmarks()->removeBookmark(item);
}
/**
* @brief QmlBookmarks::search
* @param A JavaScript object containing
* - query:
* String containing search query
* - url:
* String representing url to be search
* @return List containing [QmlBookmarkTreeNode](@ref QmlBookmarkTreeNode). If both
* query and url are not supplied then empty list is returned.
*/
QList<QObject*> QmlBookmarks::search(const QVariantMap &map) const
{
if (!map.contains(QSL("query")) && !map.contains(QSL("url"))) {
@ -248,19 +188,6 @@ QList<QObject*> QmlBookmarks::search(const QVariantMap &map) const
return ret;
}
/**
* @brief Updates a bookmark item
* @param Object of type [QmlBookmarkTreeNode](@ref QmlBookmarkTreeNode), representing the bookmark
* to update
* @param JavaScript object containing the values to be updated
* - title:
* String representing the new title of the bookmark item
* - description:
* String representing the new description of the bookmark item
* - keyword:
* String representing the new keyword of the bookmark item
* @return true if the bookmark is updated, else false
*/
bool QmlBookmarks::update(QObject *object, const QVariantMap &changes) const
{
auto treeNode = qobject_cast<QmlBookmarkTreeNode*>(object);
@ -299,12 +226,6 @@ bool QmlBookmarks::update(QObject *object, const QVariantMap &changes) const
return true;
}
/**
* @brief Get the first matched bookmark item
* @param String representing the query
* @return Object of type [QmlBookmarkTreeNode](@ref QmlBookmarkTreeNode) if
* the query is matched with a bookmark, else null
*/
QmlBookmarkTreeNode *QmlBookmarks::get(const QString &string) const
{
auto items = mApp->bookmarks()->searchBookmarks(QUrl(string));
@ -317,12 +238,6 @@ QmlBookmarkTreeNode *QmlBookmarks::get(const QString &string) const
return nullptr;
}
/**
* @brief Get children of the bookmark item
* @param Object of type [QmlBookmarkTreeNode](@ref QmlBookmarkTreeNode), representing
* the parent whose children are requested.
* @return List containing the children, of type [QmlBookmarkTreeNode](@ref QmlBookmarkTreeNode)
*/
QList<QObject*> QmlBookmarks::getChildren(QObject *object) const
{
QList<QObject*> ret;
@ -343,8 +258,5 @@ QList<QObject*> QmlBookmarks::getChildren(QObject *object) const
bool QmlBookmarks::isTreeNodeEqualsItem(QmlBookmarkTreeNode *treeNode, BookmarkItem *item) const
{
return treeNode->title() == item->title()
&& treeNode->url() == item->urlString()
&& treeNode->description() == item->description()
&& (int)(treeNode->type()) == (int)(item->type());
return treeNode->item() == item;
}

View File

@ -32,17 +32,102 @@ class QmlBookmarks : public QObject
public:
explicit QmlBookmarks(QObject *parent = nullptr);
/**
* @brief Checks if the url is bookmarked
* @param String representing the url to check
* @return true if bookmarked, else false
*/
Q_INVOKABLE bool isBookmarked(const QString &url) const;
/**
* @brief Get the root bookmark item
* @return Root boomkark item
*/
Q_INVOKABLE QmlBookmarkTreeNode *rootItem() const;
/**
* @brief Get the bookmarks toolbar
* @return Bookmarks toolbar
*/
Q_INVOKABLE QmlBookmarkTreeNode *toolbarFolder() const;
/**
* @brief Get the bookmarks menu folder
* @return Bookmarks menu folder
*/
Q_INVOKABLE QmlBookmarkTreeNode *menuFolder() const;
/**
* @brief Get the unsorted bookmarks folder
* @return Unsorted bookmarks folder
*/
Q_INVOKABLE QmlBookmarkTreeNode *unsortedFolder() const;
/**
* @brief Get the last used bookmarks folder
* @return Last used bookmarks folder
*/
Q_INVOKABLE QmlBookmarkTreeNode *lastUsedFolder() const;
/**
* @brief Creates a bookmark item
* @param A JavaScript object containing
* - parent:
* Object of type [QmlBookmarkTreeNode](@ref QmlBookmarkTreeNode), representing
* the parent of the new bookmark item. This is required field.
* - title:
* String representing the title of the new bookmark item. Defaults to empty string
* - url:
* String representing the url of the new bookmark item. Defaults to empty string
* - description
* String representing the description of the new bookmark item. Defaults to empty string
* - type:
* [Type](@ref QmlBookmarkTreeNode::Type) representing the type of the new bookmark item.
* Defaults to [Url](@ref QmlBookmarkTreeNode::Url) if url is provided, else
* [Folder](@ref QmlBookmarkTreeNode::Folder) if title is provided, else
* [Invalid](@ref QmlBookmarkTreeNode::Invalid)
* @return true if the bookmark it created, else false
*/
Q_INVOKABLE bool create(const QVariantMap &map) const;
/**
* @brief Removes a bookmark item
* @param treeNode:
* Object of type [QmlBookmarkTreeNode](@ref QmlBookmarkTreeNode) to be removed
* @return true if the bookmark is removed, else false
*/
Q_INVOKABLE bool remove(QmlBookmarkTreeNode *treeNode) const;
/**
* @brief QmlBookmarks::search
* @param A JavaScript object containing
* - query:
* String containing search query
* - url:
* String representing url to be search
* @return List containing [QmlBookmarkTreeNode](@ref QmlBookmarkTreeNode). If both
* query and url are not supplied then empty list is returned.
*/
Q_INVOKABLE QList<QObject*> search(const QVariantMap &map) const;
/**
* @brief Updates a bookmark item
* @param Object of type [QmlBookmarkTreeNode](@ref QmlBookmarkTreeNode), representing the bookmark
* to update
* @param JavaScript object containing the values to be updated
* - title:
* String representing the new title of the bookmark item
* - description:
* String representing the new description of the bookmark item
* - keyword:
* String representing the new keyword of the bookmark item
* @return true if the bookmark is updated, else false
*/
Q_INVOKABLE bool update(QObject *object, const QVariantMap &changes) const;
/**
* @brief Get the first matched bookmark item
* @param String representing the query
* @return Object of type [QmlBookmarkTreeNode](@ref QmlBookmarkTreeNode) if
* the query is matched with a bookmark, else null
*/
Q_INVOKABLE QmlBookmarkTreeNode *get(const QString &string) const;
/**
* @brief Get children of the bookmark item
* @param Object of type [QmlBookmarkTreeNode](@ref QmlBookmarkTreeNode), representing
* the parent whose children are requested.
* @return List containing the children, of type [QmlBookmarkTreeNode](@ref QmlBookmarkTreeNode)
*/
Q_INVOKABLE QList<QObject*> getChildren(QObject *object) const;
Q_SIGNALS:

View File

@ -28,6 +28,11 @@ QmlBookmarkTreeNode::QmlBookmarkTreeNode(BookmarkItem *item)
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
}
BookmarkItem *QmlBookmarkTreeNode::item()
{
return m_item;
}
QmlBookmarkTreeNode::Type QmlBookmarkTreeNode::type() const
{
if (!m_item) {

View File

@ -87,6 +87,7 @@ public:
explicit QmlBookmarkTreeNode(BookmarkItem *item = nullptr);
BookmarkItem *item();
Type type() const;
QString title() const;
QString url() const;

View File

@ -213,9 +213,6 @@ void QmlBrowserActionButton::setIcon(const QString &icon)
m_iconUrl = icon;
if (QIcon::hasThemeIcon(m_iconUrl)) {
AbstractButtonInterface::setIcon(QIcon::fromTheme(m_iconUrl));
} else if (m_iconUrl.startsWith(QSL(":"))) {
// Icon is loaded from falkon resource
AbstractButtonInterface::setIcon(QIcon(m_iconUrl));
} else {
const QString pluginPath = m_popup->creationContext()->contextProperty("__path__").toString();
QmlFileUtils fileUtils(pluginPath);

View File

@ -24,10 +24,6 @@ QmlClipboard::QmlClipboard(QObject *parent)
{
}
/**
* @brief Copy the string to clipboard
* @param String representing the text to be copied
*/
void QmlClipboard::copy(const QString &text)
{
mApp->clipboard()->setText(text);

View File

@ -28,5 +28,9 @@ class QmlClipboard : public QObject
Q_OBJECT
public:
explicit QmlClipboard(QObject *parent = nullptr);
/**
* @brief Copy the string to clipboard
* @param String representing the text to be copied
*/
Q_INVOKABLE void copy(const QString &text);
};

View File

@ -26,7 +26,6 @@ QmlCookies::QmlCookies(QObject *parent)
: QObject(parent)
{
connect(mApp->cookieJar(), &CookieJar::cookieAdded, this, [this](QNetworkCookie network_cookie){
// FIXME: improve this
QmlCookie *cookie = cookieData->get(&network_cookie);
QVariantMap map;
map.insert(QSL("cookie"), QVariant::fromValue(cookie));
@ -35,7 +34,6 @@ QmlCookies::QmlCookies(QObject *parent)
});
connect(mApp->cookieJar(), &CookieJar::cookieRemoved, this, [this](QNetworkCookie network_cookie){
// FIXME: improve this
QmlCookie *cookie = cookieData->get(&network_cookie);
QVariantMap map;
map.insert(QSL("cookie"), QVariant::fromValue(cookie));
@ -61,16 +59,6 @@ QNetworkCookie *QmlCookies::getNetworkCookie(const QVariantMap &map)
return nullptr;
}
/**
* @brief Get a cookie
* @param A JavaScript object containing
* - name:
* String representing the name of the cookie
* - url:
* String representing the url of the cookie
* @return Cookie of type [QmlCookie](@ref QmlCookie)
* if such cookie exists, else null
*/
QmlCookie *QmlCookies::get(const QVariantMap &map)
{
QNetworkCookie *netCookie = getNetworkCookie(map);
@ -80,21 +68,6 @@ QmlCookie *QmlCookies::get(const QVariantMap &map)
return cookieData->get(netCookie);
}
/**
* @brief Get all cookies matching a criteria
* @param A JavaScript object containing
* - name:
* String representing the name of the cookie
* - url:
* String representing the url of the cookie
* - path:
* String representing the path of the cookie
* - secure:
* Bool representing if the cookie is secure
* - session:
* Bool representing if the cookie is a session cookie
* @return List containing cookies, each of type [QmlCookie](@ref QmlCookie)
*/
QList<QObject*> QmlCookies::getAll(const QVariantMap &map)
{
QList<QObject*> qmlCookies;
@ -117,24 +90,6 @@ QList<QObject*> QmlCookies::getAll(const QVariantMap &map)
return qmlCookies;
}
/**
* @brief Set a cookie
* @param A JavaScript object containing
* - name:
* String representing the name of the cookie
* - url:
* String representing the name of the cookie
* - path:
* String representing the path of the cookie
* - secure:
* Bool representing if the cookie is secure
* - expirationDate:
* A JavaScript Date object, representing the expiration date of the cookie
* - httpOnly:
* Bool representing if the cookie is httpOnly
* - value:
* String representing the value of the cookie
*/
void QmlCookies::set(const QVariantMap &map)
{
const QString name = map.value(QSL("name")).toString();
@ -155,14 +110,6 @@ void QmlCookies::set(const QVariantMap &map)
mApp->webProfile()->cookieStore()->setCookie(cookie);
}
/**
* @brief Remove a cookie
* @param A JavaScript object containing
* - name:
* String representing the name of the cookie
* - url:
* String representing the url of the cookie
*/
void QmlCookies::remove(const QVariantMap &map)
{
QNetworkCookie *netCookie = getNetworkCookie(map);

View File

@ -28,9 +28,60 @@ class QmlCookies : public QObject
Q_OBJECT
public:
explicit QmlCookies(QObject *parent = nullptr);
/**
* @brief Get a cookie
* @param A JavaScript object containing
* - name:
* String representing the name of the cookie
* - url:
* String representing the url of the cookie
* @return Cookie of type [QmlCookie](@ref QmlCookie)
* if such cookie exists, else null
*/
Q_INVOKABLE QmlCookie *get(const QVariantMap &map);
/**
* @brief Get all cookies matching a criteria
* @param A JavaScript object containing
* - name:
* String representing the name of the cookie
* - url:
* String representing the url of the cookie
* - path:
* String representing the path of the cookie
* - secure:
* Bool representing if the cookie is secure
* - session:
* Bool representing if the cookie is a session cookie
* @return List containing cookies, each of type [QmlCookie](@ref QmlCookie)
*/
Q_INVOKABLE QList<QObject*> getAll(const QVariantMap &map);
/**
* @brief Set a cookie
* @param A JavaScript object containing
* - name:
* String representing the name of the cookie
* - url:
* String representing the name of the cookie
* - path:
* String representing the path of the cookie
* - secure:
* Bool representing if the cookie is secure
* - expirationDate:
* A JavaScript Date object, representing the expiration date of the cookie
* - httpOnly:
* Bool representing if the cookie is httpOnly
* - value:
* String representing the value of the cookie
*/
Q_INVOKABLE void set(const QVariantMap &map);
/**
* @brief Remove a cookie
* @param A JavaScript object containing
* - name:
* String representing the name of the cookie
* - url:
* String representing the url of the cookie
*/
Q_INVOKABLE void remove(const QVariantMap &map);
Q_SIGNALS:
/**

View File

@ -22,69 +22,46 @@ QmlKeyEvent::QmlKeyEvent(QKeyEvent *keyEvent, QObject *parent)
: QObject(parent)
, m_keyEvent(keyEvent)
{
delete keyEvent;
QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership);
}
int QmlKeyEvent::count() const
{
if (!m_keyEvent) {
return -1;
}
return m_keyEvent->count();
}
bool QmlKeyEvent::isAutoRepeat() const
{
if (!m_keyEvent) {
return false;
}
return m_keyEvent->isAutoRepeat();
}
int QmlKeyEvent::key() const
{
if (!m_keyEvent) {
return -1;
}
return m_keyEvent->key();
}
int QmlKeyEvent::modifiers() const
{
if (!m_keyEvent) {
return -1;
}
return (int)m_keyEvent->modifiers();
}
quint32 QmlKeyEvent::nativeModifiers() const
{
if (!m_keyEvent) {
return -1;
}
return m_keyEvent->nativeModifiers();
}
quint32 QmlKeyEvent::nativeScanCode() const
{
if (!m_keyEvent) {
return -1;
}
return m_keyEvent->nativeScanCode();
}
quint32 QmlKeyEvent::nativeVirtualKey() const
{
if (!m_keyEvent) {
return -1;
}
return m_keyEvent->nativeVirtualKey();
}
QString QmlKeyEvent::text() const
{
if (!m_keyEvent) {
return QString();
}
return m_keyEvent->text();
}

View File

@ -27,96 +27,60 @@ QmlMouseEvent::QmlMouseEvent(QMouseEvent *mouseEvent, QObject *parent)
int QmlMouseEvent::button() const
{
if (!m_mouseEvent) {
return -1;
}
return (int)m_mouseEvent->button();
}
int QmlMouseEvent::buttons() const
{
if (!m_mouseEvent) {
return -1;
}
return (int)m_mouseEvent->buttons();
}
QPoint QmlMouseEvent::globalPos() const
{
if (!m_mouseEvent) {
return QPoint(-1, -1);
}
return m_mouseEvent->globalPos();
}
int QmlMouseEvent::globalX() const
{
if (!m_mouseEvent) {
return -1;
}
return m_mouseEvent->globalX();
}
int QmlMouseEvent::globalY() const
{
if (!m_mouseEvent) {
return -1;
}
return m_mouseEvent->globalY();
}
QPointF QmlMouseEvent::localPos() const
{
if (!m_mouseEvent) {
return QPointF(-1, -1);
}
return m_mouseEvent->localPos();
}
QPoint QmlMouseEvent::pos() const
{
if (!m_mouseEvent) {
return QPoint(-1, -1);
}
return m_mouseEvent->pos();
}
QPointF QmlMouseEvent::screenPos() const
{
if (!m_mouseEvent) {
return QPointF(-1, -1);
}
return m_mouseEvent->screenPos();
}
int QmlMouseEvent::source() const
{
if (!m_mouseEvent) {
return -1;
}
return (int)m_mouseEvent->source();
}
QPointF QmlMouseEvent::windowPos() const
{
if (!m_mouseEvent) {
return QPointF(-1, -1);
}
return m_mouseEvent->windowPos();
}
int QmlMouseEvent::x() const
{
if (!m_mouseEvent) {
return -1;
}
return m_mouseEvent->x();
}
int QmlMouseEvent::y() const
{
if (!m_mouseEvent) {
return -1;
}
return m_mouseEvent->y();
}

View File

@ -27,112 +27,70 @@ QmlWheelEvent::QmlWheelEvent(QWheelEvent *wheelEvent, QObject *parent)
QPoint QmlWheelEvent::angleDelta() const
{
if (!m_wheelEvent) {
return QPoint(-1, -1);
}
return m_wheelEvent->angleDelta();
}
int QmlWheelEvent::buttons() const
{
if (!m_wheelEvent) {
return -1;
}
return (int)m_wheelEvent->buttons();
}
QPoint QmlWheelEvent::globalPos() const
{
if (!m_wheelEvent) {
return QPoint(-1, -1);
}
return m_wheelEvent->globalPos();
}
QPointF QmlWheelEvent::globalPosF() const
{
if (!m_wheelEvent) {
return QPointF(-1, -1);
}
return m_wheelEvent->globalPosF();
}
int QmlWheelEvent::globalX() const
{
if (!m_wheelEvent) {
return -1;
}
return m_wheelEvent->globalX();
}
int QmlWheelEvent::globalY() const
{
if (!m_wheelEvent) {
return -1;
}
return m_wheelEvent->globalY();
}
bool QmlWheelEvent::inverted() const
{
if (!m_wheelEvent) {
return false;
}
return m_wheelEvent->inverted();
}
int QmlWheelEvent::phase() const
{
if (!m_wheelEvent) {
return -1;
}
return (int)m_wheelEvent->phase();
}
QPoint QmlWheelEvent::pixelDelta() const
{
if (!m_wheelEvent) {
return QPoint(-1, -1);
}
return m_wheelEvent->pixelDelta();
}
QPoint QmlWheelEvent::pos() const
{
if (!m_wheelEvent) {
return QPoint(-1, -1);
}
return m_wheelEvent->pos();
}
QPointF QmlWheelEvent::posF() const
{
if (!m_wheelEvent) {
return QPointF(-1, -1);
}
return m_wheelEvent->posF();
}
int QmlWheelEvent::source() const
{
if (!m_wheelEvent) {
return -1;
}
return (int)m_wheelEvent->source();
}
int QmlWheelEvent::x() const
{
if (!m_wheelEvent) {
return -1;
}
return m_wheelEvent->x();
}
int QmlWheelEvent::y() const
{
if (!m_wheelEvent) {
return -1;
}
return m_wheelEvent->y();
}

View File

@ -26,10 +26,6 @@ QmlWebEngineUrlRequestJob::QmlWebEngineUrlRequestJob(QWebEngineUrlRequestJob *jo
{
}
/**
* @brief Fails the request with the error
* @param error
*/
void QmlWebEngineUrlRequestJob::fail(QmlWebEngineUrlRequestJob::Error error)
{
if (!m_job) {
@ -38,10 +34,6 @@ void QmlWebEngineUrlRequestJob::fail(QmlWebEngineUrlRequestJob::Error error)
m_job->fail(QWebEngineUrlRequestJob::Error(error));
}
/**
* @brief Redirects the request to the url
* @param urlString, represents the url to which the request is to be redirected
*/
void QmlWebEngineUrlRequestJob::redirect(const QString &urlString)
{
if (!m_job) {
@ -50,12 +42,6 @@ void QmlWebEngineUrlRequestJob::redirect(const QString &urlString)
return m_job->redirect(QUrl::fromEncoded(urlString.toUtf8()));
}
/**
* @brief Replies to the request
* @param A JavaScript object containing
* - content: String representing the reply data
* - contentType: String representing the contentType of reply data
*/
void QmlWebEngineUrlRequestJob::reply(const QVariantMap &map)
{
if (!m_job) {

View File

@ -51,8 +51,22 @@ public:
};
Q_ENUM(Error)
explicit QmlWebEngineUrlRequestJob(QWebEngineUrlRequestJob *job = nullptr, QObject *parent = nullptr);
/**
* @brief Fails the request with the error
* @param error
*/
Q_INVOKABLE void fail(Error error);
/**
* @brief Redirects the request to the url
* @param urlString, represents the url to which the request is to be redirected
*/
Q_INVOKABLE void redirect(const QString &urlString);
/**
* @brief Replies to the request
* @param A JavaScript object containing
* - content: String representing the reply data
* - contentType: String representing the contentType of reply data
*/
Q_INVOKABLE void reply(const QVariantMap &map);
private:
QWebEngineUrlRequestJob *m_job;

View File

@ -35,12 +35,6 @@ QmlHistory::QmlHistory(QObject *parent)
});
}
/**
* @brief Searches History Entries against a search query
* @param String representing the search query
* @return List of History Entries, each of type [QmlHistoryItem](@ref QmlHistoryItem),
* matching the search query
*/
QList<QObject*> QmlHistory::search(const QString &text)
{
QList<QObject*> list;
@ -53,25 +47,12 @@ QList<QObject*> QmlHistory::search(const QString &text)
return list;
}
/**
* @brief Get the visit count of a url
* @param String representing the url
* @return Integer representing the visit count of the given url
*/
int QmlHistory::getVisits(const QString &url)
{
HistoryEntry *entry = mApp->history()->getHistoryEntry(url);
return entry->count;
}
/**
* @brief Add url to the history
* @param A JavaScript object containing
* - title:
* String representing the title of the hisotry entry
* - url:
* String representing the url of the history entry
*/
void QmlHistory::addUrl(const QVariantMap &map)
{
if (!map.contains(QSL("title")) || !map.contains(QSL("url"))) {
@ -86,23 +67,11 @@ void QmlHistory::addUrl(const QVariantMap &map)
mApp->history()->addHistoryEntry(QUrl::fromEncoded(url.toUtf8()), title);
}
/**
* @brief Deletes a url from the history
* @param String representing the url of the history entry
*/
void QmlHistory::deleteUrl(const QString &url)
{
mApp->history()->deleteHistoryEntry(url);
}
/**
* @brief Deletes history entries within the given range
* @param A JavaScript object containing
* - startTime:
* A JavaScript Date object representing the start time
* - endTime:
* A JavaScript Date object representing the end time
*/
void QmlHistory::deleteRange(const QVariantMap &map)
{
if (!map.contains(QSL("startTime")) || !map.contains(QSL("endTime"))) {
@ -114,9 +83,6 @@ void QmlHistory::deleteRange(const QVariantMap &map)
mApp->history()->deleteRange(startTime, endTime);
}
/**
* @brief Clears all the history
*/
void QmlHistory::deleteAll()
{
mApp->history()->clearHistory();

View File

@ -28,11 +28,45 @@ class QmlHistory : public QObject
Q_OBJECT
public:
explicit QmlHistory(QObject *parent = nullptr);
/**
* @brief Searches History Entries against a search query
* @param String representing the search query
* @return List of History Entries, each of type [QmlHistoryItem](@ref QmlHistoryItem),
* matching the search query
*/
Q_INVOKABLE QList<QObject*> search(const QString &text);
/**
* @brief Get the visit count of a url
* @param String representing the url
* @return Integer representing the visit count of the given url
*/
Q_INVOKABLE int getVisits(const QString &url);
/**
* @brief Add url to the history
* @param A JavaScript object containing
* - title:
* String representing the title of the hisotry entry
* - url:
* String representing the url of the history entry
*/
Q_INVOKABLE void addUrl(const QVariantMap &map);
/**
* @brief Deletes a url from the history
* @param String representing the url of the history entry
*/
Q_INVOKABLE void deleteUrl(const QString &url);
/**
* @brief Deletes history entries within the given range
* @param A JavaScript object containing
* - startTime:
* A JavaScript Date object representing the start time
* - endTime:
* A JavaScript Date object representing the end time
*/
Q_INVOKABLE void deleteRange(const QVariantMap &map);
/**
* @brief Clears all the history
*/
Q_INVOKABLE void deleteAll();
Q_SIGNALS:
/**

View File

@ -25,10 +25,6 @@ QmlHistoryItem::QmlHistoryItem(HistoryEntry *entry, QObject *parent)
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
}
/**
* @brief Get the id of the HistoryEntry
* @return Integer representing the id of the HistoryEntry if it exists, else 0
*/
int QmlHistoryItem::id() const
{
if (!m_entry) {
@ -37,10 +33,6 @@ int QmlHistoryItem::id() const
return m_entry->id;
}
/**
* @brief Get the url of the HistoryEntry
* @return String representing the url of the HistoryEntry
*/
QString QmlHistoryItem::url() const
{
if (!m_entry) {
@ -49,10 +41,6 @@ QString QmlHistoryItem::url() const
return QString::fromUtf8(m_entry->url.toEncoded());
}
/**
* @brief Get the title of the HistoryEntry
* @return String representing the title of the HistoryEntry
*/
QString QmlHistoryItem::title() const
{
if (!m_entry) {
@ -61,10 +49,6 @@ QString QmlHistoryItem::title() const
return m_entry->title;
}
/**
* @brief Get the visit count of the HistoryEntry
* @return Integer representing the visit count of the HistoryEntry
*/
int QmlHistoryItem::visitCount() const
{
if (!m_entry) {
@ -73,10 +57,6 @@ int QmlHistoryItem::visitCount() const
return m_entry->count;
}
/**
* @brief Get the last visit time of the HistoryEntry
* @return Last visit time of the HistoryEntry
*/
QDateTime QmlHistoryItem::lastVisitTime() const
{
if (!m_entry) {

View File

@ -37,17 +37,11 @@ void QmlI18n::initTranslations()
textdomain(domain.toUtf8());
}
/**
* @brief wrapper for gettext function
*/
QString QmlI18n::i18n(const QString &string)
{
return QString::fromUtf8(gettext(string.toUtf8()));
}
/**
* @brief wrapper for ngettext function
*/
QString QmlI18n::i18np(const QString &string1, const QString &string2, int count)
{
return QString::fromUtf8(ngettext(string1.toUtf8(), string2.toUtf8(), count));

View File

@ -18,11 +18,10 @@
#pragma once
#include <QObject>
#include <libintl.h>
// libintl.h redefines inline which causes MSVC to abort compilation with the message
// fatal error C1189: #error : The C++ Standard Library forbids macroizing keywords
#undef inline
extern "C" {
#include <libintl.h>
}
/**
* @brief The class exposing GNU Gettext to QML
@ -33,7 +32,13 @@ class QmlI18n : public QObject
public:
explicit QmlI18n(const QString &pluginName, QObject *parent = nullptr);
void initTranslations();
/**
* @brief wrapper for gettext function
*/
Q_INVOKABLE QString i18n(const QString &string);
/**
* @brief wrapper for ngettext function
*/
Q_INVOKABLE QString i18np(const QString &string1, const QString &string2, int count);
private:
QString m_pluginName;

View File

@ -41,9 +41,6 @@ void QmlAction::setProperties(const QVariantMap &map)
QIcon icon;
if (QIcon::hasThemeIcon(iconPath)) {
icon = QIcon::fromTheme(iconPath);
} else if (iconPath.startsWith(QSL(":"))) {
// Icon is loaded from falkon resource
icon = QIcon(iconPath);
} else {
QmlFileUtils fileUtils(m_pluginPath);
icon = QIcon(fileUtils.resolve(iconPath));
@ -57,10 +54,6 @@ void QmlAction::setProperties(const QVariantMap &map)
}
}
/**
* @brief Updates the properties of the action
* @param A JavaScript object containing the updated properties of the action.
*/
void QmlAction::update(const QVariantMap &map)
{
setProperties(map);

View File

@ -30,6 +30,10 @@ class QmlAction : public QObject
public:
explicit QmlAction(QAction *action, QObject *parent = nullptr);
void setProperties(const QVariantMap &map);
/**
* @brief Updates the properties of the action
* @param A JavaScript object containing the updated properties of the action.
*/
Q_INVOKABLE void update(const QVariantMap &map);
void setPluginPath(const QString &path);

View File

@ -29,13 +29,6 @@ QmlMenu::QmlMenu(QMenu *menu, QObject *parent)
connect(m_menu, &QMenu::triggered, this, &QmlMenu::triggered);
}
/**
* @brief Adds action to menu
* @param A JavaScript object containing properties for action.
* The icon property must be in form of url of the path
* and shortcut in form string.
* @return action of type [QmlAction](@ref QmlAction)
*/
QmlAction *QmlMenu::addAction(const QVariantMap &map)
{
if (!m_menu) {
@ -51,12 +44,6 @@ QmlAction *QmlMenu::addAction(const QVariantMap &map)
return qmlAction;
}
/**
* @brief Adds sub-menu to menu
* @param A JavaScript object containing properties of menu.
* The icon property must be in form of url of the path.
* @return menu of type [QmlMenu](@ref QmlMenu)
*/
QmlMenu *QmlMenu::addMenu(const QVariantMap &map)
{
if (!m_menu) {
@ -72,9 +59,6 @@ QmlMenu *QmlMenu::addMenu(const QVariantMap &map)
QIcon icon;
if (QIcon::hasThemeIcon(iconPath)) {
icon = QIcon::fromTheme(iconPath);
} else if (iconPath.startsWith(QSL(":"))) {
// Icon is loaded from falkon resource
icon = QIcon(iconPath);
} else {
QmlFileUtils fileUtils(m_pluginPath);
icon = QIcon(fileUtils.resolve(iconPath));
@ -90,9 +74,6 @@ QmlMenu *QmlMenu::addMenu(const QVariantMap &map)
return newQmlMenu;
}
/**
* @brief Adds a separator to menu
*/
void QmlMenu::addSeparator()
{
if (!m_menu) {

View File

@ -28,8 +28,24 @@ class QmlMenu : public QObject
Q_OBJECT
public:
explicit QmlMenu(QMenu *menu, QObject *parent = nullptr);
/**
* @brief Adds action to menu
* @param A JavaScript object containing properties for action.
* The icon property must be in form of url of the path
* and shortcut in form string.
* @return action of type [QmlAction](@ref QmlAction)
*/
Q_INVOKABLE QmlAction *addAction(const QVariantMap &map);
/**
* @brief Adds sub-menu to menu
* @param A JavaScript object containing properties of menu.
* The icon property must be in form of url of the path.
* @return menu of type [QmlMenu](@ref QmlMenu)
*/
Q_INVOKABLE QmlMenu *addMenu(const QVariantMap &map);
/**
* @brief Adds a separator to menu
*/
Q_INVOKABLE void addSeparator();
void setPluginPath(const QString &path);

View File

@ -25,149 +25,85 @@ QmlWebHitTestResult::QmlWebHitTestResult(const WebHitTestResult &webHitTestResul
QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership);
}
/**
* @brief Checks if the context menu is requested on image.
* @return true if image, else false
*/
bool QmlWebHitTestResult::isImage() const
{
return !m_webHitTestResult.imageUrl().isEmpty();
}
/**
* @brief Checks if the context menu is requested on editable content.
* @return true if the content is editable, else false
*/
bool QmlWebHitTestResult::isContentEditable() const
{
return m_webHitTestResult.isContentEditable();
}
/**
* @brief Checks if the context menu is requested on the selected content.
* @return true if content is selected, else false.
*/
bool QmlWebHitTestResult::isContentSelected() const
{
return m_webHitTestResult.isContentSelected();
}
/**
* @brief Checks if the context menu is requested on null element.
* @return true if the element is null, else false
*/
bool QmlWebHitTestResult::isNull() const
{
return m_webHitTestResult.isNull();
}
/**
* @brief Checks if the context menu is requested on a link.
* @return true if the element is link, else false
*/
bool QmlWebHitTestResult::isLink() const
{
return !m_webHitTestResult.linkUrl().isEmpty();
}
/**
* @brief Checks if the context menu is requested on a media element.
* @return true if the element is media, else false
*/
bool QmlWebHitTestResult::isMedia() const
{
return !m_webHitTestResult.mediaUrl().isEmpty();
}
/**
* @brief Checks if the context menu requested on media element is paused.
* @return true if media is paused, else false
*/
bool QmlWebHitTestResult::mediaPaused() const
{
return m_webHitTestResult.mediaPaused();
}
/**
* @brief Checks if the context menu requested on media element is muted.
* @return true if media is muted, else false
*/
bool QmlWebHitTestResult::mediaMuted() const
{
return m_webHitTestResult.mediaMuted();
}
/**
* @brief Gets the tagName of the element on which the context menu is requested.
* @return String representing the tag name of the element
*/
QString QmlWebHitTestResult::tagName() const
{
return m_webHitTestResult.tagName();
}
/**
* @brief Gets the base url on which the context menu is requested.
* @return String representing the base url
*/
QString QmlWebHitTestResult::baseUrl() const
{
const QUrl base = m_webHitTestResult.baseUrl();
return QString::fromUtf8(base.toEncoded());
}
/**
* @brief Gets the link title on which the context menu is requested.
* @return String representing the link title
*/
QString QmlWebHitTestResult::linkTitle() const
{
return m_webHitTestResult.linkTitle();
}
/**
* @brief Gets the link url on which the context menu is requested.
* @return String representing the link url
*/
QString QmlWebHitTestResult::linkUrl() const
{
const QUrl link = m_webHitTestResult.linkUrl();
return QString::fromUtf8(link.toEncoded());
}
/**
* @brief Gets the url of image on which the context menu is requested.
* @return String representing the image url
*/
QString QmlWebHitTestResult::imageUrl() const
{
const QUrl image = m_webHitTestResult.imageUrl();
return QString::fromUtf8(image.toEncoded());
}
/**
* @brief Gets the url of media on which the context menu is requested.
* @return String representing the media url
*/
QString QmlWebHitTestResult::mediaUrl() const
{
const QUrl media = m_webHitTestResult.mediaUrl();
return QString::fromUtf8(media.toEncoded());
}
/**
* @brief Gets the position at which the context menu is requested.
* @return QPoint representing the position
*/
QPoint QmlWebHitTestResult::pos() const
{
return m_webHitTestResult.pos();
}
/**
* @brief Gets the viewport position at which the context menu is requested.
* @return QPoint representing the viewport position
*/
QPointF QmlWebHitTestResult::viewportPos() const
{
return m_webHitTestResult.viewportPos();

View File

@ -26,23 +26,79 @@
class QmlWebHitTestResult : public QObject
{
Q_OBJECT
/**
* @brief Gets the tagName of the element on which the context menu is requested.
*/
Q_PROPERTY(QString tagName READ tagName CONSTANT)
/**
* @brief Gets the base url on which the context menu is requested.
*/
Q_PROPERTY(QString baseUrl READ baseUrl CONSTANT)
/**
* @brief Gets the link title on which the context menu is requested.
*/
Q_PROPERTY(QString linkTitle READ linkTitle CONSTANT)
/**
* @brief Gets the link url on which the context menu is requested.
*/
Q_PROPERTY(QString linkUrl READ linkUrl CONSTANT)
/**
* @brief Gets the url of image on which the context menu is requested.
*/
Q_PROPERTY(QString imageUrl READ imageUrl CONSTANT)
/**
* @brief Gets the url of media on which the context menu is requested.
*/
Q_PROPERTY(QString mediaUrl READ mediaUrl CONSTANT)
/**
* @brief Gets the position at which the context menu is requested.
*/
Q_PROPERTY(QPoint pos READ pos CONSTANT)
/**
* @brief Gets the viewport position at which the context menu is requested.
*/
Q_PROPERTY(QPointF viewportPos READ viewportPos CONSTANT)
public:
explicit QmlWebHitTestResult(const WebHitTestResult &webHitTestResult, QObject *parent = nullptr);
/**
* @brief Checks if the context menu is requested on image.
* @return true if image, else false
*/
Q_INVOKABLE bool isImage() const;
/**
* @brief Checks if the context menu is requested on editable content.
* @return true if the content is editable, else false
*/
Q_INVOKABLE bool isContentEditable() const;
/**
* @brief Checks if the context menu is requested on the selected content.
* @return true if content is selected, else false.
*/
Q_INVOKABLE bool isContentSelected() const;
/**
* @brief Checks if the context menu is requested on null element.
* @return true if the element is null, else false
*/
Q_INVOKABLE bool isNull() const;
/**
* @brief Checks if the context menu is requested on a link.
* @return true if the element is link, else false
*/
Q_INVOKABLE bool isLink() const;
/**
* @brief Checks if the context menu is requested on a media element.
* @return true if the element is media, else false
*/
Q_INVOKABLE bool isMedia() const;
/**
* @brief Checks if the context menu requested on media element is paused.
* @return true if media is paused, else false
*/
Q_INVOKABLE bool mediaPaused() const;
/**
* @brief Checks if the context menu requested on media element is muted.
* @return true if media is muted, else false
*/
Q_INVOKABLE bool mediaMuted() const;
QString tagName() const;
QString baseUrl() const;

View File

@ -26,34 +26,12 @@ QmlNotifications::QmlNotifications(QObject *parent)
{
}
/**
* @brief Create and display a notification
* @param JavaScript object containing
* - icon:
* String representing the icon file url. The icon path will be
* search in the following order
* - Falkon resource: for the icons starting with ":", they are searched in
* falkon resource file
* - Files in plugin directory: All other paths will be resolved relative to
* the plugin directory. If the icon path is outside the
* plugin directory, then it will be resolved as empty path.
* - heading:
* String representing the heading of the notification
* - message:
* String representing the message of the notification
*/
void QmlNotifications::create(const QVariantMap &map)
{
const QString iconUrl = map.value(QSL("icon")).toString();
QPixmap icon;
if (iconUrl.startsWith(QSL(":"))) {
// Icon is loaded from falkon resource
icon = QPixmap(iconUrl);
} else {
QmlFileUtils fileUtils(m_pluginPath);
const QString iconPath = fileUtils.resolve(iconUrl);
icon = QPixmap(iconPath);
}
QmlFileUtils fileUtils(m_pluginPath);
const QString iconPath = fileUtils.resolve(iconUrl);
QPixmap icon = QPixmap(iconPath);
const QString heading = map.value(QSL("heading")).toString();
const QString message = map.value(QSL("message")).toString();
mApp->desktopNotifications()->showNotification(icon, heading, message);

View File

@ -27,6 +27,22 @@ class QmlNotifications : public QObject
Q_OBJECT
public:
explicit QmlNotifications(QObject *parent = nullptr);
/**
* @brief Create and display a notification
* @param JavaScript object containing
* - icon:
* String representing the icon file url. The icon path will be
* search in the following order
* - Falkon resource: for the icons starting with ":", they are searched in
* falkon resource file
* - Files in plugin directory: All other paths will be resolved relative to
* the plugin directory. If the icon path is outside the
* plugin directory, then it will be resolved as empty path.
* - heading:
* String representing the heading of the notification
* - message:
* String representing the message of the notification
*/
Q_INVOKABLE void create(const QVariantMap &map);
void setPluginPath(const QString &path);
private:

View File

@ -26,13 +26,11 @@ QmlSettings::QmlSettings(QObject *parent)
m_settingsPath = DataPaths::currentProfilePath() + QL1S("/extensions");
}
/**
* @brief Sets the value for a given key.
* @param A JavaScript object containing
* - key: QString representing the key
* - value: QVariant representing the value for the key
* @return true if value is set, else false
*/
QmlSettings::~QmlSettings()
{
m_settings->deleteLater();
}
bool QmlSettings::setValue(const QVariantMap &map)
{
if (!m_settings) {
@ -49,13 +47,6 @@ bool QmlSettings::setValue(const QVariantMap &map)
return true;
}
/**
* @brief Gets the value for a given key.
* @param A JavaScript object containing
* - key: QString representing the key
* - defaultValue: QVariant representing the default value for the key
* @return QVariant representing value
*/
QVariant QmlSettings::value(const QVariantMap &map)
{
if (!m_settings) {
@ -72,11 +63,6 @@ QVariant QmlSettings::value(const QVariantMap &map)
return m_settings->value(key, defaultValue);
}
/**
* @brief Checks if a given key exists.
* @param QString representing the key
* @return true if key exists, else false
*/
bool QmlSettings::contains(const QString &key)
{
if (!m_settings) {
@ -86,11 +72,6 @@ bool QmlSettings::contains(const QString &key)
return m_settings->contains(key);
}
/**
* @brief Removes the given key-value from the settings.
* @param QString representing the key
* @return true if key-value pair is removed, else false
*/
bool QmlSettings::remove(const QString &key)
{
if (!m_settings) {
@ -101,10 +82,6 @@ bool QmlSettings::remove(const QString &key)
return true;
}
/**
* @brief syncs the settings
* @return true if success, else false
*/
bool QmlSettings::sync()
{
if (!m_settings) {

View File

@ -35,10 +35,39 @@ class QmlSettings : public QObject
public:
explicit QmlSettings(QObject *parent = nullptr);
~QmlSettings();
/**
* @brief Sets the value for a given key.
* @param A JavaScript object containing
* - key: QString representing the key
* - value: QVariant representing the value for the key
* @return true if value is set, else false
*/
Q_INVOKABLE bool setValue(const QVariantMap &map);
/**
* @brief Gets the value for a given key.
* @param A JavaScript object containing
* - key: QString representing the key
* - defaultValue: QVariant representing the default value for the key
* @return QVariant representing value
*/
Q_INVOKABLE QVariant value(const QVariantMap &map);
/**
* @brief Checks if a given key exists.
* @param QString representing the key
* @return true if key exists, else false
*/
Q_INVOKABLE bool contains(const QString &key);
/**
* @brief Removes the given key-value from the settings.
* @param QString representing the key
* @return true if key-value pair is removed, else false
*/
Q_INVOKABLE bool remove(const QString &key);
/**
* @brief syncs the settings
* @return true if success, else false
*/
Q_INVOKABLE bool sync();
private:

View File

@ -135,9 +135,6 @@ QAction *QmlSideBarHelper::createMenuAction()
action->setShortcut(QKeySequence(m_shortcut));
if (QIcon::hasThemeIcon(m_iconUrl)) {
action->setIcon(QIcon::fromTheme(m_iconUrl));
} else if (m_iconUrl.startsWith(QSL(":"))) {
// Icon is loaded from falkon resource
action->setIcon(QIcon(m_iconUrl));
} else {
const QString pluginPath = m_item->creationContext()->contextProperty("__path__").toString();
QmlFileUtils fileUtils(pluginPath);

View File

@ -38,9 +38,6 @@ QmlTab::QmlTab(WebTab *webTab, QObject *parent)
createConnections();
}
/**
* @brief Detaches the tab
*/
void QmlTab::detach()
{
if (!m_webTab) {
@ -50,10 +47,6 @@ void QmlTab::detach()
m_webTab->detach();
}
/**
* @brief Set the zoom level of the tab
* @param Integer representing the zoom level
*/
void QmlTab::setZoomLevel(int zoomLevel)
{
if (!m_webTab) {
@ -63,9 +56,6 @@ void QmlTab::setZoomLevel(int zoomLevel)
m_webTab->setZoomLevel(zoomLevel);
}
/**
* @brief Stops webview associated with the tab
*/
void QmlTab::stop()
{
if (!m_webTab) {
@ -75,9 +65,6 @@ void QmlTab::stop()
m_webTab->stop();
}
/**
* @brief Reloads webview associated with the tab
*/
void QmlTab::reload()
{
if (!m_webTab) {
@ -87,9 +74,6 @@ void QmlTab::reload()
m_webTab->reload();
}
/**
* @brief Unloads the tab
*/
void QmlTab::unload()
{
if (!m_webTab) {
@ -99,10 +83,6 @@ void QmlTab::unload()
m_webTab->unload();
}
/**
* @brief Loads webview associated with the tab
* @param String representing the url to load
*/
void QmlTab::load(const QString &url)
{
if (!m_webTab) {
@ -114,9 +94,6 @@ void QmlTab::load(const QString &url)
m_webTab->load(req);
}
/**
* @brief Decreases the zoom level of the tab
*/
void QmlTab::zoomIn()
{
if (!m_webTab) {
@ -126,9 +103,6 @@ void QmlTab::zoomIn()
m_webTab->webView()->zoomIn();
}
/**
* @brief Increases the zoom level of the tab
*/
void QmlTab::zoomOut()
{
if (!m_webTab) {
@ -138,9 +112,6 @@ void QmlTab::zoomOut()
m_webTab->webView()->zoomOut();
}
/**
* @brief Resets the tab zoom level
*/
void QmlTab::zoomReset()
{
if (!m_webTab) {
@ -150,9 +121,6 @@ void QmlTab::zoomReset()
m_webTab->webView()->zoomReset();
}
/**
* @brief Performs edit undo on the tab
*/
void QmlTab::undo()
{
if (!m_webTab) {
@ -162,9 +130,6 @@ void QmlTab::undo()
m_webTab->webView()->editUndo();
}
/**
* @brief Performs edit redo on the tab
*/
void QmlTab::redo()
{
if (!m_webTab) {
@ -174,9 +139,6 @@ void QmlTab::redo()
m_webTab->webView()->editRedo();
}
/**
* @brief Performs edit select-all on the tab
*/
void QmlTab::selectAll()
{
if (!m_webTab) {
@ -186,9 +148,6 @@ void QmlTab::selectAll()
m_webTab->webView()->editSelectAll();
}
/**
* @brief Reloads the tab by bypassing the cache
*/
void QmlTab::reloadBypassCache()
{
if (!m_webTab) {
@ -198,9 +157,6 @@ void QmlTab::reloadBypassCache()
m_webTab->webView()->reloadBypassCache();
}
/**
* @brief Loads the previous page
*/
void QmlTab::back()
{
if (!m_webTab) {
@ -210,9 +166,6 @@ void QmlTab::back()
m_webTab->webView()->back();
}
/**
* @brief Loads the next page
*/
void QmlTab::forward()
{
if (!m_webTab) {
@ -222,9 +175,6 @@ void QmlTab::forward()
m_webTab->webView()->forward();
}
/**
* @brief Prints the page
*/
void QmlTab::printPage()
{
if (!m_webTab) {
@ -234,9 +184,6 @@ void QmlTab::printPage()
m_webTab->webView()->printPage();
}
/**
* @brief Shows the page source
*/
void QmlTab::showSource()
{
if (!m_webTab) {
@ -246,9 +193,6 @@ void QmlTab::showSource()
m_webTab->webView()->showSource();
}
/**
* @brief Sends page by mail
*/
void QmlTab::sendPageByMail()
{
if (!m_webTab) {
@ -258,11 +202,6 @@ void QmlTab::sendPageByMail()
m_webTab->webView()->sendPageByMail();
}
/**
* @brief execute JavaScript function in a page
* @param value, representing JavaScript function
* @return QVariant, the return value of executed javascript
*/
QVariant QmlTab::execJavaScript(const QJSValue &value)
{
if (!m_webPage && !m_webTab) {
@ -275,11 +214,6 @@ QVariant QmlTab::execJavaScript(const QJSValue &value)
return webPage->execJavaScript(value.toString());
}
/**
* @brief Gets result of web hit test at a given point
* @param point
* @return result of web hit test
*/
QmlWebHitTestResult *QmlTab::hitTestContent(const QPoint &point)
{
if (!m_webPage && !m_webTab) {
@ -431,6 +365,9 @@ bool QmlTab::canGoForward() const
void QmlTab::setWebPage(WebPage *webPage)
{
if (m_webPage) {
removeConnections();
}
m_webPage = webPage;
TabbedWebView *tabbedWebView = qobject_cast<TabbedWebView*>(m_webPage->view());
m_webTab = tabbedWebView->webTab();
@ -441,29 +378,37 @@ void QmlTab::setWebPage(WebPage *webPage)
void QmlTab::createConnections()
{
connect(m_webTab, &WebTab::titleChanged, this, [this](const QString &title){
Q_ASSERT(m_lambdaConnections.length() == 0);
auto titleChangedConnection = connect(m_webTab, &WebTab::titleChanged, this, [this](const QString &title){
emit titleChanged(title);
});
m_lambdaConnections.append(titleChangedConnection);
connect(m_webTab, &WebTab::pinnedChanged, this, [this](bool pinned){
auto pinnedChangedConnection = connect(m_webTab, &WebTab::pinnedChanged, this, [this](bool pinned){
emit pinnedChanged(pinned);
});
m_lambdaConnections.append(pinnedChangedConnection);
connect(m_webTab, &WebTab::loadingChanged, this, [this](bool loading){
auto loadingChangedConnection = connect(m_webTab, &WebTab::loadingChanged, this, [this](bool loading){
emit loadingChanged(loading);
});
m_lambdaConnections.append(loadingChangedConnection);
connect(m_webTab, &WebTab::mutedChanged, this, [this](bool muted){
auto mutedChangedConnection = connect(m_webTab, &WebTab::mutedChanged, this, [this](bool muted){
emit mutedChanged(muted);
});
m_lambdaConnections.append(mutedChangedConnection);
connect(m_webTab, &WebTab::restoredChanged, this, [this](bool restored){
auto restoredChangedConnection = connect(m_webTab, &WebTab::restoredChanged, this, [this](bool restored){
emit restoredChanged(restored);
});
m_lambdaConnections.append(restoredChangedConnection);
connect(m_webTab, &WebTab::playingChanged, this, [this](bool playing){
auto playingChangedConnection = connect(m_webTab, &WebTab::playingChanged, this, [this](bool playing){
emit playingChanged(playing);
});
m_lambdaConnections.append(playingChangedConnection);
connect(m_webTab->webView(), &TabbedWebView::zoomLevelChanged, this, &QmlTab::zoomLevelChanged);
connect(m_webTab->webView(), &TabbedWebView::backgroundActivityChanged, this, &QmlTab::backgroundActivityChanged);
@ -473,6 +418,21 @@ void QmlTab::createConnections()
}
}
void QmlTab::removeConnections()
{
for (auto connection : qAsConst(m_lambdaConnections)) {
disconnect(connection);
}
m_lambdaConnections.clear();
disconnect(m_webTab->webView(), &TabbedWebView::zoomLevelChanged, this, &QmlTab::zoomLevelChanged);
disconnect(m_webTab->webView(), &TabbedWebView::backgroundActivityChanged, this, &QmlTab::backgroundActivityChanged);
if (m_webPage) {
disconnect(m_webPage, &WebPage::navigationRequestAccepted, this, &QmlTab::navigationRequestAccepted);
}
}
QmlTabData::QmlTabData()
{
}

View File

@ -18,11 +18,12 @@
#pragma once
#include <QObject>
#include <QJSValue>
#include <QWebEnginePage>
#include "webtab.h"
#include "../windows/qmlwindow.h"
#include <QJSValue>
#include "qml/api/menus/qmlwebhittestresult.h"
#include <QWebEnginePage>
/**
* @brief The class exposing a browser tab to QML
@ -110,25 +111,91 @@ class QmlTab : public QObject
public:
explicit QmlTab(WebTab *webTab = nullptr, QObject *parent = nullptr);
/**
* @brief Detaches the tab
*/
Q_INVOKABLE void detach();
/**
* @brief Set the zoom level of the tab
* @param Integer representing the zoom level
*/
Q_INVOKABLE void setZoomLevel(int zoomLevel);
/**
* @brief Stops webview associated with the tab
*/
Q_INVOKABLE void stop();
/**
* @brief Reloads webview associated with the tab
*/
Q_INVOKABLE void reload();
/**
* @brief Unloads the tab
*/
Q_INVOKABLE void unload();
/**
* @brief Loads webview associated with the tab
* @param String representing the url to load
*/
Q_INVOKABLE void load(const QString &url);
/**
* @brief Decreases the zoom level of the tab
*/
Q_INVOKABLE void zoomIn();
/**
* @brief Increases the zoom level of the tab
*/
Q_INVOKABLE void zoomOut();
/**
* @brief Resets the tab zoom level
*/
Q_INVOKABLE void zoomReset();
/**
* @brief Performs edit undo on the tab
*/
Q_INVOKABLE void undo();
/**
* @brief Performs edit redo on the tab
*/
Q_INVOKABLE void redo();
/**
* @brief Performs edit select-all on the tab
*/
Q_INVOKABLE void selectAll();
/**
* @brief Reloads the tab by bypassing the cache
*/
Q_INVOKABLE void reloadBypassCache();
/**
* @brief Loads the previous page
*/
Q_INVOKABLE void back();
/**
* @brief Loads the next page
*/
Q_INVOKABLE void forward();
/**
* @brief Prints the page
*/
Q_INVOKABLE void printPage();
/**
* @brief Shows the page source
*/
Q_INVOKABLE void showSource();
/**
* @brief Sends page by mail
*/
Q_INVOKABLE void sendPageByMail();
/**
* @brief execute JavaScript function in a page
* @param value, representing JavaScript function
* @return QVariant, the return value of executed javascript
*/
Q_INVOKABLE QVariant execJavaScript(const QJSValue &value);
/**
* @brief Gets result of web hit test at a given point
* @param point
* @return result of web hit test
*/
Q_INVOKABLE QmlWebHitTestResult *hitTestContent(const QPoint &point);
void setWebPage(WebPage *webPage);
@ -193,6 +260,7 @@ Q_SIGNALS:
private:
WebTab *m_webTab;
WebPage *m_webPage;
QList<QMetaObject::Connection> m_lambdaConnections;
QString url() const;
QString title() const;
@ -211,6 +279,7 @@ private:
bool canGoForward() const;
void createConnections();
void removeConnections();
};
class QmlTabData

View File

@ -31,15 +31,6 @@ QmlTabs::QmlTabs(QObject *parent)
connect(mApp->plugins(), &PluginProxy::mainWindowCreated, this, &QmlTabs::windowCreated);
}
/**
* @brief Sets the current tab in a window
* @param A JavaScript object containing
* - index:
* Integer representing new current index
* - windowId:
* The id of window containing the tab
* @return True if success, else false
*/
bool QmlTabs::setCurrentIndex(const QVariantMap &map)
{
if (!map.contains(QSL("index"))) {
@ -57,11 +48,6 @@ bool QmlTabs::setCurrentIndex(const QVariantMap &map)
return true;
}
/**
* @brief Sets the next tab as current tab
* @param Integer representing the window
* @return True if success, else false
*/
bool QmlTabs::nextTab(int windowId)
{
const auto window = getWindow(windowId);
@ -72,11 +58,6 @@ bool QmlTabs::nextTab(int windowId)
return true;
}
/**
* @brief Sets the prvious tab as current tab
* @param Integer representing the window
* @return True if success, else false
*/
bool QmlTabs::previousTab(int windowId)
{
const auto window = getWindow(windowId);
@ -87,17 +68,6 @@ bool QmlTabs::previousTab(int windowId)
return true;
}
/**
* @brief Moves a tab
* @param A JavaScript object containing
* - from:
* The initial index of the tab
* - to:
* The final index of the tab
* - windowId:
* The id of window containing the tab
* @return True if tab is moved, else false
*/
bool QmlTabs::moveTab(const QVariantMap &map)
{
if (!map.contains(QSL("from"))) {
@ -120,15 +90,6 @@ bool QmlTabs::moveTab(const QVariantMap &map)
return true;
}
/**
* @brief Pins a tab
* @param A JavaScript object containing
* - index:
* Integer representing the tab to be pinned
* - windowId:
* The id of window containing the tab
* @return True if success, else false
*/
bool QmlTabs::pinTab(const QVariantMap &map)
{
if (!map.contains(QSL("index"))) {
@ -153,15 +114,6 @@ bool QmlTabs::pinTab(const QVariantMap &map)
return true;
}
/**
* @brief Un-pins a tab
* @param A JavaScript object containing
* - index:
* Integer representing the tab to be unpinned
* - windowId:
* The id of window containing the tab
* @return True if success, else false
*/
bool QmlTabs::unpinTab(const QVariantMap &map)
{
if (!map.contains(QSL("index"))) {
@ -186,15 +138,6 @@ bool QmlTabs::unpinTab(const QVariantMap &map)
return true;
}
/**
* @brief Detaches a tab
* @param A JavaScript object containing
* - index:
* Integer representing the tab to be detached
* - windowId:
* The id of window containing the tab
* @return True if tab is detached, else false
*/
bool QmlTabs::detachTab(const QVariantMap &map)
{
if (!map.contains(QSL("index"))) {
@ -212,15 +155,6 @@ bool QmlTabs::detachTab(const QVariantMap &map)
return true;
}
/**
* @brief Duplicates a tab
* @param A JavaScript object containing
* - index:
* Integer representing the tab to duplicate
* - windowId:
* The id of window containing the tab
* @return True if success, else false
*/
bool QmlTabs::duplicate(const QVariantMap &map)
{
if (!map.contains(QSL("index"))) {
@ -238,15 +172,6 @@ bool QmlTabs::duplicate(const QVariantMap &map)
return true;
}
/**
* @brief Close a tab
* @param A JavaScript object containing
* - index:
* Integer representing the tab to be closed
* - windowId:
* The id of window containing the tab
* @return True if success, else false
*/
bool QmlTabs::closeTab(const QVariantMap &map)
{
if (!map.contains(QSL("index"))) {
@ -264,15 +189,6 @@ bool QmlTabs::closeTab(const QVariantMap &map)
return true;
}
/**
* @brief Reloads a tab
* @param A JavaScript object containing
* - index:
* Integer representing the tab to be reloaded
* - windowId:
* The id of window containing the tab
* @return True if success, else false
*/
bool QmlTabs::reloadTab(const QVariantMap &map)
{
if (!map.contains(QSL("index"))) {
@ -290,15 +206,6 @@ bool QmlTabs::reloadTab(const QVariantMap &map)
return true;
}
/**
* @brief Stops a tab
* @param A JavaScript object containing
* - index:
* Integer representing the tab to be stoped
* - windowId:
* The id of window containing the tab
* @return True if success, else false
*/
bool QmlTabs::stopTab(const QVariantMap &map)
{
if (!map.contains(QSL("index"))) {
@ -316,15 +223,6 @@ bool QmlTabs::stopTab(const QVariantMap &map)
return true;
}
/**
* @brief Gets a tab
* @param A JavaScript object contining
* - index:
* Integer representign the index of the tab
* - windowId:
* The id of window containing the tab
* @return Tab of type [QmlTab](@ref QmlTab) if exists, else null
*/
QmlTab *QmlTabs::get(const QVariantMap &map) const
{
if (!map.contains(QSL("index"))) {
@ -342,11 +240,6 @@ QmlTab *QmlTabs::get(const QVariantMap &map) const
return tabData->get(webTab);
}
/**
* @brief Get the normal tabs count in a window
* @param Integer representing the window
* @return Number of normal tabs in the window
*/
int QmlTabs::normalTabsCount(int windowId) const
{
const auto window = getWindow(windowId);
@ -356,11 +249,6 @@ int QmlTabs::normalTabsCount(int windowId) const
return window->tabWidget()->normalTabsCount();
}
/**
* @brief Get the pinned tabs count in a window
* @param Integer representing the window
* @return Number of pinned tabs in the window
*/
int QmlTabs::pinnedTabsCount(int windowId) const
{
const auto window = getWindow(windowId);
@ -370,15 +258,6 @@ int QmlTabs::pinnedTabsCount(int windowId) const
return window->tabWidget()->pinnedTabsCount();
}
/**
* @brief Gets all the tabs of a window
* @param A JavaScript object containing
* - windowId:
* The id of window containing the tab
* - withPinned:
* Bool representing if the searched tab can be pinned
* @return List of tabs, each of type [QmlTab](@ref QmlTab)
*/
QList<QObject*> QmlTabs::getAll(const QVariantMap &map) const
{
const auto window = getWindow(map);
@ -397,18 +276,6 @@ QList<QObject*> QmlTabs::getAll(const QVariantMap &map) const
return list;
}
/**
* @brief Searches tabs against a criteria
* @param A JavaScript object containing
* - title:
* String representing the title to be searched
* - url:
* String representing the url to be searched
* - withPinned:
* Bool representing if the searched tab can be pinned
* @return List of tabs, each of type [QmlTab](@ref QmlTab), which are
* matched against the criteria
*/
QList<QObject*> QmlTabs::search(const QVariantMap &map)
{
const QString title = map.value(QSL("title")).toString();
@ -426,15 +293,6 @@ QList<QObject*> QmlTabs::search(const QVariantMap &map)
return list;
}
/**
* @brief Adds a tab
* @param A JavaScript object containing
* - url:
* String representing the url of the tab
* - windowId:
* The id of window containing the tab
* @return True if the tab is added, else false
*/
bool QmlTabs::addTab(const QVariantMap &map)
{
const QString urlString = map.value(QSL("url")).toString();

View File

@ -29,22 +29,164 @@ class QmlTabs : public QObject
Q_OBJECT
public:
explicit QmlTabs(QObject *parent = nullptr);
/**
* @brief Sets the current tab in a window
* @param A JavaScript object containing
* - index:
* Integer representing new current index
* - windowId:
* The id of window containing the tab
* @return True if success, else false
*/
Q_INVOKABLE bool setCurrentIndex(const QVariantMap &map);
/**
* @brief Sets the next tab as current tab
* @param Integer representing the window
* @return True if success, else false
*/
Q_INVOKABLE bool nextTab(int windowId = -1);
/**
* @brief Sets the prvious tab as current tab
* @param Integer representing the window
* @return True if success, else false
*/
Q_INVOKABLE bool previousTab(int windowId = -1);
/**
* @brief Moves a tab
* @param A JavaScript object containing
* - from:
* The initial index of the tab
* - to:
* The final index of the tab
* - windowId:
* The id of window containing the tab
* @return True if tab is moved, else false
*/
Q_INVOKABLE bool moveTab(const QVariantMap &map);
/**
* @brief Pins a tab
* @param A JavaScript object containing
* - index:
* Integer representing the tab to be pinned
* - windowId:
* The id of window containing the tab
* @return True if success, else false
*/
Q_INVOKABLE bool pinTab(const QVariantMap &map);
/**
* @brief Un-pins a tab
* @param A JavaScript object containing
* - index:
* Integer representing the tab to be unpinned
* - windowId:
* The id of window containing the tab
* @return True if success, else false
*/
Q_INVOKABLE bool unpinTab(const QVariantMap &map);
/**
* @brief Detaches a tab
* @param A JavaScript object containing
* - index:
* Integer representing the tab to be detached
* - windowId:
* The id of window containing the tab
* @return True if tab is detached, else false
*/
Q_INVOKABLE bool detachTab(const QVariantMap &map);
/**
* @brief Duplicates a tab
* @param A JavaScript object containing
* - index:
* Integer representing the tab to duplicate
* - windowId:
* The id of window containing the tab
* @return True if success, else false
*/
Q_INVOKABLE bool duplicate(const QVariantMap &map);
/**
* @brief Close a tab
* @param A JavaScript object containing
* - index:
* Integer representing the tab to be closed
* - windowId:
* The id of window containing the tab
* @return True if success, else false
*/
Q_INVOKABLE bool closeTab(const QVariantMap &map);
/**
* @brief Reloads a tab
* @param A JavaScript object containing
* - index:
* Integer representing the tab to be reloaded
* - windowId:
* The id of window containing the tab
* @return True if success, else false
*/
Q_INVOKABLE bool reloadTab(const QVariantMap &map);
/**
* @brief Stops a tab
* @param A JavaScript object containing
* - index:
* Integer representing the tab to be stoped
* - windowId:
* The id of window containing the tab
* @return True if success, else false
*/
Q_INVOKABLE bool stopTab(const QVariantMap &map);
/**
* @brief Gets a tab
* @param A JavaScript object contining
* - index:
* Integer representign the index of the tab
* - windowId:
* The id of window containing the tab
* @return Tab of type [QmlTab](@ref QmlTab) if exists, else null
*/
Q_INVOKABLE QmlTab *get(const QVariantMap &map) const;
/**
* @brief Get the normal tabs count in a window
* @param Integer representing the window
* @return Number of normal tabs in the window
*/
Q_INVOKABLE int normalTabsCount(int windowId = -1) const;
/**
* @brief Get the pinned tabs count in a window
* @param Integer representing the window
* @return Number of pinned tabs in the window
*/
Q_INVOKABLE int pinnedTabsCount(int windowId = -1) const;
/**
* @brief Gets all the tabs of a window
* @param A JavaScript object containing
* - windowId:
* The id of window containing the tab
* - withPinned:
* Bool representing if the searched tab can be pinned
* @return List of tabs, each of type [QmlTab](@ref QmlTab)
*/
Q_INVOKABLE QList<QObject*> getAll(const QVariantMap &map = QVariantMap()) const;
/**
* @brief Searches tabs against a criteria
* @param A JavaScript object containing
* - title:
* String representing the title to be searched
* - url:
* String representing the url to be searched
* - withPinned:
* Bool representing if the searched tab can be pinned
* @return List of tabs, each of type [QmlTab](@ref QmlTab), which are
* matched against the criteria
*/
Q_INVOKABLE QList<QObject*> search(const QVariantMap &map);
/**
* @brief Adds a tab
* @param A JavaScript object containing
* - url:
* String representing the url of the tab
* - windowId:
* The id of window containing the tab
* @return True if the tab is added, else false
*/
Q_INVOKABLE bool addTab(const QVariantMap &map);
Q_SIGNALS:
/**

View File

@ -27,15 +27,8 @@ QmlTopSites::QmlTopSites(QObject *parent)
{
}
/**
* @brief Get the topsites. These refer to the sites which
* are displayed in the speed-dial (New tab page)
* @return List of MostVisitedUrl objects of type [QmlMostVisitedUrl](@ref QmlMostVisitedUrl)
*/
QList<QObject*> QmlTopSites::get() const
{
// FIXME: this slows the startup of browser
QList<SpeedDial::Page> pages = mApp->plugins()->speedDial()->pages();
QList<QObject*> list;
foreach(SpeedDial::Page page, pages) {

View File

@ -28,5 +28,10 @@ class QmlTopSites : public QObject
Q_OBJECT
public:
explicit QmlTopSites(QObject *parent = nullptr);
/**
* @brief Get the topsites. These refer to the sites which
* are displayed in the speed-dial (New tab page)
* @return List of MostVisitedUrl objects of type [QmlMostVisitedUrl](@ref QmlMostVisitedUrl)
*/
Q_INVOKABLE QList<QObject*> get() const;
};

View File

@ -59,11 +59,6 @@ QList<QObject *> QmlUserScripts::toQObjectList(QList<QWebEngineScript> list) con
return userScriptList;
}
/**
* @brief Checks if the script is in collection
* @param object of type QmlUserScript
* @return true if the the script in in collection, else false
*/
bool QmlUserScripts::contains(QObject *object) const
{
QmlUserScript *userScript = qobject_cast<QmlUserScript*>(object);
@ -74,11 +69,6 @@ bool QmlUserScripts::contains(QObject *object) const
return mApp->webProfile()->scripts()->contains(webEngineScript);
}
/**
* @brief Finds a script in collection by name
* @param name of the script
* @return object of type QmlUserScript, representing the script of given name
*/
QObject *QmlUserScripts::findScript(const QString &name) const
{
QWebEngineScript webEngineScript = mApp->webProfile()->scripts()->findScript(name);
@ -87,20 +77,12 @@ QObject *QmlUserScripts::findScript(const QString &name) const
return qmlUserScript;
}
/**
* @brief Finds all scripts in collection by a given name
* @return list of objects, each of type QmlUserScript, representing the script of given name
*/
QList<QObject*> QmlUserScripts::findScripts(const QString &name) const
{
QList<QWebEngineScript> list = mApp->webProfile()->scripts()->findScripts(name);
return toQObjectList(list);
}
/**
* @brief Inserts a script into collection
* @param object of type QmlUserScript
*/
void QmlUserScripts::insert(QObject *object)
{
QmlUserScript *userScript = qobject_cast<QmlUserScript*>(object);
@ -112,10 +94,6 @@ void QmlUserScripts::insert(QObject *object)
m_webEngineScripts.append(webEngineScript);
}
/**
* @brief Inserts a list of scripts into collection
* @param list of objects, each of type QmlUserScript
*/
void QmlUserScripts::insert(const QList<QObject *> &list)
{
for (QObject *object : list) {
@ -129,10 +107,6 @@ void QmlUserScripts::insert(const QList<QObject *> &list)
}
}
/**
* @brief Removes a script from collection
* @param object of type QmlUserScript
*/
void QmlUserScripts::remove(QObject *object) const
{
QmlUserScript *userScript = qobject_cast<QmlUserScript*>(object);
@ -143,10 +117,6 @@ void QmlUserScripts::remove(QObject *object) const
mApp->webProfile()->scripts()->remove(webEngineScript);
}
/**
* @brief Gets all the scripts of the collection
* @return list of objects, each of type QmlUserScript
*/
QList<QObject *> QmlUserScripts::toList() const
{
QList<QWebEngineScript> list = mApp->webProfile()->scripts()->toList();

View File

@ -41,12 +41,42 @@ class FALKON_EXPORT QmlUserScripts : public QObject
public:
explicit QmlUserScripts(QObject *parent = nullptr);
~QmlUserScripts();
/**
* @brief Checks if the script is in collection
* @param object of type QmlUserScript
* @return true if the the script in in collection, else false
*/
Q_INVOKABLE bool contains(QObject *object) const;
/**
* @brief Finds a script in collection by name
* @param name of the script
* @return object of type QmlUserScript, representing the script of given name
*/
Q_INVOKABLE QObject *findScript(const QString &name) const;
/**
* @brief Finds all scripts in collection by a given name
* @return list of objects, each of type QmlUserScript, representing the script of given name
*/
Q_INVOKABLE QList<QObject *> findScripts(const QString &name) const;
/**
* @brief Inserts a script into collection
* @param object of type QmlUserScript
*/
Q_INVOKABLE void insert(QObject *object);
/**
* @brief Inserts a list of scripts into collection
* @param list of objects, each of type QmlUserScript
*/
Q_INVOKABLE void insert(const QList<QObject*> &list);
/**
* @brief Removes a script from collection
* @param object of type QmlUserScript
*/
Q_INVOKABLE void remove(QObject *object) const;
/**
* @brief Gets all the scripts of the collection
* @return list of objects, each of type QmlUserScript
*/
Q_INVOKABLE QList<QObject *> toList() const;
private:
int count() const;

View File

@ -35,29 +35,16 @@ QmlWindows::QmlWindows(QObject *parent)
});
}
/**
* @brief Gets a browser window
* @param Integer representing the browser window
* @return Object of type [QmlWindow](@ref QmlWindow)
*/
QmlWindow *QmlWindows::get(int id) const
{
return windowData->get(getBrowserWindow(id));
}
/**
* @brief Gets the current browser window
* @return Object of type [QmlWindow](@ref QmlWindow)
*/
QmlWindow *QmlWindows::getCurrent() const
{
return windowData->get(mApp->getWindow());
}
/**
* @brief Get all the browser window
* @return List of windows of type [QmlWindow](@ref QmlWindow)
*/
QList<QObject*> QmlWindows::getAll() const
{
QList<QObject*> list;
@ -67,15 +54,6 @@ QList<QObject*> QmlWindows::getAll() const
return list;
}
/**
* @brief Creates a browser window
* @param A JavaScript object containing
* - url:
* The url of the first tab of the window
* - type:
* The window [type](@ref QmlWindowType)
* @return
*/
QmlWindow *QmlWindows::create(const QVariantMap &map) const
{
const QUrl url = QUrl::fromEncoded(map.value(QSL("url")).toString().toUtf8());
@ -84,10 +62,6 @@ QmlWindow *QmlWindows::create(const QVariantMap &map) const
return windowData->get(window);
}
/**
* @brief Removes a browser window
* @param Integer representing the window id
*/
void QmlWindows::remove(int windowId) const
{
BrowserWindow *window = getBrowserWindow(windowId);

View File

@ -28,10 +28,36 @@ class QmlWindows : public QObject
Q_OBJECT
public:
QmlWindows(QObject *parent = nullptr);
/**
* @brief Gets a browser window
* @param Integer representing the browser window
* @return Object of type [QmlWindow](@ref QmlWindow)
*/
Q_INVOKABLE QmlWindow *get(int id) const;
/**
* @brief Gets the current browser window
* @return Object of type [QmlWindow](@ref QmlWindow)
*/
Q_INVOKABLE QmlWindow *getCurrent() const;
/**
* @brief Get all the browser window
* @return List of windows of type [QmlWindow](@ref QmlWindow)
*/
Q_INVOKABLE QList<QObject*> getAll() const;
/**
* @brief Creates a browser window
* @param A JavaScript object containing
* - url:
* The url of the first tab of the window
* - type:
* The window [type](@ref QmlWindowType)
* @return
*/
Q_INVOKABLE QmlWindow *create(const QVariantMap &map) const;
/**
* @brief Removes a browser window
* @param Integer representing the window id
*/
Q_INVOKABLE void remove(int windowId) const;
Q_SIGNALS:
/**

View File

@ -39,6 +39,7 @@
QmlPluginInterface::QmlPluginInterface()
: m_settingsWindow(nullptr)
, m_qmlReusableTab(new QmlTab())
{
}
@ -221,10 +222,9 @@ bool QmlPluginInterface::acceptNavigationRequest(WebPage *page, const QUrl &url,
if (!m_acceptNavigationRequest.isCallable()) {
return true;
}
QmlTab *qmlTab = new QmlTab();
qmlTab->setWebPage(page);
m_qmlReusableTab->setWebPage(page);
QJSValueList args;
args.append(m_engine->newQObject(qmlTab));
args.append(m_engine->newQObject(m_qmlReusableTab));
args.append(QString::fromUtf8(url.toEncoded()));
args.append(type);
args.append(isMainFrame);

View File

@ -24,6 +24,8 @@
#include "desktopfile.h"
#include "plugininterface.h"
class QmlTab;
class QmlPluginInterface : public QObject, public PluginInterface
{
Q_OBJECT
@ -72,13 +74,13 @@ Q_SIGNALS:
void qmlPluginUnloaded();
private:
QQmlEngine *m_engine;
QQmlEngine *m_engine = nullptr;
QString m_name;
QJSValue m_init;
QJSValue m_unload;
QJSValue m_testPlugin;
QJSValue m_populateWebViewMenu;
QQmlComponent *m_settingsWindow;
QQmlComponent *m_settingsWindow = nullptr;
QJSValue m_mouseDoubleClick;
QJSValue m_mousePress;
QJSValue m_mouseRelease;
@ -88,6 +90,7 @@ private:
QJSValue m_keyRelease;
QJSValue m_acceptNavigationRequest;
QList<QObject*> m_childItems;
QmlTab *m_qmlReusableTab = nullptr;
QJSValue readInit() const;
void setInit(const QJSValue &init);