History

Stub desktop dialog to select recording to play from ATP assets

David Rowe committed 9 years ago

Commit dae6d6f1 parent f9201929 files · +291 −2Browse files

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

Unified · Split

interface/src/scripting/WindowScriptingInterface.cpp+29−0
@@ -28,6 +28,7 @@ · 27 unmodified lines
28 28
29static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);29static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
30static const QString LAST_BROWSE_LOCATION_SETTING = "LastBrowseLocation";30static const QString LAST_BROWSE_LOCATION_SETTING = "LastBrowseLocation";
31static const QString LAST_BROWSE_ASSETS_LOCATION_SETTING = "LastBrowseAssetsLocation";
31 32
32 33
33QScriptValue CustomPromptResultToScriptValue(QScriptEngine* engine, const CustomPromptResult& result) {34QScriptValue CustomPromptResultToScriptValue(QScriptEngine* engine, const CustomPromptResult& result) {
@@ -149,6 +150,15 @@ void WindowScriptingInterface::setPreviousBrowseLocation(const QString& location · 115 unmodified lines
149 Setting::Handle<QVariant>(LAST_BROWSE_LOCATION_SETTING).set(location);150 Setting::Handle<QVariant>(LAST_BROWSE_LOCATION_SETTING).set(location);
150}151}
151 152
153QString WindowScriptingInterface::getPreviousBrowseAssetLocation() const {
154 QString ASSETS_ROOT_PATH = "/";
155 return Setting::Handle<QString>(LAST_BROWSE_ASSETS_LOCATION_SETTING, ASSETS_ROOT_PATH).get();
156}
157
158void WindowScriptingInterface::setPreviousBrowseAssetLocation(const QString& location) {
159 Setting::Handle<QVariant>(LAST_BROWSE_ASSETS_LOCATION_SETTING).set(location);
160}
161
152/// Makes sure that the reticle is visible, use this in blocking forms that require a reticle and162/// Makes sure that the reticle is visible, use this in blocking forms that require a reticle and
153/// might be in same thread as a script that sets the reticle to invisible163/// might be in same thread as a script that sets the reticle to invisible
154void WindowScriptingInterface::ensureReticleVisible() const {164void WindowScriptingInterface::ensureReticleVisible() const {
@@ -202,6 +212,25 @@ QScriptValue WindowScriptingInterface::save(const QString& title, const QString& · 47 unmodified lines
202 return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result);212 return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result);
203}213}
204 214
215/// Display a select asset dialog that lets the user select an asset from the Asset Server. If `directory` is an invalid
216/// directory the browser will start at the root directory.
217/// \param const QString& title title of the window
218/// \param const QString& directory directory to start the asset browser at
219/// \param const QString& nameFilter filter to filter asset names by - see `QFileDialog`
220/// \return QScriptValue asset path as a string if one was selected, otherwise `QScriptValue::NullValue`
221QScriptValue WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) {
222 ensureReticleVisible();
223 QString path = directory;
224 if (path.isEmpty()) {
225 path = getPreviousBrowseAssetLocation();
226 }
227 QString result = OffscreenUi::getOpenAssetName(nullptr, title, path, nameFilter);
228 if (!result.isEmpty()) {
229 setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath());
230 }
231 return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result);
232}
233
205void WindowScriptingInterface::showAssetServer(const QString& upload) {234void WindowScriptingInterface::showAssetServer(const QString& upload) {
206 QMetaObject::invokeMethod(qApp, "showAssetServerWidget", Qt::QueuedConnection, Q_ARG(QString, upload));235 QMetaObject::invokeMethod(qApp, "showAssetServerWidget", Qt::QueuedConnection, Q_ARG(QString, upload));
207}236}