History

Add basic implementation of customPrompt

Still missing the warning and diabling of dynamic checkbox when the static mesh is selected.

Zander Otavka committed 10 years ago

Commit 71f62c01 parent 6417bb17 files · +336 −7Browse files

Showing the changes to interface/src/scripting/WindowScriptingInterface.cpp (1 of 7 files). Show all

Unified · Split

interface/src/scripting/WindowScriptingInterface.cpp+22−0
@@ -29,6 +29,20 @@ static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStanda · 28 unmodified lines
2929 static const QString LAST_BROWSE_LOCATION_SETTING = "LastBrowseLocation";
3030
3131
32+QScriptValue CustomPromptResultToScriptValue(QScriptEngine* engine, const CustomPromptResult& result) {
33+ if (!result.value.isValid()) {
34+ return QScriptValue::UndefinedValue;
35+ }
36+
37+ Q_ASSERT(result.value.userType() == qMetaTypeId<QVariantMap>());
38+ return engine->toScriptValue(result.value.toMap());
39+}
40+
41+void CustomPromptResultFromScriptValue(const QScriptValue& object, CustomPromptResult& result) {
42+ result.value = object.toVariant();
43+}
44+
45+
3246 WindowScriptingInterface::WindowScriptingInterface() {
3347 const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
3448 connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged);
@@ -95,6 +109,14 @@ QScriptValue WindowScriptingInterface::prompt(const QString& message, const QStr · 60 unmodified lines
95109 return ok ? QScriptValue(result) : QScriptValue::NullValue;
96110 }
97111
112+CustomPromptResult WindowScriptingInterface::customPrompt(const QVariant& config) {
113+ CustomPromptResult result;
114+ bool ok = false;
115+ auto configMap = config.toMap();
116+ result.value = OffscreenUi::getCustomInfo(OffscreenUi::ICON_NONE, "", configMap, &ok);
117+ return ok ? result : CustomPromptResult();
118+}
119+
98120 QString fixupPathForMac(const QString& directory) {
99121 // On OS X `directory` does not work as expected unless a file is included in the path, so we append a bogus
100122 // filename if the directory is valid.