mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 14:29:35 +02:00
Merge pull request #18 from druiz17/serverless-domains
Support file:///~/path/to/file/ format when loading domain from goto
This commit is contained in:
commit
9ba11ba3e5
3 changed files with 27 additions and 2 deletions
|
@ -22,6 +22,7 @@
|
|||
#include <NumericalConstants.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <UUID.h>
|
||||
#include <PathUtils.h>
|
||||
|
||||
#include "AddressManager.h"
|
||||
#include "NodeList.h"
|
||||
|
@ -309,10 +310,13 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
|||
} else if (lookupUrl.scheme() == "http" || lookupUrl.scheme() == "https" || lookupUrl.scheme() == "file") {
|
||||
qDebug() << "QQQQ file or http before serverless domain" << lookupUrl.toString();
|
||||
_previousLookup.clear();
|
||||
QUrl domainUrl = lookupUrl;
|
||||
const QString path = PathUtils::expandToAppAbsolutePath(lookupUrl.path());
|
||||
domainUrl.setPath(path);
|
||||
emit setServersEnabled(false);
|
||||
setDomainInfo(lookupUrl, QString(), 0, trigger);
|
||||
setDomainInfo(domainUrl, QString(), 0, trigger);
|
||||
DependencyManager::get<NodeList>()->getDomainHandler().setIsConnected(true);
|
||||
emit loadServerlessDomain(lookupUrl);
|
||||
emit loadServerlessDomain(domainUrl);
|
||||
emit lookupResultsFinished();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -116,10 +116,30 @@ const QString& PathUtils::resourcesUrl() {
|
|||
return staticResourcePath;
|
||||
}
|
||||
|
||||
QString applicationAbsolutePath() {
|
||||
QString path;
|
||||
#if defined(Q_OS_OSX)
|
||||
path = QCoreApplication::applicationDirPath() + "/../";
|
||||
#elif defined(Q_OS_ANDROID)
|
||||
path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
||||
#else
|
||||
path = QCoreApplication::applicationDirPath() + "/";
|
||||
#endif
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
QUrl PathUtils::resourcesUrl(const QString& relativeUrl) {
|
||||
return QUrl(resourcesUrl() + relativeUrl);
|
||||
}
|
||||
|
||||
QString PathUtils::expandToAppAbsolutePath(const QString& filePath) {
|
||||
QString path = filePath;
|
||||
if (path.startsWith("/~/")) {
|
||||
path.replace(1, 2, applicationAbsolutePath());
|
||||
}
|
||||
return path;
|
||||
}
|
||||
const QString& PathUtils::qmlBaseUrl() {
|
||||
static const QString staticResourcePath = resourcesUrl() + "qml/";
|
||||
return staticResourcePath;
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
static QUrl resourcesUrl(const QString& relative);
|
||||
static const QString& resourcesPath();
|
||||
static const QString& qmlBaseUrl();
|
||||
static QString expandToAppAbsolutePath(const QString& filePath);
|
||||
static QUrl qmlUrl(const QString& relative);
|
||||
#ifdef DEV_BUILD
|
||||
static const QString& projectRootPath();
|
||||
|
|
Loading…
Reference in a new issue