Showing the changes to interface/src/Application.cpp (1 of 113 files). Show all
Unified · Split
| @@ -38,8 +38,8 @@ · 37 unmodified lines | ||
| 38 | 38 | #include <QObject> |
| 39 | 39 | #include <QWheelEvent> |
| 40 | 40 | #include <QScreen> |
| 41 | −#include <QSettings> | |
| 42 | 41 | #include <QShortcut> |
| 42 | +#include <QSystemTrayIcon> | |
| 43 | 43 | #include <QTimer> |
| 44 | 44 | #include <QUrl> |
| 45 | 45 | #include <QWindow> |
| @@ -73,13 +73,16 @@ · 27 unmodified lines | ||
| 73 | 73 | #include <PhysicsEngine.h> |
| 74 | 74 | #include <ProgramObject.h> |
| 75 | 75 | #include <ResourceCache.h> |
| 76 | +#include <Settings.h> | |
| 76 | 77 | #include <SoundCache.h> |
| 77 | 78 | #include <TextRenderer.h> |
| 78 | 79 | #include <UserActivityLogger.h> |
| 79 | 80 | #include <UUID.h> |
| 80 | 81 | |
| 81 | 82 | #include "Application.h" |
| 83 | +#include "AudioClient.h" | |
| 82 | 84 | #include "InterfaceVersion.h" |
| 85 | +#include "LODManager.h" | |
| 83 | 86 | #include "Menu.h" |
| 84 | 87 | #include "ModelUploader.h" |
| 85 | 88 | #include "Util.h" |
| @@ -102,7 +105,6 @@ · 16 unmodified lines | ||
| 102 | 105 | #include "gpu/Batch.h" |
| 103 | 106 | #include "gpu/GLBackend.h" |
| 104 | 107 | |
| 105 | − | |
| 106 | 108 | #include "scripting/AccountScriptingInterface.h" |
| 107 | 109 | #include "scripting/AudioDeviceScriptingInterface.h" |
| 108 | 110 | #include "scripting/ClipboardScriptingInterface.h" |
| @@ -114,9 +116,16 @@ · 5 unmodified lines | ||
| 114 | 116 | #include "scripting/WindowScriptingInterface.h" |
| 115 | 117 | #include "scripting/WebWindowClass.h" |
| 116 | 118 | |
| 119 | +#if defined(Q_OS_MAC) || defined(Q_OS_WIN) | |
| 120 | +#include "SpeechRecognizer.h" | |
| 121 | +#endif | |
| 122 | + | |
| 117 | 123 | #include "ui/DataWebDialog.h" |
| 124 | +#include "ui/DialogsManager.h" | |
| 118 | 125 | #include "ui/InfoView.h" |
| 126 | +#include "ui/LoginDialog.h" | |
| 119 | 127 | #include "ui/Snapshot.h" |
| 128 | +#include "ui/StandAloneJSConsole.h" | |
| 120 | 129 | #include "ui/Stats.h" |
| 121 | 130 | |
| 122 | 131 | |
| @@ -139,6 +148,12 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D · 16 unmodified lines | ||
| 139 | 148 | |
| 140 | 149 | const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js"; |
| 141 | 150 | |
| 151 | +namespace SettingHandles { | |
| 152 | + const SettingHandle<bool> firstRun("firstRun", true); | |
| 153 | + const SettingHandle<QString> lastScriptLocation("LastScriptLocation"); | |
| 154 | + const SettingHandle<QString> scriptsLocation("scriptsLocation"); | |
| 155 | +} | |
| 156 | + | |
| 142 | 157 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { |
| 143 | 158 | QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message); |
| 144 | 159 | |
| @@ -155,6 +170,16 @@ bool setupEssentials(int& argc, char** argv) { · 10 unmodified lines | ||
| 155 | 170 | listenPort = atoi(portStr); |
| 156 | 171 | } |
| 157 | 172 | |
| 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 | + | |
| 158 | 183 | DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); |
| 159 | 184 | DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>(); |
| 160 | 185 | |
| @@ -177,6 +202,12 @@ bool setupEssentials(int& argc, char** argv) { · 16 unmodified lines | ||
| 177 | 202 | auto modelBlender = DependencyManager::set<ModelBlender>(); |
| 178 | 203 | auto audioToolBox = DependencyManager::set<AudioToolBox>(); |
| 179 | 204 | 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 | |
| 180 | 211 | |
| 181 | 212 | return true; |
| 182 | 213 | } |
| @@ -227,34 +258,21 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 44 unmodified lines | ||
| 227 | 258 | _isVSyncOn(true), |
| 228 | 259 | _aboutToQuit(false) |
| 229 | 260 | { |
| 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 | − | |
| 245 | 261 | _logger = new FileLogger(this); // After setting organization name in order to get correct directory |
| 262 | + qInstallMessageHandler(messageHandler); | |
| 246 | 263 | |
| 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>(); | |
| 248 | 271 | |
| 249 | 272 | _myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); |
| 250 | 273 | |
| 251 | 274 | _applicationStartupTime = startup_time; |
| 252 | 275 | |
| 253 | − QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf"); | |
| 254 | − _window->setWindowTitle("Interface"); | |
| 255 | − | |
| 256 | − qInstallMessageHandler(messageHandler); | |
| 257 | − | |
| 258 | 276 | qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion()); |
| 259 | 277 | |
| 260 | 278 | _bookmarks = new Bookmarks(); // Before setting up the menu |
| @@ -290,6 +308,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 29 unmodified lines | ||
| 290 | 308 | |
| 291 | 309 | audioIO->moveToThread(audioThread); |
| 292 | 310 | connect(audioThread, &QThread::started, audioIO.data(), &AudioClient::start); |
| 311 | + connect(audioIO.data(), SIGNAL(muteToggled()), this, SLOT(audioMuteToggled())); | |
| 293 | 312 | |
| 294 | 313 | audioThread->start(); |
| 295 | 314 | |
| @@ -301,7 +320,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 5 unmodified lines | ||
| 301 | 320 | connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle())); |
| 302 | 321 | connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails())); |
| 303 | 322 | 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); | |
| 305 | 325 | |
| 306 | 326 | // update our location every 5 seconds in the data-server, assuming that we are authenticated with one |
| 307 | 327 | 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 | ||
| 327 | 347 | |
| 328 | 348 | connect(&accountManager, &AccountManager::balanceChanged, this, &Application::updateWindowTitle); |
| 329 | 349 | |
| 330 | − connect(&accountManager, &AccountManager::authRequired, Menu::getInstance(), &Menu::loginForCurrentDomain); | |
| 350 | + auto dialogsManager = DependencyManager::get<DialogsManager>(); | |
| 351 | + connect(&accountManager, &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog); | |
| 331 | 352 | connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle); |
| 332 | 353 | |
| 333 | 354 | // 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 | ||
| 348 | 369 | |
| 349 | 370 | connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle); |
| 350 | 371 | |
| 351 | − _settings = new QSettings(this); | |
| 352 | − _numChangedSettings = 0; | |
| 353 | − | |
| 354 | 372 | #ifdef _WIN32 |
| 355 | 373 | WSADATA WsaData; |
| 356 | 374 | int wsaresult = WSAStartup(MAKEWORD(2,2), &WsaData); |
| @@ -391,7 +409,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 34 unmodified lines | ||
| 391 | 409 | |
| 392 | 410 | _window->setCentralWidget(glCanvas.data()); |
| 393 | 411 | |
| 394 | − restoreSizeAndPosition(); | |
| 412 | + _window->restoreGeometry(); | |
| 395 | 413 | |
| 396 | 414 | _window->setVisible(true); |
| 397 | 415 | glCanvas->setFocusPolicy(Qt::StrongFocus); |
| @@ -425,23 +443,31 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 27 unmodified lines | ||
| 425 | 443 | connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); |
| 426 | 444 | |
| 427 | 445 | // 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) { | |
| 430 | 448 | qDebug() << "This is a first run..."; |
| 431 | 449 | // clear the scripts, and set out script to our default scripts |
| 432 | 450 | clearScriptsBeforeRunning(); |
| 433 | 451 | loadScript(DEFAULT_SCRIPTS_JS_URL); |
| 434 | 452 | |
| 435 | − QMutexLocker locker(&_settingsMutex); | |
| 436 | − _settings->setValue("firstRun",QVariant(false)); | |
| 453 | + SettingHandles::firstRun.set(false); | |
| 437 | 454 | } else { |
| 438 | 455 | // do this as late as possible so that all required subsystems are initialized |
| 439 | 456 | loadScripts(); |
| 440 | 457 | |
| 441 | − QMutexLocker locker(&_settingsMutex); | |
| 442 | − _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); | |
| 458 | + _previousScriptLocation = SettingHandles::lastScriptLocation.get(); | |
| 443 | 459 | } |
| 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 | + | |
| 445 | 471 | _trayIcon->show(); |
| 446 | 472 | |
| 447 | 473 | // set the local loopback interface for local sounds from audio scripts |
| @@ -462,12 +488,12 @@ void Application::aboutToQuit() { · 14 unmodified lines | ||
| 462 | 488 | } |
| 463 | 489 | |
| 464 | 490 | Application::~Application() { |
| 491 | + saveSettings(); | |
| 465 | 492 | |
| 466 | 493 | _entities.getTree()->setSimulation(NULL); |
| 467 | 494 | qInstallMessageHandler(NULL); |
| 468 | 495 | |
| 469 | − saveSettings(); | |
| 470 | − storeSizeAndPosition(); | |
| 496 | + _window->saveGeometry(); | |
| 471 | 497 | |
| 472 | 498 | int DELAY_TIME = 1000; |
| 473 | 499 | UserActivityLogger::getInstance().close(DELAY_TIME); |
| @@ -504,45 +530,6 @@ Application::~Application() { · 30 unmodified lines | ||
| 504 | 530 | DependencyManager::destroy<GLCanvas>(); |
| 505 | 531 | } |
| 506 | 532 | |
| 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 | − | |
| 546 | 533 | void Application::initializeGL() { |
| 547 | 534 | qDebug( "Created Display Window."); |
| 548 | 535 | |
| @@ -664,7 +651,7 @@ void Application::paintGL() { · 115 unmodified lines | ||
| 664 | 651 | _myCamera.update(1.0f / _fps); |
| 665 | 652 | } |
| 666 | 653 | |
| 667 | − if (Menu::getInstance()->getShadowsEnabled()) { | |
| 654 | + if (getShadowsEnabled()) { | |
| 668 | 655 | updateShadowMap(); |
| 669 | 656 | } |
| 670 | 657 | |
| @@ -720,6 +707,24 @@ void Application::paintGL() { · 49 unmodified lines | ||
| 720 | 707 | _frameCount++; |
| 721 | 708 | } |
| 722 | 709 | |
| 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 | + | |
| 723 | 728 | void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) { |
| 724 | 729 | if (OculusManager::isConnected()) { |
| 725 | 730 | OculusManager::configureCamera(camera, width, height); |
| @@ -727,7 +732,7 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) · 1 unmodified line | ||
| 727 | 732 | TV3DManager::configureCamera(camera, width, height); |
| 728 | 733 | } else { |
| 729 | 734 | camera.setAspectRatio((float)width / height); |
| 730 | − camera.setFieldOfView(Menu::getInstance()->getFieldOfView()); | |
| 735 | + camera.setFieldOfView(_viewFrustum.getFieldOfView()); | |
| 731 | 736 | } |
| 732 | 737 | } |
| 733 | 738 | |
| @@ -1450,10 +1455,6 @@ void Application::idle() { · 716 unmodified lines | ||
| 1450 | 1455 | |
| 1451 | 1456 | // After finishing all of the above work, restart the idle timer, allowing 2ms to process events. |
| 1452 | 1457 | idleTimer->start(2); |
| 1453 | − | |
| 1454 | − if (_numChangedSettings > 0) { | |
| 1455 | − saveSettings(); | |
| 1456 | − } | |
| 1457 | 1458 | } |
| 1458 | 1459 | } |
| 1459 | 1460 | } |
| @@ -1471,7 +1472,7 @@ void Application::checkBandwidthMeterClick() { · 11 unmodified lines | ||
| 1471 | 1472 | |
| 1472 | 1473 | // The bandwidth meter is visible, the click didn't get dragged too far and |
| 1473 | 1474 | // we actually hit the bandwidth meter |
| 1474 | − Menu::getInstance()->bandwidthDetails(); | |
| 1475 | + DependencyManager::get<DialogsManager>()->bandwidthDetails(); | |
| 1475 | 1476 | } |
| 1476 | 1477 | } |
| 1477 | 1478 | |
| @@ -1609,6 +1610,20 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa · 131 unmodified lines | ||
| 1609 | 1610 | return true; |
| 1610 | 1611 | } |
| 1611 | 1612 | |
| 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 | + | |
| 1612 | 1627 | bool Application::importEntities(const QString& filename) { |
| 1613 | 1628 | _entityClipboard.eraseAllOctreeElements(); |
| 1614 | 1629 | bool success = _entityClipboard.readFromSVOFile(filename.toLocal8Bit().constData()); |
| @@ -1659,8 +1674,6 @@ void Application::init() { · 44 unmodified lines | ||
| 1659 | 1674 | |
| 1660 | 1675 | _timerStart.start(); |
| 1661 | 1676 | _lastTimeUpdated.start(); |
| 1662 | − | |
| 1663 | − Menu::getInstance()->loadSettings(); | |
| 1664 | 1677 | |
| 1665 | 1678 | // when --url in command line, teleport to location |
| 1666 | 1679 | const QString HIFI_URL_COMMAND_LINE_KEY = "--url"; |
| @@ -1678,11 +1691,11 @@ void Application::init() { · 11 unmodified lines | ||
| 1678 | 1691 | if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseEnabled)) { |
| 1679 | 1692 | // on OS X we only setup sixense if the user wants it on - this allows running without the hid_init crash |
| 1680 | 1693 | // if hydra support is temporarily not required |
| 1681 | − Menu::getInstance()->toggleSixense(true); | |
| 1694 | + SixenseManager::getInstance().toggleSixense(true); | |
| 1682 | 1695 | } |
| 1683 | 1696 | #else |
| 1684 | 1697 | // setup sixense |
| 1685 | − Menu::getInstance()->toggleSixense(true); | |
| 1698 | + SixenseManager::getInstance().toggleSixense(true); | |
| 1686 | 1699 | #endif |
| 1687 | 1700 | |
| 1688 | 1701 | // initialize our face trackers after loading the menu settings |
| @@ -1721,16 +1734,13 @@ void Application::init() { · 32 unmodified lines | ||
| 1721 | 1734 | _metavoxels.init(); |
| 1722 | 1735 | |
| 1723 | 1736 | auto glCanvas = DependencyManager::get<GLCanvas>(); |
| 1724 | − _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect, _settings); | |
| 1737 | + _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect); | |
| 1725 | 1738 | |
| 1726 | 1739 | connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); |
| 1727 | 1740 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| 1728 | 1741 | connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); |
| 1729 | 1742 | connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); |
| 1730 | 1743 | |
| 1731 | − // save settings when avatar changes | |
| 1732 | − connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings); | |
| 1733 | − | |
| 1734 | 1744 | // make sure our texture cache knows about window size changes |
| 1735 | 1745 | DependencyManager::get<TextureCache>()->associateWithWidget(glCanvas.data()); |
| 1736 | 1746 | |
| @@ -1772,9 +1782,9 @@ void Application::updateLOD() { · 35 unmodified lines | ||
| 1772 | 1782 | PerformanceTimer perfTimer("LOD"); |
| 1773 | 1783 | // adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode |
| 1774 | 1784 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableAutoAdjustLOD) && !isThrottleRendering()) { |
| 1775 | − Menu::getInstance()->autoAdjustLOD(_fps); | |
| 1785 | + DependencyManager::get<LODManager>()->autoAdjustLOD(_fps); | |
| 1776 | 1786 | } else { |
| 1777 | − Menu::getInstance()->resetLODAdjust(); | |
| 1787 | + DependencyManager::get<LODManager>()->resetLODAdjust(); | |
| 1778 | 1788 | } |
| 1779 | 1789 | } |
| 1780 | 1790 | |
| @@ -1891,7 +1901,7 @@ void Application::updateMyAvatarLookAtPosition() { · 110 unmodified lines | ||
| 1891 | 1901 | // deflect using Faceshift gaze data |
| 1892 | 1902 | glm::vec3 origin = _myAvatar->getHead()->getEyePosition(); |
| 1893 | 1903 | float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; |
| 1894 | − float deflection = Menu::getInstance()->getFaceshiftEyeDeflection(); | |
| 1904 | + float deflection = DependencyManager::get<Faceshift>()->getEyeDeflection(); | |
| 1895 | 1905 | if (isLookingAtSomeone) { |
| 1896 | 1906 | deflection *= GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT; |
| 1897 | 1907 | } |
| @@ -1963,14 +1973,15 @@ void Application::updateDialogs(float deltaTime) { · 65 unmodified lines | ||
| 1963 | 1973 | PerformanceTimer perfTimer("updateDialogs"); |
| 1964 | 1974 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1965 | 1975 | PerformanceWarning warn(showWarnings, "Application::updateDialogs()"); |
| 1966 | − | |
| 1976 | + auto dialogsManager = DependencyManager::get<DialogsManager>(); | |
| 1977 | + | |
| 1967 | 1978 | // Update bandwidth dialog, if any |
| 1968 | − BandwidthDialog* bandwidthDialog = Menu::getInstance()->getBandwidthDialog(); | |
| 1979 | + BandwidthDialog* bandwidthDialog = dialogsManager->getBandwidthDialog(); | |
| 1969 | 1980 | if (bandwidthDialog) { |
| 1970 | 1981 | bandwidthDialog->update(); |
| 1971 | 1982 | } |
| 1972 | 1983 | |
| 1973 | − OctreeStatsDialog* octreeStatsDialog = Menu::getInstance()->getOctreeStatsDialog(); | |
| 1984 | + QPointer<OctreeStatsDialog> octreeStatsDialog = dialogsManager->getOctreeStatsDialog(); | |
| 1974 | 1985 | if (octreeStatsDialog) { |
| 1975 | 1986 | octreeStatsDialog->update(); |
| 1976 | 1987 | } |
| @@ -2241,8 +2252,9 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 264 unmodified lines | ||
| 2241 | 2252 | _octreeQuery.setCameraNearClip(_viewFrustum.getNearClip()); |
| 2242 | 2253 | _octreeQuery.setCameraFarClip(_viewFrustum.getFarClip()); |
| 2243 | 2254 | _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()); | |
| 2246 | 2258 | |
| 2247 | 2259 | unsigned char queryPacket[MAX_PACKET_SIZE]; |
| 2248 | 2260 | |
| @@ -2294,7 +2306,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 45 unmodified lines | ||
| 2294 | 2306 | int perServerPPS = 0; |
| 2295 | 2307 | const int SMALL_BUDGET = 10; |
| 2296 | 2308 | int perUnknownServer = SMALL_BUDGET; |
| 2297 | − int totalPPS = Menu::getInstance()->getMaxOctreePacketsPerSecond(); | |
| 2309 | + int totalPPS = _octreeQuery.getMaxOctreePacketsPerSecond(); | |
| 2298 | 2310 | |
| 2299 | 2311 | // determine PPS based on number of servers |
| 2300 | 2312 | if (inViewServers >= 1) { |
| @@ -2415,7 +2427,7 @@ QRect Application::getDesirableApplicationGeometry() { · 114 unmodified lines | ||
| 2415 | 2427 | |
| 2416 | 2428 | // If our parent window is on the HMD, then don't use it's geometry, instead use |
| 2417 | 2429 | // the "main screen" geometry. |
| 2418 | − HMDToolsDialog* hmdTools = Menu::getInstance()->getHMDToolsDialog(); | |
| 2430 | + HMDToolsDialog* hmdTools = DependencyManager::get<DialogsManager>()->getHMDToolsDialog(); | |
| 2419 | 2431 | if (hmdTools && hmdTools->hasHMDScreen()) { |
| 2420 | 2432 | QScreen* hmdScreen = hmdTools->getHMDScreen(); |
| 2421 | 2433 | QWindow* appWindow = getWindow()->windowHandle(); |
| @@ -2640,15 +2652,15 @@ void Application::setupWorldLight() { · 218 unmodified lines | ||
| 2640 | 2652 | } |
| 2641 | 2653 | |
| 2642 | 2654 | bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) { |
| 2643 | − return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera); | |
| 2655 | + return DependencyManager::get<LODManager>()->shouldRenderMesh(largestDimension, distanceToCamera); | |
| 2644 | 2656 | } |
| 2645 | 2657 | |
| 2646 | 2658 | float Application::getSizeScale() const { |
| 2647 | − return Menu::getInstance()->getOctreeSizeScale(); | |
| 2659 | + return DependencyManager::get<LODManager>()->getOctreeSizeScale(); | |
| 2648 | 2660 | } |
| 2649 | 2661 | |
| 2650 | 2662 | int Application::getBoundaryLevelAdjust() const { |
| 2651 | − return Menu::getInstance()->getBoundaryLevelAdjust(); | |
| 2663 | + return DependencyManager::get<LODManager>()->getBoundaryLevelAdjust(); | |
| 2652 | 2664 | } |
| 2653 | 2665 | |
| 2654 | 2666 | PickRay Application::computePickRay(float x, float y) { |
| @@ -2944,8 +2956,10 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 289 unmodified lines | ||
| 2944 | 2956 | } |
| 2945 | 2957 | } |
| 2946 | 2958 | |
| 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); | |
| 2949 | 2963 | } |
| 2950 | 2964 | |
| 2951 | 2965 | bool Application::getCascadeShadowsEnabled() { |
| @@ -2990,7 +3004,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 38 unmodified lines | ||
| 2990 | 3004 | _mirrorCamera.setPosition(_myAvatar->getPosition() + |
| 2991 | 3005 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale()); |
| 2992 | 3006 | |
| 2993 | − } else if (_rearMirrorTools->getZoomLevel() == BODY) { | |
| 3007 | + } else if (SettingHandles::rearViewZoomLevel.get() == BODY) { | |
| 2994 | 3008 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees |
| 2995 | 3009 | _mirrorCamera.setPosition(_myAvatar->getChestPosition() + |
| 2996 | 3010 | _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 | ||
| 3387 | 3401 | _bandwidthMeter.outputStream(BandwidthMeter::OCTREE).updateValue(length); |
| 3388 | 3402 | } |
| 3389 | 3403 | |
| 3404 | +const QString SETTINGS_KEY = "Settings"; | |
| 3405 | + | |
| 3390 | 3406 | void Application::loadScripts() { |
| 3391 | 3407 | // loads all saved scripts |
| 3392 | − int size = lockSettings()->beginReadArray("Settings"); | |
| 3393 | − unlockSettings(); | |
| 3408 | + Settings settings; | |
| 3409 | + int size = settings.beginReadArray(SETTINGS_KEY); | |
| 3394 | 3410 | 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(); | |
| 3398 | 3413 | if (!string.isEmpty()) { |
| 3399 | 3414 | loadScript(string); |
| 3400 | 3415 | } |
| 3401 | 3416 | } |
| 3402 | − | |
| 3403 | − QMutexLocker locker(&_settingsMutex); | |
| 3404 | − _settings->endArray(); | |
| 3417 | + settings.endArray(); | |
| 3405 | 3418 | } |
| 3406 | 3419 | |
| 3407 | 3420 | void Application::clearScriptsBeforeRunning() { |
| 3408 | 3421 | // clears all scripts from the settings |
| 3409 | − QMutexLocker locker(&_settingsMutex); | |
| 3410 | − _settings->remove("Settings"); | |
| 3422 | + SettingHandles::SettingHandle<QVariant>(SETTINGS_KEY).remove(); | |
| 3411 | 3423 | } |
| 3412 | 3424 | |
| 3413 | 3425 | void Application::saveScripts() { |
| 3414 | − // Saves all currently running user-loaded scripts | |
| 3415 | − QMutexLocker locker(&_settingsMutex); | |
| 3416 | − _settings->beginWriteArray("Settings"); | |
| 3417 | − | |
| 3418 | 3426 | 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); | |
| 3419 | 3434 | 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) { | |
| 3421 | 3436 | 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; | |
| 3425 | 3440 | } |
| 3426 | 3441 | } |
| 3427 | − | |
| 3428 | − _settings->endArray(); | |
| 3442 | + settings.endArray(); | |
| 3429 | 3443 | } |
| 3430 | 3444 | |
| 3431 | 3445 | QScriptValue joystickToScriptValue(QScriptEngine *engine, Joystick* const &in) { |
| @@ -3452,7 +3466,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 20 unmodified lines | ||
| 3452 | 3466 | scriptEngine->registerGlobalObject("Camera", &_myCamera); |
| 3453 | 3467 | |
| 3454 | 3468 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) |
| 3455 | − scriptEngine->registerGlobalObject("SpeechRecognizer", Menu::getInstance()->getSpeechRecognizer()); | |
| 3469 | + scriptEngine->registerGlobalObject("SpeechRecognizer", DependencyManager::get<SpeechRecognizer>().data()); | |
| 3456 | 3470 | #endif |
| 3457 | 3471 | |
| 3458 | 3472 | ClipboardScriptingInterface* clipboardScriptable = new ClipboardScriptingInterface(); |
| @@ -3552,7 +3566,6 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 93 unmodified lines | ||
| 3552 | 3566 | if (activateMainWindow && !loadScriptFromEditor) { |
| 3553 | 3567 | _window->activateWindow(); |
| 3554 | 3568 | } |
| 3555 | − bumpSettings(); | |
| 3556 | 3569 | |
| 3557 | 3570 | return scriptEngine; |
| 3558 | 3571 | } |
| @@ -3580,7 +3593,6 @@ void Application::scriptFinished(const QString& scriptName) { · 21 unmodified lines | ||
| 3580 | 3593 | _scriptEnginesHash.erase(it); |
| 3581 | 3594 | _runningScriptsWidget->scriptStopped(scriptName); |
| 3582 | 3595 | _runningScriptsWidget->setRunningScripts(getRunningScripts()); |
| 3583 | − bumpSettings(); | |
| 3584 | 3596 | } |
| 3585 | 3597 | } |
| 3586 | 3598 | |
| @@ -3676,7 +3688,6 @@ void Application::openUrl(const QUrl& url) { · 89 unmodified lines | ||
| 3676 | 3688 | } |
| 3677 | 3689 | |
| 3678 | 3690 | void Application::updateMyAvatarTransform() { |
| 3679 | − bumpSettings(); | |
| 3680 | 3691 | const float SIMULATION_OFFSET_QUANTIZATION = 16.0f; // meters |
| 3681 | 3692 | glm::vec3 avatarPosition = _myAvatar->getPosition(); |
| 3682 | 3693 | glm::vec3 physicsWorldOffset = _physicsEngine.getOriginOffset(); |
| @@ -3693,7 +3704,6 @@ void Application::updateMyAvatarTransform() { · 10 unmodified lines | ||
| 3693 | 3704 | } |
| 3694 | 3705 | |
| 3695 | 3706 | void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject) { |
| 3696 | − | |
| 3697 | 3707 | // from the domain-handler, figure out the satoshi cost per voxel and per meter cubed |
| 3698 | 3708 | const QString VOXEL_SETTINGS_KEY = "voxels"; |
| 3699 | 3709 | const QString PER_VOXEL_COST_KEY = "per-voxel-credits"; |
| @@ -3736,9 +3746,7 @@ QString Application::getPreviousScriptLocation() { · 36 unmodified lines | ||
| 3736 | 3746 | |
| 3737 | 3747 | void Application::setPreviousScriptLocation(const QString& previousScriptLocation) { |
| 3738 | 3748 | _previousScriptLocation = previousScriptLocation; |
| 3739 | − QMutexLocker locker(&_settingsMutex); | |
| 3740 | − _settings->setValue("LastScriptLocation", _previousScriptLocation); | |
| 3741 | − bumpSettings(); | |
| 3749 | + SettingHandles::lastScriptLocation.set(_previousScriptLocation); | |
| 3742 | 3750 | } |
| 3743 | 3751 | |
| 3744 | 3752 | void Application::loadDialog() { |
| @@ -3754,7 +3762,6 @@ void Application::loadDialog() { · 9 unmodified lines | ||
| 3754 | 3762 | } |
| 3755 | 3763 | |
| 3756 | 3764 | void Application::loadScriptURLDialog() { |
| 3757 | − | |
| 3758 | 3765 | QInputDialog scriptURLDialog(Application::getInstance()->getWindow()); |
| 3759 | 3766 | scriptURLDialog.setWindowTitle("Open and Run Script URL"); |
| 3760 | 3767 | scriptURLDialog.setLabelText("Script:"); |
| @@ -3772,11 +3779,16 @@ void Application::loadScriptURLDialog() { · 11 unmodified lines | ||
| 3772 | 3779 | } |
| 3773 | 3780 | loadScript(newScript); |
| 3774 | 3781 | } |
| 3775 | − | |
| 3776 | − sendFakeEnterEvent(); | |
| 3777 | 3782 | } |
| 3778 | 3783 | |
| 3784 | +QString Application::getScriptsLocation() const { | |
| 3785 | + return SettingHandles::scriptsLocation.get(); | |
| 3786 | +} | |
| 3779 | 3787 | |
| 3788 | +void Application::setScriptsLocation(const QString& scriptsLocation) { | |
| 3789 | + SettingHandles::scriptsLocation.set(scriptsLocation); | |
| 3790 | + emit scriptLocationChanged(scriptsLocation); | |
| 3791 | +} | |
| 3780 | 3792 | |
| 3781 | 3793 | void Application::toggleLogDialog() { |
| 3782 | 3794 | if (! _logDialog) { |
| @@ -3878,7 +3890,8 @@ void Application::takeSnapshot() { · 95 unmodified lines | ||
| 3878 | 3890 | _snapshotShareDialog->show(); |
| 3879 | 3891 | } |
| 3880 | 3892 | |
| 3881 | −void Application::setVSyncEnabled(bool vsyncOn) { | |
| 3893 | +void Application::setVSyncEnabled() { | |
| 3894 | + bool vsyncOn = Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerateVSyncOn); | |
| 3882 | 3895 | #if defined(Q_OS_WIN) |
| 3883 | 3896 | if (wglewGetExtension("WGL_EXT_swap_control")) { |
| 3884 | 3897 | wglSwapIntervalEXT(vsyncOn); |
| @@ -3902,6 +3915,7 @@ void Application::setVSyncEnabled(bool vsyncOn) { · 17 unmodified lines | ||
| 3902 | 3915 | #else |
| 3903 | 3916 | qDebug("V-Sync is FORCED ON on this system\n"); |
| 3904 | 3917 | #endif |
| 3918 | + vsyncOn = true; // Turns off unused variable warning | |
| 3905 | 3919 | } |
| 3906 | 3920 | |
| 3907 | 3921 | bool Application::isVSyncOn() const { |