diff --git a/src/mainwin.cpp b/src/mainwin.cpp index 3b8a3a502d359e6f2466437ef8d0c65d4b9bea8b..a3fa07e7edf7bb90c6aac7d67aa5e9be1147b7e6 100644 --- a/src/mainwin.cpp +++ b/src/mainwin.cpp @@ -184,8 +184,6 @@ void MainWin::handle_youtubevideo(SKMessage &msg) if(msg.parameters.contains("url")) { std::cout << "OPEN URL " << msg.parameters["url"].toStdString() << std::endl; - //if(msg.parameters.contains("width") - //if(msg.parameters.contains("height); if(!yt_is_open) { yt = new WebWin(); @@ -194,12 +192,22 @@ void MainWin::handle_youtubevideo(SKMessage &msg) //QWebPageForMac *newWeb = new QWebPageForMac(yt); //#else QWebPage *newWeb = new QWebPage(yt); + //ReferredNetworkAccessManager nam; + ReferredNetworkAccessManager *nam = new ReferredNetworkAccessManager(); + newWeb->setNetworkAccessManager(nam); //#endif yt->setPage(newWeb); yt->setAttribute(Qt::WA_DeleteOnClose, true); yt->settings()->setAttribute(QWebSettings::PluginsEnabled, true); yt->settings()->setAttribute(QWebSettings::JavascriptEnabled, true); + if(msg.parameters.contains("width") && msg.parameters.contains("height")) + yt->resize(msg.parameters["width"].toInt(), msg.parameters["height"].toInt()); + else if(msg.parameters.contains("width")) + yt->resize(msg.parameters["width"].toInt(), yt->height()); + else if(msg.parameters.contains("height")) + yt->resize(yt->width(), msg.parameters["height"].toInt()); + yt->setUrl(QUrl(msg.parameters["url"])); connect(yt, SIGNAL(closingWindow()), this, SLOT(ytclosesignal())); yt->show(); diff --git a/src/mainwin.h b/src/mainwin.h index 5282dd53e1db33c6e949663703803c8bb6d09074..41cf180958d0a4a364e2fbc61a25f9f2a6131172 100644 --- a/src/mainwin.h +++ b/src/mainwin.h @@ -42,6 +42,9 @@ #include <QHash> #include <QString> #include <QObject> +#include <QNetworkAccessManager> +#include <QNetworkRequest> +#include <QIODevice> #include <ipcmsg.h> #include "webwin.h" #include "jsbridge.h" @@ -77,4 +80,20 @@ class MainWin : public SkylivexWin }; +class ReferredNetworkAccessManager : public QNetworkAccessManager { + + Q_OBJECT + + protected: + virtual QNetworkReply * createRequest(Operation op, + const QNetworkRequest & req, + QIODevice * outgoingData = 0) + { + QNetworkRequest newReq(req); + newReq.setRawHeader("Referer", "http://www.skylive.it"); + return QNetworkAccessManager::createRequest(op, newReq, outgoingData); + } +}; + + #endif diff --git a/src/webwin.cpp b/src/webwin.cpp index 84896479447470aab0a25d2e157201c29451e43b..c86ef92c0bd21f855751c99b473400669af3644f 100644 --- a/src/webwin.cpp +++ b/src/webwin.cpp @@ -131,6 +131,10 @@ QWebView* WebWin::createWindow(QWebPage::WebWindowType type) if (type == QWebPage::WebModalDialog) wv->setWindowModality(Qt::ApplicationModal); + // Assure plugin and js support also for this window. + wv->settings()->setAttribute(QWebSettings::PluginsEnabled, true); + wv->settings()->setAttribute(QWebSettings::JavascriptEnabled, true); + SKMessage msg("newwindow", qobject_cast<SkylivexWin *>(wv)); sendMessage(msg); @@ -290,6 +294,11 @@ SkylivexWin* SkylivexWin::createSkyliveWindow(QString url, QWebPage::WebWindowTy connect(newWeb->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), wv, SLOT(refreshJsObject())); + // Assure plugin and js support also for this window. + wv->settings()->setAttribute(QWebSettings::PluginsEnabled, true); + wv->settings()->setAttribute(QWebSettings::JavascriptEnabled, true); + + wv->setPage(newWeb); wv->setAttribute(Qt::WA_DeleteOnClose, true); if (type == QWebPage::WebModalDialog) diff --git a/src/webwin.h b/src/webwin.h index 444c855887edb8de813c96cb741b58e0f97e58ce..7767c831df6d39a76833b9565d0b2d81e15e2cae 100644 --- a/src/webwin.h +++ b/src/webwin.h @@ -52,7 +52,6 @@ typedef void (WebWin::*SKHandlerFunction)(SKMessage&); //typedef int (WebWin::*SKHandlerFunction)(SKMessage&); -//#if defined(Q_OS_MAC) /* * For some reason youtube think that the default user agent * on OSX doesn't support HTML5 videos,