mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-16 15:11:32 +02:00
on first run, go to home or entry
This commit is contained in:
parent
e478b72e67
commit
22f4beab1a
3 changed files with 42 additions and 1 deletions
|
@ -2950,7 +2950,14 @@ void Application::init() {
|
|||
addressLookupString = arguments().value(urlIndex + 1);
|
||||
}
|
||||
|
||||
DependencyManager::get<AddressManager>()->loadSettings(addressLookupString);
|
||||
Setting::Handle<bool> firstRun { "firstRun", true };
|
||||
if (addressLookupString.isEmpty() && firstRun.get()) {
|
||||
qDebug() << "First run and no URL passed... attempting to Go Home...";
|
||||
DependencyManager::get<AddressManager>()->goHomeOrElsewhere();
|
||||
} else {
|
||||
qDebug() << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString);
|
||||
DependencyManager::get<AddressManager>()->loadSettings(addressLookupString);
|
||||
}
|
||||
|
||||
qCDebug(interfaceapp) << "Loaded settings";
|
||||
|
||||
|
|
|
@ -629,3 +629,33 @@ void AddressManager::addCurrentAddressToHistory(LookupTrigger trigger) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddressManager::goHomeOrElsewhere(QString elsewhere, LookupTrigger trigger) {
|
||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
QNetworkRequest sandboxStatus(QString("http://localhost:60332/status"));
|
||||
sandboxStatus.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QNetworkReply* reply = networkAccessManager.get(sandboxStatus);
|
||||
|
||||
connect(reply, &QNetworkReply::finished, this, [this, elsewhere, trigger]() {
|
||||
QNetworkReply* sender = qobject_cast<QNetworkReply*>(QObject::sender());
|
||||
auto statusData = sender->readAll();
|
||||
auto statusJson = QJsonDocument::fromJson(statusData);
|
||||
if (!statusJson.isEmpty()) {
|
||||
auto statusObject = statusJson.object();
|
||||
auto serversValue = statusObject.value("servers");
|
||||
if (!serversValue.isUndefined() && serversValue.isObject()) {
|
||||
auto serversObject = serversValue.toObject();
|
||||
auto serversCount = serversObject.size();
|
||||
const int MINIMUM_EXPECTED_SERVER_COUNT = 6;
|
||||
if (serversCount >= MINIMUM_EXPECTED_SERVER_COUNT) {
|
||||
qDebug() << "Home sandbox is running, going to " << SANDBOX_HIFI_ADDRESS;
|
||||
handleUrl(SANDBOX_HIFI_ADDRESS, trigger);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
qDebug() << "Home sandbox was not running, going to " << elsewhere << "instead.";
|
||||
handleUrl(elsewhere, trigger);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
const QString HIFI_URL_SCHEME = "hifi";
|
||||
const QString DEFAULT_HIFI_ADDRESS = "hifi://entry";
|
||||
const QString SANDBOX_HIFI_ADDRESS = "hifi://localhost";
|
||||
const QString INDEX_PATH = "/";
|
||||
|
||||
const QString GET_PLACE = "/api/v1/places/%1";
|
||||
|
@ -65,6 +66,9 @@ public:
|
|||
const QStack<QUrl>& getBackStack() const { return _backStack; }
|
||||
const QStack<QUrl>& getForwardStack() const { return _forwardStack; }
|
||||
|
||||
void goHomeOrElsewhere(QString elsewhere = DEFAULT_HIFI_ADDRESS,
|
||||
LookupTrigger trigger = LookupTrigger::StartupFromSettings);
|
||||
|
||||
public slots:
|
||||
void handleLookupString(const QString& lookupString);
|
||||
|
||||
|
|
Loading…
Reference in a new issue