mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Add Menu::goToUrl
This commit is contained in:
parent
0570849df5
commit
ff51b22bfe
2 changed files with 38 additions and 33 deletions
|
@ -927,44 +927,48 @@ void Menu::goTo() {
|
||||||
int dialogReturn = gotoDialog.exec();
|
int dialogReturn = gotoDialog.exec();
|
||||||
if (dialogReturn == QDialog::Accepted && !gotoDialog.textValue().isEmpty()) {
|
if (dialogReturn == QDialog::Accepted && !gotoDialog.textValue().isEmpty()) {
|
||||||
QString desiredDestination = gotoDialog.textValue();
|
QString desiredDestination = gotoDialog.textValue();
|
||||||
|
if (!goToURL(desiredDestination)) {;
|
||||||
if (desiredDestination.startsWith(CUSTOM_URL_SCHEME + "//")) {
|
goTo(desiredDestination);
|
||||||
QStringList urlParts = desiredDestination.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts);
|
|
||||||
|
|
||||||
if (urlParts.count() > 1) {
|
|
||||||
// if url has 2 or more parts, the first one is domain name
|
|
||||||
QString domain = urlParts[0];
|
|
||||||
|
|
||||||
// second part is either a destination coordinate or
|
|
||||||
// a place name
|
|
||||||
QString destination = urlParts[1];
|
|
||||||
|
|
||||||
// any third part is an avatar orientation.
|
|
||||||
QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();
|
|
||||||
|
|
||||||
goToDomain(domain);
|
|
||||||
|
|
||||||
// goto either @user, #place, or x-xx,y-yy,z-zz
|
|
||||||
// style co-ordinate.
|
|
||||||
goTo(destination);
|
|
||||||
|
|
||||||
if (!orientation.isEmpty()) {
|
|
||||||
// location orientation
|
|
||||||
goToOrientation(orientation);
|
|
||||||
}
|
|
||||||
} else if (urlParts.count() == 1) {
|
|
||||||
// location coordinates or place name
|
|
||||||
QString destination = urlParts[0];
|
|
||||||
goTo(destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
goToUser(gotoDialog.textValue());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendFakeEnterEvent();
|
sendFakeEnterEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Menu::goToURL(QString location) {
|
||||||
|
if (location.startsWith(CUSTOM_URL_SCHEME + "//")) {
|
||||||
|
QStringList urlParts = location.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts);
|
||||||
|
|
||||||
|
if (urlParts.count() > 1) {
|
||||||
|
// if url has 2 or more parts, the first one is domain name
|
||||||
|
QString domain = urlParts[0];
|
||||||
|
|
||||||
|
// second part is either a destination coordinate or
|
||||||
|
// a place name
|
||||||
|
QString destination = urlParts[1];
|
||||||
|
|
||||||
|
// any third part is an avatar orientation.
|
||||||
|
QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();
|
||||||
|
|
||||||
|
goToDomain(domain);
|
||||||
|
|
||||||
|
// goto either @user, #place, or x-xx,y-yy,z-zz
|
||||||
|
// style co-ordinate.
|
||||||
|
goTo(destination);
|
||||||
|
|
||||||
|
if (!orientation.isEmpty()) {
|
||||||
|
// location orientation
|
||||||
|
goToOrientation(orientation);
|
||||||
|
}
|
||||||
|
} else if (urlParts.count() == 1) {
|
||||||
|
// location coordinates or place name
|
||||||
|
QString destination = urlParts[0];
|
||||||
|
goTo(destination);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Menu::goToUser(const QString& user) {
|
void Menu::goToUser(const QString& user) {
|
||||||
LocationManager* manager = &LocationManager::getInstance();
|
LocationManager* manager = &LocationManager::getInstance();
|
||||||
manager->goTo(user);
|
manager->goTo(user);
|
||||||
|
|
|
@ -152,6 +152,7 @@ public slots:
|
||||||
void importSettings();
|
void importSettings();
|
||||||
void exportSettings();
|
void exportSettings();
|
||||||
void goTo();
|
void goTo();
|
||||||
|
bool goToURL(QString location);
|
||||||
void goToUser(const QString& user);
|
void goToUser(const QString& user);
|
||||||
void pasteToVoxel();
|
void pasteToVoxel();
|
||||||
void openUrl(const QUrl& url);
|
void openUrl(const QUrl& url);
|
||||||
|
|
Loading…
Reference in a new issue