Showing the changes to interface/src/Application.cpp (1 of 47 files). Show all
Unified · Split
| @@ -30,7 +30,6 @@ · 29 unmodified lines | ||
| 30 | 30 | #include <QImage> |
| 31 | 31 | #include <QInputDialog> |
| 32 | 32 | #include <QKeyEvent> |
| 33 | −#include <QMainWindow> | |
| 34 | 33 | #include <QMenuBar> |
| 35 | 34 | #include <QMouseEvent> |
| 36 | 35 | #include <QNetworkAccessManager> |
| @@ -134,7 +133,7 @@ QString& Application::resourcesPath() { · 97 unmodified lines | ||
| 134 | 133 | |
| 135 | 134 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : |
| 136 | 135 | QApplication(argc, argv), |
| 137 | − _window(new QMainWindow(desktop())), | |
| 136 | + _window(new MainWindow(desktop())), | |
| 138 | 137 | _glWidget(new GLCanvas()), |
| 139 | 138 | _nodeThread(new QThread(this)), |
| 140 | 139 | _datagramProcessor(), |
| @@ -166,11 +165,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 25 unmodified lines | ||
| 166 | 165 | _packetsPerSecond(0), |
| 167 | 166 | _bytesPerSecond(0), |
| 168 | 167 | _previousScriptLocation(), |
| 169 | − _logger(new FileLogger(this)) | |
| 168 | + _logger(new FileLogger(this)), | |
| 169 | + _runningScriptsWidget(new RunningScriptsWidget(_window)), | |
| 170 | + _runningScriptsWidgetWasVisible(false) | |
| 170 | 171 | { |
| 171 | 172 | // init GnuTLS for DTLS with domain-servers |
| 172 | 173 | DTLSClientSession::globalInit(); |
| 173 | − | |
| 174 | + | |
| 174 | 175 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 175 | 176 | QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); |
| 176 | 177 | |
| @@ -318,6 +319,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 141 unmodified lines | ||
| 318 | 319 | Particle::setVoxelEditPacketSender(&_voxelEditSender); |
| 319 | 320 | Particle::setParticleEditPacketSender(&_particleEditSender); |
| 320 | 321 | |
| 322 | + // when -url in command line, teleport to location | |
| 323 | + urlGoTo(argc, constArgv); | |
| 324 | + | |
| 321 | 325 | // For now we're going to set the PPS for outbound packets to be super high, this is |
| 322 | 326 | // probably not the right long term solution. But for now, we're going to do this to |
| 323 | 327 | // allow you to move a particle around in your hand |
| @@ -333,7 +337,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 9 unmodified lines | ||
| 333 | 337 | LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree()); |
| 334 | 338 | LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard); |
| 335 | 339 | |
| 336 | − _window->addDockWidget(Qt::NoDockWidgetArea, _runningScriptsWidget = new RunningScriptsWidget()); | |
| 337 | 340 | _runningScriptsWidget->setRunningScripts(getRunningScripts()); |
| 338 | 341 | connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript); |
| 339 | 342 | |
| @@ -344,18 +347,22 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 4 unmodified lines | ||
| 344 | 347 | // clear the scripts, and set out script to our default scripts |
| 345 | 348 | clearScriptsBeforeRunning(); |
| 346 | 349 | loadScript("http://public.highfidelity.io/scripts/defaultScripts.js"); |
| 347 | − | |
| 350 | + | |
| 348 | 351 | QMutexLocker locker(&_settingsMutex); |
| 349 | 352 | _settings->setValue("firstRun",QVariant(false)); |
| 350 | 353 | } else { |
| 351 | 354 | // do this as late as possible so that all required subsystems are inialized |
| 352 | 355 | loadScripts(); |
| 353 | − | |
| 356 | + | |
| 354 | 357 | QMutexLocker locker(&_settingsMutex); |
| 355 | 358 | _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); |
| 356 | 359 | } |
| 357 | − //When -url in command line, teleport to location | |
| 358 | − urlGoTo(argc, constArgv); | |
| 360 | + | |
| 361 | + connect(_window, &MainWindow::windowGeometryChanged, | |
| 362 | + _runningScriptsWidget, &RunningScriptsWidget::setBoundary); | |
| 363 | + | |
| 364 | + //When -url in command line, teleport to location | |
| 365 | + urlGoTo(argc, constArgv); | |
| 359 | 366 | } |
| 360 | 367 | |
| 361 | 368 | Application::~Application() { |
| @@ -364,11 +371,11 @@ Application::~Application() { · 2 unmodified lines | ||
| 364 | 371 | |
| 365 | 372 | // make sure we don't call the idle timer any more |
| 366 | 373 | delete idleTimer; |
| 367 | − | |
| 374 | + | |
| 368 | 375 | _sharedVoxelSystem.changeTree(new VoxelTree); |
| 369 | − | |
| 376 | + | |
| 370 | 377 | saveSettings(); |
| 371 | − | |
| 378 | + | |
| 372 | 379 | delete _voxelImporter; |
| 373 | 380 | |
| 374 | 381 | // let the avatar mixer know we're out |
| @@ -401,14 +408,14 @@ Application::~Application() { · 26 unmodified lines | ||
| 401 | 408 | delete _glWidget; |
| 402 | 409 | |
| 403 | 410 | AccountManager::getInstance().destroy(); |
| 404 | − | |
| 411 | + | |
| 405 | 412 | DTLSClientSession::globalDeinit(); |
| 406 | 413 | } |
| 407 | 414 | |
| 408 | 415 | void Application::saveSettings() { |
| 409 | 416 | Menu::getInstance()->saveSettings(); |
| 410 | 417 | _rearMirrorTools->saveSettings(_settings); |
| 411 | − | |
| 418 | + | |
| 412 | 419 | if (_voxelImporter) { |
| 413 | 420 | _voxelImporter->saveSettings(_settings); |
| 414 | 421 | } |
| @@ -575,7 +582,7 @@ void Application::paintGL() { · 160 unmodified lines | ||
| 575 | 582 | pushback = qMin(pushback, MAX_PUSHBACK * _myAvatar->getScale()); |
| 576 | 583 | const float BASE_PUSHBACK_FOCAL_LENGTH = 0.5f; |
| 577 | 584 | pushbackFocalLength = BASE_PUSHBACK_FOCAL_LENGTH * _myAvatar->getScale(); |
| 578 | − | |
| 585 | + | |
| 579 | 586 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { |
| 580 | 587 | _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing |
| 581 | 588 | _myCamera.setTargetPosition(_myAvatar->getUprightHeadPosition()); |
| @@ -588,7 +595,7 @@ void Application::paintGL() { · 6 unmodified lines | ||
| 588 | 595 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale()); |
| 589 | 596 | _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0)); |
| 590 | 597 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); |
| 591 | − | |
| 598 | + | |
| 592 | 599 | // if the head would intersect the near clip plane, we must push the camera out |
| 593 | 600 | glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) * |
| 594 | 601 | (eyePosition - _myCamera.getTargetPosition()); |
| @@ -597,7 +604,7 @@ void Application::paintGL() { · 2 unmodified lines | ||
| 597 | 604 | pushback = relativePosition.z + pushbackRadius - _myCamera.getDistance(); |
| 598 | 605 | pushbackFocalLength = _myCamera.getDistance(); |
| 599 | 606 | } |
| 600 | − | |
| 607 | + | |
| 601 | 608 | // handle pushback, if any |
| 602 | 609 | if (pushbackFocalLength > 0.0f) { |
| 603 | 610 | const float PUSHBACK_DECAY = 0.5f; |
| @@ -859,7 +866,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 255 unmodified lines | ||
| 859 | 866 | |
| 860 | 867 | case Qt::Key_G: |
| 861 | 868 | if (isShifted) { |
| 862 | − Menu::getInstance()->triggerOption(MenuOption::ObeyGravity); | |
| 869 | + Menu::getInstance()->triggerOption(MenuOption::ObeyEnvironmentalGravity); | |
| 863 | 870 | } |
| 864 | 871 | break; |
| 865 | 872 | |
| @@ -1276,7 +1283,7 @@ void Application::timer() { · 410 unmodified lines | ||
| 1276 | 1283 | if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { |
| 1277 | 1284 | sendPingPackets(); |
| 1278 | 1285 | } |
| 1279 | − | |
| 1286 | + | |
| 1280 | 1287 | float diffTime = (float)_timerStart.nsecsElapsed() / 1000000000.0f; |
| 1281 | 1288 | |
| 1282 | 1289 | _fps = (float)_frameCount / diffTime; |
| @@ -1677,7 +1684,7 @@ void Application::init() { · 394 unmodified lines | ||
| 1677 | 1684 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| 1678 | 1685 | connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); |
| 1679 | 1686 | connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); |
| 1680 | − | |
| 1687 | + | |
| 1681 | 1688 | // set up our audio reflector |
| 1682 | 1689 | _audioReflector.setMyAvatar(getAvatar()); |
| 1683 | 1690 | _audioReflector.setVoxels(_voxels.getTree()); |
| @@ -1686,7 +1693,7 @@ void Application::init() { · 2 unmodified lines | ||
| 1686 | 1693 | |
| 1687 | 1694 | connect(getAudio(), &Audio::processInboundAudio, &_audioReflector, &AudioReflector::processInboundAudio,Qt::DirectConnection); |
| 1688 | 1695 | connect(getAudio(), &Audio::processLocalAudio, &_audioReflector, &AudioReflector::processLocalAudio,Qt::DirectConnection); |
| 1689 | − connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector, | |
| 1696 | + connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector, | |
| 1690 | 1697 | &AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection); |
| 1691 | 1698 | |
| 1692 | 1699 | // save settings when avatar changes |
| @@ -1820,7 +1827,7 @@ void Application::updateMyAvatarLookAtPosition() { · 127 unmodified lines | ||
| 1820 | 1827 | if (tracker) { |
| 1821 | 1828 | float eyePitch = tracker->getEstimatedEyePitch(); |
| 1822 | 1829 | float eyeYaw = tracker->getEstimatedEyeYaw(); |
| 1823 | − | |
| 1830 | + | |
| 1824 | 1831 | // deflect using Faceshift gaze data |
| 1825 | 1832 | glm::vec3 origin = _myAvatar->getHead()->calculateAverageEyePosition(); |
| 1826 | 1833 | float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; |
| @@ -1907,7 +1914,7 @@ void Application::updateCamera(float deltaTime) { · 80 unmodified lines | ||
| 1907 | 1914 | PerformanceWarning warn(showWarnings, "Application::updateCamera()"); |
| 1908 | 1915 | |
| 1909 | 1916 | if (!OculusManager::isConnected() && !TV3DManager::isConnected() && |
| 1910 | − Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) { | |
| 1917 | + Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) { | |
| 1911 | 1918 | FaceTracker* tracker = getActiveFaceTracker(); |
| 1912 | 1919 | if (tracker) { |
| 1913 | 1920 | const float EYE_OFFSET_SCALE = 0.025f; |
| @@ -2462,7 +2469,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 548 unmodified lines | ||
| 2462 | 2469 | |
| 2463 | 2470 | // disable specular lighting for ground and voxels |
| 2464 | 2471 | glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR); |
| 2465 | − | |
| 2472 | + | |
| 2466 | 2473 | // draw the audio reflector overlay |
| 2467 | 2474 | _audioReflector.render(); |
| 2468 | 2475 | |
| @@ -2620,7 +2627,7 @@ void Application::displayOverlay() { · 151 unmodified lines | ||
| 2620 | 2627 | const float LOG2_LOUDNESS_FLOOR = 11.f; |
| 2621 | 2628 | float audioLevel = 0.f; |
| 2622 | 2629 | float loudness = _audio.getLastInputLoudness() + 1.f; |
| 2623 | − | |
| 2630 | + | |
| 2624 | 2631 | _trailingAudioLoudness = AUDIO_METER_AVERAGING * _trailingAudioLoudness + (1.f - AUDIO_METER_AVERAGING) * loudness; |
| 2625 | 2632 | float log2loudness = log(_trailingAudioLoudness) / LOG2; |
| 2626 | 2633 | |
| @@ -2632,9 +2639,8 @@ void Application::displayOverlay() { · 5 unmodified lines | ||
| 2632 | 2639 | if (audioLevel > AUDIO_METER_SCALE_WIDTH) { |
| 2633 | 2640 | audioLevel = AUDIO_METER_SCALE_WIDTH; |
| 2634 | 2641 | } |
| 2635 | − | |
| 2636 | 2642 | bool isClipping = ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)); |
| 2637 | − | |
| 2643 | + | |
| 2638 | 2644 | if ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) { |
| 2639 | 2645 | const float MAX_MAGNITUDE = 0.7f; |
| 2640 | 2646 | float magnitude = MAX_MAGNITUDE * (1 - _audio.getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME); |
| @@ -3272,7 +3278,7 @@ void Application::loadScripts() { · 631 unmodified lines | ||
| 3272 | 3278 | loadScript(string); |
| 3273 | 3279 | } |
| 3274 | 3280 | } |
| 3275 | − | |
| 3281 | + | |
| 3276 | 3282 | QMutexLocker locker(&_settingsMutex); |
| 3277 | 3283 | _settings->endArray(); |
| 3278 | 3284 | } |
| @@ -3327,31 +3333,23 @@ void Application::reloadAllScripts() { · 48 unmodified lines | ||
| 3327 | 3333 | } |
| 3328 | 3334 | } |
| 3329 | 3335 | |
| 3330 | −void Application::toggleRunningScriptsWidget() | |
| 3331 | −{ | |
| 3332 | − if (!_runningScriptsWidget->toggleViewAction()->isChecked()) { | |
| 3333 | − _runningScriptsWidget->move(_window->geometry().topLeft().x(), _window->geometry().topLeft().y()); | |
| 3334 | − _runningScriptsWidget->resize(0, _window->height()); | |
| 3335 | − _runningScriptsWidget->toggleViewAction()->trigger(); | |
| 3336 | − _runningScriptsWidget->grabKeyboard(); | |
| 3337 | − | |
| 3338 | − QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget); | |
| 3339 | − slideAnimation->setStartValue(_runningScriptsWidget->geometry()); | |
| 3340 | − slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(), | |
| 3341 | − 310, _runningScriptsWidget->height())); | |
| 3342 | − slideAnimation->setDuration(250); | |
| 3343 | − slideAnimation->start(QAbstractAnimation::DeleteWhenStopped); | |
| 3344 | − } else { | |
| 3345 | − _runningScriptsWidget->releaseKeyboard(); | |
| 3346 | − | |
| 3347 | − QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget); | |
| 3348 | − slideAnimation->setStartValue(_runningScriptsWidget->geometry()); | |
| 3349 | − slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(), | |
| 3350 | − 0, _runningScriptsWidget->height())); | |
| 3351 | − slideAnimation->setDuration(250); | |
| 3352 | − slideAnimation->start(QAbstractAnimation::DeleteWhenStopped); | |
| 3336 | +void Application::manageRunningScriptsWidgetVisibility(bool shown) { | |
| 3337 | + if (_runningScriptsWidgetWasVisible && shown) { | |
| 3338 | + _runningScriptsWidget->show(); | |
| 3339 | + } else if (_runningScriptsWidgetWasVisible && !shown) { | |
| 3340 | + _runningScriptsWidget->hide(); | |
| 3341 | + } | |
| 3342 | +} | |
| 3353 | 3343 | |
| 3354 | − QTimer::singleShot(260, _runningScriptsWidget->toggleViewAction(), SLOT(trigger())); | |
| 3344 | +void Application::toggleRunningScriptsWidget() { | |
| 3345 | + if (_runningScriptsWidgetWasVisible) { | |
| 3346 | + _runningScriptsWidget->hide(); | |
| 3347 | + _runningScriptsWidgetWasVisible = false; | |
| 3348 | + } else { | |
| 3349 | + _runningScriptsWidget->setBoundary(QRect(_window->geometry().topLeft(), | |
| 3350 | + _window->size())); | |
| 3351 | + _runningScriptsWidget->show(); | |
| 3352 | + _runningScriptsWidgetWasVisible = true; | |
| 3355 | 3353 | } |
| 3356 | 3354 | } |
| 3357 | 3355 | |
| @@ -3361,7 +3359,7 @@ void Application::uploadFST(bool isHead) { · 3 unmodified lines | ||
| 3361 | 3359 | thread->connect(uploader, SIGNAL(destroyed()), SLOT(quit())); |
| 3362 | 3360 | thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater())); |
| 3363 | 3361 | uploader->connect(thread, SIGNAL(started()), SLOT(send())); |
| 3364 | − | |
| 3362 | + | |
| 3365 | 3363 | thread->start(); |
| 3366 | 3364 | } |
| 3367 | 3365 | |
| @@ -3471,7 +3469,7 @@ void Application::loadDialog() { · 103 unmodified lines | ||
| 3471 | 3469 | _previousScriptLocation = fileNameString; |
| 3472 | 3470 | QMutexLocker locker(&_settingsMutex); |
| 3473 | 3471 | _settings->setValue("LastScriptLocation", _previousScriptLocation); |
| 3474 | − | |
| 3472 | + | |
| 3475 | 3473 | loadScript(fileNameString); |
| 3476 | 3474 | } |
| 3477 | 3475 | } |
| @@ -3590,34 +3588,33 @@ void Application::takeSnapshot() { · 112 unmodified lines | ||
| 3590 | 3588 | void Application::urlGoTo(int argc, const char * constArgv[]) { |
| 3591 | 3589 | //Gets the url (hifi://domain/destination/orientation) |
| 3592 | 3590 | QString customUrl = getCmdOption(argc, constArgv, "-url"); |
| 3593 | − | |
| 3594 | − if (customUrl.startsWith("hifi://")) { | |
| 3591 | + if(customUrl.startsWith(CUSTOM_URL_SCHEME + "//")) { | |
| 3595 | 3592 | QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); |
| 3596 | − if (urlParts.count() > 1) { | |
| 3593 | + if (urlParts.count() == 1) { | |
| 3594 | + // location coordinates or place name | |
| 3595 | + QString domain = urlParts[0]; | |
| 3596 | + Menu::goToDomain(domain); | |
| 3597 | + } else if (urlParts.count() > 1) { | |
| 3597 | 3598 | // if url has 2 or more parts, the first one is domain name |
| 3598 | 3599 | QString domain = urlParts[0]; |
| 3599 | − | |
| 3600 | + | |
| 3600 | 3601 | // second part is either a destination coordinate or |
| 3601 | 3602 | // a place name |
| 3602 | 3603 | QString destination = urlParts[1]; |
| 3603 | − | |
| 3604 | + | |
| 3604 | 3605 | // any third part is an avatar orientation. |
| 3605 | 3606 | QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); |
| 3606 | − | |
| 3607 | + | |
| 3607 | 3608 | Menu::goToDomain(domain); |
| 3608 | − | |
| 3609 | + | |
| 3609 | 3610 | // goto either @user, #place, or x-xx,y-yy,z-zz |
| 3610 | 3611 | // style co-ordinate. |
| 3611 | 3612 | Menu::goTo(destination); |
| 3612 | − | |
| 3613 | + | |
| 3613 | 3614 | if (!orientation.isEmpty()) { |
| 3614 | 3615 | // location orientation |
| 3615 | 3616 | Menu::goToOrientation(orientation); |
| 3616 | 3617 | } |
| 3617 | − } else if (urlParts.count() == 1) { | |
| 3618 | − // location coordinates or place name | |
| 3619 | − QString destination = urlParts[0]; | |
| 3620 | − Menu::goTo(destination); | |
| 3621 | − } | |
| 3618 | + } | |
| 3622 | 3619 | } |
| 3623 | 3620 | } |