diff --git a/interface/src/ui/AddressBarDialog.cpp b/interface/src/ui/AddressBarDialog.cpp index f24dcb1ba6..274152742f 100644 --- a/interface/src/ui/AddressBarDialog.cpp +++ b/interface/src/ui/AddressBarDialog.cpp @@ -78,14 +78,16 @@ void AddressBarDialog::setupUI() { verticalLayout->addLayout(addressLayout); - connect(addressLineEdit, &QLineEdit::returnPressed, this, &AddressBarDialog::accept); connect(goButton, &QPushButton::clicked, this, &AddressBarDialog::accept); connect(closeButton, &QPushButton::clicked, this, &QDialog::close); } void AddressBarDialog::accept() { - // let the AddressManger figure out what to do with this - if (AddressManager::getInstance().handleLookupString(addressLineEdit->text())) { - close(); + if (!addressLineEdit->text().isEmpty()) { + goButton->setStyleSheet("background: #333; color: #e7eeee; border-radius: 4px;"); + + AddressManager& addressManager = AddressManager::getInstance(); + connect(&addressManager, &AddressManager::lookupResultsFinished, this, &QDialog::close); + addressManager.handleLookupString(addressLineEdit->text()); } } \ No newline at end of file diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index 0fd0d72755..4b3a84c603 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -80,12 +80,13 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl) { // if this is a relative path then handle it as a relative viewpoint handleRelativeViewpoint(lookupUrl.path()); + emit lookupResultsFinished(); } return false; } -bool AddressManager::handleLookupString(const QString& lookupString) { +void AddressManager::handleLookupString(const QString& lookupString) { if (!lookupString.isEmpty()) { // make this a valid hifi URL and handle it off to handleUrl QString sanitizedString = lookupString; @@ -100,10 +101,8 @@ bool AddressManager::handleLookupString(const QString& lookupString) { lookupURL = QUrl(lookupString); } - return handleUrl(lookupURL); + handleUrl(lookupURL); } - - return false; } void AddressManager::handleAPIResponse(const QJsonObject &jsonObject) { @@ -151,6 +150,7 @@ void AddressManager::handleAPIResponse(const QJsonObject &jsonObject) { // we've been told that this result exists but is offline, emit our signal so the application can handle emit lookupResultIsOffline(); } + emit lookupResultsFinished(); } void AddressManager::handleAPIError(QNetworkReply& errorReply) { @@ -159,6 +159,7 @@ void AddressManager::handleAPIError(QNetworkReply& errorReply) { if (errorReply.error() == QNetworkReply::ContentNotFoundError) { emit lookupResultIsNotFound(); } + emit lookupResultsFinished(); } const QString GET_PLACE = "/api/v1/places/%1"; @@ -182,6 +183,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) { if (hostnameRegex.indexIn(lookupString) != -1) { emit possibleDomainChangeRequired(hostnameRegex.cap(0)); + emit lookupResultsFinished(); return true; } @@ -189,6 +191,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) { if (ipAddressRegex.indexIn(lookupString) != -1) { emit possibleDomainChangeRequired(ipAddressRegex.cap(0)); + emit lookupResultsFinished(); return true; } diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index 4715ff0592..f7cc7c52ee 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -31,12 +31,13 @@ public: void attemptPlaceNameLookup(const QString& lookupString); public slots: - bool handleLookupString(const QString& lookupString); + void handleLookupString(const QString& lookupString); void handleAPIResponse(const QJsonObject& jsonObject); void handleAPIError(QNetworkReply& errorReply); void goToUser(const QString& username); signals: + void lookupResultsFinished(); void lookupResultIsOffline(); void lookupResultIsNotFound(); void possibleDomainChangeRequired(const QString& newHostname);