Showing the changes to interface/src/scripting/LocationScriptingInterface.cpp (1 of 10 files). Show all
Unified · Split
| @@ -1,53 +0,0 @@ | ||
| 1 | −// | |
| 2 | −// LocationScriptingInterface.cpp | |
| 3 | −// interface/src/scripting | |
| 4 | −// | |
| 5 | −// Created by Ryan Huffman on 4/29/14. | |
| 6 | −// Copyright 2014 High Fidelity, Inc. | |
| 7 | −// | |
| 8 | −// Distributed under the Apache License, Version 2.0. | |
| 9 | −// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | |
| 10 | −// | |
| 11 | − | |
| 12 | −#include <glm/glm.hpp> | |
| 13 | − | |
| 14 | −#include "NodeList.h" | |
| 15 | − | |
| 16 | −#include "LocationScriptingInterface.h" | |
| 17 | − | |
| 18 | −LocationScriptingInterface* LocationScriptingInterface::getInstance() { | |
| 19 | − static LocationScriptingInterface sharedInstance; | |
| 20 | − return &sharedInstance; | |
| 21 | −} | |
| 22 | − | |
| 23 | −bool LocationScriptingInterface::isConnected() { | |
| 24 | − return NodeList::getInstance()->getDomainHandler().isConnected(); | |
| 25 | −} | |
| 26 | − | |
| 27 | −QString LocationScriptingInterface::getHref() { | |
| 28 | − return getProtocol() + "//" + getHostname() + getPathname(); | |
| 29 | −} | |
| 30 | − | |
| 31 | −QString LocationScriptingInterface::getPathname() { | |
| 32 | − const glm::vec3& position = Application::getInstance()->getAvatar()->getPosition(); | |
| 33 | − QString path; | |
| 34 | − path.sprintf("/%.4f,%.4f,%.4f", position.x, position.y, position.z); | |
| 35 | − return path; | |
| 36 | −} | |
| 37 | − | |
| 38 | −QString LocationScriptingInterface::getHostname() { | |
| 39 | − return NodeList::getInstance()->getDomainHandler().getHostname(); | |
| 40 | −} | |
| 41 | − | |
| 42 | −void LocationScriptingInterface::assign(const QString& url) { | |
| 43 | − QMetaObject::invokeMethod(Menu::getInstance(), "goToURL", Q_ARG(const QString&, url)); | |
| 44 | −} | |
| 45 | − | |
| 46 | −QScriptValue LocationScriptingInterface::locationGetter(QScriptContext* context, QScriptEngine* engine) { | |
| 47 | − return engine->newQObject(getInstance()); | |
| 48 | −} | |
| 49 | − | |
| 50 | −QScriptValue LocationScriptingInterface::locationSetter(QScriptContext* context, QScriptEngine* engine) { | |
| 51 | − LocationScriptingInterface::getInstance()->assign(context->argument(0).toString()); | |
| 52 | − return QScriptValue::UndefinedValue; | |
| 53 | −} | |