History

Keep old function names for compatibility

vladest committed 9 years ago

Commit 15f8bc01 parent 4e5c6506 files · +121 −17Browse files

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

Unified · Split

interface/src/scripting/WindowScriptingInterface.cpp+104−5
@@ -116,7 +116,17 @@ QScriptValue WindowScriptingInterface::confirm(const QString& message) { · 115 unmodified lines
116/// Display a prompt with a text box116/// Display a prompt with a text box
117/// \param const QString& message message to display117/// \param const QString& message message to display
118/// \param const QString& defaultText default text in the text box118/// \param const QString& defaultText default text in the text box
119void WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) {119/// \return QScriptValue string text value in text box if the dialog was accepted, `null` otherwise.
120QScriptValue WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) {
121 bool ok = false;
122 QString result = OffscreenUi::getText(nullptr, "", message, QLineEdit::Normal, defaultText, &ok);
123 return ok ? QScriptValue(result) : QScriptValue::NullValue;
124}
125
126/// Display a prompt with a text box
127/// \param const QString& message message to display
128/// \param const QString& defaultText default text in the text box
129void WindowScriptingInterface::promptAsync(const QString& message, const QString& defaultText) {
120 auto offscreenUi = DependencyManager::get<OffscreenUi>();130 auto offscreenUi = DependencyManager::get<OffscreenUi>();
121 connect(offscreenUi.data(), &OffscreenUi::inputDialogResponse,131 connect(offscreenUi.data(), &OffscreenUi::inputDialogResponse,
122 this, [=] (QVariant result) {132 this, [=] (QVariant result) {
@@ -180,7 +190,29 @@ void WindowScriptingInterface::ensureReticleVisible() const { · 57 unmodified lines
180/// \param const QString& title title of the window190/// \param const QString& title title of the window
181/// \param const QString& directory directory to start the file browser at191/// \param const QString& directory directory to start the file browser at
182/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`192/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
183void WindowScriptingInterface::browseDir(const QString& title, const QString& directory) {193/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue`
194QScriptValue WindowScriptingInterface::browseDir(const QString& title, const QString& directory) {
195 ensureReticleVisible();
196 QString path = directory;
197 if (path.isEmpty()) {
198 path = getPreviousBrowseLocation();
199 }
200#ifndef Q_OS_WIN
201 path = fixupPathForMac(directory);
202#endif
203 QString result = OffscreenUi::getExistingDirectory(nullptr, title, path);
204 if (!result.isEmpty()) {
205 setPreviousBrowseLocation(QFileInfo(result).absolutePath());
206 }
207 return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result);
208}
209
210/// Display a "browse to directory" dialog. If `directory` is an invalid file or directory the browser will start at the current
211/// working directory.
212/// \param const QString& title title of the window
213/// \param const QString& directory directory to start the file browser at
214/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
215void WindowScriptingInterface::browseDirAsync(const QString& title, const QString& directory) {
184 ensureReticleVisible();216 ensureReticleVisible();
185 QString path = directory;217 QString path = directory;
186 if (path.isEmpty()) {218 if (path.isEmpty()) {
@@ -204,12 +236,32 @@ void WindowScriptingInterface::browseDir(const QString& title, const QString& di · 17 unmodified lines
204 OffscreenUi::getExistingDirectoryAsync(nullptr, title, path);236 OffscreenUi::getExistingDirectoryAsync(nullptr, title, path);
205}237}
206 238
239/// \param const QString& title title of the window
240/// \param const QString& directory directory to start the file browser at
241/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
242/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue`
243QScriptValue WindowScriptingInterface::browse(const QString& title, const QString& directory, const QString& nameFilter) {
244 ensureReticleVisible();
245 QString path = directory;
246 if (path.isEmpty()) {
247 path = getPreviousBrowseLocation();
248 }
249#ifndef Q_OS_WIN
250 path = fixupPathForMac(directory);
251#endif
252 QString result = OffscreenUi::getOpenFileName(nullptr, title, path, nameFilter);
253 if (!result.isEmpty()) {
254 setPreviousBrowseLocation(QFileInfo(result).absolutePath());
255 }
256 return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result);
257}
258
207/// Display an open file dialog. If `directory` is an invalid file or directory the browser will start at the current259/// Display an open file dialog. If `directory` is an invalid file or directory the browser will start at the current
208/// working directory.260/// working directory.
209/// \param const QString& title title of the window261/// \param const QString& title title of the window
210/// \param const QString& directory directory to start the file browser at262/// \param const QString& directory directory to start the file browser at
211/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`263/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
212void WindowScriptingInterface::browse(const QString& title, const QString& directory, const QString& nameFilter) {264void WindowScriptingInterface::browseAsync(const QString& title, const QString& directory, const QString& nameFilter) {
213 ensureReticleVisible();265 ensureReticleVisible();
214 QString path = directory;266 QString path = directory;
215 if (path.isEmpty()) {267 if (path.isEmpty()) {
@@ -238,7 +290,29 @@ void WindowScriptingInterface::browse(const QString& title, const QString& direc · 22 unmodified lines
238/// \param const QString& title title of the window290/// \param const QString& title title of the window
239/// \param const QString& directory directory to start the file browser at291/// \param const QString& directory directory to start the file browser at
240/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`292/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
241void WindowScriptingInterface::save(const QString& title, const QString& directory, const QString& nameFilter) {293/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue`
294QScriptValue WindowScriptingInterface::save(const QString& title, const QString& directory, const QString& nameFilter) {
295 ensureReticleVisible();
296 QString path = directory;
297 if (path.isEmpty()) {
298 path = getPreviousBrowseLocation();
299 }
300#ifndef Q_OS_WIN
301 path = fixupPathForMac(directory);
302#endif
303 QString result = OffscreenUi::getSaveFileName(nullptr, title, path, nameFilter);
304 if (!result.isEmpty()) {
305 setPreviousBrowseLocation(QFileInfo(result).absolutePath());
306 }
307 return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result);
308}
309
310/// Display a save file dialog. If `directory` is an invalid file or directory the browser will start at the current
311/// working directory.
312/// \param const QString& title title of the window
313/// \param const QString& directory directory to start the file browser at
314/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
315void WindowScriptingInterface::saveAsync(const QString& title, const QString& directory, const QString& nameFilter) {
242 ensureReticleVisible();316 ensureReticleVisible();
243 QString path = directory;317 QString path = directory;
244 if (path.isEmpty()) {318 if (path.isEmpty()) {
@@ -262,12 +336,37 @@ void WindowScriptingInterface::save(const QString& title, const QString& directo · 17 unmodified lines
262 OffscreenUi::getSaveFileNameAsync(nullptr, title, path, nameFilter);336 OffscreenUi::getSaveFileNameAsync(nullptr, title, path, nameFilter);
263}337}
264 338
339/// Display a select asset dialog that lets the user select an asset from the Asset Server. If `directory` is an invalid
340/// directory the browser will start at the root directory.
341/// \param const QString& title title of the window
342/// \param const QString& directory directory to start the asset browser at
343/// \param const QString& nameFilter filter to filter asset names by - see `QFileDialog`
344/// \return QScriptValue asset path as a string if one was selected, otherwise `QScriptValue::NullValue`
345QScriptValue WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) {
346 ensureReticleVisible();
347 QString path = directory;
348 if (path.isEmpty()) {
349 path = getPreviousBrowseAssetLocation();
350 }
351 if (path.left(1) != "/") {
352 path = "/" + path;
353 }
354 if (path.right(1) != "/") {
355 path = path + "/";
356 }
357 QString result = OffscreenUi::getOpenAssetName(nullptr, title, path, nameFilter);
358 if (!result.isEmpty()) {
359 setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath());
360 }
361 return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result);
362}
363
265/// Display a select asset dialog that lets the user select an asset from the Asset Server. If `directory` is an invalid 364/// Display a select asset dialog that lets the user select an asset from the Asset Server. If `directory` is an invalid
266/// directory the browser will start at the root directory.365/// directory the browser will start at the root directory.
267/// \param const QString& title title of the window366/// \param const QString& title title of the window
268/// \param const QString& directory directory to start the asset browser at367/// \param const QString& directory directory to start the asset browser at
269/// \param const QString& nameFilter filter to filter asset names by - see `QFileDialog`368/// \param const QString& nameFilter filter to filter asset names by - see `QFileDialog`
270void WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) {369void WindowScriptingInterface::browseAssetsAsync(const QString& title, const QString& directory, const QString& nameFilter) {
271 ensureReticleVisible();370 ensureReticleVisible();
272 QString path = directory;371 QString path = directory;
273 if (path.isEmpty()) {372 if (path.isEmpty()) {