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
29static const QString LAST_BROWSE_LOCATION_SETTING = "LastBrowseLocation";29static const QString LAST_BROWSE_LOCATION_SETTING = "LastBrowseLocation";
30 30
31 31
32QScriptValue 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
41void CustomPromptResultFromScriptValue(const QScriptValue& object, CustomPromptResult& result) {
42 result.value = object.toVariant();
43}
44
45
32WindowScriptingInterface::WindowScriptingInterface() {46WindowScriptingInterface::WindowScriptingInterface() {
33 const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();47 const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
34 connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged);48 connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged);
@@ -95,6 +109,14 @@ QScriptValue WindowScriptingInterface::prompt(const QString& message, const QStr · 60 unmodified lines
95 return ok ? QScriptValue(result) : QScriptValue::NullValue;109 return ok ? QScriptValue(result) : QScriptValue::NullValue;
96}110}
97 111
112CustomPromptResult 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
98QString fixupPathForMac(const QString& directory) {120QString fixupPathForMac(const QString& directory) {
99 // On OS X `directory` does not work as expected unless a file is included in the path, so we append a bogus121 // On OS X `directory` does not work as expected unless a file is included in the path, so we append a bogus
100 // filename if the directory is valid.122 // filename if the directory is valid.