allow for SnapshotReview dialog to be up during a change of href for all

media capture
This commit is contained in:
howard-stearns 2016-11-22 11:09:43 -08:00
parent dcda5d50a0
commit 5188de924f
7 changed files with 24 additions and 16 deletions

View file

@ -5450,10 +5450,10 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa
} }
}); });
} }
void Application::shareSnapshot(const QString& path) { void Application::shareSnapshot(const QString& path, const QUrl& href) {
postLambdaEvent([path] { postLambdaEvent([path, href] {
// not much to do here, everything is done in snapshot code... // 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(); } float getAverageSimsPerSecond() const { return _simCounter.rate(); }
void takeSnapshot(bool notify, bool includeAnimated = false, float aspectRatio = 0.0f); 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; } model::SkyboxPointer getDefaultSkybox() const { return _defaultSkybox; }
gpu::TexturePointer getDefaultSkyboxTexture() const { return _defaultSkyboxTexture; } 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); qApp->takeSnapshot(notify, includeAnimated, aspectRatio);
} }
void WindowScriptingInterface::shareSnapshot(const QString& path) { void WindowScriptingInterface::shareSnapshot(const QString& path, const QUrl& href) {
qApp->shareSnapshot(path); qApp->shareSnapshot(path, href);
} }
bool WindowScriptingInterface::isPhysicsEnabled() { bool WindowScriptingInterface::isPhysicsEnabled() {

View file

@ -53,7 +53,7 @@ public slots:
void showAssetServer(const QString& upload = ""); void showAssetServer(const QString& upload = "");
void copyToClipboard(const QString& text); void copyToClipboard(const QString& text);
void takeSnapshot(bool notify = true, bool includeAnimated = false, float aspectRatio = 0.0f); 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(); bool isPhysicsEnabled();
signals: signals:

View file

@ -151,13 +151,17 @@ QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary) {
return imageTempFile; 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"; 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. SnapshotUploader* uploader;
if (href.isEmpty()) {
SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(filename); SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(filename);
SnapshotUploader* uploader = new SnapshotUploader(snapshotData->getURL(), filename); uploader = new SnapshotUploader(snapshotData->getURL(), filename);
delete snapshotData; delete snapshotData;
} else {
uploader = new SnapshotUploader(href, filename);
}
QFile* file = new QFile(filename); QFile* file = new QFile(filename);
Q_ASSERT(file->exists()); Q_ASSERT(file->exists());

View file

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

View file

@ -71,7 +71,7 @@ function confirmShare(data) {
if (submessage.share) { if (submessage.share) {
print('sharing', submessage.localPath); print('sharing', submessage.localPath);
outstanding++; outstanding++;
Window.shareSnapshot(submessage.localPath); Window.shareSnapshot(submessage.localPath, submessage.href);
} else { } else {
print('not sharing', submessage.localPath); print('not sharing', submessage.localPath);
} }
@ -159,10 +159,14 @@ function resetButtons(pathStillSnapshot, pathAnimatedSnapshot, notify) {
button.writeProperty("hoverState", 3); button.writeProperty("hoverState", 3);
Window.snapshotTaken.disconnect(resetButtons); Window.snapshotTaken.disconnect(resetButtons);
// 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.)
var href = location.href;
// last element in data array tells dialog whether we can share or not // last element in data array tells dialog whether we can share or not
confirmShare([ confirmShare([
{ localPath: pathAnimatedSnapshot }, { localPath: pathAnimatedSnapshot, href: href },
{ localPath: pathStillSnapshot }, { localPath: pathStillSnapshot, href: href },
{ {
canShare: !!isDomainOpen(location.domainId), canShare: !!isDomainOpen(location.domainId),
openFeedAfterShare: shouldOpenFeedAfterShare() openFeedAfterShare: shouldOpenFeedAfterShare()