Snapshot button plus script

Minor change to allow snapshots to not notify (though the old way
with CTRL+S still does).  Added button to do it, saves them to disk.

The plan is for us to add UI to share (or not) the snapshot.  That's
why we are not going through the notifications.  Also, the
script makes sure to hide/unhide hud and overlays.  Next we will upload
the pick to AWS via data-web (if you are logged in), and _then_ make
the share UI.
This commit is contained in:
David Kelly 2016-08-01 13:24:22 -07:00
parent 17a5fa040d
commit 1d7cdff2bc
7 changed files with 196 additions and 11 deletions

View file

@ -2281,7 +2281,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
} else if (isOption && !isShifted && !isMeta) {
Menu::getInstance()->triggerOption(MenuOption::ScriptEditor);
} else if (!isOption && !isShifted && isMeta) {
takeSnapshot();
takeSnapshot(true);
}
break;
@ -5070,7 +5070,7 @@ void Application::toggleLogDialog() {
}
}
void Application::takeSnapshot() {
void Application::takeSnapshot(bool notify) {
QMediaPlayer* player = new QMediaPlayer();
QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav");
player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
@ -5078,7 +5078,7 @@ void Application::takeSnapshot() {
QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot());
emit DependencyManager::get<WindowScriptingInterface>()->snapshotTaken(path);
emit DependencyManager::get<WindowScriptingInterface>()->snapshotTaken(path, notify);
}
float Application::getRenderResolutionScale() const {

View file

@ -247,6 +247,8 @@ public:
float getAvatarSimrate() const { return _avatarSimCounter.rate(); }
float getAverageSimsPerSecond() const { return _simCounter.rate(); }
void takeSnapshot(bool notify);
signals:
void svoImportRequested(const QString& url);
@ -373,8 +375,6 @@ private:
int sendNackPackets();
void takeSnapshot();
MyAvatar* getMyAvatar() const;
void checkSkeleton() const;

View file

@ -199,3 +199,10 @@ void WindowScriptingInterface::copyToClipboard(const QString& text) {
qDebug() << "Copying";
QApplication::clipboard()->setText(text);
}
void WindowScriptingInterface::takeSnapshot(bool notify) {
// only evil-doers call takeSnapshot from a random thread
qApp->postLambdaEvent([&] {
qApp->takeSnapshot(notify);
});
}

View file

@ -54,12 +54,13 @@ public slots:
QScriptValue browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
QScriptValue save(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
void copyToClipboard(const QString& text);
void takeSnapshot(bool notify);
signals:
void domainChanged(const QString& domainHostname);
void svoImportRequested(const QString& url);
void domainConnectionRefused(const QString& reasonMessage, int reasonCode);
void snapshotTaken(const QString& path);
void snapshotTaken(const QString& path, bool notify);
private slots:
WebWindowClass* doCreateWebWindow(const QString& title, const QString& url, int width, int height);

View file

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 50 200.1" style="enable-background:new 0 0 50 200.1;" xml:space="preserve">
<style type="text/css">
.st0{fill:#414042;}
.st1{fill:#FFFFFF;}
.st2{fill:#1E1E1E;}
.st3{fill:#333333;}
</style>
<g id="Layer_2">
<g>
<g>
<path class="st0" d="M50.1,146.1c0,2.2-1.8,4-4,4h-42c-2.2,0-4-1.8-4-4v-42c0-2.2,1.8-4,4-4h42c2.2,0,4,1.8,4,4V146.1z"/>
</g>
</g>
<g>
<g>
<path class="st0" d="M50,196.1c0,2.2-1.8,4-4,4H4c-2.2,0-4-1.8-4-4v-42c0-2.2,1.8-4,4-4h42c2.2,0,4,1.8,4,4V196.1z"/>
</g>
</g>
<g>
<g>
<path class="st1" d="M50,46c0,2.2-1.8,4-4,4H4c-2.2,0-4-1.8-4-4V4c0-2.2,1.8-4,4-4h42c2.2,0,4,1.8,4,4V46z"/>
</g>
</g>
<g>
<path class="st2" d="M50,96.1c0,2.2-1.8,4-4,4H4c-2.2,0-4-1.8-4-4v-42c0-2.2,1.8-4,4-4h42c2.2,0,4,1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-0.1-0.1-0.2-0.2-0.3-0.3c-0.1-0.1-0.3-0.1-0.5-0.2S15.4,40,15.1,40
c-0.3-0.1-0.6-0.2-0.8-0.3c-0.2-0.1-0.4-0.2-0.6-0.3c-0.2-0.1-0.3-0.3-0.3-0.5c-0.1-0.2-0.1-0.4-0.1-0.6c0-0.3,0.1-0.6,0.2-0.9
c0.1-0.3,0.3-0.5,0.5-0.6s0.5-0.3,0.7-0.4c0.3-0.1,0.6-0.1,0.9-0.1c0.5,0,0.9,0.1,1.2,0.2c0.4,0.1,0.7,0.3,1,0.5L17.3,38z"/>
<path class="st3" d="M20.5,38.6v4.1h-1.2v-6.4h1l3.3,4.2v-4.2h1.2v6.4h-1L20.5,38.6z"/>
<path class="st3" d="M25.7,42.7l2.5-6.4h1l2.5,6.4h-1.3l-0.6-1.6h-2.2l-0.6,1.6H25.7z M28.8,37.6l-0.9,2.6h1.8L28.8,37.6z"/>
<path class="st3" d="M32.7,42.7v-6.4h2.7c0.3,0,0.6,0.1,0.8,0.2s0.5,0.3,0.6,0.5c0.2,0.2,0.3,0.4,0.4,0.7c0.1,0.3,0.2,0.5,0.2,0.8
c0,0.3,0,0.5-0.1,0.8c-0.1,0.3-0.2,0.5-0.4,0.7c-0.2,0.2-0.4,0.4-0.6,0.5c-0.2,0.1-0.5,0.2-0.8,0.2h-1.5v2.1H32.7z M33.9,39.5h1.4
c0.2,0,0.4-0.1,0.6-0.3c0.2-0.2,0.2-0.4,0.2-0.8c0-0.2,0-0.3-0.1-0.4s-0.1-0.2-0.2-0.3c-0.1-0.1-0.2-0.2-0.3-0.2
c-0.1,0-0.2-0.1-0.3-0.1h-1.4V39.5z"/>
</g>
<circle class="st1" cx="24.7" cy="121.2" r="4"/>
<circle class="st1" cx="24.7" cy="171.3" r="4"/>
</svg>

After

Width:  |  Height:  |  Size: 8.5 KiB

View file

@ -527,12 +527,14 @@ function onDomainConnectionRefused(reason) {
createNotification("Connection refused: " + reason, NotificationType.CONNECTION_REFUSED);
}
function onSnapshotTaken(path) {
var imageProperties = {
path: Script.resolvePath("file:///" + path),
aspectRatio: Window.innerWidth / Window.innerHeight
function onSnapshotTaken(path, notify) {
if (notify) {
var imageProperties = {
path: Script.resolvePath("file:///" + path),
aspectRatio: Window.innerWidth / Window.innerHeight
}
createNotification(wordWrap("Snapshot saved to " + path), NotificationType.SNAPSHOT, imageProperties);
}
createNotification(wordWrap("Snapshot saved to " + path), NotificationType.SNAPSHOT, imageProperties);
}
// handles mouse clicks on buttons

View file

@ -0,0 +1,66 @@
//
// snapshot.js
//
// Created by David Kelly on 1 August 2016
// Copyright 2016 High Fidelity, Inc
//
// Distributed under the Apache License, Version 2.0
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
var SNAPSHOT_DELAY = 500; // 500ms
var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system");
var resetOverlays;
var button = toolBar.addButton({
objectName: "snapshot",
imageURL: Script.resolvePath("assets/images/tools/snap.svg"),
visible: true,
buttonState: 1,
defaultState: 1,
hoverState: 1,
alpha: 0.9,
});
function onClicked() {
// update button states
resetOverlays = Menu.isOptionChecked("Overlays");
Window.snapshotTaken.connect(resetButtons);
button.writeProperty("buttonState", 0);
button.writeProperty("defaultState", 0);
button.writeProperty("hoverState", 2);
// hide overlays if they are on
if (resetOverlays) {
Menu.setIsOptionChecked("Overlays", false);
}
// hide hud
toolBar.writeProperty("visible", false);
// take snapshot (with no notification)
Script.setTimeout(function () {
Window.takeSnapshot(false);
}, SNAPSHOT_DELAY);
}
function resetButtons(path, notify) {
// show overlays if they were on
if (resetOverlays) {
Menu.setIsOptionChecked("Overlays", true);
}
// show hud
toolBar.writeProperty("visible", true);
// update button states
button.writeProperty("buttonState", 1);
button.writeProperty("defaultState", 1);
button.writeProperty("hoverState", 3);
Window.snapshotTaken.disconnect(resetButtons);
}
button.clicked.connect(onClicked);
Script.scriptEnding.connect(function () {
toolBar.removeButton("snapshot");
button.clicked.disconnect(onClicked);
});