mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-05 23:27:38 +02:00
allow json for uses /~/ for file paths
This commit is contained in:
parent
563c19bb91
commit
8fc50222f5
3 changed files with 10 additions and 4 deletions
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include <StatTracker.h>
|
#include <StatTracker.h>
|
||||||
#include <shared/FileUtils.h>
|
#include <shared/FileUtils.h>
|
||||||
|
#include <pathUtils.h>
|
||||||
|
|
||||||
#include "ResourceManager.h"
|
#include "ResourceManager.h"
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ void FileResourceRequest::doSend() {
|
||||||
if (_url.scheme() == URL_SCHEME_QRC) {
|
if (_url.scheme() == URL_SCHEME_QRC) {
|
||||||
filename = ":/" + _url.path();
|
filename = ":/" + _url.path();
|
||||||
} else {
|
} else {
|
||||||
filename = _url.toLocalFile();
|
filename = PathUtils::expandToAppAbsolutePath(_url.toLocalFile(), true);
|
||||||
// sometimes on windows, we see the toLocalFile() return null,
|
// sometimes on windows, we see the toLocalFile() return null,
|
||||||
// in this case we will attempt to simply use the url as a string
|
// in this case we will attempt to simply use the url as a string
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
|
|
|
@ -133,10 +133,15 @@ QUrl PathUtils::resourcesUrl(const QString& relativeUrl) {
|
||||||
return QUrl(resourcesUrl() + relativeUrl);
|
return QUrl(resourcesUrl() + relativeUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PathUtils::expandToAppAbsolutePath(const QString& filePath) {
|
QString PathUtils::expandToAppAbsolutePath(const QString& filePath, bool localPath) {
|
||||||
QString path = filePath;
|
QString path = filePath;
|
||||||
if (path.startsWith("/~/")) {
|
if (path.startsWith("/~/")) {
|
||||||
path.replace(1, 2, applicationAbsolutePath());
|
QString absolutePath = applicationAbsolutePath();
|
||||||
|
if (localPath) {
|
||||||
|
path.replace(0, 3, absolutePath);
|
||||||
|
} else {
|
||||||
|
path.replace(1, 2, absolutePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
static QUrl resourcesUrl(const QString& relative);
|
static QUrl resourcesUrl(const QString& relative);
|
||||||
static const QString& resourcesPath();
|
static const QString& resourcesPath();
|
||||||
static const QString& qmlBaseUrl();
|
static const QString& qmlBaseUrl();
|
||||||
static QString expandToAppAbsolutePath(const QString& filePath);
|
static QString expandToAppAbsolutePath(const QString& filePath, bool localPath = false);
|
||||||
static QUrl qmlUrl(const QString& relative);
|
static QUrl qmlUrl(const QString& relative);
|
||||||
#ifdef DEV_BUILD
|
#ifdef DEV_BUILD
|
||||||
static const QString& projectRootPath();
|
static const QString& projectRootPath();
|
||||||
|
|
Loading…
Reference in a new issue