mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-16 01:14:17 +02:00
Merge pull request #4217 from Atlante45/master
Fix for fps bug/field of view
This commit is contained in:
commit
de58c4a007
49 changed files with 610 additions and 514 deletions
|
@ -648,6 +648,7 @@ void AudioMixer::run() {
|
|||
|
||||
// setup a QThread with us as parent that will house the AudioMixerDatagramProcessor
|
||||
_datagramProcessingThread = new QThread(this);
|
||||
_datagramProcessingThread->setObjectName("Datagram Processor Thread");
|
||||
|
||||
// create an AudioMixerDatagramProcessor and move it to that thread
|
||||
AudioMixerDatagramProcessor* datagramProcessor = new AudioMixerDatagramProcessor(nodeList->getNodeSocket(), thread());
|
||||
|
|
|
@ -879,6 +879,7 @@ void OctreeServer::setupDatagramProcessingThread() {
|
|||
|
||||
// setup a QThread with us as parent that will house the OctreeServerDatagramProcessor
|
||||
_datagramProcessingThread = new QThread(this);
|
||||
_datagramProcessingThread->setObjectName("Octree Datagram Processor");
|
||||
|
||||
// create an OctreeServerDatagramProcessor and move it to that thread
|
||||
OctreeServerDatagramProcessor* datagramProcessor = new OctreeServerDatagramProcessor(nodeList->getNodeSocket(), thread());
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <HTTPConnection.h>
|
||||
#include <LogUtils.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <ShutdownEventListener.h>
|
||||
#include <UUID.h>
|
||||
|
@ -1925,7 +1925,7 @@ Headers DomainServer::setupCookieHeadersFromProfileReply(QNetworkReply* profileR
|
|||
|
||||
// persist the cookie to settings file so we can get it back on DS relaunch
|
||||
QStringList path = QStringList() << DS_SETTINGS_SESSIONS_GROUP << cookieUUID.toString();
|
||||
SettingHandles::SettingHandle<QVariant>(path).set(QVariant::fromValue(sessionData));
|
||||
Setting::Handle<QVariant>(path).set(QVariant::fromValue(sessionData));
|
||||
|
||||
// setup expiry for cookie to 1 month from today
|
||||
QDateTime cookieExpiry = QDateTime::currentDateTimeUtc().addMonths(1);
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
#include <PhysicsEngine.h>
|
||||
#include <ProgramObject.h>
|
||||
#include <ResourceCache.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <SoundCache.h>
|
||||
#include <TextRenderer.h>
|
||||
#include <UserActivityLogger.h>
|
||||
|
@ -146,12 +146,6 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D
|
|||
|
||||
const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<bool> firstRun("firstRun", true);
|
||||
const SettingHandle<QString> lastScriptLocation("LastScriptLocation");
|
||||
const SettingHandle<QString> scriptsLocation("scriptsLocation");
|
||||
}
|
||||
|
||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
||||
QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);
|
||||
|
||||
|
@ -167,16 +161,8 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
if (portStr) {
|
||||
listenPort = atoi(portStr);
|
||||
}
|
||||
|
||||
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
|
||||
// set the associated application properties
|
||||
applicationInfo.beginGroup("INFO");
|
||||
QApplication::setApplicationName(applicationInfo.value("name").toString());
|
||||
QApplication::setApplicationVersion(BUILD_VERSION);
|
||||
QApplication::setOrganizationName(applicationInfo.value("organizationName").toString());
|
||||
QApplication::setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
|
||||
// Set build version
|
||||
QCoreApplication::setApplicationVersion(BUILD_VERSION);
|
||||
|
||||
DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
|
||||
|
||||
|
@ -209,7 +195,6 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||
QApplication(argc, argv),
|
||||
_dependencyManagerIsSetup(setupEssentials(argc, argv)),
|
||||
|
@ -230,6 +215,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_lastQueriedViewFrustum(),
|
||||
_lastQueriedTime(usecTimestampNow()),
|
||||
_mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
|
||||
_firstRun("firstRun", true),
|
||||
_previousScriptLocation("LastScriptLocation"),
|
||||
_scriptsLocationHandle("scriptsLocation"),
|
||||
_fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES),
|
||||
_viewTransform(),
|
||||
_scaleMirror(1.0f),
|
||||
_rotateMirror(0.0f),
|
||||
|
@ -243,7 +232,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_enableProcessOctreeThread(true),
|
||||
_octreeProcessor(),
|
||||
_nodeBoundsDisplay(this),
|
||||
_previousScriptLocation(),
|
||||
_applicationOverlay(),
|
||||
_runningScriptsWidget(NULL),
|
||||
_runningScriptsWidgetWasVisible(false),
|
||||
|
@ -279,6 +267,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_runningScriptsWidget = new RunningScriptsWidget(_window);
|
||||
|
||||
// start the nodeThread so its event loop is running
|
||||
_nodeThread->setObjectName("Datagram Processor Thread");
|
||||
_nodeThread->start();
|
||||
|
||||
// make sure the node thread is given highest priority
|
||||
|
@ -293,6 +282,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
|
||||
// put the audio processing on a separate thread
|
||||
QThread* audioThread = new QThread(this);
|
||||
audioThread->setObjectName("Audio Thread");
|
||||
|
||||
auto audioIO = DependencyManager::get<Audio>();
|
||||
audioIO->moveToThread(audioThread);
|
||||
|
@ -440,26 +430,23 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
bandwidthRecorder.data(), SLOT(updateInboundData(const quint8, const int)));
|
||||
|
||||
// check first run...
|
||||
bool firstRun = SettingHandles::firstRun.get();
|
||||
if (firstRun) {
|
||||
if (_firstRun.get()) {
|
||||
qDebug() << "This is a first run...";
|
||||
// clear the scripts, and set out script to our default scripts
|
||||
clearScriptsBeforeRunning();
|
||||
loadScript(DEFAULT_SCRIPTS_JS_URL);
|
||||
|
||||
SettingHandles::firstRun.set(false);
|
||||
_firstRun.set(false);
|
||||
} else {
|
||||
// do this as late as possible so that all required subsystems are initialized
|
||||
loadScripts();
|
||||
|
||||
_previousScriptLocation = SettingHandles::lastScriptLocation.get();
|
||||
}
|
||||
|
||||
loadSettings();
|
||||
int SAVE_SETTINGS_INTERVAL = 10 * MSECS_PER_SECOND; // Let's save every seconds for now
|
||||
connect(&_settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
|
||||
connect(&_settingsThread, SIGNAL(started), &_settingsTimer, SLOT(start));
|
||||
connect(&_settingsThread, &QThread::finished, &_settingsTimer, &QTimer::deleteLater);
|
||||
connect(&_settingsThread, SIGNAL(started()), &_settingsTimer, SLOT(start()));
|
||||
connect(&_settingsThread, SIGNAL(finished()), &_settingsTimer, SLOT(stop()));
|
||||
_settingsTimer.moveToThread(&_settingsThread);
|
||||
_settingsTimer.setSingleShot(false);
|
||||
_settingsTimer.setInterval(SAVE_SETTINGS_INTERVAL);
|
||||
|
@ -485,6 +472,8 @@ void Application::aboutToQuit() {
|
|||
}
|
||||
|
||||
Application::~Application() {
|
||||
QMetaObject::invokeMethod(&_settingsTimer, "stop", Qt::BlockingQueuedConnection);
|
||||
_settingsThread.quit();
|
||||
saveSettings();
|
||||
|
||||
_entities.getTree()->setSimulation(NULL);
|
||||
|
@ -730,7 +719,7 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height)
|
|||
TV3DManager::configureCamera(camera, width, height);
|
||||
} else {
|
||||
camera.setAspectRatio((float)width / height);
|
||||
camera.setFieldOfView(_viewFrustum.getFieldOfView());
|
||||
camera.setFieldOfView(_fieldOfView.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1571,14 +1560,12 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa
|
|||
|
||||
void Application::loadSettings() {
|
||||
DependencyManager::get<Audio>()->loadSettings();
|
||||
DependencyManager::get<LODManager>()->loadSettings();
|
||||
Menu::getInstance()->loadSettings();
|
||||
_myAvatar->loadData();
|
||||
}
|
||||
|
||||
void Application::saveSettings() {
|
||||
DependencyManager::get<Audio>()->saveSettings();
|
||||
DependencyManager::get<LODManager>()->saveSettings();
|
||||
Menu::getInstance()->saveSettings();
|
||||
_myAvatar->saveData();
|
||||
}
|
||||
|
@ -2959,7 +2946,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) {
|
|||
_mirrorCamera.setPosition(_myAvatar->getPosition() +
|
||||
_myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale());
|
||||
|
||||
} else if (SettingHandles::rearViewZoomLevel.get() == BODY) {
|
||||
} else if (RearMirrorTools::rearViewZoomLevel.get() == BODY) {
|
||||
_mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
|
||||
_mirrorCamera.setPosition(_myAvatar->getChestPosition() +
|
||||
_myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
|
||||
|
@ -3468,6 +3455,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
#endif
|
||||
|
||||
QThread* workerThread = new QThread(this);
|
||||
workerThread->setObjectName("Script Engine Thread");
|
||||
|
||||
// when the worker thread is started, call our engine's run..
|
||||
connect(workerThread, &QThread::started, scriptEngine, &ScriptEngine::run);
|
||||
|
@ -3686,21 +3674,20 @@ void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject
|
|||
|
||||
QString Application::getPreviousScriptLocation() {
|
||||
QString suggestedName;
|
||||
if (_previousScriptLocation.isEmpty()) {
|
||||
if (_previousScriptLocation.get().isEmpty()) {
|
||||
QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
||||
// Temporary fix to Qt bug: http://stackoverflow.com/questions/16194475
|
||||
#ifdef __APPLE__
|
||||
suggestedName = desktopLocation.append("/script.js");
|
||||
#endif
|
||||
} else {
|
||||
suggestedName = _previousScriptLocation;
|
||||
suggestedName = _previousScriptLocation.get();
|
||||
}
|
||||
return suggestedName;
|
||||
}
|
||||
|
||||
void Application::setPreviousScriptLocation(const QString& previousScriptLocation) {
|
||||
_previousScriptLocation = previousScriptLocation;
|
||||
SettingHandles::lastScriptLocation.set(_previousScriptLocation);
|
||||
_previousScriptLocation.set(previousScriptLocation);
|
||||
}
|
||||
|
||||
void Application::loadDialog() {
|
||||
|
@ -3735,12 +3722,12 @@ void Application::loadScriptURLDialog() {
|
|||
}
|
||||
}
|
||||
|
||||
QString Application::getScriptsLocation() const {
|
||||
return SettingHandles::scriptsLocation.get();
|
||||
QString Application::getScriptsLocation() {
|
||||
return _scriptsLocationHandle.get();
|
||||
}
|
||||
|
||||
void Application::setScriptsLocation(const QString& scriptsLocation) {
|
||||
SettingHandles::scriptsLocation.set(scriptsLocation);
|
||||
_scriptsLocationHandle.set(scriptsLocation);
|
||||
emit scriptLocationChanged(scriptsLocation);
|
||||
}
|
||||
|
||||
|
|
|
@ -212,6 +212,9 @@ public:
|
|||
|
||||
virtual const Transform& getViewTransform() const { return _viewTransform; }
|
||||
void setViewTransform(const Transform& view);
|
||||
|
||||
float getFieldOfView() { return _fieldOfView.get(); }
|
||||
void setFieldOfView(float fov) { _fieldOfView.set(fov); }
|
||||
|
||||
NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; }
|
||||
void lockOctreeSceneStats() { _octreeSceneStatsLock.lockForRead(); }
|
||||
|
@ -296,7 +299,7 @@ public:
|
|||
|
||||
Bookmarks* getBookmarks() const { return _bookmarks; }
|
||||
|
||||
QString getScriptsLocation() const;
|
||||
QString getScriptsLocation();
|
||||
void setScriptsLocation(const QString& scriptsLocation);
|
||||
|
||||
signals:
|
||||
|
@ -490,6 +493,11 @@ private:
|
|||
Camera _mirrorCamera; // Cammera for mirror view
|
||||
QRect _mirrorViewRect;
|
||||
RearMirrorTools* _rearMirrorTools;
|
||||
|
||||
Setting::Handle<bool> _firstRun;
|
||||
Setting::Handle<QString> _previousScriptLocation;
|
||||
Setting::Handle<QString> _scriptsLocationHandle;
|
||||
Setting::Handle<float> _fieldOfView;
|
||||
|
||||
Transform _viewTransform;
|
||||
glm::mat4 _untranslatedViewMatrix;
|
||||
|
@ -547,8 +555,6 @@ private:
|
|||
QPointer<LogDialog> _logDialog;
|
||||
QPointer<SnapshotShareDialog> _snapshotShareDialog;
|
||||
|
||||
QString _previousScriptLocation;
|
||||
|
||||
FileLogger* _logger;
|
||||
|
||||
void checkVersion();
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <PositionalAudioStream.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <UUID.h>
|
||||
|
||||
|
@ -47,16 +47,17 @@
|
|||
|
||||
static const int RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES = 100;
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<bool> audioOutputStarveDetectionEnabled("audioOutputStarveDetectionEnabled",
|
||||
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_ENABLED);
|
||||
const SettingHandle<int> audioOutputStarveDetectionThreshold("audioOutputStarveDetectionThreshold",
|
||||
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_THRESHOLD);
|
||||
const SettingHandle<int> audioOutputStarveDetectionPeriod("audioOutputStarveDetectionPeriod",
|
||||
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_PERIOD);
|
||||
const SettingHandle<int> audioOutputBufferSize("audioOutputBufferSize",
|
||||
DEFAULT_MAX_FRAMES_OVER_DESIRED);
|
||||
}
|
||||
Setting::Handle<bool> dynamicJitterBuffers("dynamicJitterBuffers", DEFAULT_DYNAMIC_JITTER_BUFFERS);
|
||||
Setting::Handle<int> maxFramesOverDesired("maxFramesOverDesired", DEFAULT_MAX_FRAMES_OVER_DESIRED);
|
||||
Setting::Handle<int> staticDesiredJitterBufferFrames("staticDesiredJitterBufferFrames",
|
||||
DEFAULT_STATIC_DESIRED_JITTER_BUFFER_FRAMES);
|
||||
Setting::Handle<bool> useStDevForJitterCalc("useStDevForJitterCalc", DEFAULT_USE_STDEV_FOR_JITTER_CALC);
|
||||
Setting::Handle<int> windowStarveThreshold("windowStarveThreshold", DEFAULT_WINDOW_STARVE_THRESHOLD);
|
||||
Setting::Handle<int> windowSecondsForDesiredCalcOnTooManyStarves("windowSecondsForDesiredCalcOnTooManyStarves",
|
||||
DEFAULT_WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES);
|
||||
Setting::Handle<int> windowSecondsForDesiredReduction("windowSecondsForDesiredReduction",
|
||||
DEFAULT_WINDOW_SECONDS_FOR_DESIRED_REDUCTION);
|
||||
Setting::Handle<bool> repetitionWithFade("repetitionWithFade", DEFAULT_REPETITION_WITH_FADE);
|
||||
|
||||
Audio::Audio() :
|
||||
AbstractAudioInterface(),
|
||||
|
@ -74,12 +75,16 @@ Audio::Audio() :
|
|||
_inputRingBuffer(0),
|
||||
_receivedAudioStream(0, RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES, InboundAudioStream::Settings()),
|
||||
_isStereoInput(false),
|
||||
_outputBufferSizeFrames(DEFAULT_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES),
|
||||
_outputStarveDetectionEnabled(true),
|
||||
_outputStarveDetectionStartTimeMsec(0),
|
||||
_outputStarveDetectionCount(0),
|
||||
_outputStarveDetectionPeriodMsec(DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_PERIOD),
|
||||
_outputStarveDetectionThreshold(DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_THRESHOLD),
|
||||
_outputBufferSizeFrames("audioOutputBufferSize",
|
||||
DEFAULT_MAX_FRAMES_OVER_DESIRED),
|
||||
_outputStarveDetectionEnabled("audioOutputStarveDetectionEnabled",
|
||||
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_ENABLED),
|
||||
_outputStarveDetectionPeriodMsec("audioOutputStarveDetectionPeriod",
|
||||
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_PERIOD),
|
||||
_outputStarveDetectionThreshold("audioOutputStarveDetectionThreshold",
|
||||
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_THRESHOLD),
|
||||
_averagedLatency(0.0f),
|
||||
_lastInputLoudness(0.0f),
|
||||
_timeSinceLastClip(-1.0f),
|
||||
|
@ -962,16 +967,16 @@ bool Audio::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceInfo) {
|
|||
void Audio::outputNotify() {
|
||||
int recentUnfulfilled = _audioOutputIODevice.getRecentUnfulfilledReads();
|
||||
if (recentUnfulfilled > 0) {
|
||||
if (_outputStarveDetectionEnabled) {
|
||||
if (_outputStarveDetectionEnabled.get()) {
|
||||
quint64 now = usecTimestampNow() / 1000;
|
||||
quint64 dt = now - _outputStarveDetectionStartTimeMsec;
|
||||
if (dt > _outputStarveDetectionPeriodMsec) {
|
||||
if (dt > _outputStarveDetectionPeriodMsec.get()) {
|
||||
_outputStarveDetectionStartTimeMsec = now;
|
||||
_outputStarveDetectionCount = 0;
|
||||
} else {
|
||||
_outputStarveDetectionCount += recentUnfulfilled;
|
||||
if (_outputStarveDetectionCount > _outputStarveDetectionThreshold) {
|
||||
int newOutputBufferSizeFrames = _outputBufferSizeFrames + 1;
|
||||
if (_outputStarveDetectionCount > _outputStarveDetectionThreshold.get()) {
|
||||
int newOutputBufferSizeFrames = _outputBufferSizeFrames.get() + 1;
|
||||
qDebug() << "Starve detection threshold met, increasing buffer size to " << newOutputBufferSizeFrames;
|
||||
setOutputBufferSize(newOutputBufferSizeFrames);
|
||||
|
||||
|
@ -1009,7 +1014,7 @@ bool Audio::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo)
|
|||
|
||||
// setup our general output device for audio-mixer audio
|
||||
_audioOutput = new QAudioOutput(outputDeviceInfo, _outputFormat, this);
|
||||
_audioOutput->setBufferSize(_outputBufferSizeFrames * _outputFrameSize * sizeof(int16_t));
|
||||
_audioOutput->setBufferSize(_outputBufferSizeFrames.get() * _outputFrameSize * sizeof(int16_t));
|
||||
|
||||
connect(_audioOutput, &QAudioOutput::notify, this, &Audio::outputNotify);
|
||||
|
||||
|
@ -1032,9 +1037,9 @@ bool Audio::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo)
|
|||
|
||||
void Audio::setOutputBufferSize(int numFrames) {
|
||||
numFrames = std::min(std::max(numFrames, MIN_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES), MAX_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES);
|
||||
if (numFrames != _outputBufferSizeFrames) {
|
||||
if (numFrames != _outputBufferSizeFrames.get()) {
|
||||
qDebug() << "Audio output buffer size (frames): " << numFrames;
|
||||
_outputBufferSizeFrames = numFrames;
|
||||
_outputBufferSizeFrames.set(numFrames);
|
||||
|
||||
if (_audioOutput) {
|
||||
// The buffer size can't be adjusted after QAudioOutput::start() has been called, so
|
||||
|
@ -1133,26 +1138,25 @@ void Audio::checkDevices() {
|
|||
}
|
||||
|
||||
void Audio::loadSettings() {
|
||||
_receivedAudioStream.loadSettings();
|
||||
|
||||
setOutputStarveDetectionEnabled(SettingHandles::audioOutputStarveDetectionEnabled.get());
|
||||
setOutputStarveDetectionThreshold(SettingHandles::audioOutputStarveDetectionThreshold.get());
|
||||
setOutputStarveDetectionPeriod(SettingHandles::audioOutputStarveDetectionPeriod.get());
|
||||
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "setOutputBufferSize",
|
||||
Q_ARG(int, SettingHandles::audioOutputBufferSize.get()));
|
||||
} else {
|
||||
setOutputBufferSize(SettingHandles::audioOutputBufferSize.get());
|
||||
}
|
||||
_receivedAudioStream.setDynamicJitterBuffers(dynamicJitterBuffers.get());
|
||||
_receivedAudioStream.setMaxFramesOverDesired(maxFramesOverDesired.get());
|
||||
_receivedAudioStream.setStaticDesiredJitterBufferFrames(staticDesiredJitterBufferFrames.get());
|
||||
_receivedAudioStream.setUseStDevForJitterCalc(useStDevForJitterCalc.get());
|
||||
_receivedAudioStream.setWindowStarveThreshold(windowStarveThreshold.get());
|
||||
_receivedAudioStream.setWindowSecondsForDesiredCalcOnTooManyStarves(
|
||||
windowSecondsForDesiredCalcOnTooManyStarves.get());
|
||||
_receivedAudioStream.setWindowSecondsForDesiredReduction(windowSecondsForDesiredReduction.get());
|
||||
_receivedAudioStream.setRepetitionWithFade(repetitionWithFade.get());
|
||||
}
|
||||
|
||||
void Audio::saveSettings() {
|
||||
_receivedAudioStream.saveSettings();
|
||||
|
||||
SettingHandles::audioOutputStarveDetectionEnabled.set(getOutputStarveDetectionEnabled());
|
||||
SettingHandles::audioOutputStarveDetectionThreshold.set(getOutputStarveDetectionThreshold());
|
||||
SettingHandles::audioOutputStarveDetectionPeriod.set(getOutputStarveDetectionPeriod());
|
||||
SettingHandles::audioOutputBufferSize.set(getOutputBufferSize());
|
||||
dynamicJitterBuffers.set(_receivedAudioStream.getDynamicJitterBuffers());
|
||||
maxFramesOverDesired.set(_receivedAudioStream.getMaxFramesOverDesired());
|
||||
staticDesiredJitterBufferFrames.set(_receivedAudioStream.getDesiredJitterBufferFrames());
|
||||
windowStarveThreshold.set(_receivedAudioStream.getWindowStarveThreshold());
|
||||
windowSecondsForDesiredCalcOnTooManyStarves.set(_receivedAudioStream.
|
||||
getWindowSecondsForDesiredCalcOnTooManyStarves());
|
||||
windowSecondsForDesiredReduction.set(_receivedAudioStream.getWindowSecondsForDesiredReduction());
|
||||
repetitionWithFade.set(_receivedAudioStream.getRepetitionWithFade());
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <AbstractAudioInterface.h>
|
||||
#include <AudioRingBuffer.h>
|
||||
#include <DependencyManager.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <StDev.h>
|
||||
|
||||
#include "audio/AudioIOStats.h"
|
||||
|
@ -115,16 +116,16 @@ public:
|
|||
|
||||
void setRecorder(RecorderPointer recorder) { _recorder = recorder; }
|
||||
|
||||
int getOutputBufferSize() { return _outputBufferSizeFrames; }
|
||||
int getOutputBufferSize() { return _outputBufferSizeFrames.get(); }
|
||||
|
||||
bool getOutputStarveDetectionEnabled() { return _outputStarveDetectionEnabled; }
|
||||
void setOutputStarveDetectionEnabled(bool enabled) { _outputStarveDetectionEnabled = enabled; }
|
||||
bool getOutputStarveDetectionEnabled() { return _outputStarveDetectionEnabled.get(); }
|
||||
void setOutputStarveDetectionEnabled(bool enabled) { _outputStarveDetectionEnabled.set(enabled); }
|
||||
|
||||
int getOutputStarveDetectionPeriod() { return _outputStarveDetectionPeriodMsec; }
|
||||
void setOutputStarveDetectionPeriod(int msecs) { _outputStarveDetectionPeriodMsec = msecs; }
|
||||
int getOutputStarveDetectionPeriod() { return _outputStarveDetectionPeriodMsec.get(); }
|
||||
void setOutputStarveDetectionPeriod(int msecs) { _outputStarveDetectionPeriodMsec.set(msecs); }
|
||||
|
||||
int getOutputStarveDetectionThreshold() { return _outputStarveDetectionThreshold; }
|
||||
void setOutputStarveDetectionThreshold(int threshold) { _outputStarveDetectionThreshold = threshold; }
|
||||
int getOutputStarveDetectionThreshold() { return _outputStarveDetectionThreshold.get(); }
|
||||
void setOutputStarveDetectionThreshold(int threshold) { _outputStarveDetectionThreshold.set(threshold); }
|
||||
|
||||
static const float CALLBACK_ACCELERATOR_RATIO;
|
||||
|
||||
|
@ -208,13 +209,14 @@ private:
|
|||
QString _inputAudioDeviceName;
|
||||
QString _outputAudioDeviceName;
|
||||
|
||||
int _outputBufferSizeFrames;
|
||||
bool _outputStarveDetectionEnabled;
|
||||
quint64 _outputStarveDetectionStartTimeMsec;
|
||||
int _outputStarveDetectionCount;
|
||||
int _outputStarveDetectionPeriodMsec;
|
||||
int _outputStarveDetectionThreshold; // Maximum number of starves per _outputStarveDetectionPeriod before increasing buffer size
|
||||
|
||||
|
||||
Setting::Handle<int> _outputBufferSizeFrames;
|
||||
Setting::Handle<bool> _outputStarveDetectionEnabled;
|
||||
Setting::Handle<int> _outputStarveDetectionPeriodMsec;
|
||||
// Maximum number of starves per _outputStarveDetectionPeriod before increasing buffer size
|
||||
Setting::Handle<int> _outputStarveDetectionThreshold;
|
||||
|
||||
StDev _stdev;
|
||||
QElapsedTimer _timeSinceLastReceived;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <SettingHandle.h>
|
||||
#include <Util.h>
|
||||
|
||||
#include "Application.h"
|
||||
|
@ -16,15 +17,14 @@
|
|||
|
||||
#include "LODManager.h"
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<bool> automaticAvatarLOD("automaticAvatarLOD", true);
|
||||
const SettingHandle<float> avatarLODDecreaseFPS("avatarLODDecreaseFPS", DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS);
|
||||
const SettingHandle<float> avatarLODIncreaseFPS("avatarLODIncreaseFPS", ADJUST_LOD_UP_FPS);
|
||||
const SettingHandle<float> avatarLODDistanceMultiplier("avatarLODDistanceMultiplier",
|
||||
Setting::Handle<bool> automaticAvatarLOD("automaticAvatarLOD", true);
|
||||
Setting::Handle<float> avatarLODDecreaseFPS("avatarLODDecreaseFPS", DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS);
|
||||
Setting::Handle<float> avatarLODIncreaseFPS("avatarLODIncreaseFPS", ADJUST_LOD_UP_FPS);
|
||||
Setting::Handle<float> avatarLODDistanceMultiplier("avatarLODDistanceMultiplier",
|
||||
DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER);
|
||||
const SettingHandle<int> boundaryLevelAdjust("boundaryLevelAdjust", 0);
|
||||
const SettingHandle<float> octreeSizeScale("octreeSizeScale", DEFAULT_OCTREE_SIZE_SCALE);
|
||||
}
|
||||
Setting::Handle<int> boundaryLevelAdjust("boundaryLevelAdjust", 0);
|
||||
Setting::Handle<float> octreeSizeScale("octreeSizeScale", DEFAULT_OCTREE_SIZE_SCALE);
|
||||
|
||||
|
||||
void LODManager::autoAdjustLOD(float currentFPS) {
|
||||
// NOTE: our first ~100 samples at app startup are completely all over the place, and we don't
|
||||
|
@ -190,21 +190,21 @@ void LODManager::setBoundaryLevelAdjust(int boundaryLevelAdjust) {
|
|||
|
||||
|
||||
void LODManager::loadSettings() {
|
||||
setAutomaticAvatarLOD(SettingHandles::automaticAvatarLOD.get());
|
||||
setAvatarLODDecreaseFPS(SettingHandles::avatarLODDecreaseFPS.get());
|
||||
setAvatarLODIncreaseFPS(SettingHandles::avatarLODIncreaseFPS.get());
|
||||
setAvatarLODDistanceMultiplier(SettingHandles::avatarLODDistanceMultiplier.get());
|
||||
setBoundaryLevelAdjust(SettingHandles::boundaryLevelAdjust.get());
|
||||
setOctreeSizeScale(SettingHandles::octreeSizeScale.get());
|
||||
setAutomaticAvatarLOD(automaticAvatarLOD.get());
|
||||
setAvatarLODDecreaseFPS(avatarLODDecreaseFPS.get());
|
||||
setAvatarLODIncreaseFPS(avatarLODIncreaseFPS.get());
|
||||
setAvatarLODDistanceMultiplier(avatarLODDistanceMultiplier.get());
|
||||
setBoundaryLevelAdjust(boundaryLevelAdjust.get());
|
||||
setOctreeSizeScale(octreeSizeScale.get());
|
||||
}
|
||||
|
||||
void LODManager::saveSettings() {
|
||||
SettingHandles::automaticAvatarLOD.set(getAutomaticAvatarLOD());
|
||||
SettingHandles::avatarLODDecreaseFPS.set(getAvatarLODDecreaseFPS());
|
||||
SettingHandles::avatarLODIncreaseFPS.set(getAvatarLODIncreaseFPS());
|
||||
SettingHandles::avatarLODDistanceMultiplier.set(getAvatarLODDistanceMultiplier());
|
||||
SettingHandles::boundaryLevelAdjust.set(getBoundaryLevelAdjust());
|
||||
SettingHandles::octreeSizeScale.set(getOctreeSizeScale());
|
||||
automaticAvatarLOD.set(getAutomaticAvatarLOD());
|
||||
avatarLODDecreaseFPS.set(getAvatarLODDecreaseFPS());
|
||||
avatarLODIncreaseFPS.set(getAvatarLODIncreaseFPS());
|
||||
avatarLODDistanceMultiplier.set(getAvatarLODDistanceMultiplier());
|
||||
boundaryLevelAdjust.set(getBoundaryLevelAdjust());
|
||||
octreeSizeScale.set(getOctreeSizeScale());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include <DependencyManager.h>
|
||||
#include <OctreeConstants.h>
|
||||
#include <Settings.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <SimpleMovingAverage.h>
|
||||
|
||||
|
|
|
@ -18,24 +18,20 @@
|
|||
#include <QHideEvent>
|
||||
#include <QWindowStateChangeEvent>
|
||||
|
||||
#include <Settings.h>
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QRect> windowGeometry("WindowGeometry");
|
||||
}
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) {
|
||||
MainWindow::MainWindow(QWidget* parent) :
|
||||
QMainWindow(parent),
|
||||
_windowGeometry("WindowGeometry")
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::restoreGeometry() {
|
||||
// Did not use setGeometry() on purpose,
|
||||
// see http://doc.qt.io/qt-5/qsettings.html#restoring-the-state-of-a-gui-application
|
||||
QRect geometry = SettingHandles::windowGeometry.get(qApp->desktop()->availableGeometry());
|
||||
QRect geometry = _windowGeometry.get(qApp->desktop()->availableGeometry());
|
||||
move(geometry.topLeft());
|
||||
resize(geometry.size());
|
||||
}
|
||||
|
@ -44,7 +40,7 @@ void MainWindow::saveGeometry() {
|
|||
// Did not use geometry() on purpose,
|
||||
// see http://doc.qt.io/qt-5/qsettings.html#restoring-the-state-of-a-gui-application
|
||||
QRect geometry(pos(), size());
|
||||
SettingHandles::windowGeometry.set(geometry);
|
||||
_windowGeometry.set(geometry);
|
||||
}
|
||||
|
||||
void MainWindow::moveEvent(QMoveEvent* event) {
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include <QMainWindow>
|
||||
|
||||
#include <SettingHandle.h>
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -33,6 +35,9 @@ protected:
|
|||
virtual void showEvent(QShowEvent* event);
|
||||
virtual void hideEvent(QHideEvent* event);
|
||||
virtual void changeEvent(QEvent* event);
|
||||
|
||||
private:
|
||||
Setting::Handle<QRect> _windowGeometry;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__MainWindow__) */
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <DependencyManager.h>
|
||||
#include <GlowEffect.h>
|
||||
#include <PathUtils.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <UserActivityLogger.h>
|
||||
#include <XmppClient.h>
|
||||
|
||||
|
|
|
@ -239,8 +239,6 @@ namespace MenuOption {
|
|||
const QString RunTimingTests = "Run Timing Tests";
|
||||
const QString ScriptEditor = "Script Editor...";
|
||||
const QString ScriptedMotorControl = "Enable Scripted Motor Control";
|
||||
const QString SettingsExport = "Export Settings";
|
||||
const QString SettingsImport = "Import Settings";
|
||||
const QString ShowBordersEntityNodes = "Show Entity Nodes";
|
||||
const QString ShowBordersVoxelNodes = "Show Voxel Nodes";
|
||||
const QString ShowIKConstraints = "Show IK Constraints";
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include <GeometryCache.h>
|
||||
#include <GLMHelpers.h>
|
||||
#include <ResourceCache.h>
|
||||
#include <Settings.h>
|
||||
#include <TextureCache.h>
|
||||
|
||||
#include "ModelUploader.h"
|
||||
|
@ -68,14 +67,13 @@ static const int MAX_CHECK = 30;
|
|||
static const int QCOMPRESS_HEADER_POSITION = 0;
|
||||
static const int QCOMPRESS_HEADER_SIZE = 4;
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QString> lastModelUploadLocation("LastModelUploadLocation",
|
||||
QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
|
||||
}
|
||||
Setting::Handle<QString> ModelUploader::_lastModelUploadLocation("LastModelUploadLocation",
|
||||
QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
|
||||
|
||||
void ModelUploader::uploadModel(ModelType modelType) {
|
||||
ModelUploader* uploader = new ModelUploader(modelType);
|
||||
QThread* thread = new QThread();
|
||||
thread->setObjectName("Model Uploader");
|
||||
thread->connect(uploader, SIGNAL(destroyed()), SLOT(quit()));
|
||||
thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater()));
|
||||
uploader->connect(thread, SIGNAL(started()), SLOT(send()));
|
||||
|
@ -117,7 +115,7 @@ ModelUploader::~ModelUploader() {
|
|||
|
||||
bool ModelUploader::zip() {
|
||||
// File Dialog
|
||||
QString lastLocation = SettingHandles::lastModelUploadLocation.get();
|
||||
QString lastLocation = _lastModelUploadLocation.get();
|
||||
|
||||
if (lastLocation.isEmpty()) {
|
||||
lastLocation = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
||||
|
@ -134,7 +132,7 @@ bool ModelUploader::zip() {
|
|||
// If the user canceled we return.
|
||||
return false;
|
||||
}
|
||||
SettingHandles::lastModelUploadLocation.set(filename);
|
||||
_lastModelUploadLocation.set(filename);
|
||||
|
||||
// First we check the FST file (if any)
|
||||
QFile* fst;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <QTimer>
|
||||
|
||||
#include <FBXReader.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "ui/ModelsBrowser.h"
|
||||
|
||||
|
@ -68,13 +69,15 @@ private:
|
|||
ModelType _modelType;
|
||||
bool _readyToSend;
|
||||
|
||||
QHttpMultiPart* _dataMultiPart;
|
||||
QHttpMultiPart* _dataMultiPart = nullptr;
|
||||
|
||||
int _numberOfChecks;
|
||||
QTimer _timer;
|
||||
|
||||
QDialog* _progressDialog;
|
||||
QProgressBar* _progressBar;
|
||||
QDialog* _progressDialog = nullptr;
|
||||
QProgressBar* _progressBar = nullptr;
|
||||
|
||||
static Setting::Handle<QString> _lastModelUploadLocation;
|
||||
};
|
||||
|
||||
/// A dialog that allows customization of various model properties.
|
||||
|
@ -101,23 +104,23 @@ private:
|
|||
QVariantHash _originalMapping;
|
||||
QString _basePath;
|
||||
FBXGeometry _geometry;
|
||||
QLineEdit* _name;
|
||||
QPushButton* _textureDirectory;
|
||||
QDoubleSpinBox* _scale;
|
||||
QDoubleSpinBox* _translationX;
|
||||
QDoubleSpinBox* _translationY;
|
||||
QDoubleSpinBox* _translationZ;
|
||||
QCheckBox* _pivotAboutCenter;
|
||||
QComboBox* _pivotJoint;
|
||||
QComboBox* _leftEyeJoint;
|
||||
QComboBox* _rightEyeJoint;
|
||||
QComboBox* _neckJoint;
|
||||
QComboBox* _rootJoint;
|
||||
QComboBox* _leanJoint;
|
||||
QComboBox* _headJoint;
|
||||
QComboBox* _leftHandJoint;
|
||||
QComboBox* _rightHandJoint;
|
||||
QVBoxLayout* _freeJoints;
|
||||
QLineEdit* _name = nullptr;
|
||||
QPushButton* _textureDirectory = nullptr;
|
||||
QDoubleSpinBox* _scale = nullptr;
|
||||
QDoubleSpinBox* _translationX = nullptr;
|
||||
QDoubleSpinBox* _translationY = nullptr;
|
||||
QDoubleSpinBox* _translationZ = nullptr;
|
||||
QCheckBox* _pivotAboutCenter = nullptr;
|
||||
QComboBox* _pivotJoint = nullptr;
|
||||
QComboBox* _leftEyeJoint = nullptr;
|
||||
QComboBox* _rightEyeJoint = nullptr;
|
||||
QComboBox* _neckJoint = nullptr;
|
||||
QComboBox* _rootJoint = nullptr;
|
||||
QComboBox* _leanJoint = nullptr;
|
||||
QComboBox* _headJoint = nullptr;
|
||||
QComboBox* _leftHandJoint = nullptr;
|
||||
QComboBox* _rightHandJoint = nullptr;
|
||||
QVBoxLayout* _freeJoints = nullptr;
|
||||
};
|
||||
|
||||
#endif // hifi_ModelUploader_h
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <PerfStat.h>
|
||||
#include <Settings.h>
|
||||
#include <ShapeCollider.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <TextRenderer.h>
|
||||
|
@ -52,6 +51,7 @@ const float YAW_SPEED = 500.0f; // degrees/sec
|
|||
const float PITCH_SPEED = 100.0f; // degrees/sec
|
||||
const float COLLISION_RADIUS_SCALAR = 1.2f; // pertains to avatar-to-avatar collisions
|
||||
const float COLLISION_RADIUS_SCALE = 0.125f;
|
||||
const float DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES = 30.0f;
|
||||
|
||||
const float MAX_WALKING_SPEED = 2.5f; // human walking speed
|
||||
const float MAX_BOOST_SPEED = 0.5f * MAX_WALKING_SPEED; // keyboard motor gets additive boost below this speed
|
||||
|
@ -90,7 +90,9 @@ MyAvatar::MyAvatar() :
|
|||
_billboardValid(false),
|
||||
_physicsSimulation(),
|
||||
_feetTouchFloor(true),
|
||||
_isLookingAtLeftEye(true)
|
||||
_isLookingAtLeftEye(true),
|
||||
_realWorldFieldOfView("realWorldFieldOfView",
|
||||
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES)
|
||||
{
|
||||
ShapeCollider::initDispatchTable();
|
||||
for (int i = 0; i < MAX_DRIVE_KEYS; i++) {
|
||||
|
@ -339,8 +341,8 @@ void MyAvatar::updateFromTrackers(float deltaTime) {
|
|||
head->setDeltaPitch(estimatedRotation.x);
|
||||
head->setDeltaYaw(estimatedRotation.y);
|
||||
} else {
|
||||
float magnifyFieldOfView = qApp->getViewFrustum()->getFieldOfView() /
|
||||
qApp->getViewFrustum()->getRealWorldFieldOfView();
|
||||
float magnifyFieldOfView = qApp->getFieldOfView() /
|
||||
_realWorldFieldOfView.get();
|
||||
head->setDeltaPitch(estimatedRotation.x * magnifyFieldOfView);
|
||||
head->setDeltaYaw(estimatedRotation.y * magnifyFieldOfView);
|
||||
}
|
||||
|
|
|
@ -12,9 +12,8 @@
|
|||
#ifndef hifi_MyAvatar_h
|
||||
#define hifi_MyAvatar_h
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
#include <PhysicsSimulation.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "Avatar.h"
|
||||
|
||||
|
@ -47,12 +46,14 @@ public:
|
|||
void setLeanScale(float scale) { _leanScale = scale; }
|
||||
void setLocalGravity(glm::vec3 gravity);
|
||||
void setShouldRenderLocally(bool shouldRender) { _shouldRender = shouldRender; }
|
||||
void setRealWorldFieldOfView(float realWorldFov) { _realWorldFieldOfView.set(realWorldFov); }
|
||||
|
||||
// getters
|
||||
float getLeanScale() const { return _leanScale; }
|
||||
glm::vec3 getGravity() const { return _gravity; }
|
||||
Q_INVOKABLE glm::vec3 getDefaultEyePosition() const;
|
||||
bool getShouldRenderLocally() const { return _shouldRender; }
|
||||
float getRealWorldFieldOfView() { return _realWorldFieldOfView.get(); }
|
||||
|
||||
const QList<AnimationHandlePointer>& getAnimationHandles() const { return _animationHandles; }
|
||||
AnimationHandlePointer addAnimationHandle();
|
||||
|
@ -225,6 +226,8 @@ private:
|
|||
|
||||
glm::vec3 _trackedHeadPosition;
|
||||
|
||||
Setting::Handle<float> _realWorldFieldOfView;
|
||||
|
||||
// private methods
|
||||
void updateOrientation(float deltaTime);
|
||||
glm::vec3 applyKeyboardMotor(float deltaTime, const glm::vec3& velocity, bool walkingOnFloor);
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
#include <GLMHelpers.h>
|
||||
#include <PerfStat.h>
|
||||
#include <Settings.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "Faceshift.h"
|
||||
|
@ -29,11 +28,6 @@ using namespace std;
|
|||
const quint16 FACESHIFT_PORT = 33433;
|
||||
float STARTING_FACESHIFT_FRAME_TIME = 0.033f;
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<float> faceshiftEyeDeflection("faceshiftEyeDeflection", DEFAULT_FACESHIFT_EYE_DEFLECTION);
|
||||
const SettingHandle<QString> faceshiftHostname("faceshiftHostname", DEFAULT_FACESHIFT_HOSTNAME);
|
||||
}
|
||||
|
||||
Faceshift::Faceshift() :
|
||||
_tcpEnabled(true),
|
||||
_tcpRetryCount(0),
|
||||
|
@ -61,7 +55,9 @@ Faceshift::Faceshift() :
|
|||
_jawOpenIndex(21),
|
||||
_longTermAverageEyePitch(0.0f),
|
||||
_longTermAverageEyeYaw(0.0f),
|
||||
_longTermAverageInitialized(false)
|
||||
_longTermAverageInitialized(false),
|
||||
_eyeDeflection("faceshiftEyeDeflection", DEFAULT_FACESHIFT_EYE_DEFLECTION),
|
||||
_hostname("faceshiftHostname", DEFAULT_FACESHIFT_HOSTNAME)
|
||||
{
|
||||
#ifdef HAVE_FACESHIFT
|
||||
connect(&_tcpSocket, SIGNAL(connected()), SLOT(noteConnected()));
|
||||
|
@ -73,9 +69,6 @@ Faceshift::Faceshift() :
|
|||
|
||||
_udpSocket.bind(FACESHIFT_PORT);
|
||||
#endif
|
||||
|
||||
_eyeDeflection = SettingHandles::faceshiftEyeDeflection.get();
|
||||
_hostname = SettingHandles::faceshiftHostname.get();
|
||||
}
|
||||
|
||||
void Faceshift::init() {
|
||||
|
@ -169,7 +162,7 @@ void Faceshift::connectSocket() {
|
|||
qDebug("Faceshift: Connecting...");
|
||||
}
|
||||
|
||||
_tcpSocket.connectToHost(_hostname, FACESHIFT_PORT);
|
||||
_tcpSocket.connectToHost(_hostname.get(), FACESHIFT_PORT);
|
||||
_tracking = false;
|
||||
}
|
||||
}
|
||||
|
@ -321,11 +314,9 @@ void Faceshift::receive(const QByteArray& buffer) {
|
|||
}
|
||||
|
||||
void Faceshift::setEyeDeflection(float faceshiftEyeDeflection) {
|
||||
_eyeDeflection = faceshiftEyeDeflection;
|
||||
SettingHandles::faceshiftEyeDeflection.set(_eyeDeflection);
|
||||
_eyeDeflection.set(faceshiftEyeDeflection);
|
||||
}
|
||||
|
||||
void Faceshift::setHostname(const QString& hostname) {
|
||||
_hostname = hostname;
|
||||
SettingHandles::faceshiftHostname.set(_hostname);
|
||||
_hostname.set(hostname);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#endif
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "FaceTracker.h"
|
||||
|
||||
|
@ -62,10 +63,10 @@ public:
|
|||
float getMouthSmileLeft() const { return getBlendshapeCoefficient(_mouthSmileLeftIndex); }
|
||||
float getMouthSmileRight() const { return getBlendshapeCoefficient(_mouthSmileRightIndex); }
|
||||
|
||||
float getEyeDeflection() const { return _eyeDeflection; }
|
||||
float getEyeDeflection() { return _eyeDeflection.get(); }
|
||||
void setEyeDeflection(float faceshiftEyeDeflection);
|
||||
|
||||
const QString& getHostname() const { return _hostname; }
|
||||
QString getHostname() { return _hostname.get(); }
|
||||
void setHostname(const QString& hostname);
|
||||
|
||||
void update();
|
||||
|
@ -151,8 +152,8 @@ private:
|
|||
float _longTermAverageEyeYaw;
|
||||
bool _longTermAverageInitialized;
|
||||
|
||||
float _eyeDeflection = DEFAULT_FACESHIFT_EYE_DEFLECTION;
|
||||
QString _hostname = DEFAULT_FACESHIFT_HOSTNAME;
|
||||
Setting::Handle<float> _eyeDeflection;
|
||||
Setting::Handle<QString> _hostname;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "SettingsScriptingInterface.h"
|
||||
|
||||
|
@ -20,7 +20,7 @@ SettingsScriptingInterface* SettingsScriptingInterface::getInstance() {
|
|||
}
|
||||
|
||||
QVariant SettingsScriptingInterface::getValue(const QString& setting) {
|
||||
QVariant value = SettingHandles::SettingHandle<QVariant>(setting).get();
|
||||
QVariant value = Setting::Handle<QVariant>(setting).get();
|
||||
if (!value.isValid()) {
|
||||
value = "";
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ QVariant SettingsScriptingInterface::getValue(const QString& setting) {
|
|||
}
|
||||
|
||||
QVariant SettingsScriptingInterface::getValue(const QString& setting, const QVariant& defaultValue) {
|
||||
QVariant value = SettingHandles::SettingHandle<QVariant>(setting, defaultValue).get();
|
||||
QVariant value = Setting::Handle<QVariant>(setting, defaultValue).get();
|
||||
if (!value.isValid()) {
|
||||
value = "";
|
||||
}
|
||||
|
@ -36,5 +36,5 @@ QVariant SettingsScriptingInterface::getValue(const QString& setting, const QVar
|
|||
}
|
||||
|
||||
void SettingsScriptingInterface::setValue(const QString& setting, const QVariant& value) {
|
||||
SettingHandles::SettingHandle<QVariant>(setting).set(value);
|
||||
Setting::Handle<QVariant>(setting).set(value);
|
||||
}
|
||||
|
|
|
@ -20,16 +20,10 @@
|
|||
#include <QScrollArea>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <Settings.h>
|
||||
|
||||
#include "AnimationsDialog.h"
|
||||
#include "Application.h"
|
||||
#include "MainWindow.h"
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QString> animationDirectory("animation_directory", QString());
|
||||
}
|
||||
|
||||
AnimationsDialog::AnimationsDialog(QWidget* parent) :
|
||||
QDialog(parent) {
|
||||
|
||||
|
@ -78,6 +72,8 @@ void AnimationsDialog::addAnimation() {
|
|||
this, Application::getInstance()->getAvatar()->addAnimationHandle()));
|
||||
}
|
||||
|
||||
Setting::Handle<QString> AnimationPanel::_animationDirectory("animation_directory", QString());
|
||||
|
||||
AnimationPanel::AnimationPanel(AnimationsDialog* dialog, const AnimationHandlePointer& handle) :
|
||||
_dialog(dialog),
|
||||
_handle(handle),
|
||||
|
@ -163,12 +159,12 @@ AnimationPanel::AnimationPanel(AnimationsDialog* dialog, const AnimationHandlePo
|
|||
}
|
||||
|
||||
void AnimationPanel::chooseURL() {
|
||||
QString directory = SettingHandles::animationDirectory.get();
|
||||
QString filename = QFileDialog::getOpenFileName(this, "Choose Animation", directory, "Animation files (*.fbx)");
|
||||
QString filename = QFileDialog::getOpenFileName(this, "Choose Animation",
|
||||
_animationDirectory.get(), "Animation files (*.fbx)");
|
||||
if (filename.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
SettingHandles::animationDirectory.set(QFileInfo(filename).path());
|
||||
_animationDirectory.set(QFileInfo(filename).path());
|
||||
_url->setText(QUrl::fromLocalFile(filename).toString());
|
||||
emit _url->returnPressed();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include <QDoubleSpinBox>
|
||||
#include <QFrame>
|
||||
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "avatar/MyAvatar.h"
|
||||
|
||||
class QCheckBox;
|
||||
|
@ -41,8 +43,8 @@ private slots:
|
|||
|
||||
private:
|
||||
|
||||
QVBoxLayout* _animations;
|
||||
QPushButton* _ok;
|
||||
QVBoxLayout* _animations = nullptr;
|
||||
QPushButton* _ok = nullptr;
|
||||
};
|
||||
|
||||
/// A panel controlling a single animation.
|
||||
|
@ -62,22 +64,24 @@ private slots:
|
|||
|
||||
private:
|
||||
|
||||
AnimationsDialog* _dialog;
|
||||
AnimationsDialog* _dialog = nullptr;
|
||||
AnimationHandlePointer _handle;
|
||||
QComboBox* _role;
|
||||
QLineEdit* _url;
|
||||
QDoubleSpinBox* _fps;
|
||||
QDoubleSpinBox* _priority;
|
||||
QCheckBox* _loop;
|
||||
QCheckBox* _hold;
|
||||
QCheckBox* _startAutomatically;
|
||||
QDoubleSpinBox* _firstFrame;
|
||||
QDoubleSpinBox* _lastFrame;
|
||||
QLineEdit* _maskedJoints;
|
||||
QPushButton* _chooseMaskedJoints;
|
||||
QPushButton* _start;
|
||||
QPushButton* _stop;
|
||||
QComboBox* _role = nullptr;
|
||||
QLineEdit* _url = nullptr;
|
||||
QDoubleSpinBox* _fps = nullptr;
|
||||
QDoubleSpinBox* _priority = nullptr;
|
||||
QCheckBox* _loop = nullptr;
|
||||
QCheckBox* _hold = nullptr;
|
||||
QCheckBox* _startAutomatically = nullptr;
|
||||
QDoubleSpinBox* _firstFrame = nullptr;
|
||||
QDoubleSpinBox* _lastFrame = nullptr;
|
||||
QLineEdit* _maskedJoints = nullptr;
|
||||
QPushButton* _chooseMaskedJoints = nullptr;
|
||||
QPushButton* _start = nullptr;
|
||||
QPushButton* _stop = nullptr;
|
||||
bool _applying;
|
||||
|
||||
static Setting::Handle<QString> _animationDirectory;
|
||||
};
|
||||
|
||||
#endif // hifi_AnimationsDialog_h
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <AddressManager.h>
|
||||
#include <AccountManager.h>
|
||||
#include <PathUtils.h>
|
||||
#include <Settings.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "ChatMessageArea.h"
|
||||
|
@ -42,10 +41,6 @@ const QRegularExpression regexHifiLinks("([#@]\\S+)");
|
|||
const QString mentionSoundsPath("/mention-sounds/");
|
||||
const QString mentionRegex("@(\\b%1\\b)");
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QDateTime> usernameMentionTimestamp("MentionTimestamp", QDateTime());
|
||||
}
|
||||
|
||||
ChatWindow::ChatWindow(QWidget* parent) :
|
||||
QWidget(parent, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint |
|
||||
Qt::WindowCloseButtonHint),
|
||||
|
@ -54,7 +49,8 @@ ChatWindow::ChatWindow(QWidget* parent) :
|
|||
_mousePressed(false),
|
||||
_mouseStartPosition(),
|
||||
_trayIcon(parent),
|
||||
_effectPlayer()
|
||||
_effectPlayer(),
|
||||
_usernameMentionTimestamp("MentionTimestamp", QDateTime())
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose, false);
|
||||
|
||||
|
@ -382,9 +378,9 @@ void ChatWindow::messageReceived(const QXmppMessage& message) {
|
|||
if (message.body().contains(usernameMention)) {
|
||||
|
||||
// Don't show messages already seen in icon tray at start-up.
|
||||
bool showMessage = SettingHandles::usernameMentionTimestamp.get() < _lastMessageStamp;
|
||||
bool showMessage = _usernameMentionTimestamp.get() < _lastMessageStamp;
|
||||
if (showMessage) {
|
||||
SettingHandles::usernameMentionTimestamp.set(_lastMessageStamp);
|
||||
_usernameMentionTimestamp.set(_lastMessageStamp);
|
||||
}
|
||||
|
||||
if (isHidden() && showMessage) {
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include <QTimer>
|
||||
|
||||
#include <Application.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "FramelessDialog.h"
|
||||
|
||||
#ifdef HAVE_QXMPP
|
||||
|
@ -69,6 +71,8 @@ private:
|
|||
QSystemTrayIcon _trayIcon;
|
||||
QStringList _mentionSounds;
|
||||
QMediaPlayer _effectPlayer;
|
||||
|
||||
Setting::Handle<QDateTime> _usernameMentionTimestamp;
|
||||
|
||||
private slots:
|
||||
void connected();
|
||||
|
|
|
@ -16,15 +16,13 @@
|
|||
#include <QtWebKit/QWebElement>
|
||||
|
||||
#include <PathUtils.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "InfoView.h"
|
||||
|
||||
static const float MAX_DIALOG_HEIGHT_RATIO = 0.9f;
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QString> infoVersion("info-version", QString());
|
||||
}
|
||||
Setting::Handle<QString> infoVersion("info-version", QString());
|
||||
|
||||
InfoView::InfoView(bool forced, QString path) :
|
||||
_forced(forced)
|
||||
|
@ -52,13 +50,13 @@ bool InfoView::shouldShow() {
|
|||
return true;
|
||||
}
|
||||
|
||||
QString lastVersion = SettingHandles::infoVersion.get();
|
||||
QString lastVersion = infoVersion.get();
|
||||
|
||||
QWebElement versionTag = page()->mainFrame()->findFirstElement("#version");
|
||||
QString version = versionTag.attribute("value");
|
||||
|
||||
if (version != QString::null && (lastVersion == QString::null || lastVersion != version)) {
|
||||
SettingHandles::infoVersion.set(version);
|
||||
infoVersion.set(version);
|
||||
shouldShow = true;
|
||||
} else {
|
||||
shouldShow = false;
|
||||
|
|
|
@ -85,6 +85,7 @@ ModelsBrowser::ModelsBrowser(ModelType modelsType, QWidget* parent) :
|
|||
|
||||
// Setup and launch update thread
|
||||
QThread* thread = new QThread();
|
||||
thread->setObjectName("Models Browser");
|
||||
thread->connect(_handler, SIGNAL(destroyed()), SLOT(quit()));
|
||||
thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater()));
|
||||
_handler->moveToThread(thread);
|
||||
|
|
|
@ -121,7 +121,7 @@ void PreferencesDialog::loadPreferences() {
|
|||
|
||||
ui.sendDataCheckBox->setChecked(!menuInstance->isOptionChecked(MenuOption::DisableActivityLogger));
|
||||
|
||||
ui.snapshotLocationEdit->setText(SettingHandles::snapshotsLocation.get());
|
||||
ui.snapshotLocationEdit->setText(Snapshot::snapshotsLocation.get());
|
||||
|
||||
ui.scriptsLocationEdit->setText(qApp->getScriptsLocation());
|
||||
|
||||
|
@ -153,9 +153,9 @@ void PreferencesDialog::loadPreferences() {
|
|||
ui.outputStarveDetectionThresholdSpinner->setValue(audio->getOutputStarveDetectionThreshold());
|
||||
ui.outputStarveDetectionPeriodSpinner->setValue(audio->getOutputStarveDetectionPeriod());
|
||||
|
||||
ui.realWorldFieldOfViewSpin->setValue(qApp->getViewFrustum()->getRealWorldFieldOfView());
|
||||
ui.realWorldFieldOfViewSpin->setValue(qApp->getAvatar()->getRealWorldFieldOfView());
|
||||
|
||||
ui.fieldOfViewSpin->setValue(qApp->getViewFrustum()->getFieldOfView());
|
||||
ui.fieldOfViewSpin->setValue(qApp->getFieldOfView());
|
||||
|
||||
ui.leanScaleSpin->setValue(myAvatar->getLeanScale());
|
||||
|
||||
|
@ -219,7 +219,7 @@ void PreferencesDialog::savePreferences() {
|
|||
}
|
||||
|
||||
if (!ui.snapshotLocationEdit->text().isEmpty() && QDir(ui.snapshotLocationEdit->text()).exists()) {
|
||||
SettingHandles::snapshotsLocation.set(ui.snapshotLocationEdit->text());
|
||||
Snapshot::snapshotsLocation.set(ui.snapshotLocationEdit->text());
|
||||
}
|
||||
|
||||
if (!ui.scriptsLocationEdit->text().isEmpty() && QDir(ui.scriptsLocationEdit->text()).exists()) {
|
||||
|
@ -233,9 +233,9 @@ void PreferencesDialog::savePreferences() {
|
|||
auto glCanvas = DependencyManager::get<GLCanvas>();
|
||||
Application::getInstance()->resizeGL(glCanvas->width(), glCanvas->height());
|
||||
|
||||
qApp->getViewFrustum()->setRealWorldFieldOfView(ui.realWorldFieldOfViewSpin->value());
|
||||
qApp->getAvatar()->setRealWorldFieldOfView(ui.realWorldFieldOfViewSpin->value());
|
||||
|
||||
qApp->getViewFrustum()->setFieldOfView(ui.fieldOfViewSpin->value());
|
||||
qApp->setFieldOfView(ui.fieldOfViewSpin->value());
|
||||
|
||||
auto faceshift = DependencyManager::get<Faceshift>();
|
||||
faceshift->setEyeDeflection(ui.faceshiftEyeDeflectionSider->value() /
|
||||
|
|
|
@ -23,6 +23,11 @@
|
|||
const int ICON_SIZE = 24;
|
||||
const int ICON_PADDING = 5;
|
||||
|
||||
const char SETTINGS_GROUP_NAME[] = "Rear View Tools";
|
||||
const char ZOOM_LEVEL_SETTINGS[] = "ZoomLevel";
|
||||
Setting::Handle<int> RearMirrorTools::rearViewZoomLevel(QStringList() << SETTINGS_GROUP_NAME << ZOOM_LEVEL_SETTINGS,
|
||||
ZoomLevel::HEAD);
|
||||
|
||||
RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds) :
|
||||
_parent(parent),
|
||||
_bounds(bounds),
|
||||
|
@ -52,7 +57,7 @@ void RearMirrorTools::render(bool fullScreen) {
|
|||
if (_windowed) {
|
||||
displayIcon(_bounds, _closeIconRect, _closeTextureId);
|
||||
|
||||
ZoomLevel zoomLevel = (ZoomLevel)SettingHandles::rearViewZoomLevel.get();
|
||||
ZoomLevel zoomLevel = (ZoomLevel)rearViewZoomLevel.get();
|
||||
displayIcon(_bounds, _headZoomIconRect, _zoomHeadTextureId, zoomLevel == HEAD);
|
||||
displayIcon(_bounds, _bodyZoomIconRect, _zoomBodyTextureId, zoomLevel == BODY);
|
||||
}
|
||||
|
@ -68,12 +73,12 @@ bool RearMirrorTools::mousePressEvent(int x, int y) {
|
|||
}
|
||||
|
||||
if (_headZoomIconRect.contains(x, y)) {
|
||||
SettingHandles::rearViewZoomLevel.set(HEAD);
|
||||
rearViewZoomLevel.set(HEAD);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_bodyZoomIconRect.contains(x, y)) {
|
||||
SettingHandles::rearViewZoomLevel.set(BODY);
|
||||
rearViewZoomLevel.set(BODY);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,26 +16,21 @@
|
|||
|
||||
#include <QGLWidget>
|
||||
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
enum ZoomLevel {
|
||||
HEAD = 0,
|
||||
BODY = 1
|
||||
};
|
||||
|
||||
namespace SettingHandles {
|
||||
const char SETTINGS_GROUP_NAME[] = "Rear View Tools";
|
||||
const char ZOOM_LEVEL_SETTINGS[] = "ZoomLevel";
|
||||
const SettingHandle<int> rearViewZoomLevel(QStringList() << SETTINGS_GROUP_NAME << ZOOM_LEVEL_SETTINGS,
|
||||
ZoomLevel::HEAD);
|
||||
}
|
||||
|
||||
class RearMirrorTools : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RearMirrorTools(QGLWidget* parent, QRect& bounds);
|
||||
void render(bool fullScreen);
|
||||
bool mousePressEvent(int x, int y);
|
||||
|
||||
static Setting::Handle<int> rearViewZoomLevel;
|
||||
|
||||
signals:
|
||||
void closeView();
|
||||
|
|
|
@ -40,6 +40,9 @@ const QString ORIENTATION_W = "orientation-w";
|
|||
|
||||
const QString DOMAIN_KEY = "domain";
|
||||
|
||||
Setting::Handle<QString> Snapshot::snapshotsLocation("snapshotsLocation",
|
||||
QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
|
||||
|
||||
SnapshotMetaData* Snapshot::parseSnapshotData(QString snapshotPath) {
|
||||
|
||||
if (!QFile(snapshotPath).exists()) {
|
||||
|
@ -122,7 +125,7 @@ QFile* Snapshot::savedFileForSnapshot(bool isTemporary) {
|
|||
const int IMAGE_QUALITY = 100;
|
||||
|
||||
if (!isTemporary) {
|
||||
QString snapshotFullPath = SettingHandles::snapshotsLocation.get();
|
||||
QString snapshotFullPath = snapshotsLocation.get();
|
||||
|
||||
if (!snapshotFullPath.endsWith(QDir::separator())) {
|
||||
snapshotFullPath.append(QDir::separator());
|
||||
|
|
|
@ -16,16 +16,11 @@
|
|||
|
||||
#include <QString>
|
||||
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
class QFile;
|
||||
class QTemporaryFile;
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QString> snapshotsLocation("snapshotsLocation",
|
||||
QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
|
||||
}
|
||||
|
||||
class SnapshotMetaData {
|
||||
public:
|
||||
|
||||
|
@ -50,6 +45,7 @@ public:
|
|||
static QTemporaryFile* saveTempSnapshot();
|
||||
static SnapshotMetaData* parseSnapshotData(QString snapshotPath);
|
||||
|
||||
static Setting::Handle<QString> snapshotsLocation;
|
||||
private:
|
||||
static QFile* savedFileForSnapshot(bool isTemporary);
|
||||
};
|
||||
|
|
|
@ -53,6 +53,7 @@ AudioInjector* AudioScriptingInterface::playSound(Sound* sound, const AudioInjec
|
|||
injector->setLocalAudioInterface(_localAudioInterface);
|
||||
|
||||
QThread* injectorThread = new QThread();
|
||||
injectorThread->setObjectName("Audio Injector Thread");
|
||||
|
||||
injector->moveToThread(injectorThread);
|
||||
|
||||
|
|
|
@ -11,27 +11,11 @@
|
|||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <Settings.h>
|
||||
|
||||
#include "InboundAudioStream.h"
|
||||
#include "PacketHeaders.h"
|
||||
|
||||
const int STARVE_HISTORY_CAPACITY = 50;
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<bool> dynamicJitterBuffers("dynamicJitterBuffers", DEFAULT_DYNAMIC_JITTER_BUFFERS);
|
||||
const SettingHandle<int> maxFramesOverDesired("maxFramesOverDesired", DEFAULT_MAX_FRAMES_OVER_DESIRED);
|
||||
const SettingHandle<int> staticDesiredJitterBufferFrames("staticDesiredJitterBufferFrames",
|
||||
DEFAULT_STATIC_DESIRED_JITTER_BUFFER_FRAMES);
|
||||
const SettingHandle<bool> useStDevForJitterCalc("useStDevForJitterCalc", DEFAULT_USE_STDEV_FOR_JITTER_CALC);
|
||||
const SettingHandle<int> windowStarveThreshold("windowStarveThreshold", DEFAULT_WINDOW_STARVE_THRESHOLD);
|
||||
const SettingHandle<int> windowSecondsForDesiredCalcOnTooManyStarves("windowSecondsForDesiredCalcOnTooManyStarves",
|
||||
DEFAULT_WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES);
|
||||
const SettingHandle<int> windowSecondsForDesiredReduction("windowSecondsForDesiredReduction",
|
||||
DEFAULT_WINDOW_SECONDS_FOR_DESIRED_REDUCTION);
|
||||
const SettingHandle<bool> repetitionWithFade("repetitionWithFade", DEFAULT_REPETITION_WITH_FADE);
|
||||
}
|
||||
|
||||
InboundAudioStream::InboundAudioStream(int numFrameSamples, int numFramesCapacity, const Settings& settings) :
|
||||
_ringBuffer(numFrameSamples, false, numFramesCapacity),
|
||||
_lastPopSucceeded(false),
|
||||
|
@ -517,27 +501,3 @@ float calculateRepeatedFrameFadeFactor(int indexOfRepeat) {
|
|||
return 0.0f;
|
||||
}
|
||||
|
||||
void InboundAudioStream::loadSettings() {
|
||||
setDynamicJitterBuffers(SettingHandles::dynamicJitterBuffers.get());
|
||||
setMaxFramesOverDesired(SettingHandles::maxFramesOverDesired.get());
|
||||
setStaticDesiredJitterBufferFrames(SettingHandles::staticDesiredJitterBufferFrames.get());
|
||||
setUseStDevForJitterCalc(SettingHandles::useStDevForJitterCalc.get());
|
||||
setWindowStarveThreshold(SettingHandles::windowStarveThreshold.get());
|
||||
setWindowSecondsForDesiredCalcOnTooManyStarves(SettingHandles::windowSecondsForDesiredCalcOnTooManyStarves.get());
|
||||
setWindowSecondsForDesiredReduction(SettingHandles::windowSecondsForDesiredReduction.get());
|
||||
setRepetitionWithFade(SettingHandles::repetitionWithFade.get());
|
||||
}
|
||||
|
||||
void InboundAudioStream::saveSettings() {
|
||||
SettingHandles::dynamicJitterBuffers.set(getDynamicJitterBuffers());
|
||||
SettingHandles::maxFramesOverDesired.set(getMaxFramesOverDesired());
|
||||
SettingHandles::staticDesiredJitterBufferFrames.set(getDesiredJitterBufferFrames());
|
||||
SettingHandles::useStDevForJitterCalc.set(getUseStDevForJitterCalc());
|
||||
SettingHandles::windowStarveThreshold.set(getWindowStarveThreshold());
|
||||
SettingHandles::windowSecondsForDesiredCalcOnTooManyStarves.set(getWindowSecondsForDesiredCalcOnTooManyStarves());
|
||||
SettingHandles::windowSecondsForDesiredReduction.set(getWindowSecondsForDesiredReduction());
|
||||
SettingHandles::repetitionWithFade.set(getRepetitionWithFade());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -126,9 +126,6 @@ public:
|
|||
void setWindowSecondsForDesiredReduction(int windowSecondsForDesiredReduction);
|
||||
void setRepetitionWithFade(bool repetitionWithFade) { _repetitionWithFade = repetitionWithFade; }
|
||||
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
virtual AudioStreamStats getAudioStreamStats() const;
|
||||
|
||||
/// returns the desired number of jitter buffer frames under the dyanmic jitter buffers scheme
|
||||
|
|
|
@ -166,6 +166,7 @@ void Player::pausePlayer() {
|
|||
|
||||
void Player::setupAudioThread() {
|
||||
_audioThread = new QThread();
|
||||
_audioThread->setObjectName("Player Audio Thread");
|
||||
_options.position = _avatar->getPosition();
|
||||
_options.orientation = _avatar->getOrientation();
|
||||
_injector.reset(new AudioInjector(_recording->getAudioData(), _options), &QObject::deleteLater);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <QtDebug>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "MetavoxelUtil.h"
|
||||
#include "ScriptCache.h"
|
||||
|
@ -485,9 +485,7 @@ void QColorEditor::selectColor() {
|
|||
}
|
||||
}
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QStringList> editorURLs("editorURLs");
|
||||
}
|
||||
Setting::Handle<QStringList> editorURLs("editorURLs");
|
||||
|
||||
QUrlEditor::QUrlEditor(QWidget* parent) :
|
||||
QComboBox(parent) {
|
||||
|
@ -496,7 +494,7 @@ QUrlEditor::QUrlEditor(QWidget* parent) :
|
|||
setInsertPolicy(InsertAtTop);
|
||||
|
||||
// populate initial URL list from settings
|
||||
addItems(SettingHandles::editorURLs.get());
|
||||
addItems(editorURLs.get());
|
||||
|
||||
connect(this, SIGNAL(activated(const QString&)), SLOT(updateURL(const QString&)));
|
||||
connect(model(), SIGNAL(rowsInserted(const QModelIndex&,int,int)), SLOT(updateSettings()));
|
||||
|
@ -516,7 +514,7 @@ void QUrlEditor::updateSettings() {
|
|||
for (int i = 0, size = qMin(MAX_STORED_URLS, count()); i < size; i++) {
|
||||
urls.append(itemText(i));
|
||||
}
|
||||
SettingHandles::editorURLs.set(urls);
|
||||
editorURLs.set(urls);
|
||||
}
|
||||
|
||||
BaseVec3Editor::BaseVec3Editor(QWidget* parent) : QWidget(parent) {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <glm/gtx/transform.hpp>
|
||||
|
||||
#include <GeometryUtil.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "MetavoxelData.h"
|
||||
#include "Spanner.h"
|
||||
|
@ -58,9 +58,7 @@ static QItemEditorCreatorBase* heightfieldColorEditorCreator = createHeightfield
|
|||
const float DEFAULT_PLACEMENT_GRANULARITY = 0.01f;
|
||||
const float DEFAULT_VOXELIZATION_GRANULARITY = powf(2.0f, -3.0f);
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QString> heightfieldDir("heightDir", QString());
|
||||
}
|
||||
Setting::Handle<QString> heightfieldDir("heightDir");
|
||||
|
||||
Spanner::Spanner() :
|
||||
_renderer(NULL),
|
||||
|
@ -615,12 +613,12 @@ static int getHeightfieldSize(int size) {
|
|||
|
||||
void HeightfieldHeightEditor::select() {
|
||||
QString result = QFileDialog::getOpenFileName(this, "Select Height Image",
|
||||
SettingHandles::heightfieldDir.get(),
|
||||
heightfieldDir.get(),
|
||||
"Images (*.png *.jpg *.bmp *.raw *.mdr)");
|
||||
if (result.isNull()) {
|
||||
return;
|
||||
}
|
||||
SettingHandles::heightfieldDir.set(QFileInfo(result).path());
|
||||
heightfieldDir.set(QFileInfo(result).path());
|
||||
const quint16 CONVERSION_OFFSET = 1;
|
||||
QString lowerResult = result.toLower();
|
||||
bool isMDR = lowerResult.endsWith(".mdr");
|
||||
|
@ -885,12 +883,12 @@ void HeightfieldColorEditor::setColor(const HeightfieldColorPointer& color) {
|
|||
|
||||
void HeightfieldColorEditor::select() {
|
||||
QString result = QFileDialog::getOpenFileName(this, "Select Color Image",
|
||||
SettingHandles::heightfieldDir.get(),
|
||||
heightfieldDir.get(),
|
||||
"Images (*.png *.jpg *.bmp)");
|
||||
if (result.isNull()) {
|
||||
return;
|
||||
}
|
||||
SettingHandles::heightfieldDir.get(QFileInfo(result).path());
|
||||
heightfieldDir.get(QFileInfo(result).path());
|
||||
QImage image;
|
||||
if (!image.load(result)) {
|
||||
QMessageBox::warning(this, "Invalid Image", "The selected image could not be read.");
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <QtNetwork/QNetworkRequest>
|
||||
#include <qthread.h>
|
||||
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "NodeList.h"
|
||||
#include "PacketHeaders.h"
|
||||
|
@ -93,7 +93,7 @@ void AccountManager::logout() {
|
|||
if (_shouldPersistToSettingsFile) {
|
||||
QString keyURLString(_authURL.toString().replace("//", DOUBLE_SLASH_SUBSTITUTE));
|
||||
QStringList path = QStringList() << ACCOUNTS_GROUP << keyURLString;
|
||||
SettingHandles::SettingHandle<DataServerAccountInfo>(path).remove();
|
||||
Setting::Handle<DataServerAccountInfo>(path).remove();
|
||||
|
||||
qDebug() << "Removed account info for" << _authURL << "from in-memory accounts and .ini file";
|
||||
} else {
|
||||
|
@ -341,7 +341,7 @@ void AccountManager::persistAccountToSettings() {
|
|||
// store this access token into the local settings
|
||||
QString keyURLString(_authURL.toString().replace("//", DOUBLE_SLASH_SUBSTITUTE));
|
||||
QStringList path = QStringList() << ACCOUNTS_GROUP << keyURLString;
|
||||
SettingHandles::SettingHandle<QVariant>(path).set(QVariant::fromValue(_accountInfo));
|
||||
Setting::Handle<QVariant>(path).set(QVariant::fromValue(_accountInfo));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -497,6 +497,7 @@ void AccountManager::requestProfileError(QNetworkReply::NetworkError error) {
|
|||
void AccountManager::generateNewKeypair() {
|
||||
// setup a new QThread to generate the keypair on, in case it takes a while
|
||||
QThread* generateThread = new QThread(this);
|
||||
generateThread->setObjectName("Account Manager Generator Thread");
|
||||
|
||||
// setup a keypair generator
|
||||
RSAKeypairGenerator* keypairGenerator = new RSAKeypairGenerator();
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <QStringList>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <UUID.h>
|
||||
|
||||
#include "NodeList.h"
|
||||
|
@ -26,11 +26,9 @@
|
|||
|
||||
const QString ADDRESS_MANAGER_SETTINGS_GROUP = "AddressManager";
|
||||
const QString SETTINGS_CURRENT_ADDRESS_KEY = "address";
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QUrl> currentAddress(QStringList() << ADDRESS_MANAGER_SETTINGS_GROUP
|
||||
<< "address",
|
||||
QUrl());
|
||||
}
|
||||
|
||||
Setting::Handle<QUrl> currentAddressHandle(QStringList() << ADDRESS_MANAGER_SETTINGS_GROUP << "address");
|
||||
|
||||
|
||||
AddressManager::AddressManager() :
|
||||
_rootPlaceName(),
|
||||
|
@ -57,14 +55,14 @@ const QUrl AddressManager::currentAddress() const {
|
|||
|
||||
void AddressManager::loadSettings(const QString& lookupString) {
|
||||
if (lookupString.isEmpty()) {
|
||||
handleLookupString(SettingHandles::currentAddress.get().toString());
|
||||
handleLookupString(currentAddressHandle.get().toString());
|
||||
} else {
|
||||
handleLookupString(lookupString);
|
||||
}
|
||||
}
|
||||
|
||||
void AddressManager::storeCurrentAddress() {
|
||||
SettingHandles::currentAddress.set(currentAddress());
|
||||
currentAddressHandle.set(currentAddress());
|
||||
}
|
||||
|
||||
const QString AddressManager::currentPath(bool withOrientation) const {
|
||||
|
|
|
@ -11,23 +11,21 @@
|
|||
|
||||
#include <GLMHelpers.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "OctreeConstants.h"
|
||||
#include "OctreeQuery.h"
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
|
||||
}
|
||||
Setting::Handle<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
|
||||
|
||||
OctreeQuery::OctreeQuery() {
|
||||
_maxOctreePPS = SettingHandles::maxOctreePacketsPerSecond.get();
|
||||
_maxOctreePPS = maxOctreePacketsPerSecond.get();
|
||||
}
|
||||
|
||||
void OctreeQuery::setMaxOctreePacketsPerSecond(int maxOctreePPS) {
|
||||
if (maxOctreePPS != _maxOctreePPS) {
|
||||
_maxOctreePPS = maxOctreePPS;
|
||||
SettingHandles::maxOctreePacketsPerSecond.set(_maxOctreePPS);
|
||||
maxOctreePacketsPerSecond.set(_maxOctreePPS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include <Settings.h>
|
||||
|
||||
#include "GeometryUtil.h"
|
||||
#include "SharedUtil.h"
|
||||
#include "ViewFrustum.h"
|
||||
|
@ -26,14 +24,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<float> fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES);
|
||||
const SettingHandle<float> realWorldFieldOfView("realWorldFieldOfView", DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES);
|
||||
}
|
||||
|
||||
ViewFrustum::ViewFrustum() {
|
||||
_fieldOfView = SettingHandles::fieldOfView.get();
|
||||
_realWorldFieldOfView = SettingHandles::realWorldFieldOfView.get();
|
||||
}
|
||||
|
||||
void ViewFrustum::setOrientation(const glm::quat& orientationAsQuaternion) {
|
||||
|
@ -43,19 +34,6 @@ void ViewFrustum::setOrientation(const glm::quat& orientationAsQuaternion) {
|
|||
_direction = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_FRONT, 0.0f));
|
||||
}
|
||||
|
||||
void ViewFrustum::setFieldOfView(float f) {
|
||||
if (f != _fieldOfView) {
|
||||
_fieldOfView = f;
|
||||
SettingHandles::fieldOfView.set(f);
|
||||
}
|
||||
}
|
||||
void ViewFrustum::setRealWorldFieldOfView(float realWorldFieldOfView) {
|
||||
if (realWorldFieldOfView != _realWorldFieldOfView) {
|
||||
_realWorldFieldOfView = realWorldFieldOfView;
|
||||
SettingHandles::realWorldFieldOfView.set(realWorldFieldOfView);
|
||||
}
|
||||
}
|
||||
|
||||
// ViewFrustum::calculateViewFrustum()
|
||||
//
|
||||
// Description: this will calculate the view frustum bounds for a given position and direction
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
const float DEFAULT_KEYHOLE_RADIUS = 3.0f;
|
||||
const float DEFAULT_FIELD_OF_VIEW_DEGREES = 45.0f;
|
||||
const float DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES = 30.0f;
|
||||
const float DEFAULT_ASPECT_RATIO = 16.0f/9.0f;
|
||||
const float DEFAULT_NEAR_CLIP = 0.08f;
|
||||
const float DEFAULT_FAR_CLIP = TREE_SCALE;
|
||||
|
@ -52,8 +51,7 @@ public:
|
|||
void setOrthographic(bool orthographic) { _orthographic = orthographic; }
|
||||
void setWidth(float width) { _width = width; }
|
||||
void setHeight(float height) { _height = height; }
|
||||
void setFieldOfView(float f);
|
||||
void setRealWorldFieldOfView(float realWorldFieldOfView);
|
||||
void setFieldOfView(float f) { _fieldOfView = f; }
|
||||
void setAspectRatio(float a) { _aspectRatio = a; }
|
||||
void setNearClip(float n) { _nearClip = n; }
|
||||
void setFarClip(float f) { _farClip = f; }
|
||||
|
@ -66,7 +64,6 @@ public:
|
|||
float getWidth() const { return _width; }
|
||||
float getHeight() const { return _height; }
|
||||
float getFieldOfView() const { return _fieldOfView; }
|
||||
float getRealWorldFieldOfView() const { return _realWorldFieldOfView; }
|
||||
float getAspectRatio() const { return _aspectRatio; }
|
||||
float getNearClip() const { return _nearClip; }
|
||||
float getFarClip() const { return _farClip; }
|
||||
|
@ -158,9 +155,6 @@ private:
|
|||
|
||||
// in Degrees, doesn't apply to HMD like Oculus
|
||||
float _fieldOfView = DEFAULT_FIELD_OF_VIEW_DEGREES;
|
||||
// The actual FOV set by the user's monitor size and view distance
|
||||
float _realWorldFieldOfView = DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES;
|
||||
|
||||
|
||||
// keyhole attributes
|
||||
float _keyholeRadius = DEFAULT_KEYHOLE_RADIUS;
|
||||
|
|
68
libraries/shared/src/SettingHandle.h
Normal file
68
libraries/shared/src/SettingHandle.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
//
|
||||
// SettingHandle.h
|
||||
//
|
||||
//
|
||||
// Created by Clement on 1/18/15.
|
||||
// Copyright 2015 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_SettingHandle_h
|
||||
#define hifi_SettingHandle_h
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
#include "SettingInterface.h"
|
||||
|
||||
// TODO: remove
|
||||
class Settings : public QSettings {
|
||||
|
||||
};
|
||||
|
||||
namespace Setting {
|
||||
template <typename T>
|
||||
class Handle : public Interface {
|
||||
public:
|
||||
Handle(const QString& key) : Interface(key) {}
|
||||
Handle(const QStringList& path) : Interface(path.join("/")) {}
|
||||
|
||||
Handle(const QString& key, const T& defaultValue) : Interface(key), _defaultValue(defaultValue) {}
|
||||
Handle(const QStringList& path, const T& defaultValue) : Handle(path.join("/"), defaultValue) {}
|
||||
|
||||
virtual ~Handle() { save(); }
|
||||
|
||||
// Returns setting value, returns its default value if not found
|
||||
T get() { return get(_defaultValue); }
|
||||
// Returns setting value, returns other if not found
|
||||
T get(const T& other) { maybeInit(); return (_isSet) ? _value : other; }
|
||||
T getDefault() const { return _defaultValue; }
|
||||
|
||||
void set(const T& value) { maybeInit(); _value = value; _isSet = true; }
|
||||
void reset() { set(_defaultValue); }
|
||||
|
||||
void remove() { maybeInit(); _isSet = false; }
|
||||
|
||||
protected:
|
||||
virtual void setVariant(const QVariant& variant);
|
||||
virtual QVariant getVariant() { return QVariant::fromValue(get()); }
|
||||
|
||||
private:
|
||||
T _value;
|
||||
const T _defaultValue;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void Handle<T>::setVariant(const QVariant& variant) {
|
||||
if (variant.canConvert<T>() || std::is_same<T, QVariant>::value) {
|
||||
set(variant.value<T>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // hifi_SettingHandle_h
|
100
libraries/shared/src/SettingInterface.cpp
Normal file
100
libraries/shared/src/SettingInterface.cpp
Normal file
|
@ -0,0 +1,100 @@
|
|||
//
|
||||
// SettingInterface.cpp
|
||||
//
|
||||
//
|
||||
// Created by Clement on 2/2/15.
|
||||
// Copyright 2015 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 <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QThread>
|
||||
|
||||
#include "PathUtils.h"
|
||||
#include "SettingInterface.h"
|
||||
#include "SettingManager.h"
|
||||
|
||||
namespace Setting {
|
||||
static Manager* privateInstance = nullptr;
|
||||
|
||||
// cleans up the settings private instance. Should only be run once at closing down.
|
||||
void cleanupPrivateInstance() {
|
||||
delete privateInstance;
|
||||
privateInstance = nullptr;
|
||||
}
|
||||
|
||||
// Sets up the settings private instance. Should only be run once at startup
|
||||
void setupPrivateInstance() {
|
||||
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
|
||||
// set the associated application properties
|
||||
applicationInfo.beginGroup("INFO");
|
||||
QCoreApplication::setApplicationName(applicationInfo.value("name").toString());
|
||||
QCoreApplication::setOrganizationName(applicationInfo.value("organizationName").toString());
|
||||
QCoreApplication::setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
|
||||
|
||||
// Let's set up the settings Private instance on it's own thread
|
||||
QThread* thread = new QThread();
|
||||
Q_CHECK_PTR(thread);
|
||||
thread->setObjectName("Settings Thread");
|
||||
|
||||
privateInstance = new Manager();
|
||||
Q_CHECK_PTR(privateInstance);
|
||||
|
||||
QObject::connect(privateInstance, SIGNAL(destroyed()), thread, SLOT(quit()));
|
||||
QObject::connect(thread, SIGNAL(started()), privateInstance, SLOT(startTimer()));
|
||||
QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||
privateInstance->moveToThread(thread);
|
||||
thread->start();
|
||||
qDebug() << "Settings thread started.";
|
||||
|
||||
// Register cleanupPrivateInstance to run inside QCoreApplication's destructor.
|
||||
qAddPostRoutine(cleanupPrivateInstance);
|
||||
}
|
||||
// Register setupPrivateInstance to run after QCoreApplication's constructor.
|
||||
Q_COREAPP_STARTUP_FUNCTION(setupPrivateInstance)
|
||||
|
||||
|
||||
Interface::~Interface() {
|
||||
if (privateInstance) {
|
||||
privateInstance->removeHandle(_key);
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::init() {
|
||||
if (!privateInstance) {
|
||||
qWarning() << "Setting::Interface::init(): Manager not yet created, bailing";
|
||||
return;
|
||||
}
|
||||
|
||||
// Register Handle
|
||||
privateInstance->registerHandle(this);
|
||||
_isInitialized = true;
|
||||
|
||||
// Load value from disk
|
||||
load();
|
||||
}
|
||||
|
||||
void Interface::maybeInit() {
|
||||
if (!_isInitialized) {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::save() {
|
||||
if (privateInstance) {
|
||||
privateInstance->saveSetting(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::load() {
|
||||
if (privateInstance) {
|
||||
privateInstance->loadSetting(this);
|
||||
}
|
||||
}
|
||||
}
|
45
libraries/shared/src/SettingInterface.h
Normal file
45
libraries/shared/src/SettingInterface.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// SettingInterface.h
|
||||
//
|
||||
//
|
||||
// Created by Clement on 2/2/15.
|
||||
// Copyright 2015 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_SettingInterface_h
|
||||
#define hifi_SettingInterface_h
|
||||
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
namespace Setting {
|
||||
class Interface {
|
||||
public:
|
||||
QString getKey() const { return _key; }
|
||||
bool isSet() const { return _isSet; }
|
||||
|
||||
virtual void setVariant(const QVariant& variant) = 0;
|
||||
virtual QVariant getVariant() = 0;
|
||||
|
||||
protected:
|
||||
Interface(const QString& key) : _key(key) {}
|
||||
virtual ~Interface();
|
||||
|
||||
void init();
|
||||
void maybeInit();
|
||||
|
||||
void save();
|
||||
void load();
|
||||
|
||||
bool _isInitialized = false;
|
||||
bool _isSet = false;
|
||||
const QString _key;
|
||||
|
||||
friend class Manager;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // hifi_SettingInterface_h
|
80
libraries/shared/src/SettingManager.cpp
Normal file
80
libraries/shared/src/SettingManager.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
//
|
||||
// SettingManager.cpp
|
||||
//
|
||||
//
|
||||
// Created by Clement on 2/2/15.
|
||||
// Copyright 2015 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 <QDebug>
|
||||
|
||||
#include "SettingInterface.h"
|
||||
#include "SettingManager.h"
|
||||
|
||||
namespace Setting {
|
||||
Manager::~Manager() {
|
||||
// Cleanup timer
|
||||
stopTimer();
|
||||
disconnect(_saveTimer, 0, 0, 0);
|
||||
|
||||
// Save all settings before exit
|
||||
saveAll();
|
||||
sync();
|
||||
}
|
||||
|
||||
void Manager::registerHandle(Setting::Interface* handle) {
|
||||
QString key = handle->getKey();
|
||||
if (_handles.contains(key)) {
|
||||
qWarning() << "Setting::Manager::registerHandle(): Key registered more than once, overriding: " << key;
|
||||
}
|
||||
_handles.insert(key, handle);
|
||||
}
|
||||
|
||||
void Manager::removeHandle(const QString& key) {
|
||||
_handles.remove(key);
|
||||
}
|
||||
|
||||
void Manager::loadSetting(Interface* handle) {
|
||||
handle->setVariant(value(handle->getKey()));
|
||||
}
|
||||
|
||||
void Manager::saveSetting(Interface* handle) {
|
||||
if (handle->isSet()) {
|
||||
setValue(handle->getKey(), handle->getVariant());
|
||||
} else {
|
||||
remove(handle->getKey());
|
||||
}
|
||||
}
|
||||
|
||||
static const int SAVE_INTERVAL_MSEC = 5 * 1000; // 5 sec
|
||||
void Manager::startTimer() {
|
||||
if (!_saveTimer) {
|
||||
_saveTimer = new QTimer(this);
|
||||
Q_CHECK_PTR(_saveTimer);
|
||||
_saveTimer->setSingleShot(true); // We will restart it once settings are saved.
|
||||
_saveTimer->setInterval(SAVE_INTERVAL_MSEC);
|
||||
connect(_saveTimer, SIGNAL(timeout()), this, SLOT(saveAll()));
|
||||
}
|
||||
_saveTimer->start();
|
||||
}
|
||||
|
||||
void Manager::stopTimer() {
|
||||
if (_saveTimer) {
|
||||
_saveTimer->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::saveAll() {
|
||||
for (auto handle : _handles) {
|
||||
saveSetting(handle);
|
||||
}
|
||||
|
||||
// Restart timer
|
||||
if (_saveTimer) {
|
||||
_saveTimer->start();
|
||||
}
|
||||
}
|
||||
}
|
48
libraries/shared/src/SettingManager.h
Normal file
48
libraries/shared/src/SettingManager.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// SettingManager.h
|
||||
//
|
||||
//
|
||||
// Created by Clement on 2/2/15.
|
||||
// Copyright 2015 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_SettingManager_h
|
||||
#define hifi_SettingManager_h
|
||||
|
||||
#include <QPointer>
|
||||
#include <QSettings>
|
||||
#include <QTimer>
|
||||
|
||||
namespace Setting {
|
||||
class Interface;
|
||||
|
||||
class Manager : public QSettings {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
~Manager();
|
||||
void registerHandle(Interface* handle);
|
||||
void removeHandle(const QString& key);
|
||||
|
||||
void loadSetting(Interface* handle);
|
||||
void saveSetting(Interface* handle);
|
||||
|
||||
private slots:
|
||||
void startTimer();
|
||||
void stopTimer();
|
||||
|
||||
void saveAll();
|
||||
|
||||
private:
|
||||
QHash<QString, Interface*> _handles;
|
||||
QPointer<QTimer> _saveTimer = nullptr;
|
||||
|
||||
friend class Interface;
|
||||
friend void cleanupPrivateInstance();
|
||||
friend void setupPrivateInstance();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // hifi_SettingManager_h
|
|
@ -1,43 +0,0 @@
|
|||
//
|
||||
// Settings.cpp
|
||||
//
|
||||
//
|
||||
// Created by Clement on 1/18/15.
|
||||
// Copyright 2015 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 <QSettings>
|
||||
#include <QThread>
|
||||
#include <QThreadStorage>
|
||||
|
||||
#include "Settings.h"
|
||||
|
||||
namespace SettingHandles {
|
||||
|
||||
static QThreadStorage<QSettings*> storage;
|
||||
|
||||
QSettings* getSettings() {
|
||||
if (!storage.hasLocalData()) {
|
||||
storage.setLocalData(new QSettings());
|
||||
QObject::connect(QThread::currentThread(), &QThread::destroyed,
|
||||
storage.localData(), &QSettings::deleteLater);
|
||||
}
|
||||
return storage.localData();
|
||||
}
|
||||
|
||||
QVariant SettingsBridge::getFromSettings(const QString& key, const QVariant& defaultValue) {
|
||||
return getSettings()->value(key, defaultValue);
|
||||
}
|
||||
|
||||
void SettingsBridge::setInSettings(const QString& key, const QVariant& value) {
|
||||
getSettings()->setValue(key, value);
|
||||
}
|
||||
|
||||
void SettingsBridge::removeFromSettings(const QString& key) {
|
||||
getSettings()->remove(key);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
//
|
||||
// Settings.h
|
||||
//
|
||||
//
|
||||
// Created by Clement on 1/18/15.
|
||||
// Copyright 2015 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_Settings_h
|
||||
#define hifi_Settings_h
|
||||
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
// TODO: remove
|
||||
class Settings : public QSettings {
|
||||
|
||||
};
|
||||
|
||||
namespace SettingHandles {
|
||||
|
||||
template <typename T>
|
||||
class SettingHandle {
|
||||
public:
|
||||
SettingHandle(const QString& key);
|
||||
SettingHandle(const QStringList& path);
|
||||
SettingHandle(const QString& key, const T& defaultValue);
|
||||
SettingHandle(const QStringList& path, const T& defaultValue);
|
||||
|
||||
T get() const; // Returns setting value, returns its default value if not found
|
||||
T get(const T& other) const; // Returns setting value, returns other if not found
|
||||
T getDefault() const;
|
||||
|
||||
void set(const T& value) const;
|
||||
void reset() const;
|
||||
|
||||
void remove() const;
|
||||
|
||||
private:
|
||||
const QString _key;
|
||||
const QVariant _defaultValue;
|
||||
};
|
||||
|
||||
class SettingsBridge {
|
||||
private:
|
||||
static QVariant getFromSettings(const QString& key, const QVariant& defaultValue);
|
||||
static void setInSettings(const QString& key, const QVariant& value);
|
||||
static void removeFromSettings(const QString& key);
|
||||
|
||||
template<typename T>
|
||||
friend class SettingHandle;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
SettingHandle<T>::SettingHandle(const QString& key) : _key(key) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
SettingHandle<T>::SettingHandle(const QStringList& path) : _key(path.join("/")) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
SettingHandle<T>::SettingHandle(const QString& key, const T& defaultValue) :
|
||||
_key(key),
|
||||
_defaultValue(defaultValue) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
SettingHandle<T>::SettingHandle(const QStringList& path, const T& defaultValue) :
|
||||
_key(path.join("/")),
|
||||
_defaultValue(defaultValue) {
|
||||
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T SettingHandle<T>::get() const {
|
||||
QVariant variant = SettingsBridge::getFromSettings(_key, _defaultValue);
|
||||
if (variant.canConvert<T>()) {
|
||||
return variant.value<T>();
|
||||
}
|
||||
return _defaultValue.value<T>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T SettingHandle<T>::get(const T& other) const {
|
||||
QVariant variant = SettingsBridge::getFromSettings(_key, QVariant(other));
|
||||
if (variant.canConvert<T>()) {
|
||||
return variant.value<T>();
|
||||
}
|
||||
return other;
|
||||
}
|
||||
|
||||
template <typename T> inline
|
||||
T SettingHandle<T>::getDefault() const {
|
||||
return _defaultValue.value<T>();
|
||||
}
|
||||
|
||||
template <typename T> inline
|
||||
void SettingHandle<T>::set(const T& value) const {
|
||||
if (value != get()) {
|
||||
SettingsBridge::setInSettings(_key, QVariant(value));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T> inline
|
||||
void SettingHandle<T>::reset() const {
|
||||
SettingsBridge::setInSettings(_key, _defaultValue);
|
||||
}
|
||||
|
||||
template <typename T> inline
|
||||
void SettingHandle<T>::remove() const {
|
||||
SettingsBridge::removeFromSettings(_key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // hifi_Settings_h
|
Loading…
Reference in a new issue