Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -608,8 +608,20 @@ void ScriptEngine::include(const QString& includeFile) { · 607 unmodified lines | ||
| 608 | 608 | QUrl url = resolveInclude(includeFile); |
| 609 | 609 | QString includeContents; |
| 610 | 610 | |
| 611 | − if (url.scheme() == "file") { | |
| 611 | + if (url.scheme() == "http" || url.scheme() == "ftp") { | |
| 612 | + QNetworkAccessManager* networkManager = new QNetworkAccessManager(this); | |
| 613 | + QNetworkReply* reply = networkManager->get(QNetworkRequest(url)); | |
| 614 | + qDebug() << "Downloading included script at" << includeFile; | |
| 615 | + QEventLoop loop; | |
| 616 | + QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); | |
| 617 | + loop.exec(); | |
| 618 | + includeContents = reply->readAll(); | |
| 619 | + } else { | |
| 620 | +#ifdef _WIN32 | |
| 621 | + QString fileName = url.toString(); | |
| 622 | +#else | |
| 612 | 623 | QString fileName = url.toLocalFile(); |
| 624 | +#endif | |
| 613 | 625 | QFile scriptFile(fileName); |
| 614 | 626 | if (scriptFile.open(QFile::ReadOnly | QFile::Text)) { |
| 615 | 627 | qDebug() << "Loading file:" << fileName; |
| @@ -619,14 +631,6 @@ void ScriptEngine::include(const QString& includeFile) { · 3 unmodified lines | ||
| 619 | 631 | qDebug() << "ERROR Loading file:" << fileName; |
| 620 | 632 | emit errorMessage("ERROR Loading file:" + fileName); |
| 621 | 633 | } |
| 622 | − } else { | |
| 623 | − QNetworkAccessManager* networkManager = new QNetworkAccessManager(this); | |
| 624 | − QNetworkReply* reply = networkManager->get(QNetworkRequest(url)); | |
| 625 | − qDebug() << "Downloading included script at" << includeFile; | |
| 626 | − QEventLoop loop; | |
| 627 | − QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); | |
| 628 | − loop.exec(); | |
| 629 | − includeContents = reply->readAll(); | |
| 630 | 634 | } |
| 631 | 635 | |
| 632 | 636 | QScriptValue result = _engine.evaluate(includeContents); |