From 7f4613f136b282c1f83e869168fe84c848600c32 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 17 Nov 2016 17:39:26 -0800 Subject: [PATCH] Add checkbox for GIF and length selector --- interface/src/Application.cpp | 2 +- interface/src/ui/PreferencesDialog.cpp | 15 +++++++++++++++ interface/src/ui/SnapshotAnimated.cpp | 5 ++++- interface/src/ui/SnapshotAnimated.h | 3 +++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d71cc12858..82007c4f06 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5441,7 +5441,7 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio)); // If we're not doing an animated snapshot as well... - if (!includeAnimated) { + if (!includeAnimated || !(SnapshotAnimated::alsoTakeAnimatedSnapshot.get())) { // Tell the dependency manager that the capture of the still snapshot has taken place. emit DependencyManager::get()->snapshotTaken(path, "", notify); } else { diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 7d3261aa78..35af1067d8 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -23,6 +23,7 @@ #include "LODManager.h" #include "Menu.h" #include "Snapshot.h" +#include "SnapshotAnimated.h" #include "UserActivityLogger.h" #include "AmbientOcclusionEffect.h" @@ -83,6 +84,20 @@ void setupPreferences() { auto preference = new BrowsePreference(SNAPSHOTS, "Put my snapshots here", getter, setter); preferences->addPreference(preference); } + { + auto getter = []()->bool { return SnapshotAnimated::alsoTakeAnimatedSnapshot.get(); }; + auto setter = [](bool value) { SnapshotAnimated::alsoTakeAnimatedSnapshot.set(value); }; + preferences->addPreference(new CheckPreference(SNAPSHOTS, "Take Animated GIF Snapshot with HUD Button", getter, setter)); + } + { + auto getter = []()->float { return SnapshotAnimated::snapshotAnimatedDuration.get(); }; + auto setter = [](float value) { SnapshotAnimated::snapshotAnimatedDuration.set(value); }; + auto preference = new SpinnerPreference(SNAPSHOTS, "Animated Snapshot Duration", getter, setter); + preference->setMin(3); + preference->setMax(10); + preference->setStep(1); + preferences->addPreference(preference); + } // Scripts { diff --git a/interface/src/ui/SnapshotAnimated.cpp b/interface/src/ui/SnapshotAnimated.cpp index 0d2c6707a5..70971fd7c9 100644 --- a/interface/src/ui/SnapshotAnimated.cpp +++ b/interface/src/ui/SnapshotAnimated.cpp @@ -25,6 +25,9 @@ bool SnapshotAnimated::snapshotAnimatedTimerRunning = false; QString SnapshotAnimated::snapshotAnimatedPath; QString SnapshotAnimated::snapshotStillPath; +Setting::Handle SnapshotAnimated::alsoTakeAnimatedSnapshot("alsoTakeAnimatedSnapshot", true); +Setting::Handle SnapshotAnimated::snapshotAnimatedDuration("snapshotAnimatedDuration", SNAPSNOT_ANIMATED_DURATION_SECS); + void SnapshotAnimated::saveSnapshotAnimated(QString pathStill, float aspectRatio, Application* app, QSharedPointer dm) { // If we're not in the middle of capturing an animated snapshot... if (SnapshotAnimated::snapshotAnimatedFirstFrameTimestamp == 0) { @@ -62,7 +65,7 @@ void SnapshotAnimated::saveSnapshotAnimated(QString pathStill, float aspectRatio // Record how long it took for the current frame to pack SnapshotAnimated::snapshotAnimatedLastWriteFrameDuration = SnapshotAnimated::snapshotAnimatedTimestamp - framePackStartTime; // If that was the last frame... - if ((SnapshotAnimated::snapshotAnimatedTimestamp - SnapshotAnimated::snapshotAnimatedFirstFrameTimestamp) >= (SNAPSNOT_ANIMATED_DURATION_MSEC)) { + if ((SnapshotAnimated::snapshotAnimatedTimestamp - SnapshotAnimated::snapshotAnimatedFirstFrameTimestamp) >= (SnapshotAnimated::snapshotAnimatedDuration.get() * MSECS_PER_SECOND)) { // Stop the snapshot QTimer. This action by itself DOES NOT GUARANTEE // that the slot will not be called again in the future. // See: http://lists.qt-project.org/pipermail/qt-interest-old/2009-October/013926.html diff --git a/interface/src/ui/SnapshotAnimated.h b/interface/src/ui/SnapshotAnimated.h index 4de7c339dd..5870eb9e35 100644 --- a/interface/src/ui/SnapshotAnimated.h +++ b/interface/src/ui/SnapshotAnimated.h @@ -16,6 +16,7 @@ #include #include #include +#include #include "scripting/WindowScriptingInterface.h" // If the snapshot width or the framerate are too high for the @@ -43,6 +44,8 @@ private: static QString snapshotStillPath; public: static void saveSnapshotAnimated(QString pathStill, float aspectRatio, Application* app, QSharedPointer dm); + static Setting::Handle alsoTakeAnimatedSnapshot; + static Setting::Handle snapshotAnimatedDuration; }; #endif // hifi_SnapshotAnimated_h