From 322121428398fb926658c73ba2c1571471a11699 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 26 Apr 2017 12:38:38 -0700 Subject: [PATCH] New Snap FTUE flow --- .../scripting/WindowScriptingInterface.cpp | 22 +++++++++++++++++++ .../src/scripting/WindowScriptingInterface.h | 1 + scripts/system/html/css/SnapshotReview.css | 1 + scripts/system/html/js/SnapshotReview.js | 9 ++++++++ scripts/system/snapshot.js | 10 +++++++-- 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 2df825d643..1e14c24da3 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -168,6 +168,28 @@ void WindowScriptingInterface::ensureReticleVisible() const { } } +/// Display a "browse to directory" dialog. If `directory` is an invalid file or directory the browser will start at the current +/// working directory. +/// \param const QString& title title of the window +/// \param const QString& directory directory to start the file browser at +/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog` +/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue` +QScriptValue WindowScriptingInterface::browseDir(const QString& title, const QString& directory) { + ensureReticleVisible(); + QString path = directory; + if (path.isEmpty()) { + path = getPreviousBrowseLocation(); + } +#ifndef Q_OS_WIN + path = fixupPathForMac(directory); +#endif + QString result = OffscreenUi::getExistingDirectory(nullptr, title, path); + if (!result.isEmpty()) { + setPreviousBrowseLocation(QFileInfo(result).absolutePath()); + } + return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result); +} + /// Display an open file dialog. If `directory` is an invalid file or directory the browser will start at the current /// working directory. /// \param const QString& title title of the window diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index 7641110972..2b1e48d918 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -51,6 +51,7 @@ public slots: QScriptValue confirm(const QString& message = ""); QScriptValue prompt(const QString& message = "", const QString& defaultText = ""); CustomPromptResult customPrompt(const QVariant& config); + QScriptValue browseDir(const QString& title = "", const QString& directory = ""); QScriptValue browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); QScriptValue save(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); QScriptValue browseAssets(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); diff --git a/scripts/system/html/css/SnapshotReview.css b/scripts/system/html/css/SnapshotReview.css index 9db7e35b9f..ef737870e0 100644 --- a/scripts/system/html/css/SnapshotReview.css +++ b/scripts/system/html/css/SnapshotReview.css @@ -204,6 +204,7 @@ input[type=button].naked:active { margin: auto; box-sizing: content-box; display: inline; + outline:none; } #snap-button:disabled { background: gray; diff --git a/scripts/system/html/js/SnapshotReview.js b/scripts/system/html/js/SnapshotReview.js index 9ee45281ac..418e623aa8 100644 --- a/scripts/system/html/js/SnapshotReview.js +++ b/scripts/system/html/js/SnapshotReview.js @@ -25,6 +25,14 @@ function showSetupInstructions() { ''; document.getElementById("snap-button").disabled = true; } +function showSetupComplete() { + var snapshotImagesDiv = document.getElementById("snapshot-images"); + snapshotImagesDiv.className = "snapshotInstructions"; + snapshotImagesDiv.innerHTML = 'Snapshot Instructions' + + '
' + + "

You're all set!

" + + '

Try taking a snapshot by pressing the button below.

'; +} function chooseSnapshotLocation() { EventBridge.emitWebEvent(JSON.stringify({ type: "snapshot", @@ -244,6 +252,7 @@ window.onload = function () { break; case 'snapshotLocationChosen': clearImages(); + showSetupComplete(); break; case 'clearPreviousImages': clearImages(); diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index 1f685924f6..88014d5c50 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -117,12 +117,18 @@ function onMessage(message) { type: "snapshot", action: "showSetupInstructions" })); + Settings.setValue("previousStillSnapPath", ""); + Settings.setValue("previousStillSnapStoryID", ""); + Settings.setValue("previousStillSnapSharingDisabled", false); + Settings.setValue("previousAnimatedSnapPath", ""); + Settings.setValue("previousAnimatedSnapStoryID", ""); + Settings.setValue("previousAnimatedSnapSharingDisabled", false); } break; case 'chooseSnapshotLocation': - var snapshotPath = Window.browse("Choose Snapshots Directory","",""); + var snapshotPath = Window.browseDir("Choose Snapshots Directory", "", ""); - if (!snapshotPath.isEmpty()) { // not cancelled + if (snapshotPath) { // not cancelled Settings.setValue("snapshotsLocation", snapshotPath); tablet.emitScriptEvent(JSON.stringify({ type: "snapshot",