History

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

Thijs Wenker committed 11 years ago

Commit 46618db2 parents 3e4f4ec 7a849e9114 files · +3511 −2185Browse files

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

Unified · Split

interface/src/Application.cpp+154−141
@@ -38,8 +38,8 @@ · 37 unmodified lines
3838 #include <QObject>
3939 #include <QWheelEvent>
4040 #include <QScreen>
41−#include <QSettings>
4241 #include <QShortcut>
42+#include <QSystemTrayIcon>
4343 #include <QTimer>
4444 #include <QUrl>
4545 #include <QWindow>
@@ -73,13 +73,16 @@ · 27 unmodified lines
7373 #include <PhysicsEngine.h>
7474 #include <ProgramObject.h>
7575 #include <ResourceCache.h>
76+#include <Settings.h>
7677 #include <SoundCache.h>
7778 #include <TextRenderer.h>
7879 #include <UserActivityLogger.h>
7980 #include <UUID.h>
8081
8182 #include "Application.h"
83+#include "Audio.h"
8284 #include "InterfaceVersion.h"
85+#include "LODManager.h"
8386 #include "Menu.h"
8487 #include "ModelUploader.h"
8588 #include "Util.h"
@@ -100,7 +103,6 @@ · 14 unmodified lines
100103 #include "gpu/Batch.h"
101104 #include "gpu/GLBackend.h"
102105
103−
104106 #include "scripting/AccountScriptingInterface.h"
105107 #include "scripting/AudioDeviceScriptingInterface.h"
106108 #include "scripting/ClipboardScriptingInterface.h"
@@ -113,9 +115,16 @@ · 6 unmodified lines
113115 #include "scripting/WindowScriptingInterface.h"
114116 #include "scripting/WebWindowClass.h"
115117
118+#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
119+#include "SpeechRecognizer.h"
120+#endif
121+
116122 #include "ui/DataWebDialog.h"
123+#include "ui/DialogsManager.h"
117124 #include "ui/InfoView.h"
125+#include "ui/LoginDialog.h"
118126 #include "ui/Snapshot.h"
127+#include "ui/StandAloneJSConsole.h"
119128 #include "ui/Stats.h"
120129
121130
@@ -138,6 +147,12 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D · 16 unmodified lines
138147
139148 const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";
140149
150+namespace SettingHandles {
151+ const SettingHandle<bool> firstRun("firstRun", true);
152+ const SettingHandle<QString> lastScriptLocation("LastScriptLocation");
153+ const SettingHandle<QString> scriptsLocation("scriptsLocation");
154+}
155+
141156 void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
142157 QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);
143158
@@ -154,6 +169,16 @@ bool setupEssentials(int& argc, char** argv) { · 10 unmodified lines
154169 listenPort = atoi(portStr);
155170 }
156171
172+ // read the ApplicationInfo.ini file for Name/Version/Domain information
173+ QSettings::setDefaultFormat(QSettings::IniFormat);
174+ QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
175+ // set the associated application properties
176+ applicationInfo.beginGroup("INFO");
177+ QApplication::setApplicationName(applicationInfo.value("name").toString());
178+ QApplication::setApplicationVersion(BUILD_VERSION);
179+ QApplication::setOrganizationName(applicationInfo.value("organizationName").toString());
180+ QApplication::setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
181+
157182 DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
158183
159184 // Set dependencies
@@ -174,6 +199,12 @@ bool setupEssentials(int& argc, char** argv) { · 14 unmodified lines
174199 auto ddeFaceTracker = DependencyManager::set<DdeFaceTracker>();
175200 auto modelBlender = DependencyManager::set<ModelBlender>();
176201 auto audioToolBox = DependencyManager::set<AudioToolBox>();
202+ auto lodManager = DependencyManager::set<LODManager>();
203+ auto jsConsole = DependencyManager::set<StandAloneJSConsole>();
204+ auto dialogsManager = DependencyManager::set<DialogsManager>();
205+#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
206+ auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();
207+#endif
177208
178209 return true;
179210 }
@@ -224,35 +255,21 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 44 unmodified lines
224255 _isVSyncOn(true),
225256 _aboutToQuit(false)
226257 {
227− auto glCanvas = DependencyManager::get<GLCanvas>();
228− auto nodeList = DependencyManager::get<NodeList>();
229− Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
258+ _logger = new FileLogger(this); // After setting organization name in order to get correct directory
259+ qInstallMessageHandler(messageHandler);
230260
261+ QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
262+ _window->setWindowTitle("Interface");
231263
232− // read the ApplicationInfo.ini file for Name/Version/Domain information
233− QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
234−
235− // set the associated application properties
236− applicationInfo.beginGroup("INFO");
237−
238− setApplicationName(applicationInfo.value("name").toString());
239− setApplicationVersion(BUILD_VERSION);
240− setOrganizationName(applicationInfo.value("organizationName").toString());
241− setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
242−
243− _logger = new FileLogger(this); // After setting organization name in order to get correct directory
244−
245− QSettings::setDefaultFormat(QSettings::IniFormat);
264+ Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
265+
266+ auto glCanvas = DependencyManager::get<GLCanvas>();
267+ auto nodeList = DependencyManager::get<NodeList>();
246268
247269 _myAvatar = _avatarManager.getMyAvatar();
248270
249271 _applicationStartupTime = startup_time;
250272
251− QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
252− _window->setWindowTitle("Interface");
253−
254− qInstallMessageHandler(messageHandler);
255−
256273 qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion());
257274
258275 _bookmarks = new Bookmarks(); // Before setting up the menu
@@ -281,6 +298,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 22 unmodified lines
281298 auto audioIO = DependencyManager::get<Audio>();
282299 audioIO->moveToThread(audioThread);
283300 connect(audioThread, &QThread::started, audioIO.data(), &Audio::start);
301+ connect(audioIO.data(), SIGNAL(muteToggled()), this, SLOT(audioMuteToggled()));
284302
285303 audioThread->start();
286304
@@ -292,7 +310,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 5 unmodified lines
292310 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle()));
293311 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails()));
294312 connect(&domainHandler, &DomainHandler::settingsReceived, this, &Application::domainSettingsReceived);
295− connect(&domainHandler, &DomainHandler::hostnameChanged, Menu::getInstance(), &Menu::clearLoginDialogDisplayedFlag);
313+ connect(&domainHandler, &DomainHandler::hostnameChanged,
314+ DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);
296315
297316 // update our location every 5 seconds in the data-server, assuming that we are authenticated with one
298317 const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * 1000;
@@ -318,7 +337,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 19 unmodified lines
318337
319338 connect(&accountManager, &AccountManager::balanceChanged, this, &Application::updateWindowTitle);
320339
321− connect(&accountManager, &AccountManager::authRequired, Menu::getInstance(), &Menu::loginForCurrentDomain);
340+ auto dialogsManager = DependencyManager::get<DialogsManager>();
341+ connect(&accountManager, &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog);
322342 connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle);
323343
324344 // once we have a profile in account manager make sure we generate a new keypair
@@ -339,9 +359,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 14 unmodified lines
339359
340360 connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle);
341361
342− _settings = new QSettings(this);
343− _numChangedSettings = 0;
344−
345362 #ifdef _WIN32
346363 WSADATA WsaData;
347364 int wsaresult = WSAStartup(MAKEWORD(2,2), &WsaData);
@@ -382,7 +399,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 34 unmodified lines
382399
383400 _window->setCentralWidget(glCanvas.data());
384401
385− restoreSizeAndPosition();
402+ _window->restoreGeometry();
386403
387404 _window->setVisible(true);
388405 glCanvas->setFocusPolicy(Qt::StrongFocus);
@@ -416,23 +433,31 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 27 unmodified lines
416433 connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
417434
418435 // check first run...
419− QVariant firstRunValue = _settings->value("firstRun",QVariant(true));
420− if (firstRunValue.isValid() && firstRunValue.toBool()) {
436+ bool firstRun = SettingHandles::firstRun.get();
437+ if (firstRun) {
421438 qDebug() << "This is a first run...";
422439 // clear the scripts, and set out script to our default scripts
423440 clearScriptsBeforeRunning();
424441 loadScript(DEFAULT_SCRIPTS_JS_URL);
425442
426− QMutexLocker locker(&_settingsMutex);
427− _settings->setValue("firstRun",QVariant(false));
443+ SettingHandles::firstRun.set(false);
428444 } else {
429445 // do this as late as possible so that all required subsystems are initialized
430446 loadScripts();
431447
432− QMutexLocker locker(&_settingsMutex);
433− _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString();
448+ _previousScriptLocation = SettingHandles::lastScriptLocation.get();
434449 }
435−
450+
451+ loadSettings();
452+ int SAVE_SETTINGS_INTERVAL = 10 * MSECS_PER_SECOND; // Let's save every seconds for now
453+ connect(&_settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
454+ connect(&_settingsThread, SIGNAL(started), &_settingsTimer, SLOT(start));
455+ connect(&_settingsThread, &QThread::finished, &_settingsTimer, &QTimer::deleteLater);
456+ _settingsTimer.moveToThread(&_settingsThread);
457+ _settingsTimer.setSingleShot(false);
458+ _settingsTimer.setInterval(SAVE_SETTINGS_INTERVAL);
459+ _settingsThread.start();
460+
436461 _trayIcon->show();
437462
438463 // set the local loopback interface for local sounds from audio scripts
@@ -453,12 +478,12 @@ void Application::aboutToQuit() { · 14 unmodified lines
453478 }
454479
455480 Application::~Application() {
481+ saveSettings();
456482
457483 _entities.getTree()->setSimulation(NULL);
458484 qInstallMessageHandler(NULL);
459485
460− saveSettings();
461− storeSizeAndPosition();
486+ _window->saveGeometry();
462487
463488 int DELAY_TIME = 1000;
464489 UserActivityLogger::getInstance().close(DELAY_TIME);
@@ -495,45 +520,6 @@ Application::~Application() { · 30 unmodified lines
495520 DependencyManager::destroy<GLCanvas>();
496521 }
497522
498−void Application::saveSettings() {
499− Menu::getInstance()->saveSettings();
500− _rearMirrorTools->saveSettings(_settings);
501−
502− _settings->sync();
503− _numChangedSettings = 0;
504−}
505−
506−
507−void Application::restoreSizeAndPosition() {
508− QRect available = desktop()->availableGeometry();
509−
510− QMutexLocker locker(&_settingsMutex);
511− _settings->beginGroup("Window");
512−
513− int x = (int)loadSetting(_settings, "x", 0);
514− int y = (int)loadSetting(_settings, "y", 0);
515− _window->move(x, y);
516−
517− int width = (int)loadSetting(_settings, "width", available.width());
518− int height = (int)loadSetting(_settings, "height", available.height());
519− _window->resize(width, height);
520−
521− _settings->endGroup();
522−}
523−
524−void Application::storeSizeAndPosition() {
525− QMutexLocker locker(&_settingsMutex);
526− _settings->beginGroup("Window");
527−
528− _settings->setValue("width", _window->rect().width());
529− _settings->setValue("height", _window->rect().height());
530−
531− _settings->setValue("x", _window->pos().x());
532− _settings->setValue("y", _window->pos().y());
533−
534− _settings->endGroup();
535−}
536−
537523 void Application::initializeGL() {
538524 qDebug( "Created Display Window.");
539525
@@ -655,7 +641,7 @@ void Application::paintGL() { · 115 unmodified lines
655641 _myCamera.update(1.0f / _fps);
656642 }
657643
658− if (Menu::getInstance()->getShadowsEnabled()) {
644+ if (getShadowsEnabled()) {
659645 updateShadowMap();
660646 }
661647
@@ -711,6 +697,24 @@ void Application::paintGL() { · 49 unmodified lines
711697 _frameCount++;
712698 }
713699
700+void Application::runTests() {
701+ runTimingTests();
702+}
703+
704+void Application::audioMuteToggled() {
705+ QAction* muteAction = Menu::getInstance()->getActionForOption(MenuOption::MuteAudio);
706+ Q_CHECK_PTR(muteAction);
707+ muteAction->setChecked(DependencyManager::get<Audio>()->isMuted());
708+}
709+
710+void Application::aboutApp() {
711+ InfoView::forcedShow(INFO_HELP_PATH);
712+}
713+
714+void Application::showEditEntitiesHelp() {
715+ InfoView::forcedShow(INFO_EDIT_ENTITIES_PATH);
716+}
717+
714718 void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) {
715719 if (OculusManager::isConnected()) {
716720 OculusManager::configureCamera(camera, width, height);
@@ -718,7 +722,7 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) · 1 unmodified line
718722 TV3DManager::configureCamera(camera, width, height);
719723 } else {
720724 camera.setAspectRatio((float)width / height);
721− camera.setFieldOfView(Menu::getInstance()->getFieldOfView());
725+ camera.setFieldOfView(_viewFrustum.getFieldOfView());
722726 }
723727 }
724728
@@ -1441,10 +1445,6 @@ void Application::idle() { · 716 unmodified lines
14411445
14421446 // After finishing all of the above work, restart the idle timer, allowing 2ms to process events.
14431447 idleTimer->start(2);
1444−
1445− if (_numChangedSettings > 0) {
1446− saveSettings();
1447− }
14481448 }
14491449 }
14501450 }
@@ -1462,7 +1462,7 @@ void Application::checkBandwidthMeterClick() { · 11 unmodified lines
14621462
14631463 // The bandwidth meter is visible, the click didn't get dragged too far and
14641464 // we actually hit the bandwidth meter
1465− Menu::getInstance()->bandwidthDetails();
1465+ DependencyManager::get<DialogsManager>()->bandwidthDetails();
14661466 }
14671467 }
14681468
@@ -1600,6 +1600,20 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa · 131 unmodified lines
16001600 return true;
16011601 }
16021602
1603+void Application::loadSettings() {
1604+ DependencyManager::get<Audio>()->loadSettings();
1605+ DependencyManager::get<LODManager>()->loadSettings();
1606+ Menu::getInstance()->loadSettings();
1607+ _myAvatar->loadData();
1608+}
1609+
1610+void Application::saveSettings() {
1611+ DependencyManager::get<Audio>()->saveSettings();
1612+ DependencyManager::get<LODManager>()->saveSettings();
1613+ Menu::getInstance()->saveSettings();
1614+ _myAvatar->saveData();
1615+}
1616+
16031617 bool Application::importEntities(const QString& filename) {
16041618 _entityClipboard.eraseAllOctreeElements();
16051619 bool success = _entityClipboard.readFromSVOFile(filename.toLocal8Bit().constData());
@@ -1650,8 +1664,6 @@ void Application::init() { · 44 unmodified lines
16501664
16511665 _timerStart.start();
16521666 _lastTimeUpdated.start();
1653−
1654− Menu::getInstance()->loadSettings();
16551667
16561668 // when --url in command line, teleport to location
16571669 const QString HIFI_URL_COMMAND_LINE_KEY = "--url";
@@ -1669,11 +1681,11 @@ void Application::init() { · 11 unmodified lines
16691681 if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseEnabled)) {
16701682 // on OS X we only setup sixense if the user wants it on - this allows running without the hid_init crash
16711683 // if hydra support is temporarily not required
1672− Menu::getInstance()->toggleSixense(true);
1684+ SixenseManager::getInstance().toggleSixense(true);
16731685 }
16741686 #else
16751687 // setup sixense
1676− Menu::getInstance()->toggleSixense(true);
1688+ SixenseManager::getInstance().toggleSixense(true);
16771689 #endif
16781690
16791691 // initialize our face trackers after loading the menu settings
@@ -1712,16 +1724,13 @@ void Application::init() { · 32 unmodified lines
17121724 _metavoxels.init();
17131725
17141726 auto glCanvas = DependencyManager::get<GLCanvas>();
1715− _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect, _settings);
1727+ _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect);
17161728
17171729 connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
17181730 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
17191731 connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
17201732 connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors()));
17211733
1722− // save settings when avatar changes
1723− connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
1724−
17251734 // make sure our texture cache knows about window size changes
17261735 DependencyManager::get<TextureCache>()->associateWithWidget(glCanvas.data());
17271736
@@ -1763,9 +1772,9 @@ void Application::updateLOD() { · 35 unmodified lines
17631772 PerformanceTimer perfTimer("LOD");
17641773 // adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode
17651774 if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableAutoAdjustLOD) && !isThrottleRendering()) {
1766− Menu::getInstance()->autoAdjustLOD(_fps);
1775+ DependencyManager::get<LODManager>()->autoAdjustLOD(_fps);
17671776 } else {
1768− Menu::getInstance()->resetLODAdjust();
1777+ DependencyManager::get<LODManager>()->resetLODAdjust();
17691778 }
17701779 }
17711780
@@ -1882,7 +1891,7 @@ void Application::updateMyAvatarLookAtPosition() { · 110 unmodified lines
18821891 // deflect using Faceshift gaze data
18831892 glm::vec3 origin = _myAvatar->getHead()->getEyePosition();
18841893 float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
1885− float deflection = Menu::getInstance()->getFaceshiftEyeDeflection();
1894+ float deflection = DependencyManager::get<Faceshift>()->getEyeDeflection();
18861895 if (isLookingAtSomeone) {
18871896 deflection *= GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT;
18881897 }
@@ -1954,14 +1963,15 @@ void Application::updateDialogs(float deltaTime) { · 65 unmodified lines
19541963 PerformanceTimer perfTimer("updateDialogs");
19551964 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
19561965 PerformanceWarning warn(showWarnings, "Application::updateDialogs()");
1957−
1966+ auto dialogsManager = DependencyManager::get<DialogsManager>();
1967+
19581968 // Update bandwidth dialog, if any
1959− BandwidthDialog* bandwidthDialog = Menu::getInstance()->getBandwidthDialog();
1969+ BandwidthDialog* bandwidthDialog = dialogsManager->getBandwidthDialog();
19601970 if (bandwidthDialog) {
19611971 bandwidthDialog->update();
19621972 }
19631973
1964− OctreeStatsDialog* octreeStatsDialog = Menu::getInstance()->getOctreeStatsDialog();
1974+ QPointer<OctreeStatsDialog> octreeStatsDialog = dialogsManager->getOctreeStatsDialog();
19651975 if (octreeStatsDialog) {
19661976 octreeStatsDialog->update();
19671977 }
@@ -2232,8 +2242,9 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 264 unmodified lines
22322242 _octreeQuery.setCameraNearClip(_viewFrustum.getNearClip());
22332243 _octreeQuery.setCameraFarClip(_viewFrustum.getFarClip());
22342244 _octreeQuery.setCameraEyeOffsetPosition(_viewFrustum.getEyeOffsetPosition());
2235− _octreeQuery.setOctreeSizeScale(Menu::getInstance()->getOctreeSizeScale());
2236− _octreeQuery.setBoundaryLevelAdjust(Menu::getInstance()->getBoundaryLevelAdjust());
2245+ auto lodManager = DependencyManager::get<LODManager>();
2246+ _octreeQuery.setOctreeSizeScale(lodManager->getOctreeSizeScale());
2247+ _octreeQuery.setBoundaryLevelAdjust(lodManager->getBoundaryLevelAdjust());
22372248
22382249 unsigned char queryPacket[MAX_PACKET_SIZE];
22392250
@@ -2285,7 +2296,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 45 unmodified lines
22852296 int perServerPPS = 0;
22862297 const int SMALL_BUDGET = 10;
22872298 int perUnknownServer = SMALL_BUDGET;
2288− int totalPPS = Menu::getInstance()->getMaxOctreePacketsPerSecond();
2299+ int totalPPS = _octreeQuery.getMaxOctreePacketsPerSecond();
22892300
22902301 // determine PPS based on number of servers
22912302 if (inViewServers >= 1) {
@@ -2406,7 +2417,7 @@ QRect Application::getDesirableApplicationGeometry() { · 114 unmodified lines
24062417
24072418 // If our parent window is on the HMD, then don't use it's geometry, instead use
24082419 // the "main screen" geometry.
2409− HMDToolsDialog* hmdTools = Menu::getInstance()->getHMDToolsDialog();
2420+ HMDToolsDialog* hmdTools = DependencyManager::get<DialogsManager>()->getHMDToolsDialog();
24102421 if (hmdTools && hmdTools->hasHMDScreen()) {
24112422 QScreen* hmdScreen = hmdTools->getHMDScreen();
24122423 QWindow* appWindow = getWindow()->windowHandle();
@@ -2631,15 +2642,15 @@ void Application::setupWorldLight() { · 218 unmodified lines
26312642 }
26322643
26332644 bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) {
2634− return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera);
2645+ return DependencyManager::get<LODManager>()->shouldRenderMesh(largestDimension, distanceToCamera);
26352646 }
26362647
26372648 float Application::getSizeScale() const {
2638− return Menu::getInstance()->getOctreeSizeScale();
2649+ return DependencyManager::get<LODManager>()->getOctreeSizeScale();
26392650 }
26402651
26412652 int Application::getBoundaryLevelAdjust() const {
2642− return Menu::getInstance()->getBoundaryLevelAdjust();
2653+ return DependencyManager::get<LODManager>()->getBoundaryLevelAdjust();
26432654 }
26442655
26452656 PickRay Application::computePickRay(float x, float y) {
@@ -2935,8 +2946,10 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 289 unmodified lines
29352946 }
29362947 }
29372948
2938−bool Application::getShadowsEnabled() {
2939− return Menu::getInstance()->getShadowsEnabled();
2949+bool Application::getShadowsEnabled() {
2950+ Menu* menubar = Menu::getInstance();
2951+ return menubar->isOptionChecked(MenuOption::SimpleShadows) ||
2952+ menubar->isOptionChecked(MenuOption::CascadedShadows);
29402953 }
29412954
29422955 bool Application::getCascadeShadowsEnabled() {
@@ -2981,7 +2994,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 38 unmodified lines
29812994 _mirrorCamera.setPosition(_myAvatar->getPosition() +
29822995 _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale());
29832996
2984− } else if (_rearMirrorTools->getZoomLevel() == BODY) {
2997+ } else if (SettingHandles::rearViewZoomLevel.get() == BODY) {
29852998 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
29862999 _mirrorCamera.setPosition(_myAvatar->getChestPosition() +
29873000 _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
@@ -3378,45 +3391,45 @@ void Application::packetSent(quint64 length) { · 390 unmodified lines
33783391 _bandwidthMeter.outputStream(BandwidthMeter::OCTREE).updateValue(length);
33793392 }
33803393
3394+const QString SETTINGS_KEY = "Settings";
3395+
33813396 void Application::loadScripts() {
33823397 // loads all saved scripts
3383− int size = lockSettings()->beginReadArray("Settings");
3384− unlockSettings();
3398+ Settings settings;
3399+ int size = settings.beginReadArray(SETTINGS_KEY);
33853400 for (int i = 0; i < size; ++i){
3386− lockSettings()->setArrayIndex(i);
3387− QString string = _settings->value("script").toString();
3388− unlockSettings();
3401+ settings.setArrayIndex(i);
3402+ QString string = settings.value("script").toString();
33893403 if (!string.isEmpty()) {
33903404 loadScript(string);
33913405 }
33923406 }
3393−
3394− QMutexLocker locker(&_settingsMutex);
3395− _settings->endArray();
3407+ settings.endArray();
33963408 }
33973409
33983410 void Application::clearScriptsBeforeRunning() {
33993411 // clears all scripts from the settings
3400− QMutexLocker locker(&_settingsMutex);
3401− _settings->remove("Settings");
3412+ SettingHandles::SettingHandle<QVariant>(SETTINGS_KEY).remove();
34023413 }
34033414
34043415 void Application::saveScripts() {
3405− // Saves all currently running user-loaded scripts
3406− QMutexLocker locker(&_settingsMutex);
3407− _settings->beginWriteArray("Settings");
3408−
34093416 QStringList runningScripts = getRunningScripts();
3417+ if (runningScripts.isEmpty()) {
3418+ return;
3419+ }
3420+
3421+ // Saves all currently running user-loaded scripts
3422+ Settings settings;
3423+ settings.beginWriteArray(SETTINGS_KEY);
34103424 int i = 0;
3411− for (QStringList::const_iterator it = runningScripts.begin(); it != runningScripts.end(); it += 1) {
3425+ for (auto it = runningScripts.begin(); it != runningScripts.end(); ++it) {
34123426 if (getScriptEngine(*it)->isUserLoaded()) {
3413− _settings->setArrayIndex(i);
3414− _settings->setValue("script", *it);
3415− i += 1;
3427+ settings.setArrayIndex(i);
3428+ settings.setValue("script", *it);
3429+ ++i;
34163430 }
34173431 }
3418−
3419− _settings->endArray();
3432+ settings.endArray();
34203433 }
34213434
34223435 QScriptValue joystickToScriptValue(QScriptEngine *engine, Joystick* const &in) {
@@ -3443,7 +3456,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 20 unmodified lines
34433456 scriptEngine->registerGlobalObject("Camera", &_myCamera);
34443457
34453458 #if defined(Q_OS_MAC) || defined(Q_OS_WIN)
3446− scriptEngine->registerGlobalObject("SpeechRecognizer", Menu::getInstance()->getSpeechRecognizer());
3459+ scriptEngine->registerGlobalObject("SpeechRecognizer", DependencyManager::get<SpeechRecognizer>().data());
34473460 #endif
34483461
34493462 ClipboardScriptingInterface* clipboardScriptable = new ClipboardScriptingInterface();
@@ -3545,7 +3558,6 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 95 unmodified lines
35453558 if (activateMainWindow && !loadScriptFromEditor) {
35463559 _window->activateWindow();
35473560 }
3548− bumpSettings();
35493561
35503562 return scriptEngine;
35513563 }
@@ -3573,7 +3585,6 @@ void Application::scriptFinished(const QString& scriptName) { · 21 unmodified lines
35733585 _scriptEnginesHash.erase(it);
35743586 _runningScriptsWidget->scriptStopped(scriptName);
35753587 _runningScriptsWidget->setRunningScripts(getRunningScripts());
3576− bumpSettings();
35773588 }
35783589 }
35793590
@@ -3669,7 +3680,6 @@ void Application::openUrl(const QUrl& url) { · 89 unmodified lines
36693680 }
36703681
36713682 void Application::updateMyAvatarTransform() {
3672− bumpSettings();
36733683 const float SIMULATION_OFFSET_QUANTIZATION = 16.0f; // meters
36743684 glm::vec3 avatarPosition = _myAvatar->getPosition();
36753685 glm::vec3 physicsWorldOffset = _physicsEngine.getOriginOffset();
@@ -3686,7 +3696,6 @@ void Application::updateMyAvatarTransform() { · 10 unmodified lines
36863696 }
36873697
36883698 void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject) {
3689−
36903699 // from the domain-handler, figure out the satoshi cost per voxel and per meter cubed
36913700 const QString VOXEL_SETTINGS_KEY = "voxels";
36923701 const QString PER_VOXEL_COST_KEY = "per-voxel-credits";
@@ -3729,9 +3738,7 @@ QString Application::getPreviousScriptLocation() { · 36 unmodified lines
37293738
37303739 void Application::setPreviousScriptLocation(const QString& previousScriptLocation) {
37313740 _previousScriptLocation = previousScriptLocation;
3732− QMutexLocker locker(&_settingsMutex);
3733− _settings->setValue("LastScriptLocation", _previousScriptLocation);
3734− bumpSettings();
3741+ SettingHandles::lastScriptLocation.set(_previousScriptLocation);
37353742 }
37363743
37373744 void Application::loadDialog() {
@@ -3747,7 +3754,6 @@ void Application::loadDialog() { · 9 unmodified lines
37473754 }
37483755
37493756 void Application::loadScriptURLDialog() {
3750−
37513757 QInputDialog scriptURLDialog(Application::getInstance()->getWindow());
37523758 scriptURLDialog.setWindowTitle("Open and Run Script URL");
37533759 scriptURLDialog.setLabelText("Script:");
@@ -3765,11 +3771,16 @@ void Application::loadScriptURLDialog() { · 11 unmodified lines
37653771 }
37663772 loadScript(newScript);
37673773 }
3768−
3769− sendFakeEnterEvent();
37703774 }
37713775
3776+QString Application::getScriptsLocation() const {
3777+ return SettingHandles::scriptsLocation.get();
3778+}
37723779
3780+void Application::setScriptsLocation(const QString& scriptsLocation) {
3781+ SettingHandles::scriptsLocation.set(scriptsLocation);
3782+ emit scriptLocationChanged(scriptsLocation);
3783+}
37733784
37743785 void Application::toggleLogDialog() {
37753786 if (! _logDialog) {
@@ -3871,7 +3882,8 @@ void Application::takeSnapshot() { · 95 unmodified lines
38713882 _snapshotShareDialog->show();
38723883 }
38733884
3874−void Application::setVSyncEnabled(bool vsyncOn) {
3885+void Application::setVSyncEnabled() {
3886+ bool vsyncOn = Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerateVSyncOn);
38753887 #if defined(Q_OS_WIN)
38763888 if (wglewGetExtension("WGL_EXT_swap_control")) {
38773889 wglSwapIntervalEXT(vsyncOn);
@@ -3895,6 +3907,7 @@ void Application::setVSyncEnabled(bool vsyncOn) { · 17 unmodified lines
38953907 #else
38963908 qDebug("V-Sync is FORCED ON on this system\n");
38973909 #endif
3910+ vsyncOn = true; // Turns off unused variable warning
38983911 }
38993912
39003913 bool Application::isVSyncOn() const {

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