History

Merge branch 'master' of https://github.com/highfidelity/hifi into deference

Andrzej Kapolka committed 12 years ago

Commit d0f30df2 parents 7074d96 3fbe18372 files · +3187 −1562Browse files

Showing the changes to interface/src/Application.cpp (1 of 72 files). Show all

Unified · Split

interface/src/Application.cpp+75−64
@@ -51,6 +51,7 @@ · 50 unmodified lines
5151 #include <QMimeData>
5252 #include <QMessageBox>
5353
54+#include <AddressManager.h>
5455 #include <AccountManager.h>
5556 #include <AudioInjector.h>
5657 #include <EntityScriptingInterface.h>
@@ -80,10 +81,10 @@ · 23 unmodified lines
8081 #include "scripting/AccountScriptingInterface.h"
8182 #include "scripting/AudioDeviceScriptingInterface.h"
8283 #include "scripting/ClipboardScriptingInterface.h"
84+#include "scripting/LocationScriptingInterface.h"
8385 #include "scripting/MenuScriptingInterface.h"
8486 #include "scripting/SettingsScriptingInterface.h"
8587 #include "scripting/WindowScriptingInterface.h"
86−#include "scripting/LocationScriptingInterface.h"
8788
8889 #include "ui/InfoView.h"
8990 #include "ui/OAuthWebViewHandler.h"
@@ -358,9 +359,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 268 unmodified lines
358359 Particle::setVoxelEditPacketSender(&_voxelEditSender);
359360 Particle::setParticleEditPacketSender(&_particleEditSender);
360361
361− // when -url in command line, teleport to location
362− urlGoTo(argc, constArgv);
363−
364362 // For now we're going to set the PPS for outbound packets to be super high, this is
365363 // probably not the right long term solution. But for now, we're going to do this to
366364 // allow you to move a particle around in your hand
@@ -405,9 +403,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 38 unmodified lines
405403
406404 connect(_window, &MainWindow::windowGeometryChanged,
407405 _runningScriptsWidget, &RunningScriptsWidget::setBoundary);
406+
407+ AddressManager& addressManager = AddressManager::getInstance();
408408
409− //When -url in command line, teleport to location
410− urlGoTo(argc, constArgv);
409+ // connect to the domainChangeRequired signal on AddressManager
410+ connect(&addressManager, &AddressManager::possibleDomainChangeRequired,
411+ this, &Application::changeDomainHostname);
412+
413+ // when -url in command line, teleport to location
414+ addressManager.handleLookupString(getCmdOption(argc, constArgv, "-url"));
411415
412416 // call the OAuthWebviewHandler static getter so that its instance lives in our thread
413417 OAuthWebViewHandler::getInstance();
@@ -807,12 +811,14 @@ bool Application::event(QEvent* event) { · 393 unmodified lines
807811 // handle custom URL
808812 if (event->type() == QEvent::FileOpen) {
809813 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
810− bool isHifiSchemeURL = !fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME);
811− if (isHifiSchemeURL) {
812− Menu::getInstance()->goToURL(fileEvent->url().toLocalFile());
814+
815+ if (!fileEvent->url().isEmpty()) {
816+ AddressManager::getInstance().handleLookupString(fileEvent->url().toLocalFile());
813817 }
818+
814819 return false;
815820 }
821+
816822 return QApplication::event(event);
817823 }
818824
@@ -912,7 +918,12 @@ void Application::keyPressEvent(QKeyEvent* event) { · 93 unmodified lines
912918
913919 case Qt::Key_Return:
914920 case Qt::Key_Enter:
915− Menu::getInstance()->triggerOption(MenuOption::Chat);
921+ if (isMeta) {
922+ Menu::getInstance()->triggerOption(MenuOption::AddressBar);
923+ } else {
924+ Menu::getInstance()->triggerOption(MenuOption::Chat);
925+ }
926+
916927 break;
917928
918929 case Qt::Key_Up:
@@ -1059,10 +1070,6 @@ void Application::keyPressEvent(QKeyEvent* event) { · 140 unmodified lines
10591070 case Qt::Key_Equal:
10601071 _myAvatar->resetSize();
10611072 break;
1062−
1063− case Qt::Key_At:
1064− Menu::getInstance()->goTo();
1065− break;
10661073 default:
10671074 event->ignore();
10681075 break;
@@ -1321,7 +1328,7 @@ void Application::dropEvent(QDropEvent *event) { · 252 unmodified lines
13211328 SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath);
13221329 if (snapshotData) {
13231330 if (!snapshotData->getDomain().isEmpty()) {
1324− Menu::getInstance()->goToDomain(snapshotData->getDomain());
1331+ changeDomainHostname(snapshotData->getDomain());
13251332 }
13261333
13271334 _myAvatar->setPosition(snapshotData->getLocation());
@@ -3387,31 +3394,53 @@ void Application::updateWindowTitle(){ · 2059 unmodified lines
33873394 #ifndef WIN32
33883395 // crashes with vs2013/win32
33893396 qDebug("Application title set to: %s", title.toStdString().c_str());
3390−#endif //!WIN32
3397+#endif
33913398 _window->setWindowTitle(title);
33923399 }
33933400
33943401 void Application::updateLocationInServer() {
33953402
33963403 AccountManager& accountManager = AccountManager::getInstance();
3397−
3398− if (accountManager.isLoggedIn()) {
3404+ const QUuid& domainUUID = NodeList::getInstance()->getDomainHandler().getUUID();
3405+
3406+ if (accountManager.isLoggedIn() && !domainUUID.isNull()) {
33993407
34003408 // construct a QJsonObject given the user's current address information
3401− QJsonObject updatedLocationObject;
3409+ QJsonObject rootObject;
34023410
3403− QJsonObject addressObject;
3404− addressObject.insert("position", QString(createByteArray(_myAvatar->getPosition())));
3405− addressObject.insert("orientation", QString(createByteArray(glm::degrees(safeEulerAngles(_myAvatar->getOrientation())))));
3406− addressObject.insert("domain", NodeList::getInstance()->getDomainHandler().getHostname());
3411+ QJsonObject locationObject;
3412+
3413+ QString pathString = AddressManager::pathForPositionAndOrientation(_myAvatar->getPosition(),
3414+ true,
3415+ _myAvatar->getOrientation());
3416+
3417+ const QString LOCATION_KEY_IN_ROOT = "location";
3418+ const QString PATH_KEY_IN_LOCATION = "path";
3419+ const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id";
3420+
3421+ locationObject.insert(PATH_KEY_IN_LOCATION, pathString);
3422+ locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, domainUUID.toString());
34073423
3408− updatedLocationObject.insert("address", addressObject);
3424+ rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject);
34093425
3410− accountManager.authenticatedRequest("/api/v1/users/address", QNetworkAccessManager::PutOperation,
3411− JSONCallbackParameters(), QJsonDocument(updatedLocationObject).toJson());
3426+ accountManager.authenticatedRequest("/api/v1/users/location", QNetworkAccessManager::PutOperation,
3427+ JSONCallbackParameters(), QJsonDocument(rootObject).toJson());
34123428 }
34133429 }
34143430
3431+void Application::changeDomainHostname(const QString &newDomainHostname) {
3432+ NodeList* nodeList = NodeList::getInstance();
3433+
3434+ if (!nodeList->getDomainHandler().isCurrentHostname(newDomainHostname)) {
3435+ // tell the MyAvatar object to send a kill packet so that it dissapears from its old avatar mixer immediately
3436+ _myAvatar->sendKillAvatar();
3437+
3438+ // call the domain hostname change as a queued connection on the nodelist
3439+ QMetaObject::invokeMethod(&NodeList::getInstance()->getDomainHandler(), "setHostname",
3440+ Q_ARG(const QString&, newDomainHostname));
3441+ }
3442+}
3443+
34153444 void Application::domainChanged(const QString& domainHostname) {
34163445 updateWindowTitle();
34173446
@@ -3795,12 +3824,11 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 377 unmodified lines
37953824
37963825 QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", WindowScriptingInterface::getInstance());
37973826 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
3798− LocationScriptingInterface::locationSetter, windowValue);
3799−
3827+ LocationScriptingInterface::locationSetter, windowValue);
38003828 // register `location` on the global object.
38013829 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
3802− LocationScriptingInterface::locationSetter);
3803−
3830+ LocationScriptingInterface::locationSetter);
3831+
38043832 scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
38053833 scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
38063834 scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
@@ -3928,6 +3956,15 @@ void Application::uploadAttachment() { · 121 unmodified lines
39283956 uploadModel(ATTACHMENT_MODEL);
39293957 }
39303958
3959+void Application::openUrl(const QUrl& url) {
3960+ if (url.scheme() == HIFI_URL_SCHEME) {
3961+ AddressManager::getInstance().handleLookupString(url.toString());
3962+ } else {
3963+ // address manager did not handle - ask QDesktopServices to handle
3964+ QDesktopServices::openUrl(url);
3965+ }
3966+}
3967+
39313968 void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject) {
39323969
39333970 // from the domain-handler, figure out the satoshi cost per voxel and per meter cubed
@@ -4098,6 +4135,14 @@ void Application::skipVersion(QString latestVersion) { · 164 unmodified lines
40984135 skipFile.write(latestVersion.toStdString().c_str());
40994136 }
41004137
4138+void Application::setCursorVisible(bool visible) {
4139+ if (visible) {
4140+ restoreOverrideCursor();
4141+ } else {
4142+ setOverrideCursor(Qt::BlankCursor);
4143+ }
4144+}
4145+
41014146 void Application::takeSnapshot() {
41024147 QMediaPlayer* player = new QMediaPlayer();
41034148 QFileInfo inf = QFileInfo(Application::resourcesPath() + "sounds/snap.wav");
@@ -4116,37 +4161,3 @@ void Application::takeSnapshot() { · 12 unmodified lines
41164161 }
41174162 _snapshotShareDialog->show();
41184163 }
4119−
4120−void Application::urlGoTo(int argc, const char * constArgv[]) {
4121− //Gets the url (hifi://domain/destination/orientation)
4122− QString customUrl = getCmdOption(argc, constArgv, "-url");
4123− if(customUrl.startsWith(CUSTOM_URL_SCHEME + "//")) {
4124− QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts);
4125− if (urlParts.count() == 1) {
4126− // location coordinates or place name
4127− QString domain = urlParts[0];
4128− Menu::goToDomain(domain);
4129− } else if (urlParts.count() > 1) {
4130− // if url has 2 or more parts, the first one is domain name
4131− QString domain = urlParts[0];
4132−
4133− // second part is either a destination coordinate or
4134− // a place name
4135− QString destination = urlParts[1];
4136−
4137− // any third part is an avatar orientation.
4138− QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();
4139−
4140− Menu::goToDomain(domain);
4141−
4142− // goto either @user, #place, or x-xx,y-yy,z-zz
4143− // style co-ordinate.
4144− Menu::goTo(destination);
4145−
4146− if (!orientation.isEmpty()) {
4147− // location orientation
4148− Menu::goToOrientation(orientation);
4149− }
4150− }
4151− }
4152−}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t