Add Graphics to general settings

This commit is contained in:
Zach Pomerantz 2016-01-25 13:47:25 -08:00
parent b42ab2179e
commit bed325d675
3 changed files with 47 additions and 8 deletions

View file

@ -7,7 +7,7 @@ PreferencesDialog {
id: root
objectName: "GeneralPreferencesDialog"
title: "General Preferences"
showCategories: ["Snapshots", "Scripts", "Privacy", "Octree", "HMD", "Sixense Controllers"]
showCategories: ["Snapshots", "Scripts", "Privacy", "Octree", "HMD", "Sixense Controllers", "Graphics"]
property var settings: Settings {
category: root.objectName
property alias x: root.x

View file

@ -24,6 +24,10 @@
#include "Snapshot.h"
#include "UserActivityLogger.h"
#include "AmbientOcclusionEffect.h"
#include "AntialiasingEffect.h"
#include "RenderShadowTask.h"
void setupPreferences() {
auto preferences = DependencyManager::get<Preferences>();
@ -310,4 +314,29 @@ void setupPreferences() {
preference->setStep(1);
preferences->addPreference(preference);
}
{
static const QString RENDER("Graphics");
auto renderConfig = qApp->getRenderEngine()->getConfiguration();
{
auto getter = [renderConfig]()->bool { return renderConfig->isJobEnabled<AmbientOcclusionEffect>(); };
auto setter = [renderConfig](bool enable) { renderConfig->setJobEnabled<AmbientOcclusionEffect>(enable); };
auto preference = new CheckPreference(RENDER, "Ambient Occlusion", getter, setter);
preferences->addPreference(preference);
}
{
auto getter = [renderConfig]()->bool { return renderConfig->isJobEnabled<Antialiasing>(); };
auto setter = [renderConfig](bool enable) { renderConfig->setJobEnabled<Antialiasing>(enable); };
auto preference = new CheckPreference(RENDER, "Antialiasing", getter, setter);
preferences->addPreference(preference);
}
{
auto getter = [renderConfig]()->bool { return renderConfig->isJobEnabled<RenderShadowTask>(); };
auto setter = [renderConfig](bool enable) { renderConfig->setJobEnabled<RenderShadowTask>(enable); };
auto preference = new CheckPreference(RENDER, "Shadows", getter, setter);
preferences->addPreference(preference);
}
}
}

View file

@ -60,11 +60,7 @@ public:
JobConfig() : alwaysEnabled{ true }, enabled{ true } {}
JobConfig(bool enabled) : alwaysEnabled{ false }, enabled{ enabled } {}
Q_PROPERTY(bool enabled MEMBER enabled READ isEnabled)
Q_PROPERTY(bool alwaysEnabled READ isAlwaysEnabled)
bool isEnabled() { return alwaysEnabled || enabled; }
bool isAlwaysEnabled() { return alwaysEnabled; }
bool alwaysEnabled{ true };
bool enabled;
@ -80,6 +76,19 @@ public:
void init(Task* task) { _task = task; }
template <class T> typename T::Config* getConfig(std::string job = "") const {
QString name = job.empty() ? QString() : QString(job.c_str()); // an empty string is not a null string
return findChild<typename T::Config*>(name);
}
template <class T> void setJobEnabled(bool enable = true, std::string job = "") const {
getConfig<T>(name)->enabled = enable;
refresh(); // trigger a Job->configure
}
template <class T> bool isJobEnabled(bool enable = true, std::string job = "") const {
return getConfig<T>(job)->isEnabled();
}
public slots:
void refresh();
@ -323,10 +332,11 @@ public:
return _jobs.back().getOutput();
}
QConfig getConfiguration() {
std::shared_ptr<Config> getConfiguration() {
auto config = std::static_pointer_cast<Config>(_config);
// If we are here, we were not made by a Model, so we must initialize our own config
std::static_pointer_cast<Config>(_config)->init(this);
return _config;
config->init(this);
return config;
}
void configure(const QObject& configuration) {