Showing the changes to libraries/script-engine/src/ScriptEngines.cpp (1 of 4 files). Show all
Unified · Split
| @@ -43,24 +43,55 @@ ScriptEngines::ScriptEngines() · 42 unmodified lines | ||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | QString normalizeScriptUrl(const QString& rawScriptUrl) { |
| 46 | − if (!rawScriptUrl.startsWith("http:") && !rawScriptUrl.startsWith("https:") && !rawScriptUrl.startsWith("atp:")) { | |
| 46 | + if (!rawScriptUrl.startsWith("http:") && !rawScriptUrl.startsWith("https:") && !rawScriptUrl.startsWith("atp:")) { | |
| 47 | 47 | #ifdef Q_OS_LINUX |
| 48 | 48 | if (rawScriptUrl.startsWith("file:")) { |
| 49 | 49 | return rawScriptUrl; |
| 50 | 50 | } |
| 51 | 51 | return QUrl::fromLocalFile(rawScriptUrl).toString(); |
| 52 | 52 | #else |
| 53 | + QString fullNormal; | |
| 53 | 54 | if (rawScriptUrl.startsWith("file:")) { |
| 54 | − return rawScriptUrl.toLower(); | |
| 55 | + fullNormal = rawScriptUrl.toLower(); | |
| 56 | + } else { | |
| 57 | + // Force lowercase on file scripts because of drive letter weirdness. | |
| 58 | + fullNormal = QUrl::fromLocalFile(rawScriptUrl).toString().toLower(); | |
| 55 | 59 | } |
| 56 | − // Force lowercase on file scripts because of drive letter weirdness. | |
| 57 | − return QUrl::fromLocalFile(rawScriptUrl).toString().toLower(); | |
| 60 | + QString defaultScriptLoc = defaultScriptsLocation(); | |
| 61 | + if (fullNormal.startsWith(defaultScriptLoc)) { | |
| 62 | + return "~" + fullNormal.mid(defaultScriptLoc.size()); | |
| 63 | + } | |
| 64 | + return fullNormal; | |
| 58 | 65 | #endif |
| 59 | 66 | |
| 60 | 67 | } |
| 61 | 68 | return QUrl(rawScriptUrl).toString(); |
| 62 | 69 | } |
| 63 | 70 | |
| 71 | +QString expandScriptUrl(const QString& normalizedScriptURL) { | |
| 72 | + if (normalizedScriptURL.startsWith("http:") || | |
| 73 | + normalizedScriptURL.startsWith("https:") || | |
| 74 | + normalizedScriptURL.startsWith("atp:")) { | |
| 75 | + return QUrl(normalizedScriptURL).toString(); | |
| 76 | + } | |
| 77 | + | |
| 78 | + QUrl url; | |
| 79 | + if (normalizedScriptURL.startsWith("file:")) { | |
| 80 | + url = QUrl(normalizedScriptURL); | |
| 81 | + } else { | |
| 82 | + url = QUrl::fromLocalFile(normalizedScriptURL); | |
| 83 | + } | |
| 84 | + | |
| 85 | + QString path = url.path(); | |
| 86 | + QStringList splitPath = path.split("/"); | |
| 87 | + if (splitPath.size() > 0 && splitPath[0] == "~") { | |
| 88 | + QString defaultScriptLoc = defaultScriptsLocation(); | |
| 89 | + url.setPath(defaultScriptLoc + splitPath.mid(1).join("/")); | |
| 90 | + return url.toString(); | |
| 91 | + } | |
| 92 | +} | |
| 93 | + | |
| 94 | + | |
| 64 | 95 | QObject* scriptsModel(); |
| 65 | 96 | |
| 66 | 97 | void ScriptEngines::registerScriptInitializer(ScriptInitializer initializer) { |