1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-22 02:02:10 +02:00

Don't use custom script for toggle play/pause and mute

This commit is contained in:
David Rosca 2016-02-28 18:25:30 +01:00
parent a37fadd8dc
commit 3d5f45bfc5
3 changed files with 4 additions and 33 deletions

View File

@ -279,30 +279,3 @@ QString Scripts::getFormData(const QPoint &pos)
return source.arg(pos.x()).arg(pos.y()); return source.arg(pos.x()).arg(pos.y());
} }
QString Scripts::toggleMediaPause(const QPoint &pos)
{
QString source = QL1S("(function() {"
"var e = document.elementFromPoint(%1, %2);"
"if (!e)"
" return;"
"if (e.paused)"
" e.play();"
"else"
" e.pause();"
"})()");
return source.arg(pos.x()).arg(pos.y());
}
QString Scripts::toggleMediaMute(const QPoint &pos)
{
QString source = QL1S("(function() {"
"var e = document.elementFromPoint(%1, %2);"
"if (!e)"
" return;"
"e.muted = !e.muted;"
"})()");
return source.arg(pos.x()).arg(pos.y());
}

View File

@ -1,6 +1,6 @@
/* ============================================================ /* ============================================================
* QupZilla - WebKit based browser * QupZilla - WebKit 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
@ -38,8 +38,6 @@ public:
static QString getAllImages(); static QString getAllImages();
static QString getAllMetaAttributes(); static QString getAllMetaAttributes();
static QString getFormData(const QPoint &pos); static QString getFormData(const QPoint &pos);
static QString toggleMediaPause(const QPoint &pos);
static QString toggleMediaMute(const QPoint &pos);
}; };
#endif // SCRIPTS_H #endif // SCRIPTS_H

View File

@ -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
@ -873,12 +873,12 @@ void WebView::reloadAllSpeedDials()
void WebView::toggleMediaPause() void WebView::toggleMediaPause()
{ {
page()->runJavaScript(Scripts::toggleMediaPause(m_clickedPos)); triggerPageAction(QWebEnginePage::ToggleMediaPlayPause);
} }
void WebView::toggleMediaMute() void WebView::toggleMediaMute()
{ {
page()->runJavaScript(Scripts::toggleMediaMute(m_clickedPos)); triggerPageAction(QWebEnginePage::ToggleMediaMute);
} }
void WebView::initializeActions() void WebView::initializeActions()