mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 04:41:15 +02:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
a84c1c9e21
3 changed files with 77 additions and 23 deletions
|
@ -237,6 +237,31 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
NodeList::getInstance()->getNodeSocket()->setBlocking(false);
|
||||
}
|
||||
|
||||
// setup QSettings
|
||||
#ifdef Q_WS_MAC
|
||||
QString resourcesPath = QCoreApplication::applicationDirPath() + "/../Resources";
|
||||
#else
|
||||
QString resourcesPath = QCoreApplication::applicationDirPath() + "/resources";
|
||||
#endif
|
||||
|
||||
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
||||
QSettings applicationInfo(resourcesPath + "/info/ApplicationInfo.ini", QSettings::IniFormat);
|
||||
|
||||
// set the associated application properties
|
||||
applicationInfo.beginGroup("INFO");
|
||||
|
||||
setApplicationName(applicationInfo.value("name").toString());
|
||||
setApplicationVersion(applicationInfo.value("version").toString());
|
||||
setOrganizationName(applicationInfo.value("organizationName").toString());
|
||||
setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
|
||||
|
||||
_settings = new QSettings(this);
|
||||
|
||||
// check if there is a saved domain server hostname
|
||||
// this must be done now instead of with the other setting checks to allow manual override with
|
||||
// --domain or --local options
|
||||
NodeList::getInstance()->loadData(_settings);
|
||||
|
||||
const char* domainIP = getCmdOption(argc, constArgv, "--domain");
|
||||
if (domainIP) {
|
||||
NodeList::getInstance()->setDomainIP(domainIP);
|
||||
|
@ -270,23 +295,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
|
||||
_window->setCentralWidget(_glWidget);
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
QString resourcesPath = QCoreApplication::applicationDirPath() + "/../Resources";
|
||||
#else
|
||||
QString resourcesPath = QCoreApplication::applicationDirPath() + "/resources";
|
||||
#endif
|
||||
|
||||
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
||||
QSettings applicationInfo(resourcesPath + "/info/ApplicationInfo.ini", QSettings::IniFormat);
|
||||
|
||||
// set the associated application properties
|
||||
applicationInfo.beginGroup("INFO");
|
||||
|
||||
setApplicationName(applicationInfo.value("name").toString());
|
||||
setApplicationVersion(applicationInfo.value("version").toString());
|
||||
setOrganizationName(applicationInfo.value("organizationName").toString());
|
||||
setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
|
||||
|
||||
#if defined(Q_WS_MAC) && defined(QT_NO_DEBUG)
|
||||
// if this is a release OS X build use fervor to check for an update
|
||||
FvUpdater::sharedUpdater()->SetFeedURL("https://s3-us-west-1.amazonaws.com/highfidelity/appcast.xml");
|
||||
|
@ -1145,11 +1153,18 @@ void Application::editPreferences() {
|
|||
return;
|
||||
}
|
||||
|
||||
char newHostname[MAX_HOSTNAME_BYTES] = {};
|
||||
memcpy(newHostname, domainServerHostname->text().toAscii().data(), domainServerHostname->text().size());
|
||||
QByteArray newHostname;
|
||||
|
||||
if (domainServerHostname->text().size() > 0) {
|
||||
// the user input a new hostname, use that
|
||||
newHostname = domainServerHostname->text().toAscii();
|
||||
} else {
|
||||
// the user left the field blank, use the default hostname
|
||||
newHostname = QByteArray(DEFAULT_DOMAIN_HOSTNAME);
|
||||
}
|
||||
|
||||
// check if the domain server hostname is new
|
||||
if (memcmp(NodeList::getInstance()->getDomainHostname(), newHostname, strlen(newHostname)) != 0) {
|
||||
if (memcmp(NodeList::getInstance()->getDomainHostname(), newHostname.constData(), newHostname.size()) != 0) {
|
||||
|
||||
NodeList::getInstance()->clear();
|
||||
|
||||
|
@ -1159,7 +1174,8 @@ void Application::editPreferences() {
|
|||
// reset the environment to default
|
||||
_environment.resetToDefault();
|
||||
|
||||
NodeList::getInstance()->setDomainHostname(newHostname);
|
||||
// set the new hostname
|
||||
NodeList::getInstance()->setDomainHostname(newHostname.constData());
|
||||
}
|
||||
|
||||
QUrl url(avatarURL->text());
|
||||
|
@ -1785,7 +1801,6 @@ void Application::initMenu() {
|
|||
settingsMenu->addAction("Export settings", this, SLOT(exportSettings()));
|
||||
|
||||
_networkAccessManager = new QNetworkAccessManager(this);
|
||||
_settings = new QSettings(this);
|
||||
}
|
||||
|
||||
void Application::updateFrustumRenderModeAction() {
|
||||
|
@ -3469,7 +3484,7 @@ void Application::saveSettings(QSettings* settings) {
|
|||
if (!settings) {
|
||||
settings = getSettings();
|
||||
}
|
||||
|
||||
|
||||
settings->setValue("headCameraPitchYawScale", _headCameraPitchYawScale);
|
||||
settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples);
|
||||
settings->setValue("horizontalFieldOfView", _horizontalFieldOfView);
|
||||
|
@ -3484,6 +3499,9 @@ void Application::saveSettings(QSettings* settings) {
|
|||
scanMenuBar(&Application::saveAction, settings);
|
||||
getAvatar()->saveData(settings);
|
||||
_swatch.saveData(settings);
|
||||
|
||||
// ask the NodeList to save its data
|
||||
NodeList::getInstance()->saveData(settings);
|
||||
}
|
||||
|
||||
void Application::importSettings() {
|
||||
|
|
|
@ -499,6 +499,37 @@ void NodeList::startSilentNodeRemovalThread() {
|
|||
void NodeList::stopSilentNodeRemovalThread() {
|
||||
silentNodeThreadStopFlag = true;
|
||||
pthread_join(removeSilentNodesThread, NULL);
|
||||
|
||||
}
|
||||
|
||||
const QString QSETTINGS_GROUP_NAME = "NodeList";
|
||||
const QString DOMAIN_SERVER_SETTING_KEY = "domainServerHostname";
|
||||
|
||||
void NodeList::loadData(QSettings *settings) {
|
||||
settings->beginGroup(DOMAIN_SERVER_SETTING_KEY);
|
||||
|
||||
QString domainServerHostname = settings->value(DOMAIN_SERVER_SETTING_KEY).toString();
|
||||
|
||||
if (domainServerHostname.size() > 0) {
|
||||
memset(_domainHostname, 0, MAX_HOSTNAME_BYTES);
|
||||
memcpy(_domainHostname, domainServerHostname.toAscii().constData(), domainServerHostname.size());
|
||||
}
|
||||
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
void NodeList::saveData(QSettings* settings) {
|
||||
settings->beginGroup(DOMAIN_SERVER_SETTING_KEY);
|
||||
|
||||
if (memcmp(_domainHostname, DEFAULT_DOMAIN_HOSTNAME, strlen(DEFAULT_DOMAIN_HOSTNAME)) != 0) {
|
||||
// the user is using a different hostname, store it
|
||||
settings->setValue(DOMAIN_SERVER_SETTING_KEY, QVariant(_domainHostname));
|
||||
} else {
|
||||
// the user has switched back to default, remove the current setting
|
||||
settings->remove(DOMAIN_SERVER_SETTING_KEY);
|
||||
}
|
||||
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
NodeList::iterator NodeList::begin() const {
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include <iterator>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
#include "Node.h"
|
||||
#include "UDPSocket.h"
|
||||
|
||||
|
@ -99,6 +101,9 @@ public:
|
|||
void startSilentNodeRemovalThread();
|
||||
void stopSilentNodeRemovalThread();
|
||||
|
||||
void loadData(QSettings* settings);
|
||||
void saveData(QSettings* settings);
|
||||
|
||||
friend class NodeListIterator;
|
||||
private:
|
||||
static NodeList* _sharedInstance;
|
||||
|
|
Loading…
Reference in a new issue