Merge pull request #9110 from howard-stearns/capture-original-location-in-snapshots

Capture original location in snapshots
This commit is contained in:
David Kelly 2016-11-28 08:55:47 -08:00 committed by GitHub
commit 1b26d51292
7 changed files with 50 additions and 27 deletions

View file

@ -5450,10 +5450,10 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa
}
});
}
void Application::shareSnapshot(const QString& path) {
postLambdaEvent([path] {
void Application::shareSnapshot(const QString& path, const QUrl& href) {
postLambdaEvent([path, href] {
// not much to do here, everything is done in snapshot code...
Snapshot::uploadSnapshot(path);
Snapshot::uploadSnapshot(path, href);
});
}

View file

@ -267,7 +267,7 @@ public:
float getAverageSimsPerSecond() const { return _simCounter.rate(); }
void takeSnapshot(bool notify, bool includeAnimated = false, float aspectRatio = 0.0f);
void shareSnapshot(const QString& filename);
void shareSnapshot(const QString& filename, const QUrl& href = QUrl(""));
model::SkyboxPointer getDefaultSkybox() const { return _defaultSkybox; }
gpu::TexturePointer getDefaultSkyboxTexture() const { return _defaultSkyboxTexture; }

View file

@ -203,8 +203,8 @@ void WindowScriptingInterface::takeSnapshot(bool notify, bool includeAnimated, f
qApp->takeSnapshot(notify, includeAnimated, aspectRatio);
}
void WindowScriptingInterface::shareSnapshot(const QString& path) {
qApp->shareSnapshot(path);
void WindowScriptingInterface::shareSnapshot(const QString& path, const QUrl& href) {
qApp->shareSnapshot(path, href);
}
bool WindowScriptingInterface::isPhysicsEnabled() {

View file

@ -53,7 +53,7 @@ public slots:
void showAssetServer(const QString& upload = "");
void copyToClipboard(const QString& text);
void takeSnapshot(bool notify = true, bool includeAnimated = false, float aspectRatio = 0.0f);
void shareSnapshot(const QString& path);
void shareSnapshot(const QString& path, const QUrl& href = QUrl(""));
bool isPhysicsEnabled();
signals:

View file

@ -63,8 +63,6 @@ SnapshotMetaData* Snapshot::parseSnapshotData(QString snapshotPath) {
// parsing URL
url = QUrl(shot.text(URL), QUrl::ParsingMode::StrictMode);
} else if (snapshotPath.right(3) == "gif") {
url = QUrl(DependencyManager::get<AddressManager>()->currentShareableAddress());
} else {
return NULL;
}
@ -151,13 +149,21 @@ QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary) {
return imageTempFile;
}
void Snapshot::uploadSnapshot(const QString& filename) {
void Snapshot::uploadSnapshot(const QString& filename, const QUrl& href) {
const QString SNAPSHOT_UPLOAD_URL = "/api/v1/snapshots";
// Alternatively to parseSnapshotData, we could pass the inWorldLocation through the call chain. This way is less disruptive to existing code.
SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(filename);
SnapshotUploader* uploader = new SnapshotUploader(snapshotData->getURL(), filename);
delete snapshotData;
QUrl url = href;
if (url.isEmpty()) {
SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(filename);
if (snapshotData) {
url = snapshotData->getURL();
}
delete snapshotData;
}
if (url.isEmpty()) {
url = QUrl(DependencyManager::get<AddressManager>()->currentShareableAddress());
}
SnapshotUploader* uploader = new SnapshotUploader(url, filename);
QFile* file = new QFile(filename);
Q_ASSERT(file->exists());

View file

@ -39,7 +39,7 @@ public:
static SnapshotMetaData* parseSnapshotData(QString snapshotPath);
static Setting::Handle<QString> snapshotsLocation;
static void uploadSnapshot(const QString& filename);
static void uploadSnapshot(const QString& filename, const QUrl& href = QUrl(""));
private:
static QFile* savedFileForSnapshot(QImage & image, bool isTemporary);
};

View file

@ -14,6 +14,7 @@ var SNAPSHOT_DELAY = 500; // 500ms
var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system");
var resetOverlays;
var reticleVisible;
var clearOverlayWhenMoving;
var button = toolBar.addButton({
objectName: "snapshot",
imageURL: Script.resolvePath("assets/images/tools/snap.svg"),
@ -71,7 +72,7 @@ function confirmShare(data) {
if (submessage.share) {
print('sharing', submessage.localPath);
outstanding++;
Window.shareSnapshot(submessage.localPath);
Window.shareSnapshot(submessage.localPath, submessage.href);
} else {
print('not sharing', submessage.localPath);
}
@ -98,10 +99,20 @@ function snapshotShared(errorMessage) {
showFeedWindow();
}
}
var href, domainId;
function onClicked() {
// Raising the desktop for the share dialog at end will interact badly with clearOverlayWhenMoving.
// Turn it off now, before we start futzing with things (and possibly moving).
clearOverlayWhenMoving = MyAvatar.getClearOverlayWhenMoving(); // Do not use Settings. MyAvatar keeps a separate copy.
MyAvatar.setClearOverlayWhenMoving(false);
// We will record snapshots based on the starting location. That could change, e.g., when recording a .gif.
// Even the domainId could change (e.g., if the user falls into a teleporter while recording).
href = location.href;
domainId = location.domainId;
// update button states
resetOverlays = Menu.isOptionChecked("Overlays");
resetOverlays = Menu.isOptionChecked("Overlays"); // For completness. Certainly true if the button is visible to be clicke.
reticleVisible = Reticle.visible;
Reticle.visible = false;
Window.snapshotTaken.connect(resetButtons);
@ -109,7 +120,7 @@ function onClicked() {
button.writeProperty("buttonState", 0);
button.writeProperty("defaultState", 0);
button.writeProperty("hoverState", 2);
// hide overlays if they are on
if (resetOverlays) {
Menu.setIsOptionChecked("Overlays", false);
@ -145,10 +156,6 @@ function isDomainOpen(id) {
}
function resetButtons(pathStillSnapshot, pathAnimatedSnapshot, notify) {
// show overlays if they were on
if (resetOverlays) {
Menu.setIsOptionChecked("Overlays", true);
}
// show hud
toolBar.writeProperty("visible", true);
Reticle.visible = reticleVisible;
@ -158,17 +165,27 @@ function resetButtons(pathStillSnapshot, pathAnimatedSnapshot, notify) {
button.writeProperty("defaultState", 1);
button.writeProperty("hoverState", 3);
Window.snapshotTaken.disconnect(resetButtons);
// show overlays if they were on
if (resetOverlays) {
Menu.setIsOptionChecked("Overlays", true);
}
// A Snapshot Review dialog might be left open indefinitely after taking the picture,
// during which time the user may have moved. So stash that info in the dialog so that
// it records the correct href. (We can also stash in .jpegs, but not .gifs.)
// last element in data array tells dialog whether we can share or not
confirmShare([
{ localPath: pathAnimatedSnapshot },
{ localPath: pathStillSnapshot },
{ localPath: pathAnimatedSnapshot, href: href },
{ localPath: pathStillSnapshot, href: href },
{
canShare: !!isDomainOpen(location.domainId),
canShare: !!isDomainOpen(domainId),
openFeedAfterShare: shouldOpenFeedAfterShare()
}
]);
}
if (clearOverlayWhenMoving) {
MyAvatar.setClearOverlayWhenMoving(true); // not until after the share dialog
}
}
button.clicked.connect(onClicked);
Window.snapshotShared.connect(snapshotShared);