History

Merge branch 'master' into menu-updates

vladest committed 8 years ago

Commit 3296ae02 parents e1222dd bc4ce12219 files · +7872 −1536Browse files

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

Unified · Split

interface/src/Application.cpp+93−41
@@ -688,6 +688,34 @@ private: · 687 unmodified lines
688688 }
689689 };
690690
691+/**jsdoc
692+ * <p>The <code>Controller.Hardware.Application</code> object has properties representing Interface's state. The property
693+ * values are integer IDs, uniquely identifying each output. <em>Read-only.</em> These can be mapped to actions or functions or
694+ * <code>Controller.Standard</code> items in a {@link RouteObject} mapping (e.g., using the {@link RouteObject#when} method).
695+ * Each data value is either <code>1.0</code> for "true" or <code>0.0</code> for "false".</p>
696+ * <table>
697+ * <thead>
698+ * <tr><th>Property</th><th>Type</th><th>Data</th><th>Description</th></tr>
699+ * </thead>
700+ * <tbody>
701+ * <tr><td><code>CameraFirstPerson</code></td><td>number</td><td>number</td><td>The camera is in first-person mode.
702+ * </td></tr>
703+ * <tr><td><code>CameraThirdPerson</code></td><td>number</td><td>number</td><td>The camera is in third-person mode.
704+ * </td></tr>
705+ * <tr><td><code>CameraFSM</code></td><td>number</td><td>number</td><td>The camera is in full screen mirror mode.</td></tr>
706+ * <tr><td><code>CameraIndependent</code></td><td>number</td><td>number</td><td>The camera is in independent mode.</td></tr>
707+ * <tr><td><code>CameraEntity</code></td><td>number</td><td>number</td><td>The camera is in entity mode.</td></tr>
708+ * <tr><td><code>InHMD</code></td><td>number</td><td>number</td><td>The user is in HMD mode.</td></tr>
709+ * <tr><td><code>AdvancedMovement</code></td><td>number</td><td>number</td><td>Advanced movement controls are enabled.
710+ * </td></tr>
711+ * <tr><td><code>SnapTurn</code></td><td>number</td><td>number</td><td>Snap turn is enabled.</td></tr>
712+ * <tr><td><code>Grounded</code></td><td>number</td><td>number</td><td>The user's avatar is on the ground.</td></tr>
713+ * <tr><td><code>NavigationFocused</code></td><td>number</td><td>number</td><td><em>Not used.</em></td></tr>
714+ * </tbody>
715+ * </table>
716+ * @typedef Controller.Hardware-Application
717+ */
718+
691719 static const QString STATE_IN_HMD = "InHMD";
692720 static const QString STATE_CAMERA_FULL_SCREEN_MIRROR = "CameraFSM";
693721 static const QString STATE_CAMERA_FIRST_PERSON = "CameraFirstPerson";
@@ -1294,49 +1322,48 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 600 unmodified lines
12941322 // Make sure we don't time out during slow operations at startup
12951323 updateHeartbeat();
12961324
1297− // sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value.
1298− // The value will be 0 if the user blew away settings this session, which is both a feature and a bug.
1299− static const QString TESTER = "HIFI_TESTER";
1300− auto gpuIdent = GPUIdent::getInstance();
1301− auto glContextData = getGLContextData();
1302− QJsonObject properties = {
1303− { "version", applicationVersion() },
1304− { "tester", QProcessEnvironment::systemEnvironment().contains(TESTER) },
1305− { "previousSessionCrashed", _previousSessionCrashed },
1306− { "previousSessionRuntime", sessionRunTime.get() },
1307− { "cpu_architecture", QSysInfo::currentCpuArchitecture() },
1308− { "kernel_type", QSysInfo::kernelType() },
1309− { "kernel_version", QSysInfo::kernelVersion() },
1310− { "os_type", QSysInfo::productType() },
1311− { "os_version", QSysInfo::productVersion() },
1312− { "gpu_name", gpuIdent->getName() },
1313− { "gpu_driver", gpuIdent->getDriver() },
1314− { "gpu_memory", static_cast<qint64>(gpuIdent->getMemory()) },
1315− { "gl_version_int", glVersionToInteger(glContextData.value("version").toString()) },
1316− { "gl_version", glContextData["version"] },
1317− { "gl_vender", glContextData["vendor"] },
1318− { "gl_sl_version", glContextData["sl_version"] },
1319− { "gl_renderer", glContextData["renderer"] },
1320− { "ideal_thread_count", QThread::idealThreadCount() }
1321− };
1322− auto macVersion = QSysInfo::macVersion();
1323− if (macVersion != QSysInfo::MV_None) {
1324− properties["os_osx_version"] = QSysInfo::macVersion();
1325− }
1326− auto windowsVersion = QSysInfo::windowsVersion();
1327− if (windowsVersion != QSysInfo::WV_None) {
1328− properties["os_win_version"] = QSysInfo::windowsVersion();
1325+ constexpr auto INSTALLER_INI_NAME = "installer.ini";
1326+ auto iniPath = QDir(applicationDirPath()).filePath(INSTALLER_INI_NAME);
1327+ QFile installerFile { iniPath };
1328+ std::unordered_map<QString, QString> installerKeyValues;
1329+ if (installerFile.open(QIODevice::ReadOnly)) {
1330+ while (!installerFile.atEnd()) {
1331+ auto line = installerFile.readLine();
1332+ if (!line.isEmpty()) {
1333+ auto index = line.indexOf("=");
1334+ if (index >= 0) {
1335+ installerKeyValues[line.mid(0, index).trimmed()] = line.mid(index + 1).trimmed();
1336+ }
1337+ }
1338+ }
13291339 }
13301340
1331− ProcessorInfo procInfo;
1332− if (getProcessorInfo(procInfo)) {
1333− properties["processor_core_count"] = procInfo.numProcessorCores;
1334− properties["logical_processor_count"] = procInfo.numLogicalProcessors;
1335− properties["processor_l1_cache_count"] = procInfo.numProcessorCachesL1;
1336− properties["processor_l2_cache_count"] = procInfo.numProcessorCachesL2;
1337− properties["processor_l3_cache_count"] = procInfo.numProcessorCachesL3;
1341+ // In practice we shouldn't run across installs that don't have a known installer type.
1342+ // Client or Client+Server installs should always have the installer.ini next to their
1343+ // respective interface.exe, and Steam installs will be detected as such. If a user were
1344+ // to delete the installer.ini, though, and as an example, we won't know the context of the
1345+ // original install.
1346+ constexpr auto INSTALLER_KEY_TYPE = "type";
1347+ constexpr auto INSTALLER_KEY_CAMPAIGN = "campaign";
1348+ constexpr auto INSTALLER_TYPE_UNKNOWN = "unknown";
1349+ constexpr auto INSTALLER_TYPE_STEAM = "steam";
1350+
1351+ auto typeIt = installerKeyValues.find(INSTALLER_KEY_TYPE);
1352+ QString installerType = INSTALLER_TYPE_UNKNOWN;
1353+ if (typeIt == installerKeyValues.end()) {
1354+ if (property(hifi::properties::STEAM).toBool()) {
1355+ installerType = INSTALLER_TYPE_STEAM;
1356+ }
1357+ } else {
1358+ installerType = typeIt->second;
13381359 }
13391360
1361+ auto campaignIt = installerKeyValues.find(INSTALLER_KEY_CAMPAIGN);
1362+ QString installerCampaign = campaignIt != installerKeyValues.end() ? campaignIt->second : "";
1363+
1364+ qDebug() << "Detected installer type:" << installerType;
1365+ qDebug() << "Detected installer campaign:" << installerCampaign;
1366+
13401367 // add firstRun flag from settings to launch event
13411368 Setting::Handle<bool> firstRun { Settings::firstRun, true };
13421369
@@ -1358,6 +1385,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 15 unmodified lines
13581385 QJsonObject properties = {
13591386 { "version", applicationVersion() },
13601387 { "tester", QProcessEnvironment::systemEnvironment().contains(TESTER) },
1388+ { "installer_campaign", installerCampaign },
1389+ { "installer_type", installerType },
13611390 { "previousSessionCrashed", _previousSessionCrashed },
13621391 { "previousSessionRuntime", sessionRunTime.get() },
13631392 { "cpu_architecture", QSysInfo::currentCpuArchitecture() },
@@ -1677,7 +1706,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 313 unmodified lines
16771706 const QString HIFI_NO_UPDATER_COMMAND_LINE_KEY = "--no-updater";
16781707 bool noUpdater = arguments().indexOf(HIFI_NO_UPDATER_COMMAND_LINE_KEY) != -1;
16791708 if (!noUpdater) {
1709+ constexpr auto INSTALLER_TYPE_CLIENT_ONLY = "client_only";
1710+
16801711 auto applicationUpdater = DependencyManager::get<AutoUpdater>();
1712+
1713+ AutoUpdater::InstallerType type = installerType == INSTALLER_TYPE_CLIENT_ONLY
1714+ ? AutoUpdater::InstallerType::CLIENT_ONLY : AutoUpdater::InstallerType::FULL;
1715+
1716+ applicationUpdater->setInstallerType(type);
1717+ applicationUpdater->setInstallerCampaign(installerCampaign);
16811718 connect(applicationUpdater.data(), &AutoUpdater::newVersionIsAvailable, dialogsManager.data(), &DialogsManager::showUpdateDialog);
16821719 applicationUpdater->checkForUpdate();
16831720 }
@@ -2654,6 +2691,12 @@ void Application::initializeUi() { · 970 unmodified lines
26542691 // Now that the menu is instantiated, ensure the display plugin menu is properly updated
26552692 updateDisplayMode();
26562693 flushMenuUpdates();
2694+
2695+ // The display plugins are created before the menu now, so we need to do this here to hide the menu bar
2696+ // now that it exists
2697+ if (_window && _window->isFullScreen()) {
2698+ setFullscreen(nullptr, true);
2699+ }
26572700 }
26582701
26592702
@@ -4707,7 +4750,7 @@ void Application::updateLOD(float deltaTime) const { · 2047 unmodified lines
47074750 }
47084751 }
47094752
4710−void Application::pushPostUpdateLambda(void* key, std::function<void()> func) {
4753+void Application::pushPostUpdateLambda(void* key, const std::function<void()>& func) {
47114754 std::unique_lock<std::mutex> guard(_postUpdateLambdasLock);
47124755 _postUpdateLambdas[key] = func;
47134756 }
@@ -7308,7 +7351,7 @@ void Application::windowMinimizedChanged(bool minimized) { · 2594 unmodified lines
73087351 }
73097352 }
73107353
7311−void Application::postLambdaEvent(std::function<void()> f) {
7354+void Application::postLambdaEvent(const std::function<void()>& f) {
73127355 if (this->thread() == QThread::currentThread()) {
73137356 f();
73147357 } else {
@@ -7316,6 +7359,15 @@ void Application::postLambdaEvent(std::function<void()> f) { · 1 unmodified line
73167359 }
73177360 }
73187361
7362+void Application::sendLambdaEvent(const std::function<void()>& f) {
7363+ if (this->thread() == QThread::currentThread()) {
7364+ f();
7365+ } else {
7366+ LambdaEvent event(f);
7367+ QCoreApplication::sendEvent(this, &event);
7368+ }
7369+}
7370+
73197371 void Application::initPlugins(const QStringList& arguments) {
73207372 QCommandLineOption display("display", "Preferred displays", "displays");
73217373 QCommandLineOption disableDisplays("disable-displays", "Displays to disable", "displays");