History

Merge branch 'master' of https://github.com/highfidelity/hifi into android

Atlante45 committed 11 years ago

Commit 4ef87b92 parents df96e02 347c74e113 files · +3501 −2168Browse files

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

Unified · Split

interface/src/Application.cpp+154−140
@@ -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 "AudioClient.h"
8284 #include "InterfaceVersion.h"
85+#include "LODManager.h"
8386 #include "Menu.h"
8487 #include "ModelUploader.h"
8588 #include "Util.h"
@@ -102,7 +105,6 @@ · 16 unmodified lines
102105 #include "gpu/Batch.h"
103106 #include "gpu/GLBackend.h"
104107
105−
106108 #include "scripting/AccountScriptingInterface.h"
107109 #include "scripting/AudioDeviceScriptingInterface.h"
108110 #include "scripting/ClipboardScriptingInterface.h"
@@ -114,9 +116,16 @@ · 5 unmodified lines
114116 #include "scripting/WindowScriptingInterface.h"
115117 #include "scripting/WebWindowClass.h"
116118
119+#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
120+#include "SpeechRecognizer.h"
121+#endif
122+
117123 #include "ui/DataWebDialog.h"
124+#include "ui/DialogsManager.h"
118125 #include "ui/InfoView.h"
126+#include "ui/LoginDialog.h"
119127 #include "ui/Snapshot.h"
128+#include "ui/StandAloneJSConsole.h"
120129 #include "ui/Stats.h"
121130
122131
@@ -139,6 +148,12 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D · 16 unmodified lines
139148
140149 const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";
141150
151+namespace SettingHandles {
152+ const SettingHandle<bool> firstRun("firstRun", true);
153+ const SettingHandle<QString> lastScriptLocation("LastScriptLocation");
154+ const SettingHandle<QString> scriptsLocation("scriptsLocation");
155+}
156+
142157 void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
143158 QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);
144159
@@ -155,6 +170,16 @@ bool setupEssentials(int& argc, char** argv) { · 10 unmodified lines
155170 listenPort = atoi(portStr);
156171 }
157172
173+ // read the ApplicationInfo.ini file for Name/Version/Domain information
174+ QSettings::setDefaultFormat(QSettings::IniFormat);
175+ QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
176+ // set the associated application properties
177+ applicationInfo.beginGroup("INFO");
178+ QApplication::setApplicationName(applicationInfo.value("name").toString());
179+ QApplication::setApplicationVersion(BUILD_VERSION);
180+ QApplication::setOrganizationName(applicationInfo.value("organizationName").toString());
181+ QApplication::setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
182+
158183 DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
159184 DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>();
160185
@@ -177,6 +202,12 @@ bool setupEssentials(int& argc, char** argv) { · 16 unmodified lines
177202 auto modelBlender = DependencyManager::set<ModelBlender>();
178203 auto audioToolBox = DependencyManager::set<AudioToolBox>();
179204 auto avatarManager = DependencyManager::set<AvatarManager>();
205+ auto lodManager = DependencyManager::set<LODManager>();
206+ auto jsConsole = DependencyManager::set<StandAloneJSConsole>();
207+ auto dialogsManager = DependencyManager::set<DialogsManager>();
208+#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
209+ auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();
210+#endif
180211
181212 return true;
182213 }
@@ -227,34 +258,21 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 44 unmodified lines
227258 _isVSyncOn(true),
228259 _aboutToQuit(false)
229260 {
230− auto glCanvas = DependencyManager::get<GLCanvas>();
231− auto nodeList = DependencyManager::get<NodeList>();
232− Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
233−
234− // read the ApplicationInfo.ini file for Name/Version/Domain information
235− QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
236−
237− // set the associated application properties
238− applicationInfo.beginGroup("INFO");
239−
240− setApplicationName(applicationInfo.value("name").toString());
241− setApplicationVersion(BUILD_VERSION);
242− setOrganizationName(applicationInfo.value("organizationName").toString());
243− setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
244−
245261 _logger = new FileLogger(this); // After setting organization name in order to get correct directory
262+ qInstallMessageHandler(messageHandler);
246263
247− QSettings::setDefaultFormat(QSettings::IniFormat);
264+ QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
265+ _window->setWindowTitle("Interface");
266+
267+ Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
268+
269+ auto glCanvas = DependencyManager::get<GLCanvas>();
270+ auto nodeList = DependencyManager::get<NodeList>();
248271
249272 _myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
250273
251274 _applicationStartupTime = startup_time;
252275
253− QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
254− _window->setWindowTitle("Interface");
255−
256− qInstallMessageHandler(messageHandler);
257−
258276 qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion());
259277
260278 _bookmarks = new Bookmarks(); // Before setting up the menu
@@ -290,6 +308,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 29 unmodified lines
290308
291309 audioIO->moveToThread(audioThread);
292310 connect(audioThread, &QThread::started, audioIO.data(), &AudioClient::start);
311+ connect(audioIO.data(), SIGNAL(muteToggled()), this, SLOT(audioMuteToggled()));
293312
294313 audioThread->start();
295314
@@ -301,7 +320,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 5 unmodified lines
301320 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle()));
302321 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails()));
303322 connect(&domainHandler, &DomainHandler::settingsReceived, this, &Application::domainSettingsReceived);
304− connect(&domainHandler, &DomainHandler::hostnameChanged, Menu::getInstance(), &Menu::clearLoginDialogDisplayedFlag);
323+ connect(&domainHandler, &DomainHandler::hostnameChanged,
324+ DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);
305325
306326 // update our location every 5 seconds in the data-server, assuming that we are authenticated with one
307327 const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * 1000;
@@ -327,7 +347,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 19 unmodified lines
327347
328348 connect(&accountManager, &AccountManager::balanceChanged, this, &Application::updateWindowTitle);
329349
330− connect(&accountManager, &AccountManager::authRequired, Menu::getInstance(), &Menu::loginForCurrentDomain);
350+ auto dialogsManager = DependencyManager::get<DialogsManager>();
351+ connect(&accountManager, &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog);
331352 connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle);
332353
333354 // once we have a profile in account manager make sure we generate a new keypair
@@ -348,9 +369,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 14 unmodified lines
348369
349370 connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle);
350371
351− _settings = new QSettings(this);
352− _numChangedSettings = 0;
353−
354372 #ifdef _WIN32
355373 WSADATA WsaData;
356374 int wsaresult = WSAStartup(MAKEWORD(2,2), &WsaData);
@@ -391,7 +409,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 34 unmodified lines
391409
392410 _window->setCentralWidget(glCanvas.data());
393411
394− restoreSizeAndPosition();
412+ _window->restoreGeometry();
395413
396414 _window->setVisible(true);
397415 glCanvas->setFocusPolicy(Qt::StrongFocus);
@@ -425,23 +443,31 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 27 unmodified lines
425443 connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
426444
427445 // check first run...
428− QVariant firstRunValue = _settings->value("firstRun",QVariant(true));
429− if (firstRunValue.isValid() && firstRunValue.toBool()) {
446+ bool firstRun = SettingHandles::firstRun.get();
447+ if (firstRun) {
430448 qDebug() << "This is a first run...";
431449 // clear the scripts, and set out script to our default scripts
432450 clearScriptsBeforeRunning();
433451 loadScript(DEFAULT_SCRIPTS_JS_URL);
434452
435− QMutexLocker locker(&_settingsMutex);
436− _settings->setValue("firstRun",QVariant(false));
453+ SettingHandles::firstRun.set(false);
437454 } else {
438455 // do this as late as possible so that all required subsystems are initialized
439456 loadScripts();
440457
441− QMutexLocker locker(&_settingsMutex);
442− _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString();
458+ _previousScriptLocation = SettingHandles::lastScriptLocation.get();
443459 }
444−
460+
461+ loadSettings();
462+ int SAVE_SETTINGS_INTERVAL = 10 * MSECS_PER_SECOND; // Let's save every seconds for now
463+ connect(&_settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
464+ connect(&_settingsThread, SIGNAL(started), &_settingsTimer, SLOT(start));
465+ connect(&_settingsThread, &QThread::finished, &_settingsTimer, &QTimer::deleteLater);
466+ _settingsTimer.moveToThread(&_settingsThread);
467+ _settingsTimer.setSingleShot(false);
468+ _settingsTimer.setInterval(SAVE_SETTINGS_INTERVAL);
469+ _settingsThread.start();
470+
445471 _trayIcon->show();
446472
447473 // set the local loopback interface for local sounds from audio scripts
@@ -462,12 +488,12 @@ void Application::aboutToQuit() { · 14 unmodified lines
462488 }
463489
464490 Application::~Application() {
491+ saveSettings();
465492
466493 _entities.getTree()->setSimulation(NULL);
467494 qInstallMessageHandler(NULL);
468495
469− saveSettings();
470− storeSizeAndPosition();
496+ _window->saveGeometry();
471497
472498 int DELAY_TIME = 1000;
473499 UserActivityLogger::getInstance().close(DELAY_TIME);
@@ -504,45 +530,6 @@ Application::~Application() { · 30 unmodified lines
504530 DependencyManager::destroy<GLCanvas>();
505531 }
506532
507−void Application::saveSettings() {
508− Menu::getInstance()->saveSettings();
509− _rearMirrorTools->saveSettings(_settings);
510−
511− _settings->sync();
512− _numChangedSettings = 0;
513−}
514−
515−
516−void Application::restoreSizeAndPosition() {
517− QRect available = desktop()->availableGeometry();
518−
519− QMutexLocker locker(&_settingsMutex);
520− _settings->beginGroup("Window");
521−
522− int x = (int)loadSetting(_settings, "x", 0);
523− int y = (int)loadSetting(_settings, "y", 0);
524− _window->move(x, y);
525−
526− int width = (int)loadSetting(_settings, "width", available.width());
527− int height = (int)loadSetting(_settings, "height", available.height());
528− _window->resize(width, height);
529−
530− _settings->endGroup();
531−}
532−
533−void Application::storeSizeAndPosition() {
534− QMutexLocker locker(&_settingsMutex);
535− _settings->beginGroup("Window");
536−
537− _settings->setValue("width", _window->rect().width());
538− _settings->setValue("height", _window->rect().height());
539−
540− _settings->setValue("x", _window->pos().x());
541− _settings->setValue("y", _window->pos().y());
542−
543− _settings->endGroup();
544−}
545−
546533 void Application::initializeGL() {
547534 qDebug( "Created Display Window.");
548535
@@ -664,7 +651,7 @@ void Application::paintGL() { · 115 unmodified lines
664651 _myCamera.update(1.0f / _fps);
665652 }
666653
667− if (Menu::getInstance()->getShadowsEnabled()) {
654+ if (getShadowsEnabled()) {
668655 updateShadowMap();
669656 }
670657
@@ -720,6 +707,24 @@ void Application::paintGL() { · 49 unmodified lines
720707 _frameCount++;
721708 }
722709
710+void Application::runTests() {
711+ runTimingTests();
712+}
713+
714+void Application::audioMuteToggled() {
715+ QAction* muteAction = Menu::getInstance()->getActionForOption(MenuOption::MuteAudio);
716+ Q_CHECK_PTR(muteAction);
717+ muteAction->setChecked(DependencyManager::get<AudioClient>()->isMuted());
718+}
719+
720+void Application::aboutApp() {
721+ InfoView::forcedShow(INFO_HELP_PATH);
722+}
723+
724+void Application::showEditEntitiesHelp() {
725+ InfoView::forcedShow(INFO_EDIT_ENTITIES_PATH);
726+}
727+
723728 void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) {
724729 if (OculusManager::isConnected()) {
725730 OculusManager::configureCamera(camera, width, height);
@@ -727,7 +732,7 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) · 1 unmodified line
727732 TV3DManager::configureCamera(camera, width, height);
728733 } else {
729734 camera.setAspectRatio((float)width / height);
730− camera.setFieldOfView(Menu::getInstance()->getFieldOfView());
735+ camera.setFieldOfView(_viewFrustum.getFieldOfView());
731736 }
732737 }
733738
@@ -1450,10 +1455,6 @@ void Application::idle() { · 716 unmodified lines
14501455
14511456 // After finishing all of the above work, restart the idle timer, allowing 2ms to process events.
14521457 idleTimer->start(2);
1453−
1454− if (_numChangedSettings > 0) {
1455− saveSettings();
1456− }
14571458 }
14581459 }
14591460 }
@@ -1471,7 +1472,7 @@ void Application::checkBandwidthMeterClick() { · 11 unmodified lines
14711472
14721473 // The bandwidth meter is visible, the click didn't get dragged too far and
14731474 // we actually hit the bandwidth meter
1474− Menu::getInstance()->bandwidthDetails();
1475+ DependencyManager::get<DialogsManager>()->bandwidthDetails();
14751476 }
14761477 }
14771478
@@ -1609,6 +1610,20 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa · 131 unmodified lines
16091610 return true;
16101611 }
16111612
1613+void Application::loadSettings() {
1614+ DependencyManager::get<AudioClient>()->loadSettings();
1615+ DependencyManager::get<LODManager>()->loadSettings();
1616+ Menu::getInstance()->loadSettings();
1617+ _myAvatar->loadData();
1618+}
1619+
1620+void Application::saveSettings() {
1621+ DependencyManager::get<AudioClient>()->saveSettings();
1622+ DependencyManager::get<LODManager>()->saveSettings();
1623+ Menu::getInstance()->saveSettings();
1624+ _myAvatar->saveData();
1625+}
1626+
16121627 bool Application::importEntities(const QString& filename) {
16131628 _entityClipboard.eraseAllOctreeElements();
16141629 bool success = _entityClipboard.readFromSVOFile(filename.toLocal8Bit().constData());
@@ -1659,8 +1674,6 @@ void Application::init() { · 44 unmodified lines
16591674
16601675 _timerStart.start();
16611676 _lastTimeUpdated.start();
1662−
1663− Menu::getInstance()->loadSettings();
16641677
16651678 // when --url in command line, teleport to location
16661679 const QString HIFI_URL_COMMAND_LINE_KEY = "--url";
@@ -1678,11 +1691,11 @@ void Application::init() { · 11 unmodified lines
16781691 if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseEnabled)) {
16791692 // on OS X we only setup sixense if the user wants it on - this allows running without the hid_init crash
16801693 // if hydra support is temporarily not required
1681− Menu::getInstance()->toggleSixense(true);
1694+ SixenseManager::getInstance().toggleSixense(true);
16821695 }
16831696 #else
16841697 // setup sixense
1685− Menu::getInstance()->toggleSixense(true);
1698+ SixenseManager::getInstance().toggleSixense(true);
16861699 #endif
16871700
16881701 // initialize our face trackers after loading the menu settings
@@ -1721,16 +1734,13 @@ void Application::init() { · 32 unmodified lines
17211734 _metavoxels.init();
17221735
17231736 auto glCanvas = DependencyManager::get<GLCanvas>();
1724− _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect, _settings);
1737+ _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect);
17251738
17261739 connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
17271740 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
17281741 connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
17291742 connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors()));
17301743
1731− // save settings when avatar changes
1732− connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
1733−
17341744 // make sure our texture cache knows about window size changes
17351745 DependencyManager::get<TextureCache>()->associateWithWidget(glCanvas.data());
17361746
@@ -1772,9 +1782,9 @@ void Application::updateLOD() { · 35 unmodified lines
17721782 PerformanceTimer perfTimer("LOD");
17731783 // adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode
17741784 if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableAutoAdjustLOD) && !isThrottleRendering()) {
1775− Menu::getInstance()->autoAdjustLOD(_fps);
1785+ DependencyManager::get<LODManager>()->autoAdjustLOD(_fps);
17761786 } else {
1777− Menu::getInstance()->resetLODAdjust();
1787+ DependencyManager::get<LODManager>()->resetLODAdjust();
17781788 }
17791789 }
17801790
@@ -1891,7 +1901,7 @@ void Application::updateMyAvatarLookAtPosition() { · 110 unmodified lines
18911901 // deflect using Faceshift gaze data
18921902 glm::vec3 origin = _myAvatar->getHead()->getEyePosition();
18931903 float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
1894− float deflection = Menu::getInstance()->getFaceshiftEyeDeflection();
1904+ float deflection = DependencyManager::get<Faceshift>()->getEyeDeflection();
18951905 if (isLookingAtSomeone) {
18961906 deflection *= GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT;
18971907 }
@@ -1963,14 +1973,15 @@ void Application::updateDialogs(float deltaTime) { · 65 unmodified lines
19631973 PerformanceTimer perfTimer("updateDialogs");
19641974 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
19651975 PerformanceWarning warn(showWarnings, "Application::updateDialogs()");
1966−
1976+ auto dialogsManager = DependencyManager::get<DialogsManager>();
1977+
19671978 // Update bandwidth dialog, if any
1968− BandwidthDialog* bandwidthDialog = Menu::getInstance()->getBandwidthDialog();
1979+ BandwidthDialog* bandwidthDialog = dialogsManager->getBandwidthDialog();
19691980 if (bandwidthDialog) {
19701981 bandwidthDialog->update();
19711982 }
19721983
1973− OctreeStatsDialog* octreeStatsDialog = Menu::getInstance()->getOctreeStatsDialog();
1984+ QPointer<OctreeStatsDialog> octreeStatsDialog = dialogsManager->getOctreeStatsDialog();
19741985 if (octreeStatsDialog) {
19751986 octreeStatsDialog->update();
19761987 }
@@ -2241,8 +2252,9 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 264 unmodified lines
22412252 _octreeQuery.setCameraNearClip(_viewFrustum.getNearClip());
22422253 _octreeQuery.setCameraFarClip(_viewFrustum.getFarClip());
22432254 _octreeQuery.setCameraEyeOffsetPosition(_viewFrustum.getEyeOffsetPosition());
2244− _octreeQuery.setOctreeSizeScale(Menu::getInstance()->getOctreeSizeScale());
2245− _octreeQuery.setBoundaryLevelAdjust(Menu::getInstance()->getBoundaryLevelAdjust());
2255+ auto lodManager = DependencyManager::get<LODManager>();
2256+ _octreeQuery.setOctreeSizeScale(lodManager->getOctreeSizeScale());
2257+ _octreeQuery.setBoundaryLevelAdjust(lodManager->getBoundaryLevelAdjust());
22462258
22472259 unsigned char queryPacket[MAX_PACKET_SIZE];
22482260
@@ -2294,7 +2306,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 45 unmodified lines
22942306 int perServerPPS = 0;
22952307 const int SMALL_BUDGET = 10;
22962308 int perUnknownServer = SMALL_BUDGET;
2297− int totalPPS = Menu::getInstance()->getMaxOctreePacketsPerSecond();
2309+ int totalPPS = _octreeQuery.getMaxOctreePacketsPerSecond();
22982310
22992311 // determine PPS based on number of servers
23002312 if (inViewServers >= 1) {
@@ -2415,7 +2427,7 @@ QRect Application::getDesirableApplicationGeometry() { · 114 unmodified lines
24152427
24162428 // If our parent window is on the HMD, then don't use it's geometry, instead use
24172429 // the "main screen" geometry.
2418− HMDToolsDialog* hmdTools = Menu::getInstance()->getHMDToolsDialog();
2430+ HMDToolsDialog* hmdTools = DependencyManager::get<DialogsManager>()->getHMDToolsDialog();
24192431 if (hmdTools && hmdTools->hasHMDScreen()) {
24202432 QScreen* hmdScreen = hmdTools->getHMDScreen();
24212433 QWindow* appWindow = getWindow()->windowHandle();
@@ -2640,15 +2652,15 @@ void Application::setupWorldLight() { · 218 unmodified lines
26402652 }
26412653
26422654 bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) {
2643− return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera);
2655+ return DependencyManager::get<LODManager>()->shouldRenderMesh(largestDimension, distanceToCamera);
26442656 }
26452657
26462658 float Application::getSizeScale() const {
2647− return Menu::getInstance()->getOctreeSizeScale();
2659+ return DependencyManager::get<LODManager>()->getOctreeSizeScale();
26482660 }
26492661
26502662 int Application::getBoundaryLevelAdjust() const {
2651− return Menu::getInstance()->getBoundaryLevelAdjust();
2663+ return DependencyManager::get<LODManager>()->getBoundaryLevelAdjust();
26522664 }
26532665
26542666 PickRay Application::computePickRay(float x, float y) {
@@ -2944,8 +2956,10 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 289 unmodified lines
29442956 }
29452957 }
29462958
2947−bool Application::getShadowsEnabled() {
2948− return Menu::getInstance()->getShadowsEnabled();
2959+bool Application::getShadowsEnabled() {
2960+ Menu* menubar = Menu::getInstance();
2961+ return menubar->isOptionChecked(MenuOption::SimpleShadows) ||
2962+ menubar->isOptionChecked(MenuOption::CascadedShadows);
29492963 }
29502964
29512965 bool Application::getCascadeShadowsEnabled() {
@@ -2990,7 +3004,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 38 unmodified lines
29903004 _mirrorCamera.setPosition(_myAvatar->getPosition() +
29913005 _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale());
29923006
2993− } else if (_rearMirrorTools->getZoomLevel() == BODY) {
3007+ } else if (SettingHandles::rearViewZoomLevel.get() == BODY) {
29943008 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
29953009 _mirrorCamera.setPosition(_myAvatar->getChestPosition() +
29963010 _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
@@ -3387,45 +3401,45 @@ void Application::packetSent(quint64 length) { · 390 unmodified lines
33873401 _bandwidthMeter.outputStream(BandwidthMeter::OCTREE).updateValue(length);
33883402 }
33893403
3404+const QString SETTINGS_KEY = "Settings";
3405+
33903406 void Application::loadScripts() {
33913407 // loads all saved scripts
3392− int size = lockSettings()->beginReadArray("Settings");
3393− unlockSettings();
3408+ Settings settings;
3409+ int size = settings.beginReadArray(SETTINGS_KEY);
33943410 for (int i = 0; i < size; ++i){
3395− lockSettings()->setArrayIndex(i);
3396− QString string = _settings->value("script").toString();
3397− unlockSettings();
3411+ settings.setArrayIndex(i);
3412+ QString string = settings.value("script").toString();
33983413 if (!string.isEmpty()) {
33993414 loadScript(string);
34003415 }
34013416 }
3402−
3403− QMutexLocker locker(&_settingsMutex);
3404− _settings->endArray();
3417+ settings.endArray();
34053418 }
34063419
34073420 void Application::clearScriptsBeforeRunning() {
34083421 // clears all scripts from the settings
3409− QMutexLocker locker(&_settingsMutex);
3410− _settings->remove("Settings");
3422+ SettingHandles::SettingHandle<QVariant>(SETTINGS_KEY).remove();
34113423 }
34123424
34133425 void Application::saveScripts() {
3414− // Saves all currently running user-loaded scripts
3415− QMutexLocker locker(&_settingsMutex);
3416− _settings->beginWriteArray("Settings");
3417−
34183426 QStringList runningScripts = getRunningScripts();
3427+ if (runningScripts.isEmpty()) {
3428+ return;
3429+ }
3430+
3431+ // Saves all currently running user-loaded scripts
3432+ Settings settings;
3433+ settings.beginWriteArray(SETTINGS_KEY);
34193434 int i = 0;
3420− for (QStringList::const_iterator it = runningScripts.begin(); it != runningScripts.end(); it += 1) {
3435+ for (auto it = runningScripts.begin(); it != runningScripts.end(); ++it) {
34213436 if (getScriptEngine(*it)->isUserLoaded()) {
3422− _settings->setArrayIndex(i);
3423− _settings->setValue("script", *it);
3424− i += 1;
3437+ settings.setArrayIndex(i);
3438+ settings.setValue("script", *it);
3439+ ++i;
34253440 }
34263441 }
3427−
3428− _settings->endArray();
3442+ settings.endArray();
34293443 }
34303444
34313445 QScriptValue joystickToScriptValue(QScriptEngine *engine, Joystick* const &in) {
@@ -3452,7 +3466,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 20 unmodified lines
34523466 scriptEngine->registerGlobalObject("Camera", &_myCamera);
34533467
34543468 #if defined(Q_OS_MAC) || defined(Q_OS_WIN)
3455− scriptEngine->registerGlobalObject("SpeechRecognizer", Menu::getInstance()->getSpeechRecognizer());
3469+ scriptEngine->registerGlobalObject("SpeechRecognizer", DependencyManager::get<SpeechRecognizer>().data());
34563470 #endif
34573471
34583472 ClipboardScriptingInterface* clipboardScriptable = new ClipboardScriptingInterface();
@@ -3552,7 +3566,6 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 93 unmodified lines
35523566 if (activateMainWindow && !loadScriptFromEditor) {
35533567 _window->activateWindow();
35543568 }
3555− bumpSettings();
35563569
35573570 return scriptEngine;
35583571 }
@@ -3580,7 +3593,6 @@ void Application::scriptFinished(const QString& scriptName) { · 21 unmodified lines
35803593 _scriptEnginesHash.erase(it);
35813594 _runningScriptsWidget->scriptStopped(scriptName);
35823595 _runningScriptsWidget->setRunningScripts(getRunningScripts());
3583− bumpSettings();
35843596 }
35853597 }
35863598
@@ -3676,7 +3688,6 @@ void Application::openUrl(const QUrl& url) { · 89 unmodified lines
36763688 }
36773689
36783690 void Application::updateMyAvatarTransform() {
3679− bumpSettings();
36803691 const float SIMULATION_OFFSET_QUANTIZATION = 16.0f; // meters
36813692 glm::vec3 avatarPosition = _myAvatar->getPosition();
36823693 glm::vec3 physicsWorldOffset = _physicsEngine.getOriginOffset();
@@ -3693,7 +3704,6 @@ void Application::updateMyAvatarTransform() { · 10 unmodified lines
36933704 }
36943705
36953706 void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject) {
3696−
36973707 // from the domain-handler, figure out the satoshi cost per voxel and per meter cubed
36983708 const QString VOXEL_SETTINGS_KEY = "voxels";
36993709 const QString PER_VOXEL_COST_KEY = "per-voxel-credits";
@@ -3736,9 +3746,7 @@ QString Application::getPreviousScriptLocation() { · 36 unmodified lines
37363746
37373747 void Application::setPreviousScriptLocation(const QString& previousScriptLocation) {
37383748 _previousScriptLocation = previousScriptLocation;
3739− QMutexLocker locker(&_settingsMutex);
3740− _settings->setValue("LastScriptLocation", _previousScriptLocation);
3741− bumpSettings();
3749+ SettingHandles::lastScriptLocation.set(_previousScriptLocation);
37423750 }
37433751
37443752 void Application::loadDialog() {
@@ -3754,7 +3762,6 @@ void Application::loadDialog() { · 9 unmodified lines
37543762 }
37553763
37563764 void Application::loadScriptURLDialog() {
3757−
37583765 QInputDialog scriptURLDialog(Application::getInstance()->getWindow());
37593766 scriptURLDialog.setWindowTitle("Open and Run Script URL");
37603767 scriptURLDialog.setLabelText("Script:");
@@ -3772,11 +3779,16 @@ void Application::loadScriptURLDialog() { · 11 unmodified lines
37723779 }
37733780 loadScript(newScript);
37743781 }
3775−
3776− sendFakeEnterEvent();
37773782 }
37783783
3784+QString Application::getScriptsLocation() const {
3785+ return SettingHandles::scriptsLocation.get();
3786+}
37793787
3788+void Application::setScriptsLocation(const QString& scriptsLocation) {
3789+ SettingHandles::scriptsLocation.set(scriptsLocation);
3790+ emit scriptLocationChanged(scriptsLocation);
3791+}
37803792
37813793 void Application::toggleLogDialog() {
37823794 if (! _logDialog) {
@@ -3878,7 +3890,8 @@ void Application::takeSnapshot() { · 95 unmodified lines
38783890 _snapshotShareDialog->show();
38793891 }
38803892
3881−void Application::setVSyncEnabled(bool vsyncOn) {
3893+void Application::setVSyncEnabled() {
3894+ bool vsyncOn = Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerateVSyncOn);
38823895 #if defined(Q_OS_WIN)
38833896 if (wglewGetExtension("WGL_EXT_swap_control")) {
38843897 wglSwapIntervalEXT(vsyncOn);
@@ -3902,6 +3915,7 @@ void Application::setVSyncEnabled(bool vsyncOn) { · 17 unmodified lines
39023915 #else
39033916 qDebug("V-Sync is FORCED ON on this system\n");
39043917 #endif
3918+ vsyncOn = true; // Turns off unused variable warning
39053919 }
39063920
39073921 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