Unity 8
screengrabber.h
1 /*
2  * Copyright (C) 2014-2015 Canonical, Ltd.
3  *
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.
7  *
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.
12  *
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/>.
15  */
16 
17 #ifndef SNAPSHOTTER_H
18 #define SNAPSHOTTER_H
19 
20 #include <QObject>
21 #include <QString>
22 #include <QtConcurrent>
23 
24 class ScreenGrabber: public QObject
25 {
26  Q_OBJECT
27 
28 public:
29  explicit ScreenGrabber(QObject *parent = 0);
30  ~ScreenGrabber() = default;
31 
32 public Q_SLOTS:
33  void captureAndSave(int angle = 0);
34 
35 Q_SIGNALS:
36  void screenshotSaved(const QString &filename);
37 
38 private Q_SLOTS:
39  void onScreenshotSaved();
40 
41 private:
42  QString makeFileName() const;
43  QString getFormat() const;
44  QString fileNamePrefix;
45  int screenshotQuality = -1; // default quality for the format
46  QFutureWatcher<QString> m_watcher;
47 };
48 
49 #endif