mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-08 06:22:14 +02:00
more preferences cleanup, removing some dead code from ScriptEngines/ScriptModel
This commit is contained in:
parent
ab9041bcab
commit
4ad5d34a10
8 changed files with 79 additions and 49 deletions
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// AdvancedPreferencesDialog.qml
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 20 Jan 2018
|
||||
// Copyright 2018 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
|
||||
//
|
||||
|
||||
import QtQuick 2.5
|
||||
import Qt.labs.settings 1.0
|
||||
|
||||
import "../../dialogs"
|
||||
|
||||
PreferencesDialog {
|
||||
id: root
|
||||
objectName: "AdvancedPreferencesDialog"
|
||||
title: "Advanced Settings"
|
||||
showCategories: ["Advanced UI" ]
|
||||
property var settings: Settings {
|
||||
category: root.objectName
|
||||
property alias x: root.x
|
||||
property alias y: root.y
|
||||
property alias width: root.width
|
||||
property alias height: root.height
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ PreferencesDialog {
|
|||
id: root
|
||||
objectName: "GeneralPreferencesDialog"
|
||||
title: "General Settings"
|
||||
showCategories: ["UI", "Snapshots", "Scripts", "Privacy", "Octree", "HMD", "Game Controller", "Sixense Controllers", "Perception Neuron", "Kinect", "Leap Motion"]
|
||||
showCategories: ["UI", "Snapshots", "Privacy", "HMD", "Game Controller", "Sixense Controllers", "Perception Neuron", "Kinect", "Leap Motion"]
|
||||
property var settings: Settings {
|
||||
category: root.objectName
|
||||
property alias x: root.x
|
||||
|
|
|
@ -1375,8 +1375,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
userInputMapper->registerDevice(_touchscreenDevice->getInputDevice());
|
||||
}
|
||||
|
||||
// force the model the look at the correct directory (weird order of operations issue)
|
||||
scriptEngines->setScriptsLocation(scriptEngines->getScriptsLocation());
|
||||
// this will force the model the look at the correct directory (weird order of operations issue)
|
||||
scriptEngines->reloadLocalFiles();
|
||||
|
||||
// do this as late as possible so that all required subsystems are initialized
|
||||
// If we've overridden the default scripts location, just load default scripts
|
||||
// otherwise, load 'em all
|
||||
|
|
|
@ -758,6 +758,13 @@ Menu::Menu() {
|
|||
// Developer > Stats
|
||||
addCheckableActionToQMenuAndActionHash(developerMenu, MenuOption::Stats);
|
||||
|
||||
// Developer > Advanced Settings...
|
||||
action = addActionToQMenuAndActionHash(developerMenu, "Advanced Preferences...");
|
||||
connect(action, &QAction::triggered, [] {
|
||||
qApp->showDialog(QString("hifi/dialogs/AdvancedPreferencesDialog.qml"),
|
||||
QString("hifi/tablet/AdvancedPreferencesDialog.qml"), "AdvancedPreferencesDialog");
|
||||
});
|
||||
|
||||
|
||||
#if 0 /// -------------- REMOVED FOR NOW --------------
|
||||
addDisabledActionAndSeparator(navigateMenu, "History");
|
||||
|
|
|
@ -82,19 +82,42 @@ void setupPreferences() {
|
|||
preference->setMax(500);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
{
|
||||
auto getter = []()->float { return qApp->getDesktopTabletScale(); };
|
||||
auto setter = [](float value) { qApp->setDesktopTabletScale(value); };
|
||||
auto preference = new SpinnerPreference(UI_CATEGORY, "Desktop Tablet Scale %", getter, setter);
|
||||
preference->setMin(20);
|
||||
preference->setMax(500);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
auto getter = []()->bool { return qApp->getPreferStylusOverLaser(); };
|
||||
auto setter = [](bool value) { qApp->setPreferStylusOverLaser(value); };
|
||||
preferences->addPreference(new CheckPreference(UI_CATEGORY, "Prefer Stylus Over Laser", getter, setter));
|
||||
}
|
||||
|
||||
static const QString ADVANCED_UI_CATEGORY { "Advanced UI" };
|
||||
{
|
||||
auto getter = []()->float { return qApp->getDesktopTabletScale(); };
|
||||
auto setter = [](float value) { qApp->setDesktopTabletScale(value); };
|
||||
auto preference = new SpinnerPreference(ADVANCED_UI_CATEGORY, "Desktop Tablet Scale %", getter, setter);
|
||||
preference->setMin(20);
|
||||
preference->setMax(500);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
{
|
||||
auto getter = [=]()->float { return myAvatar->getRealWorldFieldOfView(); };
|
||||
auto setter = [=](float value) { myAvatar->setRealWorldFieldOfView(value); };
|
||||
auto preference = new SpinnerPreference(ADVANCED_UI_CATEGORY, "Real world vertical field of view (angular size of monitor)", getter, setter);
|
||||
preference->setMin(1);
|
||||
preference->setMax(180);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
{
|
||||
auto getter = []()->float { return qApp->getFieldOfView(); };
|
||||
auto setter = [](float value) { qApp->setFieldOfView(value); };
|
||||
auto preference = new SpinnerPreference(ADVANCED_UI_CATEGORY, "Vertical field of view", getter, setter);
|
||||
preference->setMin(1);
|
||||
preference->setMax(180);
|
||||
preference->setStep(1);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
|
||||
|
||||
// FIXME: Remove setting completely or make available through JavaScript API?
|
||||
/*
|
||||
{
|
||||
|
@ -128,18 +151,11 @@ void setupPreferences() {
|
|||
preferences->addPreference(preference);
|
||||
}
|
||||
|
||||
// Scripts
|
||||
{
|
||||
auto getter = []()->QString { return DependencyManager::get<ScriptEngines>()->getScriptsLocation(); };
|
||||
auto setter = [](const QString& value) { DependencyManager::get<ScriptEngines>()->setScriptsLocation(value); };
|
||||
preferences->addPreference(new BrowsePreference("Scripts", "Load scripts from this directory", getter, setter));
|
||||
}
|
||||
|
||||
{
|
||||
auto getter = []()->bool { return !Menu::getInstance()->isOptionChecked(MenuOption::DisableActivityLogger); };
|
||||
auto setter = [](bool value) { Menu::getInstance()->setIsOptionChecked(MenuOption::DisableActivityLogger, !value); };
|
||||
preferences->addPreference(new CheckPreference("Privacy", "Send data - High Fidelity uses information provided by your "
|
||||
"client to improve the product through the logging of errors and tracking of usage patterns, "
|
||||
"client to improve the product through the logging of errors, tracking of usage patterns, "
|
||||
"installation and system details, and crash events. By allowing High Fidelity to collect "
|
||||
"this information you are helping to improve the product. ", getter, setter));
|
||||
}
|
||||
|
@ -166,23 +182,6 @@ void setupPreferences() {
|
|||
}
|
||||
|
||||
static const QString AVATAR_TUNING { "Avatar Tuning" };
|
||||
{
|
||||
auto getter = [=]()->float { return myAvatar->getRealWorldFieldOfView(); };
|
||||
auto setter = [=](float value) { myAvatar->setRealWorldFieldOfView(value); };
|
||||
auto preference = new SpinnerPreference(AVATAR_TUNING, "Real world vertical field of view (angular size of monitor)", getter, setter);
|
||||
preference->setMin(1);
|
||||
preference->setMax(180);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
{
|
||||
auto getter = []()->float { return qApp->getFieldOfView(); };
|
||||
auto setter = [](float value) { qApp->setFieldOfView(value); };
|
||||
auto preference = new SpinnerPreference(AVATAR_TUNING, "Vertical field of view", getter, setter);
|
||||
preference->setMin(1);
|
||||
preference->setMax(180);
|
||||
preference->setStep(1);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
{
|
||||
auto getter = [=]()->QString { return myAvatar->getDominantHand(); };
|
||||
auto setter = [=](const QString& value) { myAvatar->setDominantHand(value); };
|
||||
|
|
|
@ -62,8 +62,7 @@ void ScriptEngines::onErrorLoadingScript(const QString& url) {
|
|||
}
|
||||
|
||||
ScriptEngines::ScriptEngines(ScriptEngine::Context context)
|
||||
: _context(context),
|
||||
_scriptsLocationHandle("scriptsLocation", DESKTOP_LOCATION)
|
||||
: _context(context)
|
||||
{
|
||||
_scriptsModelFilter.setSourceModel(&_scriptsModel);
|
||||
_scriptsModelFilter.sort(0, Qt::AscendingOrder);
|
||||
|
@ -429,13 +428,8 @@ bool ScriptEngines::stopScript(const QString& rawScriptURL, bool restart) {
|
|||
return stoppedScript;
|
||||
}
|
||||
|
||||
QString ScriptEngines::getScriptsLocation() const {
|
||||
return _scriptsLocationHandle.get();
|
||||
}
|
||||
|
||||
void ScriptEngines::setScriptsLocation(const QString& scriptsLocation) {
|
||||
_scriptsLocationHandle.set(scriptsLocation);
|
||||
_scriptsModel.updateScriptsLocation(scriptsLocation);
|
||||
void ScriptEngines::reloadLocalFiles() {
|
||||
_scriptsModel.reloadLocalFiles();
|
||||
}
|
||||
|
||||
void ScriptEngines::reloadAllScripts() {
|
||||
|
|
|
@ -41,9 +41,9 @@ public:
|
|||
void loadScripts();
|
||||
void saveScripts();
|
||||
|
||||
QString getScriptsLocation() const;
|
||||
void loadDefaultScripts();
|
||||
void setScriptsLocation(const QString& scriptsLocation);
|
||||
void reloadLocalFiles();
|
||||
|
||||
QStringList getRunningScripts();
|
||||
ScriptEnginePointer getScriptEngine(const QUrl& scriptHash);
|
||||
|
||||
|
@ -111,7 +111,6 @@ protected:
|
|||
QSet<ScriptEnginePointer> _allKnownScriptEngines;
|
||||
QMutex _allScriptsMutex;
|
||||
std::list<ScriptInitializer> _scriptInitializers;
|
||||
mutable Setting::Handle<QString> _scriptsLocationHandle;
|
||||
ScriptsModel _scriptsModel;
|
||||
ScriptsModelFilter _scriptsModelFilter;
|
||||
std::atomic<bool> _isStopped { false };
|
||||
|
|
|
@ -100,6 +100,7 @@ QVariant ScriptsModel::data(const QModelIndex& index, int role) const {
|
|||
return QVariant();
|
||||
}
|
||||
if (node->getType() == TREE_NODE_TYPE_SCRIPT) {
|
||||
|
||||
TreeNodeScript* script = static_cast<TreeNodeScript*>(node);
|
||||
if (role == Qt::DisplayRole) {
|
||||
return QVariant(script->getName() + (script->getOrigin() == SCRIPT_ORIGIN_LOCAL ? " (local)" : ""));
|
||||
|
@ -133,7 +134,6 @@ void ScriptsModel::updateScriptsLocation(const QString& newPath) {
|
|||
_fsWatcher.addPath(_localDirectory.absolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
reloadLocalFiles();
|
||||
}
|
||||
|
||||
|
@ -305,6 +305,7 @@ void ScriptsModel::rebuildTree() {
|
|||
_treeNodes.removeAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
QHash<QString, TreeNodeFolder*> folders;
|
||||
for (int i = 0; i < _treeNodes.size(); i++) {
|
||||
TreeNodeBase* node = _treeNodes.at(i);
|
||||
|
|
Loading…
Reference in a new issue