History

Merge branch 'master' of https://github.com/worklist/hifi into modelserver

ZappoMan committed 12 years ago

Commit 58c852d2 parents f993f98 19b76e320 files · +602 −309Browse files

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

Unified · Split

interface/src/Application.cpp+49−52
@@ -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>
@@ -132,7 +131,7 @@ QString& Application::resourcesPath() { · 95 unmodified lines
132131
133132 Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
134133 QApplication(argc, argv),
135− _window(new QMainWindow(desktop())),
134+ _window(new MainWindow(desktop())),
136135 _glWidget(new GLCanvas()),
137136 _nodeThread(new QThread(this)),
138137 _datagramProcessor(),
@@ -164,11 +163,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 25 unmodified lines
164163 _packetsPerSecond(0),
165164 _bytesPerSecond(0),
166165 _previousScriptLocation(),
167− _logger(new FileLogger(this))
166+ _logger(new FileLogger(this)),
167+ _runningScriptsWidget(new RunningScriptsWidget(_window)),
168+ _runningScriptsWidgetWasVisible(false)
168169 {
169170 // init GnuTLS for DTLS with domain-servers
170171 DTLSClientSession::globalInit();
171−
172+
172173 // read the ApplicationInfo.ini file for Name/Version/Domain information
173174 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
174175
@@ -334,7 +335,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 159 unmodified lines
334335 LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree());
335336 LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard);
336337
337− _window->addDockWidget(Qt::NoDockWidgetArea, _runningScriptsWidget = new RunningScriptsWidget());
338338 _runningScriptsWidget->setRunningScripts(getRunningScripts());
339339 connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript);
340340
@@ -345,16 +345,22 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 4 unmodified lines
345345 // clear the scripts, and set out script to our default scripts
346346 clearScriptsBeforeRunning();
347347 loadScript("http://public.highfidelity.io/scripts/defaultScripts.js");
348−
348+
349349 QMutexLocker locker(&_settingsMutex);
350350 _settings->setValue("firstRun",QVariant(false));
351351 } else {
352352 // do this as late as possible so that all required subsystems are inialized
353353 loadScripts();
354−
354+
355355 QMutexLocker locker(&_settingsMutex);
356356 _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString();
357357 }
358+
359+ connect(_window, &MainWindow::windowGeometryChanged,
360+ _runningScriptsWidget, &RunningScriptsWidget::setBoundary);
361+
362+ //When -url in command line, teleport to location
363+ urlGoTo(argc, constArgv);
358364 }
359365
360366 Application::~Application() {
@@ -363,11 +369,11 @@ Application::~Application() { · 2 unmodified lines
363369
364370 // make sure we don't call the idle timer any more
365371 delete idleTimer;
366−
372+
367373 _sharedVoxelSystem.changeTree(new VoxelTree);
368−
374+
369375 saveSettings();
370−
376+
371377 delete _voxelImporter;
372378
373379 // let the avatar mixer know we're out
@@ -400,14 +406,14 @@ Application::~Application() { · 26 unmodified lines
400406 delete _glWidget;
401407
402408 AccountManager::getInstance().destroy();
403−
409+
404410 DTLSClientSession::globalDeinit();
405411 }
406412
407413 void Application::saveSettings() {
408414 Menu::getInstance()->saveSettings();
409415 _rearMirrorTools->saveSettings(_settings);
410−
416+
411417 if (_voxelImporter) {
412418 _voxelImporter->saveSettings(_settings);
413419 }
@@ -574,7 +580,7 @@ void Application::paintGL() { · 160 unmodified lines
574580 pushback = qMin(pushback, MAX_PUSHBACK * _myAvatar->getScale());
575581 const float BASE_PUSHBACK_FOCAL_LENGTH = 0.5f;
576582 pushbackFocalLength = BASE_PUSHBACK_FOCAL_LENGTH * _myAvatar->getScale();
577−
583+
578584 } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
579585 _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing
580586 _myCamera.setTargetPosition(_myAvatar->getUprightHeadPosition());
@@ -587,7 +593,7 @@ void Application::paintGL() { · 6 unmodified lines
587593 _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale());
588594 _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0));
589595 _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));
590−
596+
591597 // if the head would intersect the near clip plane, we must push the camera out
592598 glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) *
593599 (eyePosition - _myCamera.getTargetPosition());
@@ -596,7 +602,7 @@ void Application::paintGL() { · 2 unmodified lines
596602 pushback = relativePosition.z + pushbackRadius - _myCamera.getDistance();
597603 pushbackFocalLength = _myCamera.getDistance();
598604 }
599−
605+
600606 // handle pushback, if any
601607 if (pushbackFocalLength > 0.0f) {
602608 const float PUSHBACK_DECAY = 0.5f;
@@ -1277,7 +1283,7 @@ void Application::timer() { · 674 unmodified lines
12771283 if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
12781284 sendPingPackets();
12791285 }
1280−
1286+
12811287 float diffTime = (float)_timerStart.nsecsElapsed() / 1000000000.0f;
12821288
12831289 _fps = (float)_frameCount / diffTime;
@@ -1678,7 +1684,7 @@ void Application::init() { · 394 unmodified lines
16781684 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
16791685 connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
16801686 connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors()));
1681−
1687+
16821688 // set up our audio reflector
16831689 _audioReflector.setMyAvatar(getAvatar());
16841690 _audioReflector.setVoxels(_voxels.getTree());
@@ -1687,7 +1693,7 @@ void Application::init() { · 2 unmodified lines
16871693
16881694 connect(getAudio(), &Audio::processInboundAudio, &_audioReflector, &AudioReflector::processInboundAudio,Qt::DirectConnection);
16891695 connect(getAudio(), &Audio::processLocalAudio, &_audioReflector, &AudioReflector::processLocalAudio,Qt::DirectConnection);
1690− connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,
1696+ connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,
16911697 &AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection);
16921698
16931699 // save settings when avatar changes
@@ -1821,7 +1827,7 @@ void Application::updateMyAvatarLookAtPosition() { · 127 unmodified lines
18211827 if (tracker) {
18221828 float eyePitch = tracker->getEstimatedEyePitch();
18231829 float eyeYaw = tracker->getEstimatedEyeYaw();
1824−
1830+
18251831 // deflect using Faceshift gaze data
18261832 glm::vec3 origin = _myAvatar->getHead()->calculateAverageEyePosition();
18271833 float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
@@ -1908,7 +1914,7 @@ void Application::updateCamera(float deltaTime) { · 80 unmodified lines
19081914 PerformanceWarning warn(showWarnings, "Application::updateCamera()");
19091915
19101916 if (!OculusManager::isConnected() && !TV3DManager::isConnected() &&
1911− Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) {
1917+ Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) {
19121918 FaceTracker* tracker = getActiveFaceTracker();
19131919 if (tracker) {
19141920 const float EYE_OFFSET_SCALE = 0.025f;
@@ -2464,7 +2470,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 549 unmodified lines
24642470
24652471 // disable specular lighting for ground and voxels
24662472 glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR);
2467−
2473+
24682474 // draw the audio reflector overlay
24692475 _audioReflector.render();
24702476
@@ -2622,7 +2628,7 @@ void Application::displayOverlay() { · 151 unmodified lines
26222628 const float LOG2_LOUDNESS_FLOOR = 11.f;
26232629 float audioLevel = 0.f;
26242630 float loudness = _audio.getLastInputLoudness() + 1.f;
2625−
2631+
26262632 _trailingAudioLoudness = AUDIO_METER_AVERAGING * _trailingAudioLoudness + (1.f - AUDIO_METER_AVERAGING) * loudness;
26272633 float log2loudness = log(_trailingAudioLoudness) / LOG2;
26282634
@@ -2634,9 +2640,8 @@ void Application::displayOverlay() { · 5 unmodified lines
26342640 if (audioLevel > AUDIO_METER_SCALE_WIDTH) {
26352641 audioLevel = AUDIO_METER_SCALE_WIDTH;
26362642 }
2637−
26382643 bool isClipping = ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME));
2639−
2644+
26402645 if ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) {
26412646 const float MAX_MAGNITUDE = 0.7f;
26422647 float magnitude = MAX_MAGNITUDE * (1 - _audio.getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME);
@@ -3307,7 +3312,7 @@ void Application::loadScripts() { · 664 unmodified lines
33073312 loadScript(string);
33083313 }
33093314 }
3310−
3315+
33113316 QMutexLocker locker(&_settingsMutex);
33123317 _settings->endArray();
33133318 }
@@ -3362,31 +3367,23 @@ void Application::reloadAllScripts() { · 48 unmodified lines
33623367 }
33633368 }
33643369
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+}
33883377
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;
33903387 }
33913388 }
33923389
@@ -3396,7 +3393,7 @@ void Application::uploadFST(bool isHead) { · 3 unmodified lines
33963393 thread->connect(uploader, SIGNAL(destroyed()), SLOT(quit()));
33973394 thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater()));
33983395 uploader->connect(thread, SIGNAL(started()), SLOT(send()));
3399−
3396+
34003397 thread->start();
34013398 }
34023399
@@ -3494,7 +3491,7 @@ void Application::loadDialog() { · 91 unmodified lines
34943491 _previousScriptLocation = fileNameString;
34953492 QMutexLocker locker(&_settingsMutex);
34963493 _settings->setValue("LastScriptLocation", _previousScriptLocation);
3497−
3494+
34983495 loadScript(fileNameString);
34993496 }
35003497 }
@@ -3631,7 +3628,7 @@ void Application::urlGoTo(int argc, const char * constArgv[]) { · 130 unmodified lines
36313628 QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();
36323629
36333630 Menu::goToDomain(domain);
3634−
3631+
36353632 // goto either @user, #place, or x-xx,y-yy,z-zz
36363633 // style co-ordinate.
36373634 Menu::goTo(destination);

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