Showing the changes to interface/src/Application.cpp (1 of 3 files). Show all
Unified · Split
| @@ -73,7 +73,7 @@ · 72 unmodified lines | |||
| 73 | #include <PhysicsEngine.h> | 73 | #include <PhysicsEngine.h> |
| 74 | #include <ProgramObject.h> | 74 | #include <ProgramObject.h> |
| 75 | #include <ResourceCache.h> | 75 | #include <ResourceCache.h> |
| 76 | #include <Settings.h> | 76 | #include <SettingHandle.h> |
| 77 | #include <SoundCache.h> | 77 | #include <SoundCache.h> |
| 78 | #include <TextRenderer.h> | 78 | #include <TextRenderer.h> |
| 79 | #include <UserActivityLogger.h> | 79 | #include <UserActivityLogger.h> |
| @@ -146,12 +146,6 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D · 66 unmodified lines | |||
| 146 | 146 | ||
| 147 | const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js"; | 147 | const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js"; |
| 148 | 148 | ||
| 149 | namespace SettingHandles { | ||
| 150 | const SettingHandle<bool> firstRun("firstRun", true); | ||
| 151 | const SettingHandle<QString> lastScriptLocation("LastScriptLocation"); | ||
| 152 | const SettingHandle<QString> scriptsLocation("scriptsLocation"); | ||
| 153 | } | ||
| 154 | |||
| 155 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { | 149 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { |
| 156 | QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message); | 150 | QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message); |
| 157 | 151 | ||
| @@ -200,7 +194,6 @@ bool setupEssentials(int& argc, char** argv) { · 42 unmodified lines | |||
| 200 | return true; | 194 | return true; |
| 201 | } | 195 | } |
| 202 | 196 | ||
| 203 | |||
| 204 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : | 197 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : |
| 205 | QApplication(argc, argv), | 198 | QApplication(argc, argv), |
| 206 | _dependencyManagerIsSetup(setupEssentials(argc, argv)), | 199 | _dependencyManagerIsSetup(setupEssentials(argc, argv)), |
| @@ -221,6 +214,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 14 unmodified lines | |||
| 221 | _lastQueriedViewFrustum(), | 214 | _lastQueriedViewFrustum(), |
| 222 | _lastQueriedTime(usecTimestampNow()), | 215 | _lastQueriedTime(usecTimestampNow()), |
| 223 | _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), | 216 | _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), |
| 217 | _firstRun("firstRun", true), | ||
| 218 | _previousScriptLocation("LastScriptLocation"), | ||
| 219 | _scriptsLocationHandle("scriptsLocation"), | ||
| 220 | _fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES), | ||
| 224 | _viewTransform(), | 221 | _viewTransform(), |
| 225 | _scaleMirror(1.0f), | 222 | _scaleMirror(1.0f), |
| 226 | _rotateMirror(0.0f), | 223 | _rotateMirror(0.0f), |
| @@ -238,7 +235,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 11 unmodified lines | |||
| 238 | _inBytesPerSecond(0), | 235 | _inBytesPerSecond(0), |
| 239 | _outBytesPerSecond(0), | 236 | _outBytesPerSecond(0), |
| 240 | _nodeBoundsDisplay(this), | 237 | _nodeBoundsDisplay(this), |
| 241 | _previousScriptLocation(), | ||
| 242 | _applicationOverlay(), | 238 | _applicationOverlay(), |
| 243 | _runningScriptsWidget(NULL), | 239 | _runningScriptsWidget(NULL), |
| 244 | _runningScriptsWidgetWasVisible(false), | 240 | _runningScriptsWidgetWasVisible(false), |
| @@ -428,19 +424,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 183 unmodified lines | |||
| 428 | connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); | 424 | connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); |
| 429 | 425 | ||
| 430 | // check first run... | 426 | // check first run... |
| 431 | bool firstRun = SettingHandles::firstRun.get(); | 427 | if (_firstRun.get()) { |
| 432 | if (firstRun) { | ||
| 433 | qDebug() << "This is a first run..."; | 428 | qDebug() << "This is a first run..."; |
| 434 | // clear the scripts, and set out script to our default scripts | 429 | // clear the scripts, and set out script to our default scripts |
| 435 | clearScriptsBeforeRunning(); | 430 | clearScriptsBeforeRunning(); |
| 436 | loadScript(DEFAULT_SCRIPTS_JS_URL); | 431 | loadScript(DEFAULT_SCRIPTS_JS_URL); |
| 437 | 432 | ||
| 438 | SettingHandles::firstRun.set(false); | 433 | _firstRun.set(false); |
| 439 | } else { | 434 | } else { |
| 440 | // do this as late as possible so that all required subsystems are initialized | 435 | // do this as late as possible so that all required subsystems are initialized |
| 441 | loadScripts(); | 436 | loadScripts(); |
| 442 | |||
| 443 | _previousScriptLocation = SettingHandles::lastScriptLocation.get(); | ||
| 444 | } | 437 | } |
| 445 | 438 | ||
| 446 | loadSettings(); | 439 | loadSettings(); |
| @@ -717,7 +710,7 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) · 270 unmodified lines | |||
| 717 | TV3DManager::configureCamera(camera, width, height); | 710 | TV3DManager::configureCamera(camera, width, height); |
| 718 | } else { | 711 | } else { |
| 719 | camera.setAspectRatio((float)width / height); | 712 | camera.setAspectRatio((float)width / height); |
| 720 | camera.setFieldOfView(_viewFrustum.getFieldOfView()); | 713 | camera.setFieldOfView(_fieldOfView.get()); |
| 721 | } | 714 | } |
| 722 | } | 715 | } |
| 723 | 716 | ||
| @@ -2974,7 +2967,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 2250 unmodified lines | |||
| 2974 | _mirrorCamera.setPosition(_myAvatar->getPosition() + | 2967 | _mirrorCamera.setPosition(_myAvatar->getPosition() + |
| 2975 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale()); | 2968 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale()); |
| 2976 | 2969 | ||
| 2977 | } else if (SettingHandles::rearViewZoomLevel.get() == BODY) { | 2970 | } else if (RearMirrorTools::rearViewZoomLevel.get() == BODY) { |
| 2978 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees | 2971 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees |
| 2979 | _mirrorCamera.setPosition(_myAvatar->getChestPosition() + | 2972 | _mirrorCamera.setPosition(_myAvatar->getChestPosition() + |
| 2980 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale()); | 2973 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale()); |
| @@ -3704,21 +3697,20 @@ void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject · 723 unmodified lines | |||
| 3704 | 3697 | ||
| 3705 | QString Application::getPreviousScriptLocation() { | 3698 | QString Application::getPreviousScriptLocation() { |
| 3706 | QString suggestedName; | 3699 | QString suggestedName; |
| 3707 | if (_previousScriptLocation.isEmpty()) { | 3700 | if (_previousScriptLocation.get().isEmpty()) { |
| 3708 | QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); | 3701 | QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); |
| 3709 | // Temporary fix to Qt bug: http://stackoverflow.com/questions/16194475 | 3702 | // Temporary fix to Qt bug: http://stackoverflow.com/questions/16194475 |
| 3710 | #ifdef __APPLE__ | 3703 | #ifdef __APPLE__ |
| 3711 | suggestedName = desktopLocation.append("/script.js"); | 3704 | suggestedName = desktopLocation.append("/script.js"); |
| 3712 | #endif | 3705 | #endif |
| 3713 | } else { | 3706 | } else { |
| 3714 | suggestedName = _previousScriptLocation; | 3707 | suggestedName = _previousScriptLocation.get(); |
| 3715 | } | 3708 | } |
| 3716 | return suggestedName; | 3709 | return suggestedName; |
| 3717 | } | 3710 | } |
| 3718 | 3711 | ||
| 3719 | void Application::setPreviousScriptLocation(const QString& previousScriptLocation) { | 3712 | void Application::setPreviousScriptLocation(const QString& previousScriptLocation) { |
| 3720 | _previousScriptLocation = previousScriptLocation; | 3713 | _previousScriptLocation.set(previousScriptLocation); |
| 3721 | SettingHandles::lastScriptLocation.set(_previousScriptLocation); | ||
| 3722 | } | 3714 | } |
| 3723 | 3715 | ||
| 3724 | void Application::loadDialog() { | 3716 | void Application::loadDialog() { |
| @@ -3753,12 +3745,12 @@ void Application::loadScriptURLDialog() { · 28 unmodified lines | |||
| 3753 | } | 3745 | } |
| 3754 | } | 3746 | } |
| 3755 | 3747 | ||
| 3756 | QString Application::getScriptsLocation() const { | 3748 | QString Application::getScriptsLocation() { |
| 3757 | return SettingHandles::scriptsLocation.get(); | 3749 | return _scriptsLocationHandle.get(); |
| 3758 | } | 3750 | } |
| 3759 | 3751 | ||
| 3760 | void Application::setScriptsLocation(const QString& scriptsLocation) { | 3752 | void Application::setScriptsLocation(const QString& scriptsLocation) { |
| 3761 | SettingHandles::scriptsLocation.set(scriptsLocation); | 3753 | _scriptsLocationHandle.set(scriptsLocation); |
| 3762 | emit scriptLocationChanged(scriptsLocation); | 3754 | emit scriptLocationChanged(scriptsLocation); |
| 3763 | } | 3755 | } |
| 3764 | 3756 | ||