mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 13:33:38 +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);
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue