mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 08:33:29 +02:00
Merge pull request #14650 from NissimHadar/20301-addPlatformInfo
Case 20301 - add platform info
This commit is contained in:
commit
9855e9bee8
11 changed files with 263 additions and 100 deletions
|
@ -170,6 +170,7 @@
|
|||
#include "scripting/Audio.h"
|
||||
#include "networking/CloseEventSender.h"
|
||||
#include "scripting/TestScriptingInterface.h"
|
||||
#include "scripting/PlatformInfoScriptingInterface.h"
|
||||
#include "scripting/AssetMappingsScriptingInterface.h"
|
||||
#include "scripting/ClipboardScriptingInterface.h"
|
||||
#include "scripting/DesktopScriptingInterface.h"
|
||||
|
@ -6988,6 +6989,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe
|
|||
scriptEngine->registerGlobalObject("Test", TestScriptingInterface::getInstance());
|
||||
}
|
||||
|
||||
scriptEngine->registerGlobalObject("PlatformInfo", PlatformInfoScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this));
|
||||
|
||||
// hook our avatar and avatar hash map object into this script engine
|
||||
|
@ -8705,6 +8707,14 @@ void Application::updateLoginDialogOverlayPosition() {
|
|||
}
|
||||
}
|
||||
|
||||
bool Application::hasRiftControllers() {
|
||||
return PluginUtils::isOculusTouchControllerAvailable();
|
||||
}
|
||||
|
||||
bool Application::hasViveControllers() {
|
||||
return PluginUtils::isViveControllerAvailable();
|
||||
}
|
||||
|
||||
void Application::onDismissedLoginDialog() {
|
||||
_loginDialogPoppedUp = false;
|
||||
loginDialogPoppedUp.set(false);
|
||||
|
@ -8923,6 +8933,10 @@ void Application::copyToClipboard(const QString& text) {
|
|||
QApplication::clipboard()->setText(text);
|
||||
}
|
||||
|
||||
QString Application::getGraphicsCardType() {
|
||||
return GPUIdent::getInstance()->getName();
|
||||
}
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
void Application::beforeEnterBackground() {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
|
|
@ -326,6 +326,10 @@ public:
|
|||
void createLoginDialogOverlay();
|
||||
void updateLoginDialogOverlayPosition();
|
||||
|
||||
// Check if a headset is connected
|
||||
bool hasRiftControllers();
|
||||
bool hasViveControllers();
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
void beforeEnterBackground();
|
||||
void enterBackground();
|
||||
|
@ -459,6 +463,8 @@ public slots:
|
|||
|
||||
void changeViewAsNeeded(float boomLength);
|
||||
|
||||
QString getGraphicsCardType();
|
||||
|
||||
private slots:
|
||||
void onDesktopRootItemCreated(QQuickItem* qmlContext);
|
||||
void onDesktopRootContextCreated(QQmlContext* qmlContext);
|
||||
|
@ -787,6 +793,5 @@ private:
|
|||
|
||||
bool _showTrackedObjects { false };
|
||||
bool _prevShowTrackedObjects { false };
|
||||
|
||||
};
|
||||
#endif // hifi_Application_h
|
||||
|
|
135
interface/src/scripting/PlatformInfoScriptingInterface.cpp
Normal file
135
interface/src/scripting/PlatformInfoScriptingInterface.cpp
Normal file
|
@ -0,0 +1,135 @@
|
|||
//
|
||||
// Created by Nissim Hadar on 2018/12/28
|
||||
// Copyright 2013-2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#include "PlatformInfoScriptingInterface.h"
|
||||
#include "Application.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <Windows.h>
|
||||
#elif defined Q_OS_MAC
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
PlatformInfoScriptingInterface* PlatformInfoScriptingInterface::getInstance() {
|
||||
static PlatformInfoScriptingInterface sharedInstance;
|
||||
return &sharedInstance;
|
||||
}
|
||||
|
||||
QString PlatformInfoScriptingInterface::getOperatingSystemType() {
|
||||
#ifdef Q_OS_WIN
|
||||
return "WINDOWS";
|
||||
#elif defined Q_OS_MAC
|
||||
return "MACOS";
|
||||
#else
|
||||
return "UNKNOWN";
|
||||
#endif
|
||||
}
|
||||
|
||||
QString PlatformInfoScriptingInterface::getCPUBrand() {
|
||||
#ifdef Q_OS_WIN
|
||||
int CPUInfo[4] = { -1 };
|
||||
unsigned nExIds, i = 0;
|
||||
char CPUBrandString[0x40];
|
||||
// Get the information associated with each extended ID.
|
||||
__cpuid(CPUInfo, 0x80000000);
|
||||
nExIds = CPUInfo[0];
|
||||
|
||||
for (i = 0x80000000; i <= nExIds; ++i) {
|
||||
__cpuid(CPUInfo, i);
|
||||
// Interpret CPU brand string
|
||||
if (i == 0x80000002) {
|
||||
memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
|
||||
} else if (i == 0x80000003) {
|
||||
memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo));
|
||||
} else if (i == 0x80000004) {
|
||||
memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
|
||||
}
|
||||
}
|
||||
|
||||
return CPUBrandString;
|
||||
#elif defined Q_OS_MAC
|
||||
FILE* stream = popen("sysctl -n machdep.cpu.brand_string", "r");
|
||||
|
||||
std::ostringstream hostStream;
|
||||
while (!feof(stream) && !ferror(stream)) {
|
||||
char buf[128];
|
||||
int bytesRead = fread(buf, 1, 128, stream);
|
||||
hostStream.write(buf, bytesRead);
|
||||
}
|
||||
|
||||
return QString::fromStdString(hostStream.str());
|
||||
#else
|
||||
return QString("NO IMPLEMENTED");
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned int PlatformInfoScriptingInterface::getNumLogicalCores() {
|
||||
|
||||
return std::thread::hardware_concurrency();
|
||||
}
|
||||
|
||||
int PlatformInfoScriptingInterface::getTotalSystemMemoryMB() {
|
||||
#ifdef Q_OS_WIN
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof (statex);
|
||||
GlobalMemoryStatusEx(&statex);
|
||||
return statex.ullTotalPhys / 1024 / 1024;
|
||||
#elif defined Q_OS_MAC
|
||||
FILE* stream = popen("sysctl -a | grep hw.memsize", "r");
|
||||
|
||||
std::ostringstream hostStream;
|
||||
while (!feof(stream) && !ferror(stream)) {
|
||||
char buf[128];
|
||||
int bytesRead = fread(buf, 1, 128, stream);
|
||||
hostStream.write(buf, bytesRead);
|
||||
}
|
||||
|
||||
QString result = QString::fromStdString(hostStream.str());
|
||||
QStringList parts = result.split(' ');
|
||||
return (int)(parts[1].toDouble() / 1024 / 1024);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
QString PlatformInfoScriptingInterface::getGraphicsCardType() {
|
||||
#ifdef Q_OS_WIN
|
||||
return qApp->getGraphicsCardType();
|
||||
#elif defined Q_OS_MAC
|
||||
FILE* stream = popen("system_profiler SPDisplaysDataType | grep Chipset", "r");
|
||||
|
||||
std::ostringstream hostStream;
|
||||
while (!feof(stream) && !ferror(stream)) {
|
||||
char buf[128];
|
||||
int bytesRead = fread(buf, 1, 128, stream);
|
||||
hostStream.write(buf, bytesRead);
|
||||
}
|
||||
|
||||
QString result = QString::fromStdString(hostStream.str());
|
||||
QStringList parts = result.split('\n');
|
||||
for (int i = 0; i < parts.size(); ++i) {
|
||||
if (parts[i].toLower().contains("radeon") || parts[i].toLower().contains("nvidia")) {
|
||||
return parts[i];
|
||||
}
|
||||
}
|
||||
|
||||
// unkown graphics card
|
||||
return "UNKNOWN";
|
||||
#else
|
||||
return QString("NO IMPLEMENTED");
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PlatformInfoScriptingInterface::hasRiftControllers() {
|
||||
return qApp->hasRiftControllers();
|
||||
}
|
||||
|
||||
bool PlatformInfoScriptingInterface::hasViveControllers() {
|
||||
return qApp->hasViveControllers();
|
||||
}
|
70
interface/src/scripting/PlatformInfoScriptingInterface.h
Normal file
70
interface/src/scripting/PlatformInfoScriptingInterface.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
//
|
||||
// Created by Nissim Hadar on 2018/12/28
|
||||
// Copyright 2013-2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_PlatformInfoScriptingInterface_h
|
||||
#define hifi_PlatformInfoScriptingInterface_h
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
class QScriptValue;
|
||||
|
||||
class PlatformInfoScriptingInterface : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
static PlatformInfoScriptingInterface* getInstance();
|
||||
|
||||
/**jsdoc
|
||||
* Returns the Operating Sytem type
|
||||
* @function Test.getOperatingSystemType
|
||||
* @returns {string} "WINDOWS", "MACOS" or "UNKNOWN"
|
||||
*/
|
||||
QString getOperatingSystemType();
|
||||
|
||||
/**jsdoc
|
||||
* Returns the CPU brand
|
||||
*function PlatformInfo.getCPUBrand()
|
||||
* @returns {string} brand of CPU
|
||||
*/
|
||||
QString getCPUBrand();
|
||||
|
||||
/**jsdoc
|
||||
* Returns the number of logical CPU cores
|
||||
*function PlatformInfo.getNumLogicalCores()
|
||||
* @returns {int} number of logical CPU cores
|
||||
*/
|
||||
unsigned int getNumLogicalCores();
|
||||
|
||||
/**jsdoc
|
||||
* Returns the total system memory in megabyte
|
||||
*function PlatformInfo.getTotalSystemMemory()
|
||||
* @returns {int} size of memory in megabytes
|
||||
*/
|
||||
int getTotalSystemMemoryMB();
|
||||
|
||||
/**jsdoc
|
||||
* Returns the graphics card type
|
||||
* @function Test.getGraphicsCardType
|
||||
* @returns {string} graphics card type
|
||||
*/
|
||||
QString getGraphicsCardType();
|
||||
|
||||
/**jsdoc
|
||||
* Returns true if Oculus Rift is connected (looks for hand controllers)
|
||||
* @function Window.hasRift
|
||||
* @returns {boolean} <code>true</code> if running on Windows, otherwise <code>false</code>.*/
|
||||
bool hasRiftControllers();
|
||||
|
||||
/**jsdoc
|
||||
* Returns true if HTC Vive is connected (looks for hand controllers)
|
||||
* @function Window.hasRift
|
||||
* @returns {boolean} <code>true</code> if running on Windows, otherwise <code>false</code>.*/
|
||||
bool hasViveControllers();
|
||||
};
|
||||
|
||||
#endif // hifi_PlatformInfoScriptingInterface_h
|
|
@ -469,12 +469,28 @@ void TestRunner::runInterfaceWithTestScript() {
|
|||
url = "hifi://localhost";
|
||||
}
|
||||
|
||||
QString deleteScript =
|
||||
QString("https://raw.githubusercontent.com/") + _user + "/hifi_tests/" + _branch + "/tests/utils/deleteNearbyEntities.js";
|
||||
|
||||
QString testScript =
|
||||
QString("https://raw.githubusercontent.com/") + _user + "/hifi_tests/" + _branch + "/tests/testRecursive.js";
|
||||
|
||||
QString commandLine;
|
||||
#ifdef Q_OS_WIN
|
||||
QString exeFile = QString("\"") + QDir::toNativeSeparators(_installationFolder) + "\\interface.exe\"";
|
||||
QString exeFile;
|
||||
// First, run script to delete any entities in test area
|
||||
// Note that this will run to completion before continuing
|
||||
exeFile = QString("\"") + QDir::toNativeSeparators(_installationFolder) + "\\interface.exe\"";
|
||||
commandLine = "start /wait \"\" " + exeFile +
|
||||
" --url " + url +
|
||||
" --no-updater" +
|
||||
" --no-login-suggestion"
|
||||
" --testScript " + deleteScript + " quitWhenFinished";
|
||||
|
||||
system(commandLine.toStdString().c_str());
|
||||
|
||||
// Now run the test suite
|
||||
exeFile = QString("\"") + QDir::toNativeSeparators(_installationFolder) + "\\interface.exe\"";
|
||||
commandLine = exeFile +
|
||||
" --url " + url +
|
||||
" --no-updater" +
|
||||
|
@ -485,10 +501,6 @@ void TestRunner::runInterfaceWithTestScript() {
|
|||
_interfaceWorker->setCommandLine(commandLine);
|
||||
emit startInterface();
|
||||
#elif defined Q_OS_MAC
|
||||
// On The Mac, we need to resize Interface. The Interface window opens a few seconds after the process
|
||||
// has started.
|
||||
// Before starting interface, start a process that will resize interface 10s after it opens
|
||||
// This is performed by creating a bash script that runs to processes
|
||||
QFile script;
|
||||
script.setFileName(_workingFolder + "/runInterfaceTests.sh");
|
||||
if (!script.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
|
@ -498,7 +510,20 @@ void TestRunner::runInterfaceWithTestScript() {
|
|||
}
|
||||
|
||||
script.write("#!/bin/sh\n\n");
|
||||
|
||||
|
||||
// First, run script to delete any entities in test area
|
||||
commandLine =
|
||||
"open -W \"" +_installationFolder + "/interface.app\" --args" +
|
||||
" --url " + url +
|
||||
" --no-updater" +
|
||||
" --no-login-suggestion"
|
||||
" --testScript " + deleteScript + " quitWhenFinished\n";
|
||||
|
||||
script.write(commandLine.toStdString().c_str());
|
||||
|
||||
// On The Mac, we need to resize Interface. The Interface window opens a few seconds after the process
|
||||
// has started.
|
||||
// Before starting interface, start a process that will resize interface 10s after it opens
|
||||
commandLine = _workingFolder +"/waitForStart.sh interface && sleep 10 && " + _workingFolder +"/setInterfaceSizeAndPosition.sh &\n";
|
||||
script.write(commandLine.toStdString().c_str());
|
||||
|
||||
|
@ -509,7 +534,7 @@ void TestRunner::runInterfaceWithTestScript() {
|
|||
" --no-login-suggestion"
|
||||
" --testScript " + testScript + " quitWhenFinished" +
|
||||
" --testResultsLocation " + _snapshotFolder +
|
||||
" && " + _workingFolder +"/waitForFinish.sh interface";
|
||||
" && " + _workingFolder +"/waitForFinish.sh interface\n";
|
||||
|
||||
script.write(commandLine.toStdString().c_str());
|
||||
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
//
|
||||
// HelpWindow.cpp
|
||||
//
|
||||
// Created by Nissim Hadar on 8 Aug 2017.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#include "HelpWindow.h"
|
||||
|
||||
HelpWindow::HelpWindow(QWidget *parent) {
|
||||
setupUi(this);
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
//
|
||||
// HelpWindow.h
|
||||
//
|
||||
// Created by Nissim Hadar on 8 Aug 2017.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#ifndef hifi_HelpWindow_h
|
||||
#define hifi_HelpWindow_h
|
||||
|
||||
#include "ui_HelpWindow.h"
|
||||
|
||||
class HelpWindow : public QDialog, public Ui::HelpWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HelpWindow(QWidget* parent = Q_NULLPTR);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,46 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>HelpWindow</class>
|
||||
<widget class="QDialog" name="HelpWindow">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::ApplicationModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>696</width>
|
||||
<height>546</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Nitpick Help</string>
|
||||
</property>
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>50</y>
|
||||
<width>581</width>
|
||||
<height>381</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>460</y>
|
||||
<width>93</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -15,6 +15,8 @@
|
|||
#include <shellapi.h>
|
||||
#endif
|
||||
|
||||
#include <QDesktopServices>
|
||||
|
||||
Nitpick::Nitpick(QWidget* parent) : QMainWindow(parent) {
|
||||
_ui.setupUi(this);
|
||||
|
||||
|
@ -36,10 +38,7 @@ Nitpick::Nitpick(QWidget* parent) : QMainWindow(parent) {
|
|||
_ui.statusLabel->setText("");
|
||||
_ui.plainTextEdit->setReadOnly(true);
|
||||
|
||||
setWindowTitle("Nitpick - v1.2");
|
||||
|
||||
// Coming soon to a nitpick near you...
|
||||
//// _helpWindow.textBrowser->setText()
|
||||
setWindowTitle("Nitpick - v1.3");
|
||||
}
|
||||
|
||||
Nitpick::~Nitpick() {
|
||||
|
@ -287,7 +286,7 @@ void Nitpick::about() {
|
|||
}
|
||||
|
||||
void Nitpick::content() {
|
||||
_helpWindow.show();
|
||||
QDesktopServices::openUrl(QUrl("https://github.com/highfidelity/hifi/blob/master/tools/nitpick/README.md"));
|
||||
}
|
||||
|
||||
void Nitpick::setUserText(const QString& user) {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "../Downloader.h"
|
||||
#include "../Test.h"
|
||||
|
||||
#include "HelpWindow.h"
|
||||
#include "../TestRunner.h"
|
||||
#include "../AWSInterface.h"
|
||||
|
||||
|
@ -116,8 +115,6 @@ private:
|
|||
|
||||
bool _isRunningFromCommandline{ false };
|
||||
|
||||
HelpWindow _helpWindow;
|
||||
|
||||
void* _caller;
|
||||
};
|
||||
|
||||
|
|
|
@ -803,7 +803,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>720</width>
|
||||
<height>22</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
@ -843,7 +843,7 @@
|
|||
</action>
|
||||
<action name="actionContent">
|
||||
<property name="text">
|
||||
<string>Content</string>
|
||||
<string>Online readme</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
|
|
Loading…
Reference in a new issue