mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 00:03:39 +02:00
Add getUserAgent function that includes plugin information
This commit is contained in:
parent
335d9abddd
commit
cf49c8e2bf
2 changed files with 37 additions and 0 deletions
|
@ -1057,6 +1057,40 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
|||
firstRun.set(false);
|
||||
}
|
||||
|
||||
QString Application::getUserAgent() {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QString userAgent;
|
||||
|
||||
QMetaObject::invokeMethod(this, "getUserAgent", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QString, userAgent));
|
||||
|
||||
return userAgent;
|
||||
}
|
||||
|
||||
QString userAgent = "Mozilla/5.0 (HighFidelityInterface/" + BuildInfo::VERSION + "; "
|
||||
+ QSysInfo::productType() + " " + QSysInfo::productVersion() + ")";
|
||||
|
||||
auto formatPluginName = [](QString name) -> QString { return name.trimmed().replace(" ", "-"); };
|
||||
|
||||
// For each plugin, add to userAgent
|
||||
auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
|
||||
foreach(auto dp, displayPlugins) {
|
||||
if (dp->isActive() && dp->isHmd()) {
|
||||
userAgent += " " + formatPluginName(dp->getName());
|
||||
}
|
||||
}
|
||||
|
||||
// For each plugin, add to userAgent
|
||||
auto inputPlugins= PluginManager::getInstance()->getInputPlugins();
|
||||
foreach(auto ip, inputPlugins) {
|
||||
if (ip->isActive()) {
|
||||
userAgent += " " + formatPluginName(ip->getName());
|
||||
}
|
||||
}
|
||||
|
||||
return userAgent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Application::checkChangeCursor() {
|
||||
QMutexLocker locker(&_changeCursorLock);
|
||||
|
|
|
@ -112,6 +112,9 @@ public:
|
|||
QString getPreviousScriptLocation();
|
||||
void setPreviousScriptLocation(const QString& previousScriptLocation);
|
||||
|
||||
// Return an HTTP User-Agent string with OS and device information.
|
||||
Q_INVOKABLE QString getUserAgent();
|
||||
|
||||
void initializeGL();
|
||||
void initializeUi();
|
||||
void paintGL();
|
||||
|
|
Loading…
Reference in a new issue