mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 03:03:35 +02:00
#19505 - Add domain & orientation parsing to hifi:// protocol handler
This commit is contained in:
parent
e5072bc00f
commit
ab4164a6df
3 changed files with 65 additions and 8 deletions
|
@ -687,8 +687,25 @@ bool Application::event(QEvent* event) {
|
|||
if (event->type() == QEvent::FileOpen) {
|
||||
QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
|
||||
if (!fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME)) {
|
||||
QString destination = fileEvent->url().toLocalFile().remove(QRegExp(CUSTOM_URL_SCHEME + "|/"));
|
||||
Menu::getInstance()->goToDestination(destination);
|
||||
QString destination = fileEvent->url().toLocalFile().remove(CUSTOM_URL_SCHEME);
|
||||
QStringList urlParts = destination.split('/', QString::SkipEmptyParts);
|
||||
|
||||
if (urlParts.count() > 1) {
|
||||
// if url has 2 or more parts, the first one is domain name
|
||||
Menu::getInstance()->goToDomain(urlParts[0]);
|
||||
|
||||
// location coordinates
|
||||
Menu::getInstance()->goToDestination(urlParts[1]);
|
||||
if (urlParts.count() > 2) {
|
||||
|
||||
// location orientation
|
||||
Menu::getInstance()->goToOrientation(urlParts[2]);
|
||||
}
|
||||
} else if (urlParts.count() == 1) {
|
||||
|
||||
// location coordinates
|
||||
Menu::getInstance()->goToDestination(urlParts[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -889,6 +889,17 @@ void Menu::editPreferences() {
|
|||
sendFakeEnterEvent();
|
||||
}
|
||||
|
||||
void Menu::goToDomain(const QString newDomain) {
|
||||
if (NodeList::getInstance()->getDomainHostname() != newDomain) {
|
||||
|
||||
// send a node kill request, indicating to other clients that they should play the "disappeared" effect
|
||||
Application::getInstance()->getAvatar()->sendKillAvatar();
|
||||
|
||||
// give our nodeList the new domain-server hostname
|
||||
NodeList::getInstance()->setDomainHostname(newDomain);
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::goToDomain() {
|
||||
|
||||
QString currentDomainHostname = NodeList::getInstance()->getDomainHostname();
|
||||
|
@ -913,17 +924,44 @@ void Menu::goToDomain() {
|
|||
// the user input a new hostname, use that
|
||||
newHostname = domainDialog.textValue();
|
||||
}
|
||||
|
||||
// send a node kill request, indicating to other clients that they should play the "disappeared" effect
|
||||
Application::getInstance()->getAvatar()->sendKillAvatar();
|
||||
|
||||
// give our nodeList the new domain-server hostname
|
||||
NodeList::getInstance()->setDomainHostname(domainDialog.textValue());
|
||||
|
||||
goToDomain(newHostname);
|
||||
}
|
||||
|
||||
sendFakeEnterEvent();
|
||||
}
|
||||
|
||||
void Menu::goToOrientation(QString orientation) {
|
||||
|
||||
if (orientation.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList orientationItems = orientation.split(QRegExp("_|,"), QString::SkipEmptyParts);
|
||||
|
||||
const int NUMBER_OF_ORIENTATION_ITEMS = 4;
|
||||
const int W_ITEM = 0;
|
||||
const int X_ITEM = 1;
|
||||
const int Y_ITEM = 2;
|
||||
const int Z_ITEM = 3;
|
||||
|
||||
if (orientationItems.size() == NUMBER_OF_ORIENTATION_ITEMS) {
|
||||
|
||||
double w = replaceLastOccurrence('-', '.', orientationItems[W_ITEM].trimmed()).toDouble();
|
||||
double x = replaceLastOccurrence('-', '.', orientationItems[X_ITEM].trimmed()).toDouble();
|
||||
double y = replaceLastOccurrence('-', '.', orientationItems[Y_ITEM].trimmed()).toDouble();
|
||||
double z = replaceLastOccurrence('-', '.', orientationItems[Z_ITEM].trimmed()).toDouble();
|
||||
|
||||
glm::quat newAvatarOrientation(w, x, y, z);
|
||||
|
||||
MyAvatar* myAvatar = Application::getInstance()->getAvatar();
|
||||
glm::quat avatarOrientation = myAvatar->getOrientation();
|
||||
if (newAvatarOrientation != avatarOrientation) {
|
||||
myAvatar->setOrientation(newAvatarOrientation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Menu::goToDestination(QString destination) {
|
||||
|
||||
QStringList coordinateItems = destination.split(QRegExp("_|,"), QString::SkipEmptyParts);
|
||||
|
|
|
@ -85,6 +85,8 @@ public:
|
|||
QAction::MenuRole role = QAction::NoRole);
|
||||
virtual void removeAction(QMenu* menu, const QString& actionName);
|
||||
bool goToDestination(QString destination);
|
||||
void goToOrientation(QString orientation);
|
||||
void goToDomain(const QString newDomain);
|
||||
|
||||
public slots:
|
||||
void bandwidthDetails();
|
||||
|
|
Loading…
Reference in a new issue