Showing the changes to interface/src/Application.cpp (1 of 20 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> |
| @@ -132,7 +131,7 @@ QString& Application::resourcesPath() { · 95 unmodified lines | ||
| 132 | 131 | |
| 133 | 132 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : |
| 134 | 133 | QApplication(argc, argv), |
| 135 | − _window(new QMainWindow(desktop())), | |
| 134 | + _window(new MainWindow(desktop())), | |
| 136 | 135 | _glWidget(new GLCanvas()), |
| 137 | 136 | _nodeThread(new QThread(this)), |
| 138 | 137 | _datagramProcessor(), |
| @@ -164,11 +163,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 25 unmodified lines | ||
| 164 | 163 | _packetsPerSecond(0), |
| 165 | 164 | _bytesPerSecond(0), |
| 166 | 165 | _previousScriptLocation(), |
| 167 | − _logger(new FileLogger(this)) | |
| 166 | + _logger(new FileLogger(this)), | |
| 167 | + _runningScriptsWidget(new RunningScriptsWidget(_window)), | |
| 168 | + _runningScriptsWidgetWasVisible(false) | |
| 168 | 169 | { |
| 169 | 170 | // init GnuTLS for DTLS with domain-servers |
| 170 | 171 | DTLSClientSession::globalInit(); |
| 171 | − | |
| 172 | + | |
| 172 | 173 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 173 | 174 | QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); |
| 174 | 175 | |
| @@ -334,7 +335,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 159 unmodified lines | ||
| 334 | 335 | LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree()); |
| 335 | 336 | LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard); |
| 336 | 337 | |
| 337 | − _window->addDockWidget(Qt::NoDockWidgetArea, _runningScriptsWidget = new RunningScriptsWidget()); | |
| 338 | 338 | _runningScriptsWidget->setRunningScripts(getRunningScripts()); |
| 339 | 339 | connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript); |
| 340 | 340 | |
| @@ -345,16 +345,22 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 4 unmodified lines | ||
| 345 | 345 | // clear the scripts, and set out script to our default scripts |
| 346 | 346 | clearScriptsBeforeRunning(); |
| 347 | 347 | loadScript("http://public.highfidelity.io/scripts/defaultScripts.js"); |
| 348 | − | |
| 348 | + | |
| 349 | 349 | QMutexLocker locker(&_settingsMutex); |
| 350 | 350 | _settings->setValue("firstRun",QVariant(false)); |
| 351 | 351 | } else { |
| 352 | 352 | // do this as late as possible so that all required subsystems are inialized |
| 353 | 353 | loadScripts(); |
| 354 | − | |
| 354 | + | |
| 355 | 355 | QMutexLocker locker(&_settingsMutex); |
| 356 | 356 | _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); |
| 357 | 357 | } |
| 358 | + | |
| 359 | + connect(_window, &MainWindow::windowGeometryChanged, | |
| 360 | + _runningScriptsWidget, &RunningScriptsWidget::setBoundary); | |
| 361 | + | |
| 362 | + //When -url in command line, teleport to location | |
| 363 | + urlGoTo(argc, constArgv); | |
| 358 | 364 | } |
| 359 | 365 | |
| 360 | 366 | Application::~Application() { |
| @@ -363,11 +369,11 @@ Application::~Application() { · 2 unmodified lines | ||
| 363 | 369 | |
| 364 | 370 | // make sure we don't call the idle timer any more |
| 365 | 371 | delete idleTimer; |
| 366 | − | |
| 372 | + | |
| 367 | 373 | _sharedVoxelSystem.changeTree(new VoxelTree); |
| 368 | − | |
| 374 | + | |
| 369 | 375 | saveSettings(); |
| 370 | − | |
| 376 | + | |
| 371 | 377 | delete _voxelImporter; |
| 372 | 378 | |
| 373 | 379 | // let the avatar mixer know we're out |
| @@ -400,14 +406,14 @@ Application::~Application() { · 26 unmodified lines | ||
| 400 | 406 | delete _glWidget; |
| 401 | 407 | |
| 402 | 408 | AccountManager::getInstance().destroy(); |
| 403 | − | |
| 409 | + | |
| 404 | 410 | DTLSClientSession::globalDeinit(); |
| 405 | 411 | } |
| 406 | 412 | |
| 407 | 413 | void Application::saveSettings() { |
| 408 | 414 | Menu::getInstance()->saveSettings(); |
| 409 | 415 | _rearMirrorTools->saveSettings(_settings); |
| 410 | − | |
| 416 | + | |
| 411 | 417 | if (_voxelImporter) { |
| 412 | 418 | _voxelImporter->saveSettings(_settings); |
| 413 | 419 | } |
| @@ -574,7 +580,7 @@ void Application::paintGL() { · 160 unmodified lines | ||
| 574 | 580 | pushback = qMin(pushback, MAX_PUSHBACK * _myAvatar->getScale()); |
| 575 | 581 | const float BASE_PUSHBACK_FOCAL_LENGTH = 0.5f; |
| 576 | 582 | pushbackFocalLength = BASE_PUSHBACK_FOCAL_LENGTH * _myAvatar->getScale(); |
| 577 | − | |
| 583 | + | |
| 578 | 584 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { |
| 579 | 585 | _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing |
| 580 | 586 | _myCamera.setTargetPosition(_myAvatar->getUprightHeadPosition()); |
| @@ -587,7 +593,7 @@ void Application::paintGL() { · 6 unmodified lines | ||
| 587 | 593 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale()); |
| 588 | 594 | _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0)); |
| 589 | 595 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); |
| 590 | − | |
| 596 | + | |
| 591 | 597 | // if the head would intersect the near clip plane, we must push the camera out |
| 592 | 598 | glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) * |
| 593 | 599 | (eyePosition - _myCamera.getTargetPosition()); |
| @@ -596,7 +602,7 @@ void Application::paintGL() { · 2 unmodified lines | ||
| 596 | 602 | pushback = relativePosition.z + pushbackRadius - _myCamera.getDistance(); |
| 597 | 603 | pushbackFocalLength = _myCamera.getDistance(); |
| 598 | 604 | } |
| 599 | − | |
| 605 | + | |
| 600 | 606 | // handle pushback, if any |
| 601 | 607 | if (pushbackFocalLength > 0.0f) { |
| 602 | 608 | const float PUSHBACK_DECAY = 0.5f; |
| @@ -1277,7 +1283,7 @@ void Application::timer() { · 674 unmodified lines | ||
| 1277 | 1283 | if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { |
| 1278 | 1284 | sendPingPackets(); |
| 1279 | 1285 | } |
| 1280 | − | |
| 1286 | + | |
| 1281 | 1287 | float diffTime = (float)_timerStart.nsecsElapsed() / 1000000000.0f; |
| 1282 | 1288 | |
| 1283 | 1289 | _fps = (float)_frameCount / diffTime; |
| @@ -1678,7 +1684,7 @@ void Application::init() { · 394 unmodified lines | ||
| 1678 | 1684 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| 1679 | 1685 | connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); |
| 1680 | 1686 | connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); |
| 1681 | − | |
| 1687 | + | |
| 1682 | 1688 | // set up our audio reflector |
| 1683 | 1689 | _audioReflector.setMyAvatar(getAvatar()); |
| 1684 | 1690 | _audioReflector.setVoxels(_voxels.getTree()); |
| @@ -1687,7 +1693,7 @@ void Application::init() { · 2 unmodified lines | ||
| 1687 | 1693 | |
| 1688 | 1694 | connect(getAudio(), &Audio::processInboundAudio, &_audioReflector, &AudioReflector::processInboundAudio,Qt::DirectConnection); |
| 1689 | 1695 | connect(getAudio(), &Audio::processLocalAudio, &_audioReflector, &AudioReflector::processLocalAudio,Qt::DirectConnection); |
| 1690 | − connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector, | |
| 1696 | + connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector, | |
| 1691 | 1697 | &AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection); |
| 1692 | 1698 | |
| 1693 | 1699 | // save settings when avatar changes |
| @@ -1821,7 +1827,7 @@ void Application::updateMyAvatarLookAtPosition() { · 127 unmodified lines | ||
| 1821 | 1827 | if (tracker) { |
| 1822 | 1828 | float eyePitch = tracker->getEstimatedEyePitch(); |
| 1823 | 1829 | float eyeYaw = tracker->getEstimatedEyeYaw(); |
| 1824 | − | |
| 1830 | + | |
| 1825 | 1831 | // deflect using Faceshift gaze data |
| 1826 | 1832 | glm::vec3 origin = _myAvatar->getHead()->calculateAverageEyePosition(); |
| 1827 | 1833 | float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; |
| @@ -1908,7 +1914,7 @@ void Application::updateCamera(float deltaTime) { · 80 unmodified lines | ||
| 1908 | 1914 | PerformanceWarning warn(showWarnings, "Application::updateCamera()"); |
| 1909 | 1915 | |
| 1910 | 1916 | if (!OculusManager::isConnected() && !TV3DManager::isConnected() && |
| 1911 | − Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) { | |
| 1917 | + Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) { | |
| 1912 | 1918 | FaceTracker* tracker = getActiveFaceTracker(); |
| 1913 | 1919 | if (tracker) { |
| 1914 | 1920 | const float EYE_OFFSET_SCALE = 0.025f; |
| @@ -2464,7 +2470,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 549 unmodified lines | ||
| 2464 | 2470 | |
| 2465 | 2471 | // disable specular lighting for ground and voxels |
| 2466 | 2472 | glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR); |
| 2467 | − | |
| 2473 | + | |
| 2468 | 2474 | // draw the audio reflector overlay |
| 2469 | 2475 | _audioReflector.render(); |
| 2470 | 2476 | |
| @@ -2622,7 +2628,7 @@ void Application::displayOverlay() { · 151 unmodified lines | ||
| 2622 | 2628 | const float LOG2_LOUDNESS_FLOOR = 11.f; |
| 2623 | 2629 | float audioLevel = 0.f; |
| 2624 | 2630 | float loudness = _audio.getLastInputLoudness() + 1.f; |
| 2625 | − | |
| 2631 | + | |
| 2626 | 2632 | _trailingAudioLoudness = AUDIO_METER_AVERAGING * _trailingAudioLoudness + (1.f - AUDIO_METER_AVERAGING) * loudness; |
| 2627 | 2633 | float log2loudness = log(_trailingAudioLoudness) / LOG2; |
| 2628 | 2634 | |
| @@ -2634,9 +2640,8 @@ void Application::displayOverlay() { · 5 unmodified lines | ||
| 2634 | 2640 | if (audioLevel > AUDIO_METER_SCALE_WIDTH) { |
| 2635 | 2641 | audioLevel = AUDIO_METER_SCALE_WIDTH; |
| 2636 | 2642 | } |
| 2637 | − | |
| 2638 | 2643 | bool isClipping = ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)); |
| 2639 | − | |
| 2644 | + | |
| 2640 | 2645 | if ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) { |
| 2641 | 2646 | const float MAX_MAGNITUDE = 0.7f; |
| 2642 | 2647 | float magnitude = MAX_MAGNITUDE * (1 - _audio.getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME); |
| @@ -3307,7 +3312,7 @@ void Application::loadScripts() { · 664 unmodified lines | ||
| 3307 | 3312 | loadScript(string); |
| 3308 | 3313 | } |
| 3309 | 3314 | } |
| 3310 | − | |
| 3315 | + | |
| 3311 | 3316 | QMutexLocker locker(&_settingsMutex); |
| 3312 | 3317 | _settings->endArray(); |
| 3313 | 3318 | } |
| @@ -3362,31 +3367,23 @@ void Application::reloadAllScripts() { · 48 unmodified lines | ||
| 3362 | 3367 | } |
| 3363 | 3368 | } |
| 3364 | 3369 | |
| 3365 | −void Application::toggleRunningScriptsWidget() | |
| 3366 | −{ | |
| 3367 | − if (!_runningScriptsWidget->toggleViewAction()->isChecked()) { | |
| 3368 | − _runningScriptsWidget->move(_window->geometry().topLeft().x(), _window->geometry().topLeft().y()); | |
| 3369 | − _runningScriptsWidget->resize(0, _window->height()); | |
| 3370 | − _runningScriptsWidget->toggleViewAction()->trigger(); | |
| 3371 | − _runningScriptsWidget->grabKeyboard(); | |
| 3372 | − | |
| 3373 | − QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget); | |
| 3374 | − slideAnimation->setStartValue(_runningScriptsWidget->geometry()); | |
| 3375 | − slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(), | |
| 3376 | − 310, _runningScriptsWidget->height())); | |
| 3377 | − slideAnimation->setDuration(250); | |
| 3378 | − slideAnimation->start(QAbstractAnimation::DeleteWhenStopped); | |
| 3379 | − } else { | |
| 3380 | − _runningScriptsWidget->releaseKeyboard(); | |
| 3381 | − | |
| 3382 | − QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget); | |
| 3383 | − slideAnimation->setStartValue(_runningScriptsWidget->geometry()); | |
| 3384 | − slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(), | |
| 3385 | − 0, _runningScriptsWidget->height())); | |
| 3386 | − slideAnimation->setDuration(250); | |
| 3387 | − slideAnimation->start(QAbstractAnimation::DeleteWhenStopped); | |
| 3370 | +void Application::manageRunningScriptsWidgetVisibility(bool shown) { | |
| 3371 | + if (_runningScriptsWidgetWasVisible && shown) { | |
| 3372 | + _runningScriptsWidget->show(); | |
| 3373 | + } else if (_runningScriptsWidgetWasVisible && !shown) { | |
| 3374 | + _runningScriptsWidget->hide(); | |
| 3375 | + } | |
| 3376 | +} | |
| 3388 | 3377 | |
| 3389 | − QTimer::singleShot(260, _runningScriptsWidget->toggleViewAction(), SLOT(trigger())); | |
| 3378 | +void Application::toggleRunningScriptsWidget() { | |
| 3379 | + if (_runningScriptsWidgetWasVisible) { | |
| 3380 | + _runningScriptsWidget->hide(); | |
| 3381 | + _runningScriptsWidgetWasVisible = false; | |
| 3382 | + } else { | |
| 3383 | + _runningScriptsWidget->setBoundary(QRect(_window->geometry().topLeft(), | |
| 3384 | + _window->size())); | |
| 3385 | + _runningScriptsWidget->show(); | |
| 3386 | + _runningScriptsWidgetWasVisible = true; | |
| 3390 | 3387 | } |
| 3391 | 3388 | } |
| 3392 | 3389 | |
| @@ -3396,7 +3393,7 @@ void Application::uploadFST(bool isHead) { · 3 unmodified lines | ||
| 3396 | 3393 | thread->connect(uploader, SIGNAL(destroyed()), SLOT(quit())); |
| 3397 | 3394 | thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater())); |
| 3398 | 3395 | uploader->connect(thread, SIGNAL(started()), SLOT(send())); |
| 3399 | − | |
| 3396 | + | |
| 3400 | 3397 | thread->start(); |
| 3401 | 3398 | } |
| 3402 | 3399 | |
| @@ -3494,7 +3491,7 @@ void Application::loadDialog() { · 91 unmodified lines | ||
| 3494 | 3491 | _previousScriptLocation = fileNameString; |
| 3495 | 3492 | QMutexLocker locker(&_settingsMutex); |
| 3496 | 3493 | _settings->setValue("LastScriptLocation", _previousScriptLocation); |
| 3497 | − | |
| 3494 | + | |
| 3498 | 3495 | loadScript(fileNameString); |
| 3499 | 3496 | } |
| 3500 | 3497 | } |
| @@ -3631,7 +3628,7 @@ void Application::urlGoTo(int argc, const char * constArgv[]) { · 130 unmodified lines | ||
| 3631 | 3628 | QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); |
| 3632 | 3629 | |
| 3633 | 3630 | Menu::goToDomain(domain); |
| 3634 | − | |
| 3631 | + | |
| 3635 | 3632 | // goto either @user, #place, or x-xx,y-yy,z-zz |
| 3636 | 3633 | // style co-ordinate. |
| 3637 | 3634 | Menu::goTo(destination); |