2 * Copyright (C) 2014-2016 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18import ScreenshotDirectory 0.1
21 Captures an image of the given item and saves it in a screenshots directory.
22 It also displays a flash visual effect and camera shutter sound, as feedback
23 to the user to hint that a screenshot was taken.
31 signal snapshotTaken(string path)
34 id: screenshotDirectory
35 objectName: "screenGrabber"
40 source: "/usr/share/sounds/lomiri/camera/click/camera_click.ogg"
43 function capture(item) {
44 // Disallow spamming the lightdm home directory with screenshots
45 // without access to remove them easily.
47 console.log("Taking screenshots is blocked.");
58 NumberAnimation on opacity {
74 NumberAnimation on opacity {
80 d.target.grabToImage(function(result)
82 const fileName = screenshotDirectory.makeFileName();
83 if (fileName.length === 0) {
84 console.warn("ItemGrabber: No fileName to save image to");
88 console.log("ItemGrabber: Saving image to " + fileName);
89 const success = result.saveToFile(fileName);
91 console.log("Failed to save image.");
95 root.snapshotTaken(fileName);