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 | QString normalizeScriptUrl(const QString& rawScriptUrl) { | 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 | #ifdef Q_OS_LINUX | 47 | #ifdef Q_OS_LINUX |
| 48 | if (rawScriptUrl.startsWith("file:")) { | 48 | if (rawScriptUrl.startsWith("file:")) { |
| 49 | return rawScriptUrl; | 49 | return rawScriptUrl; |
| 50 | } | 50 | } |
| 51 | return QUrl::fromLocalFile(rawScriptUrl).toString(); | 51 | return QUrl::fromLocalFile(rawScriptUrl).toString(); |
| 52 | #else | 52 | #else |
| 53 | QString fullNormal; | ||
| 53 | if (rawScriptUrl.startsWith("file:")) { | 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. | 60 | QString defaultScriptLoc = defaultScriptsLocation(); |
| 57 | return QUrl::fromLocalFile(rawScriptUrl).toString().toLower(); | 61 | if (fullNormal.startsWith(defaultScriptLoc)) { |
| 62 | return "~" + fullNormal.mid(defaultScriptLoc.size()); | ||
| 63 | } | ||
| 64 | return fullNormal; | ||
| 58 | #endif | 65 | #endif |
| 59 | 66 | ||
| 60 | } | 67 | } |
| 61 | return QUrl(rawScriptUrl).toString(); | 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 | QObject* scriptsModel(); | 95 | QObject* scriptsModel(); |
| 65 | 96 | ||
| 66 | void ScriptEngines::registerScriptInitializer(ScriptInitializer initializer) { | 97 | void ScriptEngines::registerScriptInitializer(ScriptInitializer initializer) { |