Showing the changes to interface/src/Application.cpp (1 of 19 files). Show all
Unified · Split
| @@ -38,7 +38,6 @@ · 37 unmodified lines | |||
| 38 | #include <QObject> | 38 | #include <QObject> |
| 39 | #include <QWheelEvent> | 39 | #include <QWheelEvent> |
| 40 | #include <QScreen> | 40 | #include <QScreen> |
| 41 | #include <QSettings> | ||
| 42 | #include <QShortcut> | 41 | #include <QShortcut> |
| 43 | #include <QSystemTrayIcon> | 42 | #include <QSystemTrayIcon> |
| 44 | #include <QTimer> | 43 | #include <QTimer> |
| @@ -146,6 +145,12 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D · 101 unmodified lines | |||
| 146 | 145 | ||
| 147 | const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js"; | 146 | const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js"; |
| 148 | 147 | ||
| 148 | namespace SettingHandles { | ||
| 149 | const SettingHandle<bool> firstRun("firstRun", true); | ||
| 150 | const SettingHandle<QString> lastScriptLocation("LastScriptLocation"); | ||
| 151 | const SettingHandle<QString> scriptsLocation("scriptsLocation"); | ||
| 152 | } | ||
| 153 | |||
| 149 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { | 154 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { |
| 150 | QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message); | 155 | QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message); |
| 151 | 156 | ||
| @@ -428,21 +433,19 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 276 unmodified lines | |||
| 428 | connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); | 433 | connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); |
| 429 | 434 | ||
| 430 | // check first run... | 435 | // check first run... |
| 431 | Settings settings; | 436 | bool firstRun = SettingHandles::firstRun.get(); |
| 432 | QString firstRunKey = "firstRun"; | 437 | if (firstRun) { |
| 433 | QVariant firstRunValue = settings.value(firstRunKey, true); | ||
| 434 | if (firstRunValue.isValid() && firstRunValue.toBool()) { | ||
| 435 | qDebug() << "This is a first run..."; | 438 | qDebug() << "This is a first run..."; |
| 436 | // clear the scripts, and set out script to our default scripts | 439 | // clear the scripts, and set out script to our default scripts |
| 437 | clearScriptsBeforeRunning(); | 440 | clearScriptsBeforeRunning(); |
| 438 | loadScript(DEFAULT_SCRIPTS_JS_URL); | 441 | loadScript(DEFAULT_SCRIPTS_JS_URL); |
| 439 | 442 | ||
| 440 | settings.setValue(firstRunKey, false); | 443 | SettingHandles::firstRun.set(false); |
| 441 | } else { | 444 | } else { |
| 442 | // do this as late as possible so that all required subsystems are initialized | 445 | // do this as late as possible so that all required subsystems are initialized |
| 443 | loadScripts(); | 446 | loadScripts(); |
| 444 | 447 | ||
| 445 | _previousScriptLocation = settings.value("LastScriptLocation", "").toString(); | 448 | _previousScriptLocation = SettingHandles::lastScriptLocation.get(); |
| 446 | } | 449 | } |
| 447 | 450 | ||
| 448 | _trayIcon->show(); | 451 | _trayIcon->show(); |
| @@ -2968,7 +2971,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 2519 unmodified lines | |||
| 2968 | _mirrorCamera.setPosition(_myAvatar->getPosition() + | 2971 | _mirrorCamera.setPosition(_myAvatar->getPosition() + |
| 2969 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale()); | 2972 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale()); |
| 2970 | 2973 | ||
| 2971 | } else if (_rearMirrorTools->getZoomLevel() == BODY) { | 2974 | } else if (SettingHandles::rearViewZoomLevel.get() == BODY) { |
| 2972 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees | 2975 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees |
| 2973 | _mirrorCamera.setPosition(_myAvatar->getChestPosition() + | 2976 | _mirrorCamera.setPosition(_myAvatar->getChestPosition() + |
| 2974 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale()); | 2977 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale()); |
| @@ -3365,10 +3368,12 @@ void Application::packetSent(quint64 length) { · 390 unmodified lines | |||
| 3365 | _bandwidthMeter.outputStream(BandwidthMeter::OCTREE).updateValue(length); | 3368 | _bandwidthMeter.outputStream(BandwidthMeter::OCTREE).updateValue(length); |
| 3366 | } | 3369 | } |
| 3367 | 3370 | ||
| 3371 | const QString SETTINGS_KEY = "Settings"; | ||
| 3372 | |||
| 3368 | void Application::loadScripts() { | 3373 | void Application::loadScripts() { |
| 3369 | // loads all saved scripts | 3374 | // loads all saved scripts |
| 3370 | Settings settings; | 3375 | Settings settings; |
| 3371 | int size = settings.beginReadArray("Settings"); | 3376 | int size = settings.beginReadArray(SETTINGS_KEY); |
| 3372 | for (int i = 0; i < size; ++i){ | 3377 | for (int i = 0; i < size; ++i){ |
| 3373 | settings.setArrayIndex(i); | 3378 | settings.setArrayIndex(i); |
| 3374 | QString string = settings.value("script").toString(); | 3379 | QString string = settings.value("script").toString(); |
| @@ -3381,7 +3386,7 @@ void Application::loadScripts() { · 6 unmodified lines | |||
| 3381 | 3386 | ||
| 3382 | void Application::clearScriptsBeforeRunning() { | 3387 | void Application::clearScriptsBeforeRunning() { |
| 3383 | // clears all scripts from the settings | 3388 | // clears all scripts from the settings |
| 3384 | Settings().remove("Settings"); | 3389 | SettingHandles::SettingHandle<QVariant>(SETTINGS_KEY).remove(); |
| 3385 | } | 3390 | } |
| 3386 | 3391 | ||
| 3387 | void Application::saveScripts() { | 3392 | void Application::saveScripts() { |
| @@ -3392,7 +3397,7 @@ void Application::saveScripts() { · 4 unmodified lines | |||
| 3392 | 3397 | ||
| 3393 | // Saves all currently running user-loaded scripts | 3398 | // Saves all currently running user-loaded scripts |
| 3394 | Settings settings; | 3399 | Settings settings; |
| 3395 | settings.beginWriteArray("Settings"); | 3400 | settings.beginWriteArray(SETTINGS_KEY); |
| 3396 | int i = 0; | 3401 | int i = 0; |
| 3397 | for (auto it = runningScripts.begin(); it != runningScripts.end(); ++it) { | 3402 | for (auto it = runningScripts.begin(); it != runningScripts.end(); ++it) { |
| 3398 | if (getScriptEngine(*it)->isUserLoaded()) { | 3403 | if (getScriptEngine(*it)->isUserLoaded()) { |
| @@ -3708,7 +3713,7 @@ QString Application::getPreviousScriptLocation() { · 309 unmodified lines | |||
| 3708 | 3713 | ||
| 3709 | void Application::setPreviousScriptLocation(const QString& previousScriptLocation) { | 3714 | void Application::setPreviousScriptLocation(const QString& previousScriptLocation) { |
| 3710 | _previousScriptLocation = previousScriptLocation; | 3715 | _previousScriptLocation = previousScriptLocation; |
| 3711 | Settings().setValue("LastScriptLocation", _previousScriptLocation); | 3716 | SettingHandles::lastScriptLocation.set(_previousScriptLocation); |
| 3712 | } | 3717 | } |
| 3713 | 3718 | ||
| 3714 | void Application::loadDialog() { | 3719 | void Application::loadDialog() { |
| @@ -3744,11 +3749,11 @@ void Application::loadScriptURLDialog() { · 29 unmodified lines | |||
| 3744 | } | 3749 | } |
| 3745 | 3750 | ||
| 3746 | QString Application::getScriptsLocation() const { | 3751 | QString Application::getScriptsLocation() const { |
| 3747 | return Settings().value("scriptsLocation", QString()).toString(); | 3752 | return SettingHandles::scriptsLocation.get(); |
| 3748 | } | 3753 | } |
| 3749 | 3754 | ||
| 3750 | void Application::setScriptsLocation(const QString& scriptsLocation) { | 3755 | void Application::setScriptsLocation(const QString& scriptsLocation) { |
| 3751 | Settings().setValue("scriptsLocation", scriptsLocation); | 3756 | SettingHandles::scriptsLocation.set(scriptsLocation); |
| 3752 | emit scriptLocationChanged(scriptsLocation); | 3757 | emit scriptLocationChanged(scriptsLocation); |
| 3753 | } | 3758 | } |
| 3754 | 3759 | ||