mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:49:12 +02:00
Add finish lookup event
This commit is contained in:
parent
cc83c2b2e0
commit
5a7b7cca44
3 changed files with 15 additions and 9 deletions
|
@ -78,14 +78,16 @@ void AddressBarDialog::setupUI() {
|
||||||
|
|
||||||
verticalLayout->addLayout(addressLayout);
|
verticalLayout->addLayout(addressLayout);
|
||||||
|
|
||||||
connect(addressLineEdit, &QLineEdit::returnPressed, this, &AddressBarDialog::accept);
|
|
||||||
connect(goButton, &QPushButton::clicked, this, &AddressBarDialog::accept);
|
connect(goButton, &QPushButton::clicked, this, &AddressBarDialog::accept);
|
||||||
connect(closeButton, &QPushButton::clicked, this, &QDialog::close);
|
connect(closeButton, &QPushButton::clicked, this, &QDialog::close);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressBarDialog::accept() {
|
void AddressBarDialog::accept() {
|
||||||
// let the AddressManger figure out what to do with this
|
if (!addressLineEdit->text().isEmpty()) {
|
||||||
if (AddressManager::getInstance().handleLookupString(addressLineEdit->text())) {
|
goButton->setStyleSheet("background: #333; color: #e7eeee; border-radius: 4px;");
|
||||||
close();
|
|
||||||
|
AddressManager& addressManager = AddressManager::getInstance();
|
||||||
|
connect(&addressManager, &AddressManager::lookupResultsFinished, this, &QDialog::close);
|
||||||
|
addressManager.handleLookupString(addressLineEdit->text());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -80,12 +80,13 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl) {
|
||||||
|
|
||||||
// if this is a relative path then handle it as a relative viewpoint
|
// if this is a relative path then handle it as a relative viewpoint
|
||||||
handleRelativeViewpoint(lookupUrl.path());
|
handleRelativeViewpoint(lookupUrl.path());
|
||||||
|
emit lookupResultsFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddressManager::handleLookupString(const QString& lookupString) {
|
void AddressManager::handleLookupString(const QString& lookupString) {
|
||||||
if (!lookupString.isEmpty()) {
|
if (!lookupString.isEmpty()) {
|
||||||
// make this a valid hifi URL and handle it off to handleUrl
|
// make this a valid hifi URL and handle it off to handleUrl
|
||||||
QString sanitizedString = lookupString;
|
QString sanitizedString = lookupString;
|
||||||
|
@ -100,10 +101,8 @@ bool AddressManager::handleLookupString(const QString& lookupString) {
|
||||||
lookupURL = QUrl(lookupString);
|
lookupURL = QUrl(lookupString);
|
||||||
}
|
}
|
||||||
|
|
||||||
return handleUrl(lookupURL);
|
handleUrl(lookupURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressManager::handleAPIResponse(const QJsonObject &jsonObject) {
|
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
|
// we've been told that this result exists but is offline, emit our signal so the application can handle
|
||||||
emit lookupResultIsOffline();
|
emit lookupResultIsOffline();
|
||||||
}
|
}
|
||||||
|
emit lookupResultsFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressManager::handleAPIError(QNetworkReply& errorReply) {
|
void AddressManager::handleAPIError(QNetworkReply& errorReply) {
|
||||||
|
@ -159,6 +159,7 @@ void AddressManager::handleAPIError(QNetworkReply& errorReply) {
|
||||||
if (errorReply.error() == QNetworkReply::ContentNotFoundError) {
|
if (errorReply.error() == QNetworkReply::ContentNotFoundError) {
|
||||||
emit lookupResultIsNotFound();
|
emit lookupResultIsNotFound();
|
||||||
}
|
}
|
||||||
|
emit lookupResultsFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString GET_PLACE = "/api/v1/places/%1";
|
const QString GET_PLACE = "/api/v1/places/%1";
|
||||||
|
@ -182,6 +183,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) {
|
||||||
|
|
||||||
if (hostnameRegex.indexIn(lookupString) != -1) {
|
if (hostnameRegex.indexIn(lookupString) != -1) {
|
||||||
emit possibleDomainChangeRequired(hostnameRegex.cap(0));
|
emit possibleDomainChangeRequired(hostnameRegex.cap(0));
|
||||||
|
emit lookupResultsFinished();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,6 +191,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) {
|
||||||
|
|
||||||
if (ipAddressRegex.indexIn(lookupString) != -1) {
|
if (ipAddressRegex.indexIn(lookupString) != -1) {
|
||||||
emit possibleDomainChangeRequired(ipAddressRegex.cap(0));
|
emit possibleDomainChangeRequired(ipAddressRegex.cap(0));
|
||||||
|
emit lookupResultsFinished();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,12 +31,13 @@ public:
|
||||||
|
|
||||||
void attemptPlaceNameLookup(const QString& lookupString);
|
void attemptPlaceNameLookup(const QString& lookupString);
|
||||||
public slots:
|
public slots:
|
||||||
bool handleLookupString(const QString& lookupString);
|
void handleLookupString(const QString& lookupString);
|
||||||
|
|
||||||
void handleAPIResponse(const QJsonObject& jsonObject);
|
void handleAPIResponse(const QJsonObject& jsonObject);
|
||||||
void handleAPIError(QNetworkReply& errorReply);
|
void handleAPIError(QNetworkReply& errorReply);
|
||||||
void goToUser(const QString& username);
|
void goToUser(const QString& username);
|
||||||
signals:
|
signals:
|
||||||
|
void lookupResultsFinished();
|
||||||
void lookupResultIsOffline();
|
void lookupResultIsOffline();
|
||||||
void lookupResultIsNotFound();
|
void lookupResultIsNotFound();
|
||||||
void possibleDomainChangeRequired(const QString& newHostname);
|
void possibleDomainChangeRequired(const QString& newHostname);
|
||||||
|
|
Loading…
Reference in a new issue