1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Fixed showing of Click2Flash plugin

Added workaround for showing click2flash right after the plugin is
created, no longer need to scroll / resize page
Also fixed one crash in floating status bar message
Also improved detection of object element on page
This commit is contained in:
nowrep 2011-10-27 14:26:40 +02:00
parent 627fcd1d7b
commit b2056321ef
7 changed files with 78 additions and 22 deletions

View File

@ -11,6 +11,12 @@ General
QupZilla by clicking from Help Menu to Informations about program, then in
Path section.
You may want to build QupZilla with debugging symbols (for generating
backtrace of crash) as easily as adding one line to QupZilla.pro:
CONFIG += debug
Microsoft Windows
----------------------------------------------------------------------------------
@ -36,12 +42,10 @@ OS/2
machine with OS/2, but it is possible to get QupZilla working there.
There may be some more things to do, but as far as I know, you need to
add Q_WS_WIN define to qmake.
You will do this by adding one line
You will do this by adding one line to QupZilla.pro:
DEFINES += Q_WS_WIN
to QupZilla.pro file.
Available Defines
----------------------------------------------------------------------------------
@ -67,7 +71,8 @@ Available Defines
example:
$ export USE_WEBGL="true"
Windows specific defines
Windows specific defines:
W7API Enable Windows 7 API support
Requires linking against libraries from Microsoft Visual C++
Compiler 2010
@ -75,6 +80,7 @@ Available Defines
Linux / Unix specific defines:
NO_SYSTEM_DATAPATH By default, QupZilla is using /usr/share/qupzilla/ path
for storing themes, translations and plugins.
By setting this define, QupZilla will use path of execution.
@ -85,7 +91,9 @@ Available Defines
QUPZILLA_PREFIX You can define different prefix. Prefix must contain ending slash.
(default prefix is "/usr/")
value:
QupZilla binary will then be moved to PREFIX/bin/, use
PREFIX/share/qupzilla/ as datadir, PREFIX/share/applications for
desktop launcher and PREFIX/share/pixmaps for icon.
example:
$ export QUPZILLA_PREFIX="/usr/"

View File

@ -59,6 +59,7 @@ StatusBarMessage::StatusBarMessage(QupZilla* mainClass)
, p_QupZilla(mainClass)
, m_statusBarText(new TipLabel(mainClass))
{
m_statusBarText->setParent(p_QupZilla);
}
void StatusBarMessage::showMessage(const QString &message)
@ -68,7 +69,6 @@ void StatusBarMessage::showMessage(const QString &message)
else {
WebView* view = p_QupZilla->weView();
QWebFrame* mainFrame = view->page()->mainFrame();
m_statusBarText->setParent(view);
int horizontalScrollSize = 0;
int verticalScrollSize = 0;
@ -91,7 +91,7 @@ void StatusBarMessage::showMessage(const QString &message)
if (statusRect.contains(QCursor::pos()))
position.setY(position.y() - m_statusBarText->height());
m_statusBarText->move(/*view->mapToGlobal(*/position/*)*/);
m_statusBarText->move(view->mapToGlobal(position));
m_statusBarText->show();
}
}

View File

@ -45,9 +45,12 @@
#include "adblockmanager.h"
#include "adblocksubscription.h"
#include "squeezelabelv2.h"
#include "webpage.h"
#include "globalfunctions.h"
#include "qupzilla.h"
ClickToFlash::ClickToFlash(const QUrl &pluginUrl, const QStringList &argumentNames, const QStringList &argumentValues, QWidget* parent)
: QWidget(parent)
ClickToFlash::ClickToFlash(const QUrl &pluginUrl, const QStringList &argumentNames, const QStringList &argumentValues, WebPage* parentPage)
: QWidget()
, m_argumentNames(argumentNames)
, m_argumentValues(argumentValues)
, m_toolButton(0)
@ -55,6 +58,7 @@ ClickToFlash::ClickToFlash(const QUrl &pluginUrl, const QStringList &argumentNam
, m_layout2(0)
, m_frame(0)
, m_url(pluginUrl)
, m_page(parentPage)
{
//AdBlock
AdBlockManager* manager = AdBlockManager::instance();
@ -87,8 +91,19 @@ ClickToFlash::ClickToFlash(const QUrl &pluginUrl, const QStringList &argumentNam
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint)));
QTimer::singleShot(0, this, SLOT(ensurePluginVisible()));
}
void ClickToFlash::ensurePluginVisible()
{
// Well, kind of a dirty workaround, but it works.
// I don't know any other method how to show our plugin
// and adjust it on the proper position in page
m_page->mainFrame()->setZoomFactor(m_page->mainFrame()->zoomFactor() + 1);
m_page->mainFrame()->setZoomFactor(m_page->mainFrame()->zoomFactor() - 1);
}
void ClickToFlash::customContextMenuRequested(const QPoint &pos)
{
QMenu menu;
@ -175,15 +190,15 @@ void ClickToFlash::load()
bool ClickToFlash::checkUrlOnElement(QWebElement el)
{
QString checkString = QUrl(el.attribute("src")).toString(QUrl::RemoveQuery);
QString checkString = el.attribute("src");
if (checkString.isEmpty())
checkString = QUrl(el.attribute("data")).toString(QUrl::RemoveQuery);
checkString = el.attribute("data");
if (checkString.isEmpty())
checkString = QUrl(el.attribute("value")).toString(QUrl::RemoveQuery);
checkString = el.attribute("value");
if (m_url.toEncoded().contains(checkString.toAscii()))
return true;
return false;
checkString = m_page->getView()->url().resolved(QUrl(checkString)).toString(QUrl::RemoveQuery);
return m_url.toEncoded().contains(checkString.toAscii());
}
bool ClickToFlash::checkElement(QWebElement el)
@ -219,6 +234,7 @@ void ClickToFlash::showInfo()
lay->addRow(new QLabel(tr("No more informations available.")));
widg->setMaximumHeight(500);
qz_centerWidgetToParent(widg, m_page->qupzilla());
widg->show();
}

View File

@ -57,12 +57,13 @@
#include <QFormLayout>
class QWebElement;
class WebPage;
class ClickToFlash : public QWidget
{
Q_OBJECT
public:
explicit ClickToFlash(const QUrl &pluginUrl, const QStringList &argumentNames, const QStringList &argumentValues, QWidget* parent = 0);
explicit ClickToFlash(const QUrl &pluginUrl, const QStringList &argumentNames, const QStringList &argumentValues, WebPage* parentPage);
~ClickToFlash();
private slots:
@ -74,6 +75,8 @@ private slots:
void hideAdBlocked();
void showInfo();
void ensurePluginVisible();
private:
bool checkElement(QWebElement el);
bool checkUrlOnElement(QWebElement el);
@ -90,6 +93,8 @@ private:
used to find the right QWebElement between the ones of the different plugins
*/
const QUrl m_url;
WebPage* m_page;
};
#endif // CLICKTOFLASH_H

View File

@ -19,20 +19,23 @@
#include "clicktoflash.h"
#include "mainapplication.h"
#include "pluginproxy.h"
#include "webpage.h"
WebPluginFactory::WebPluginFactory(QObject* parent)
: QWebPluginFactory(parent)
, m_page(0)
{
}
QObject* WebPluginFactory::create(const QString &mimeType, const QUrl &url, const QStringList &argumentNames, const QStringList &argumentValues) const
{
if (mimeType.isEmpty())
QString mime = mimeType.trimmed(); //Fixing bad behaviour when mimeType contains spaces
if (mime.isEmpty())
return 0;
if (mimeType != "application/x-shockwave-flash") {
if (mimeType != "application/futuresplash")
qDebug() << "missing mimeType handler for: " << mimeType;
if (mime != "application/x-shockwave-flash") {
if (mime != "application/futuresplash")
qDebug() << "missing mimeType handler for: " << mime;
return 0;
}
@ -44,10 +47,28 @@ QObject* WebPluginFactory::create(const QString &mimeType, const QUrl &url, cons
if (whitelist.contains(url.host()) || whitelist.contains("www."+url.host()) || whitelist.contains(url.host().remove("www.")))
return 0;
ClickToFlash* ctf = new ClickToFlash(url, argumentNames, argumentValues);
WebPluginFactory* factory = const_cast<WebPluginFactory*>(this);
if (!factory)
return 0;
WebPage* page = factory->parentPage();
if (!page)
return 0;
ClickToFlash* ctf = new ClickToFlash(url, argumentNames, argumentValues, page);
return ctf;
}
WebPage* WebPluginFactory::parentPage()
{
if (m_page)
return m_page;
WebPage* page = qobject_cast<WebPage*> (parent());
return page;
}
QList<QWebPluginFactory::Plugin> WebPluginFactory::plugins() const
{
QList<QWebPluginFactory::Plugin> plugins;

View File

@ -21,6 +21,7 @@
#include <QWebPluginFactory>
#include <QDebug>
class WebPage;
class WebPluginFactory : public QWebPluginFactory
{
Q_OBJECT
@ -31,6 +32,9 @@ public:
QList<QWebPluginFactory::Plugin> plugins() const;
private:
WebPage* parentPage();
WebPage* m_page;
};
#endif // WEB_PLUGIN_FACTORY_H

View File

@ -64,6 +64,8 @@ public:
void addAdBlockRule(const QString &filter, const QUrl &url);
QList<AdBlockedEntry> adBlockedEntries() { return m_adBlockedEntries; }
QupZilla* qupzilla() { return p_QupZilla; }
signals:
void privacyChanged(bool status);