History

Merge remote-tracking branch 'upstream/master' into 19612

Ryan Huffman committed 12 years ago

Commit 65fd2a72 parents 45beeaa 19b76e347 files · +1877 −604Browse files

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

Unified · Split

interface/src/Application.cpp+64−67
@@ -30,7 +30,6 @@ · 29 unmodified lines
3030 #include <QImage>
3131 #include <QInputDialog>
3232 #include <QKeyEvent>
33−#include <QMainWindow>
3433 #include <QMenuBar>
3534 #include <QMouseEvent>
3635 #include <QNetworkAccessManager>
@@ -134,7 +133,7 @@ QString& Application::resourcesPath() { · 97 unmodified lines
134133
135134 Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
136135 QApplication(argc, argv),
137− _window(new QMainWindow(desktop())),
136+ _window(new MainWindow(desktop())),
138137 _glWidget(new GLCanvas()),
139138 _nodeThread(new QThread(this)),
140139 _datagramProcessor(),
@@ -166,11 +165,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 25 unmodified lines
166165 _packetsPerSecond(0),
167166 _bytesPerSecond(0),
168167 _previousScriptLocation(),
169− _logger(new FileLogger(this))
168+ _logger(new FileLogger(this)),
169+ _runningScriptsWidget(new RunningScriptsWidget(_window)),
170+ _runningScriptsWidgetWasVisible(false)
170171 {
171172 // init GnuTLS for DTLS with domain-servers
172173 DTLSClientSession::globalInit();
173−
174+
174175 // read the ApplicationInfo.ini file for Name/Version/Domain information
175176 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
176177
@@ -318,6 +319,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 141 unmodified lines
318319 Particle::setVoxelEditPacketSender(&_voxelEditSender);
319320 Particle::setParticleEditPacketSender(&_particleEditSender);
320321
322+ // when -url in command line, teleport to location
323+ urlGoTo(argc, constArgv);
324+
321325 // For now we're going to set the PPS for outbound packets to be super high, this is
322326 // probably not the right long term solution. But for now, we're going to do this to
323327 // 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
333337 LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree());
334338 LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard);
335339
336− _window->addDockWidget(Qt::NoDockWidgetArea, _runningScriptsWidget = new RunningScriptsWidget());
337340 _runningScriptsWidget->setRunningScripts(getRunningScripts());
338341 connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript);
339342
@@ -344,18 +347,22 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 4 unmodified lines
344347 // clear the scripts, and set out script to our default scripts
345348 clearScriptsBeforeRunning();
346349 loadScript("http://public.highfidelity.io/scripts/defaultScripts.js");
347−
350+
348351 QMutexLocker locker(&_settingsMutex);
349352 _settings->setValue("firstRun",QVariant(false));
350353 } else {
351354 // do this as late as possible so that all required subsystems are inialized
352355 loadScripts();
353−
356+
354357 QMutexLocker locker(&_settingsMutex);
355358 _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString();
356359 }
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);
359366 }
360367
361368 Application::~Application() {
@@ -364,11 +371,11 @@ Application::~Application() { · 2 unmodified lines
364371
365372 // make sure we don't call the idle timer any more
366373 delete idleTimer;
367−
374+
368375 _sharedVoxelSystem.changeTree(new VoxelTree);
369−
376+
370377 saveSettings();
371−
378+
372379 delete _voxelImporter;
373380
374381 // let the avatar mixer know we're out
@@ -401,14 +408,14 @@ Application::~Application() { · 26 unmodified lines
401408 delete _glWidget;
402409
403410 AccountManager::getInstance().destroy();
404−
411+
405412 DTLSClientSession::globalDeinit();
406413 }
407414
408415 void Application::saveSettings() {
409416 Menu::getInstance()->saveSettings();
410417 _rearMirrorTools->saveSettings(_settings);
411−
418+
412419 if (_voxelImporter) {
413420 _voxelImporter->saveSettings(_settings);
414421 }
@@ -575,7 +582,7 @@ void Application::paintGL() { · 160 unmodified lines
575582 pushback = qMin(pushback, MAX_PUSHBACK * _myAvatar->getScale());
576583 const float BASE_PUSHBACK_FOCAL_LENGTH = 0.5f;
577584 pushbackFocalLength = BASE_PUSHBACK_FOCAL_LENGTH * _myAvatar->getScale();
578−
585+
579586 } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
580587 _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing
581588 _myCamera.setTargetPosition(_myAvatar->getUprightHeadPosition());
@@ -588,7 +595,7 @@ void Application::paintGL() { · 6 unmodified lines
588595 _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale());
589596 _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0));
590597 _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));
591−
598+
592599 // if the head would intersect the near clip plane, we must push the camera out
593600 glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) *
594601 (eyePosition - _myCamera.getTargetPosition());
@@ -597,7 +604,7 @@ void Application::paintGL() { · 2 unmodified lines
597604 pushback = relativePosition.z + pushbackRadius - _myCamera.getDistance();
598605 pushbackFocalLength = _myCamera.getDistance();
599606 }
600−
607+
601608 // handle pushback, if any
602609 if (pushbackFocalLength > 0.0f) {
603610 const float PUSHBACK_DECAY = 0.5f;
@@ -859,7 +866,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 255 unmodified lines
859866
860867 case Qt::Key_G:
861868 if (isShifted) {
862− Menu::getInstance()->triggerOption(MenuOption::ObeyGravity);
869+ Menu::getInstance()->triggerOption(MenuOption::ObeyEnvironmentalGravity);
863870 }
864871 break;
865872
@@ -1276,7 +1283,7 @@ void Application::timer() { · 410 unmodified lines
12761283 if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
12771284 sendPingPackets();
12781285 }
1279−
1286+
12801287 float diffTime = (float)_timerStart.nsecsElapsed() / 1000000000.0f;
12811288
12821289 _fps = (float)_frameCount / diffTime;
@@ -1677,7 +1684,7 @@ void Application::init() { · 394 unmodified lines
16771684 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
16781685 connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
16791686 connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors()));
1680−
1687+
16811688 // set up our audio reflector
16821689 _audioReflector.setMyAvatar(getAvatar());
16831690 _audioReflector.setVoxels(_voxels.getTree());
@@ -1686,7 +1693,7 @@ void Application::init() { · 2 unmodified lines
16861693
16871694 connect(getAudio(), &Audio::processInboundAudio, &_audioReflector, &AudioReflector::processInboundAudio,Qt::DirectConnection);
16881695 connect(getAudio(), &Audio::processLocalAudio, &_audioReflector, &AudioReflector::processLocalAudio,Qt::DirectConnection);
1689− connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,
1696+ connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,
16901697 &AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection);
16911698
16921699 // save settings when avatar changes
@@ -1820,7 +1827,7 @@ void Application::updateMyAvatarLookAtPosition() { · 127 unmodified lines
18201827 if (tracker) {
18211828 float eyePitch = tracker->getEstimatedEyePitch();
18221829 float eyeYaw = tracker->getEstimatedEyeYaw();
1823−
1830+
18241831 // deflect using Faceshift gaze data
18251832 glm::vec3 origin = _myAvatar->getHead()->calculateAverageEyePosition();
18261833 float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
@@ -1907,7 +1914,7 @@ void Application::updateCamera(float deltaTime) { · 80 unmodified lines
19071914 PerformanceWarning warn(showWarnings, "Application::updateCamera()");
19081915
19091916 if (!OculusManager::isConnected() && !TV3DManager::isConnected() &&
1910− Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) {
1917+ Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) {
19111918 FaceTracker* tracker = getActiveFaceTracker();
19121919 if (tracker) {
19131920 const float EYE_OFFSET_SCALE = 0.025f;
@@ -2462,7 +2469,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 548 unmodified lines
24622469
24632470 // disable specular lighting for ground and voxels
24642471 glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR);
2465−
2472+
24662473 // draw the audio reflector overlay
24672474 _audioReflector.render();
24682475
@@ -2620,7 +2627,7 @@ void Application::displayOverlay() { · 151 unmodified lines
26202627 const float LOG2_LOUDNESS_FLOOR = 11.f;
26212628 float audioLevel = 0.f;
26222629 float loudness = _audio.getLastInputLoudness() + 1.f;
2623−
2630+
26242631 _trailingAudioLoudness = AUDIO_METER_AVERAGING * _trailingAudioLoudness + (1.f - AUDIO_METER_AVERAGING) * loudness;
26252632 float log2loudness = log(_trailingAudioLoudness) / LOG2;
26262633
@@ -2632,9 +2639,8 @@ void Application::displayOverlay() { · 5 unmodified lines
26322639 if (audioLevel > AUDIO_METER_SCALE_WIDTH) {
26332640 audioLevel = AUDIO_METER_SCALE_WIDTH;
26342641 }
2635−
26362642 bool isClipping = ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME));
2637−
2643+
26382644 if ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) {
26392645 const float MAX_MAGNITUDE = 0.7f;
26402646 float magnitude = MAX_MAGNITUDE * (1 - _audio.getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME);
@@ -3272,7 +3278,7 @@ void Application::loadScripts() { · 631 unmodified lines
32723278 loadScript(string);
32733279 }
32743280 }
3275−
3281+
32763282 QMutexLocker locker(&_settingsMutex);
32773283 _settings->endArray();
32783284 }
@@ -3327,31 +3333,23 @@ void Application::reloadAllScripts() { · 48 unmodified lines
33273333 }
33283334 }
33293335
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+}
33533343
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;
33553353 }
33563354 }
33573355
@@ -3361,7 +3359,7 @@ void Application::uploadFST(bool isHead) { · 3 unmodified lines
33613359 thread->connect(uploader, SIGNAL(destroyed()), SLOT(quit()));
33623360 thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater()));
33633361 uploader->connect(thread, SIGNAL(started()), SLOT(send()));
3364−
3362+
33653363 thread->start();
33663364 }
33673365
@@ -3471,7 +3469,7 @@ void Application::loadDialog() { · 103 unmodified lines
34713469 _previousScriptLocation = fileNameString;
34723470 QMutexLocker locker(&_settingsMutex);
34733471 _settings->setValue("LastScriptLocation", _previousScriptLocation);
3474−
3472+
34753473 loadScript(fileNameString);
34763474 }
34773475 }
@@ -3590,34 +3588,33 @@ void Application::takeSnapshot() { · 112 unmodified lines
35903588 void Application::urlGoTo(int argc, const char * constArgv[]) {
35913589 //Gets the url (hifi://domain/destination/orientation)
35923590 QString customUrl = getCmdOption(argc, constArgv, "-url");
3593−
3594− if (customUrl.startsWith("hifi://")) {
3591+ if(customUrl.startsWith(CUSTOM_URL_SCHEME + "//")) {
35953592 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) {
35973598 // if url has 2 or more parts, the first one is domain name
35983599 QString domain = urlParts[0];
3599−
3600+
36003601 // second part is either a destination coordinate or
36013602 // a place name
36023603 QString destination = urlParts[1];
3603−
3604+
36043605 // any third part is an avatar orientation.
36053606 QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();
3606−
3607+
36073608 Menu::goToDomain(domain);
3608−
3609+
36093610 // goto either @user, #place, or x-xx,y-yy,z-zz
36103611 // style co-ordinate.
36113612 Menu::goTo(destination);
3612−
3613+
36133614 if (!orientation.isEmpty()) {
36143615 // location orientation
36153616 Menu::goToOrientation(orientation);
36163617 }
3617− } else if (urlParts.count() == 1) {
3618− // location coordinates or place name
3619− QString destination = urlParts[0];
3620− Menu::goTo(destination);
3621− }
3618+ }
36223619 }
36233620 }

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