History

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

samcake committed 8 years ago

Commit 1dc69882 parents 023941a a689c58146 files · +2945 −4095Browse files

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

Unified · Split

interface/src/Application.cpp+108−3
@@ -252,6 +252,7 @@ extern "C" { · 251 unmodified lines
252 252
253#if defined(Q_OS_ANDROID)253#if defined(Q_OS_ANDROID)
254#include <android/log.h>254#include <android/log.h>
255#include "AndroidHelper.h"
255#endif256#endif
256 257
257enum ApplicationEvent {258enum ApplicationEvent {
@@ -1070,6 +1071,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 812 unmodified lines
1070 if (steamClient) {1071 if (steamClient) {
1071 qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << steamClient->getSteamVRBuildID();1072 qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << steamClient->getSteamVRBuildID();
1072 }1073 }
1074 setCrashAnnotation("steam", property(hifi::properties::STEAM).toBool() ? "1" : "0");
1075
1073 qCDebug(interfaceapp) << "[VERSION] Build sequence:" << qPrintable(applicationVersion());1076 qCDebug(interfaceapp) << "[VERSION] Build sequence:" << qPrintable(applicationVersion());
1074 qCDebug(interfaceapp) << "[VERSION] MODIFIED_ORGANIZATION:" << BuildInfo::MODIFIED_ORGANIZATION;1077 qCDebug(interfaceapp) << "[VERSION] MODIFIED_ORGANIZATION:" << BuildInfo::MODIFIED_ORGANIZATION;
1075 qCDebug(interfaceapp) << "[VERSION] VERSION:" << BuildInfo::VERSION;1078 qCDebug(interfaceapp) << "[VERSION] VERSION:" << BuildInfo::VERSION;
@@ -1155,6 +1158,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 79 unmodified lines
1155 const DomainHandler& domainHandler = nodeList->getDomainHandler();1158 const DomainHandler& domainHandler = nodeList->getDomainHandler();
1156 1159
1157 connect(&domainHandler, SIGNAL(domainURLChanged(QUrl)), SLOT(domainURLChanged(QUrl)));1160 connect(&domainHandler, SIGNAL(domainURLChanged(QUrl)), SLOT(domainURLChanged(QUrl)));
1161 connect(&domainHandler, &DomainHandler::domainURLChanged, [](QUrl domainURL){
1162 setCrashAnnotation("domain", domainURL.toString().toStdString());
1163 });
1158 connect(&domainHandler, SIGNAL(resetting()), SLOT(resettingDomain()));1164 connect(&domainHandler, SIGNAL(resetting()), SLOT(resettingDomain()));
1159 connect(&domainHandler, SIGNAL(connectedToDomain(QUrl)), SLOT(updateWindowTitle()));1165 connect(&domainHandler, SIGNAL(connectedToDomain(QUrl)), SLOT(updateWindowTitle()));
1160 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle()));1166 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle()));
@@ -1200,6 +1206,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 39 unmodified lines
1200 auto dialogsManager = DependencyManager::get<DialogsManager>();1206 auto dialogsManager = DependencyManager::get<DialogsManager>();
1201 connect(accountManager.data(), &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog);1207 connect(accountManager.data(), &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog);
1202 connect(accountManager.data(), &AccountManager::usernameChanged, this, &Application::updateWindowTitle);1208 connect(accountManager.data(), &AccountManager::usernameChanged, this, &Application::updateWindowTitle);
1209 connect(accountManager.data(), &AccountManager::usernameChanged, [](QString username){
1210 setCrashAnnotation("username", username.toStdString());
1211 });
1203 1212
1204 // set the account manager's root URL and trigger a login request if we don't have the access token1213 // set the account manager's root URL and trigger a login request if we don't have the access token
1205 accountManager->setIsAgent(true);1214 accountManager->setIsAgent(true);
@@ -1217,6 +1226,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 11 unmodified lines
1217 connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateThreadPoolCount);1226 connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateThreadPoolCount);
1218 connect(this, &Application::activeDisplayPluginChanged, this, [](){1227 connect(this, &Application::activeDisplayPluginChanged, this, [](){
1219 qApp->setProperty(hifi::properties::HMD, qApp->isHMDMode());1228 qApp->setProperty(hifi::properties::HMD, qApp->isHMDMode());
1229 auto displayPlugin = qApp->getActiveDisplayPlugin();
1230 setCrashAnnotation("display_plugin", displayPlugin->getName().toStdString());
1231 setCrashAnnotation("hmd", displayPlugin->isHmd() ? "1" : "0");
1220 });1232 });
1221 connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateSystemTabletMode);1233 connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateSystemTabletMode);
1222 1234
@@ -1224,6 +1236,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1 unmodified line
1224 connect(myAvatar.get(), &MyAvatar::positionGoneTo,1236 connect(myAvatar.get(), &MyAvatar::positionGoneTo,
1225 DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);1237 DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);
1226 1238
1239 connect(myAvatar.get(), &MyAvatar::skeletonModelURLChanged, [](){
1240 QUrl avatarURL = qApp->getMyAvatar()->getSkeletonModelURL();
1241 setCrashAnnotation("avatar", avatarURL.toString().toStdString());
1242 });
1243
1244
1227 // Inititalize sample before registering1245 // Inititalize sample before registering
1228 _sampleSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/sample.wav"));1246 _sampleSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/sample.wav"));
1229 1247
@@ -1241,6 +1259,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 11 unmodified lines
1241 1259
1242 connect(scriptEngines, &ScriptEngines::scriptsReloading, scriptEngines, [this] {1260 connect(scriptEngines, &ScriptEngines::scriptsReloading, scriptEngines, [this] {
1243 getEntities()->reloadEntityScripts();1261 getEntities()->reloadEntityScripts();
1262 loadAvatarScripts(getMyAvatar()->getScriptUrls());
1244 }, Qt::QueuedConnection);1263 }, Qt::QueuedConnection);
1245 1264
1246 connect(scriptEngines, &ScriptEngines::scriptLoadError,1265 connect(scriptEngines, &ScriptEngines::scriptLoadError,
@@ -1388,6 +1407,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 141 unmodified lines
1388 userActivityLogger.disable(false);1407 userActivityLogger.disable(false);
1389 }1408 }
1390 1409
1410 QString machineFingerPrint = uuidStringWithoutCurlyBraces(FingerprintUtils::getMachineFingerprint());
1411
1391 if (userActivityLogger.isEnabled()) {1412 if (userActivityLogger.isEnabled()) {
1392 // sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value.1413 // sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value.
1393 // The value will be 0 if the user blew away settings this session, which is both a feature and a bug.1414 // The value will be 0 if the user blew away settings this session, which is both a feature and a bug.
@@ -1437,11 +1458,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 43 unmodified lines
1437 properties["first_run"] = firstRun.get();1458 properties["first_run"] = firstRun.get();
1438 1459
1439 // add the user's machine ID to the launch event1460 // add the user's machine ID to the launch event
1440 properties["machine_fingerprint"] = uuidStringWithoutCurlyBraces(FingerprintUtils::getMachineFingerprint());1461 properties["machine_fingerprint"] = machineFingerPrint;
1441 1462
1442 userActivityLogger.logAction("launch", properties);1463 userActivityLogger.logAction("launch", properties);
1443 }1464 }
1444 1465
1466 setCrashAnnotation("machine_fingerprint", machineFingerPrint.toStdString());
1467
1445 _entityEditSender.setMyAvatar(myAvatar.get());1468 _entityEditSender.setMyAvatar(myAvatar.get());
1446 1469
1447 // The entity octree will have to know about MyAvatar for the parentJointName import1470 // The entity octree will have to know about MyAvatar for the parentJointName import
@@ -2712,6 +2735,9 @@ void Application::initializeUi() { · 1264 unmodified lines
2712 offscreenUi->resume();2735 offscreenUi->resume();
2713 connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect& r){2736 connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect& r){
2714 resizeGL();2737 resizeGL();
2738 if (_touchscreenVirtualPadDevice) {
2739 _touchscreenVirtualPadDevice->resize();
2740 }
2715 });2741 });
2716 2742
2717 // This will set up the input plugins UI2743 // This will set up the input plugins UI
@@ -3148,11 +3174,14 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 430 unmodified lines
3148 3174
3149 // If this is a first run we short-circuit the address passed in3175 // If this is a first run we short-circuit the address passed in
3150 if (firstRun.get()) {3176 if (firstRun.get()) {
3151#if !defined(Q_OS_ANDROID)3177#if defined(Q_OS_ANDROID)
3178 qCDebug(interfaceapp) << "First run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("default location") : addressLookupString);
3179 DependencyManager::get<AddressManager>()->loadSettings(addressLookupString);
3180#else
3152 showHelp();3181 showHelp();
3153#endif
3154 DependencyManager::get<AddressManager>()->goToEntry();3182 DependencyManager::get<AddressManager>()->goToEntry();
3155 sentTo = SENT_TO_ENTRY;3183 sentTo = SENT_TO_ENTRY;
3184#endif
3156 firstRun.set(false);3185 firstRun.set(false);
3157 3186
3158 } else {3187 } else {
@@ -3722,6 +3751,12 @@ void Application::keyPressEvent(QKeyEvent* event) { · 563 unmodified lines
3722void Application::keyReleaseEvent(QKeyEvent* event) {3751void Application::keyReleaseEvent(QKeyEvent* event) {
3723 _keysPressed.remove(event->key());3752 _keysPressed.remove(event->key());
3724 3753
3754#if defined(Q_OS_ANDROID)
3755 if (event->key() == Qt::Key_Back) {
3756 event->accept();
3757 openAndroidActivity("Home");
3758 }
3759#endif
3725 _controllerScriptingInterface->emitKeyReleaseEvent(event); // send events to any registered scripts3760 _controllerScriptingInterface->emitKeyReleaseEvent(event); // send events to any registered scripts
3726 3761
3727 // if one of our scripts have asked to capture this event, then stop processing it3762 // if one of our scripts have asked to capture this event, then stop processing it
@@ -4798,6 +4833,31 @@ void Application::init() { · 1070 unmodified lines
4798 _entitySimulation->setWorkloadSpace(getEntities()->getWorkloadSpace());4833 _entitySimulation->setWorkloadSpace(getEntities()->getWorkloadSpace());
4799}4834}
4800 4835
4836void Application::loadAvatarScripts(const QVector<QString>& urls) {
4837 auto scriptEngines = DependencyManager::get<ScriptEngines>();
4838 auto runningScripts = scriptEngines->getRunningScripts();
4839 for (auto url : urls) {
4840 int index = runningScripts.indexOf(url);
4841 if (index < 0) {
4842 auto scriptEnginePointer = scriptEngines->loadScript(url, false);
4843 if (scriptEnginePointer) {
4844 scriptEnginePointer->setType(ScriptEngine::Type::AVATAR);
4845 }
4846 }
4847 }
4848}
4849
4850void Application::unloadAvatarScripts() {
4851 auto scriptEngines = DependencyManager::get<ScriptEngines>();
4852 auto urls = scriptEngines->getRunningScripts();
4853 for (auto url : urls) {
4854 auto scriptEngine = scriptEngines->getScriptEngine(url);
4855 if (scriptEngine->getType() == ScriptEngine::Type::AVATAR) {
4856 scriptEngines->stopScript(url, false);
4857 }
4858 }
4859}
4860
4801void Application::updateLOD(float deltaTime) const {4861void Application::updateLOD(float deltaTime) const {
4802 PerformanceTimer perfTimer("LOD");4862 PerformanceTimer perfTimer("LOD");
4803 // adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode4863 // adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode
@@ -7843,6 +7903,26 @@ void Application::switchDisplayMode() { · 3039 unmodified lines
7843 _previousHMDWornStatus = currentHMDWornStatus;7903 _previousHMDWornStatus = currentHMDWornStatus;
7844}7904}
7845 7905
7906void Application::setShowBulletWireframe(bool value) {
7907 _physicsEngine->setShowBulletWireframe(value);
7908}
7909
7910void Application::setShowBulletAABBs(bool value) {
7911 _physicsEngine->setShowBulletAABBs(value);
7912}
7913
7914void Application::setShowBulletContactPoints(bool value) {
7915 _physicsEngine->setShowBulletContactPoints(value);
7916}
7917
7918void Application::setShowBulletConstraints(bool value) {
7919 _physicsEngine->setShowBulletConstraints(value);
7920}
7921
7922void Application::setShowBulletConstraintLimits(bool value) {
7923 _physicsEngine->setShowBulletConstraintLimits(value);
7924}
7925
7846void Application::startHMDStandBySession() {7926void Application::startHMDStandBySession() {
7847 _autoSwitchDisplayModeSupportedHMDPlugin->startStandBySession();7927 _autoSwitchDisplayModeSupportedHMDPlugin->startStandBySession();
7848}7928}
@@ -8024,4 +8104,29 @@ void Application::saveNextPhysicsStats(QString filename) { · 175 unmodified lines
8024 _physicsEngine->saveNextPhysicsStats(filename);8104 _physicsEngine->saveNextPhysicsStats(filename);
8025}8105}
8026 8106
8107void Application::openAndroidActivity(const QString& activityName) {
8108#if defined(Q_OS_ANDROID)
8109 AndroidHelper::instance().requestActivity(activityName);
8110#endif
8111}
8112
8113#if defined(Q_OS_ANDROID)
8114void Application::enterBackground() {
8115 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
8116 "stop", Qt::BlockingQueuedConnection);
8117 //GC: commenting it out until we fix it
8118 //getActiveDisplayPlugin()->deactivate();
8119}
8120void Application::enterForeground() {
8121 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
8122 "start", Qt::BlockingQueuedConnection);
8123 //GC: commenting it out until we fix it
8124 /*if (!getActiveDisplayPlugin() || !getActiveDisplayPlugin()->activate()) {
8125 qWarning() << "Could not re-activate display plugin";
8126 }*/
8127
8128}
8129#endif
8130
8131#include "Application_jni.cpp"
8027#include "Application.moc"8132#include "Application.moc"

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