on xenial help sign in
Rename to SessionGrabber
94a999bAlbert Astals Cid
debian/unity8-private.install+1−1
@@ -8,7 +8,7 @@ usr/lib/*/unity8/qml/Lights
8usr/lib/*/unity8/qml/Powerd
8usr/lib/*/unity8/qml/Powerd
9usr/lib/*/unity8/qml/ScreenGrabber
9usr/lib/*/unity8/qml/ScreenGrabber
10usr/lib/*/unity8/qml/SessionBroadcast
10usr/lib/*/unity8/qml/SessionBroadcast
11−usr/lib/*/unity8/qml/SessionScreenshoter
11+usr/lib/*/unity8/qml/SessionGrabber
12usr/lib/*/unity8/qml/Ubuntu
12usr/lib/*/unity8/qml/Ubuntu
13usr/lib/*/unity8/qml/Unity
13usr/lib/*/unity8/qml/Unity
14usr/lib/*/unity8/qml/Utils
14usr/lib/*/unity8/qml/Utils
plugins/CMakeLists.txt+1−1
@@ -18,7 +18,7 @@ add_subdirectory(Lights)
18add_subdirectory(Dash)
18add_subdirectory(Dash)
19add_subdirectory(Powerd)
19add_subdirectory(Powerd)
20add_subdirectory(SessionBroadcast)
20add_subdirectory(SessionBroadcast)
21−add_subdirectory(SessionScreenshoter)
21+add_subdirectory(SessionGrabber)
22add_subdirectory(ScreenGrabber)
22add_subdirectory(ScreenGrabber)
23add_subdirectory(Ubuntu)
23add_subdirectory(Ubuntu)
24add_subdirectory(Unity)
24add_subdirectory(Unity)
plugins/SessionGrabber/CMakeLists.txtnew file+13
@@ -0,0 +1,13 @@
1+include_directories(
2+ ${CMAKE_CURRENT_BINARY_DIR}
3+)
4+
5+set(SOURCES
6+ sessiongrabber.cpp
7+ plugin.cpp
8+)
9+
10+add_library(SessionGrabber-qml MODULE ${SOURCES})
11+qt5_use_modules(SessionGrabber-qml Qml Gui Quick Concurrent)
12+
13+add_unity8_plugin(SessionGrabber 0.1 SessionGrabber TARGETS SessionGrabber-qml)
plugins/SessionScreenshoter/plugin.cpp → plugins/SessionGrabber/plugin.cpprenamed+4−4
@@ -16,12 +16,12 @@
16 */
16 */
17
17
18#include "plugin.h"
18#include "plugin.h"
19−#include "sessionscreenshoter.h"
19+#include "sessiongrabber.h"
20
20
21#include <QtQml/qqml.h>
21#include <QtQml/qqml.h>
22
22
23−void SessionScreenshoterPlugin::registerTypes(const char *uri)
23+void SessionGrabberPlugin::registerTypes(const char *uri)
24{
24{
25− Q_ASSERT(uri == QLatin1String("SessionScreenshoter"));
25+ Q_ASSERT(uri == QLatin1String("SessionGrabber"));
26− qmlRegisterType<SessionScreenshoter>(uri, 0, 1, "SessionScreenshoter");
26+ qmlRegisterType<SessionGrabber>(uri, 0, 1, "SessionGrabber");
27}
27}
plugins/SessionScreenshoter/plugin.h → plugins/SessionGrabber/plugin.hrenamed+3−3
@@ -15,12 +15,12 @@
15 *
15 *
16 */
16 */
17
17
18−#ifndef SESSIONSCREENSHOTER_PLUGIN_H
18+#ifndef SESSIONGRABBER_PLUGIN_H
19−#define SESSIONSCREENSHOTER_PLUGIN_H
19+#define SESSIONGRABBER_PLUGIN_H
20
20
21#include <QtQml/QQmlExtensionPlugin>
21#include <QtQml/QQmlExtensionPlugin>
22
22
23−class SessionScreenshoterPlugin : public QQmlExtensionPlugin
23+class SessionGrabberPlugin : public QQmlExtensionPlugin
24{
24{
25 Q_OBJECT
25 Q_OBJECT
26 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
plugins/SessionGrabber/qmldirnew file+2
@@ -0,0 +1,2 @@
1+module SessionGrabber
2+plugin SessionGrabber-qml
plugins/SessionScreenshoter/sessionscreenshoter.cpp → plugins/SessionGrabber/sessiongrabber.cpprenamed+14−14
@@ -15,7 +15,7 @@
15 *
15 *
16 */
16 */
17
17
18−#include "sessionscreenshoter.h"
18+#include "sessiongrabber.h"
19
19
20#include <QDebug>
20#include <QDebug>
21#include <QQuickItem>
21#include <QQuickItem>
@@ -27,18 +27,18 @@ static QString cachePath()
27 return QDir::homePath() + "/.cache/app_shots/";
27 return QDir::homePath() + "/.cache/app_shots/";
28}
28}
29
29
30−SessionScreenshoter::SessionScreenshoter(QObject *parent)
30+SessionGrabber::SessionGrabber(QObject *parent)
31 : QObject(parent),
31 : QObject(parent),
32 m_target(nullptr)
32 m_target(nullptr)
33{
33{
34}
34}
35
35
36−QString SessionScreenshoter::appId() const
36+QString SessionGrabber::appId() const
37{
37{
38 return m_appId;
38 return m_appId;
39}
39}
40
40
41−void SessionScreenshoter::setAppdId(const QString &appId)
41+void SessionGrabber::setAppdId(const QString &appId)
42{
42{
43 if (appId != m_appId) {
43 if (appId != m_appId) {
44 m_appId = appId;
44 m_appId = appId;
@@ -49,12 +49,12 @@ void SessionScreenshoter::setAppdId(const QString &appId)
49 }
49 }
50}
50}
51
51
52−QQuickItem *SessionScreenshoter::target() const
52+QQuickItem *SessionGrabber::target() const
53{
53{
54 return m_target;
54 return m_target;
55}
55}
56
56
57−void SessionScreenshoter::setTarget(QQuickItem *target)
57+void SessionGrabber::setTarget(QQuickItem *target)
58{
58{
59 if (target != m_target) {
59 if (target != m_target) {
60 m_target = target;
60 m_target = target;
@@ -62,12 +62,12 @@ void SessionScreenshoter::setTarget(QQuickItem *target)
62 }
62 }
63}
63}
64
64
65−QString SessionScreenshoter::path() const
65+QString SessionGrabber::path() const
66{
66{
67 return m_path;
67 return m_path;
68}
68}
69
69
70−void SessionScreenshoter::setPath(const QString &path)
70+void SessionGrabber::setPath(const QString &path)
71{
71{
72 if (path != m_path) {
72 if (path != m_path) {
73 m_path = path;
73 m_path = path;
@@ -90,7 +90,7 @@ static QString saveScreenshot(const QString &appId, const QSharedPointer<QQuickI
90 }
90 }
91}
91}
92
92
93−void SessionScreenshoter::take()
93+void SessionGrabber::take()
94{
94{
95 if (!m_grabResult.isNull()) {
95 if (!m_grabResult.isNull()) {
96 qWarning() << "Asked to take a screenshot when there's one already being taken, ignoring";
96 qWarning() << "Asked to take a screenshot when there's one already being taken, ignoring";
@@ -100,27 +100,27 @@ void SessionScreenshoter::take()
100 if (m_target && !m_appId.isEmpty()) {
100 if (m_target && !m_appId.isEmpty()) {
101 // grabToImage runs in a separate thread
101 // grabToImage runs in a separate thread
102 m_grabResult = m_target->grabToImage();
102 m_grabResult = m_target->grabToImage();
103− connect(m_grabResult.data(), &QQuickItemGrabResult::ready, this, &SessionScreenshoter::grabReady);
103+ connect(m_grabResult.data(), &QQuickItemGrabResult::ready, this, &SessionGrabber::grabReady);
104 } else {
104 } else {
105 qWarning() << "Can't take screnshot: appId:" << m_appId << " target:" << m_target;
105 qWarning() << "Can't take screnshot: appId:" << m_appId << " target:" << m_target;
106 }
106 }
107}
107}
108
108
109−void SessionScreenshoter::removeScreenshot()
109+void SessionGrabber::removeScreenshot()
110{
110{
111 const QString path = cachePath() + m_appId + ".png";
111 const QString path = cachePath() + m_appId + ".png";
112 QFile::remove(path);
112 QFile::remove(path);
113}
113}
114
114
115−void SessionScreenshoter::grabReady()
115+void SessionGrabber::grabReady()
116{
116{
117 QFuture<QString> f = QtConcurrent::run(saveScreenshot, m_appId, m_grabResult);
117 QFuture<QString> f = QtConcurrent::run(saveScreenshot, m_appId, m_grabResult);
118 m_watcher.reset(new QFutureWatcher<QString>(this));
118 m_watcher.reset(new QFutureWatcher<QString>(this));
119 m_watcher->setFuture(f);
119 m_watcher->setFuture(f);
120− connect(m_watcher.data(), &QFutureWatcher<QString>::finished, this, &SessionScreenshoter::saveFinished);
120+ connect(m_watcher.data(), &QFutureWatcher<QString>::finished, this, &SessionGrabber::saveFinished);
121}
121}
122
122
123−void SessionScreenshoter::saveFinished()
123+void SessionGrabber::saveFinished()
124{
124{
125 setPath(m_watcher->future().result());
125 setPath(m_watcher->future().result());
126 m_watcher.clear();
126 m_watcher.clear();
plugins/SessionScreenshoter/sessionscreenshoter.h → plugins/SessionGrabber/sessiongrabber.hrenamed+5−5
@@ -15,8 +15,8 @@
15 *
15 *
16 */
16 */
17
17
18−#ifndef SESSIONSCREENSHOTER_H
18+#ifndef SESSIONGRABBER_H
19−#define SESSIONSCREENSHOTER_H
19+#define SESSIONGRABBER_H
20
20
21#include <QObject>
21#include <QObject>
22#include <QSharedPointer>
22#include <QSharedPointer>
@@ -26,11 +26,11 @@ class QQuickItem;
26class QQuickItemGrabResult;
26class QQuickItemGrabResult;
27
27
28/**
28/**
29− * SessionScreenshoter saves to disk screenshots of the given item.
29+ * SessionGrabber saves to disk screenshots of the given item.
30 * Images are saved into $HOME/.cache/app_shots/appId.png
30 * Images are saved into $HOME/.cache/app_shots/appId.png
31 * It also handles giving back the screenshot path if it already exists (e.g. because a reboot)
31 * It also handles giving back the screenshot path if it already exists (e.g. because a reboot)
32 */
32 */
33−class SessionScreenshoter : public QObject
33+class SessionGrabber : public QObject
34{
34{
35 Q_OBJECT
35 Q_OBJECT
36
36
@@ -44,7 +44,7 @@ class SessionScreenshoter : public QObject
44 Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged)
44 Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged)
45
45
46public:
46public:
47− explicit SessionScreenshoter(QObject *parent = 0);
47+ explicit SessionGrabber(QObject *parent = 0);
48
48
49 QString appId() const;
49 QString appId() const;
50 void setAppdId(const QString &appId);
50 void setAppdId(const QString &appId);
plugins/SessionScreenshoter/CMakeLists.txtdeleted−13
@@ -1,13 +0,0 @@
1−include_directories(
2− ${CMAKE_CURRENT_BINARY_DIR}
3−)
4−
5−set(SOURCES
6− sessionscreenshoter.cpp
7− plugin.cpp
8−)
9−
10−add_library(SessionScreenshoter-qml MODULE ${SOURCES})
11−qt5_use_modules(SessionScreenshoter-qml Qml Gui Quick Concurrent)
12−
13−add_unity8_plugin(SessionScreenshoter 0.1 SessionScreenshoter TARGETS SessionScreenshoter-qml)
plugins/SessionScreenshoter/qmldirdeleted−2
@@ -1,2 +0,0 @@
1−module SessionScreenshoter
2−plugin SessionScreenshoter-qml
qml/Stages/ApplicationWindow.qml+7−7
@@ -17,7 +17,7 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 1.1
18import Ubuntu.Components 1.1
19import Unity.Application 0.1
19import Unity.Application 0.1
20−import SessionScreenshoter 0.1
20+import SessionGrabber 0.1
21
21
22FocusScope {
22FocusScope {
23 id: root
23 id: root
@@ -31,7 +31,7 @@ FocusScope {
31 property int orientation
31 property int orientation
32
32
33 function removeScreenshot() {
33 function removeScreenshot() {
34− screenshoter.removeScreenshot();
34+ sessionGrabber.removeScreenshot();
35 }
35 }
36
36
37 QtObject {
37 QtObject {
@@ -59,7 +59,7 @@ FocusScope {
59 && (d.applicationState === ApplicationInfoInterface.Stopped || d.applicationState === ApplicationInfoInterface.Suspended)
59 && (d.applicationState === ApplicationInfoInterface.Stopped || d.applicationState === ApplicationInfoInterface.Suspended)
60 onNeedToTakeScreenshotChanged: {
60 onNeedToTakeScreenshotChanged: {
61 if (needToTakeScreenshot) {
61 if (needToTakeScreenshot) {
62− screenshoter.take();
62+ sessionGrabber.take();
63 }
63 }
64 }
64 }
65
65
@@ -79,7 +79,7 @@ FocusScope {
79 Image {
79 Image {
80 id: screenshotImage
80 id: screenshotImage
81 objectName: "screenshotImage"
81 objectName: "screenshotImage"
82− source: screenshoter.path != "" ? screenshoter.path : d.defaultScreenshot
82+ source: sessionGrabber.path != "" ? sessionGrabber.path : d.defaultScreenshot
83 anchors.fill: parent
83 anchors.fill: parent
84 antialiasing: !root.interactive
84 antialiasing: !root.interactive
85 cache: false
85 cache: false
@@ -90,14 +90,14 @@ FocusScope {
90 sourceSize.height: root.height / 2
90 sourceSize.height: root.height / 2
91 }
91 }
92
92
93− SessionScreenshoter {
93+ SessionGrabber {
94− id: screenshoter
94+ id: sessionGrabber
95 appId: d.appId
95 appId: d.appId
96 target: root
96 target: root
97
97
98 onScreenshotTaken: {
98 onScreenshotTaken: {
99 screenshotImage.source = "";
99 screenshotImage.source = "";
100− screenshotImage.source = screenshoter.path;
100+ screenshotImage.source = sessionGrabber.path;
101 }
101 }
102 }
102 }
103
103
tests/plugins/CMakeLists.txt+1−1
@@ -2,7 +2,7 @@ add_subdirectory(AccountsService)
2add_subdirectory(Greeter)
2add_subdirectory(Greeter)
3add_subdirectory(LightDM)
3add_subdirectory(LightDM)
4add_subdirectory(Dash)
4add_subdirectory(Dash)
5−add_subdirectory(SessionScreenshoter)
5+add_subdirectory(SessionGrabber)
6add_subdirectory(Ubuntu)
6add_subdirectory(Ubuntu)
7add_subdirectory(Unity)
7add_subdirectory(Unity)
8add_subdirectory(Utils)
8add_subdirectory(Utils)
tests/plugins/SessionGrabber/CMakeLists.txtnew file+14
@@ -0,0 +1,14 @@
1+add_executable(SessionGrabberTestExec
2+ sessiongrabbertest.cpp
3+ ${CMAKE_SOURCE_DIR}/plugins/SessionGrabber/sessiongrabber.cpp
4+ )
5+qt5_use_modules(SessionGrabberTestExec Core Quick Test Concurrent)
6+
7+add_definitions(-DCURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
8+
9+include_directories(
10+ ${CMAKE_CURRENT_BINARY_DIR}
11+ ${CMAKE_SOURCE_DIR}/plugins/SessionGrabber
12+ )
13+
14+add_binary_qml_test(SessionGrabber "" "" "")
tests/plugins/SessionScreenshoter/sessionscreenshotertest.cpp → tests/plugins/SessionGrabber/sessiongrabbertest.cpprenamed+8−8
@@ -19,9 +19,9 @@
19#include <QQuickView>
19#include <QQuickView>
20#include <QSignalSpy>
20#include <QSignalSpy>
21
21
22−#include "sessionscreenshoter.h"
22+#include "sessiongrabber.h"
23
23
24−class SessionScreenshoterTest : public QObject
24+class SessionGrabberTest : public QObject
25{
25{
26 Q_OBJECT
26 Q_OBJECT
27
27
@@ -30,17 +30,17 @@ private Q_SLOTS:
30 void init()
30 void init()
31 {
31 {
32 view = new QQuickView();
32 view = new QQuickView();
33− view->setSource(QUrl::fromLocalFile(CURRENT_SOURCE_DIR "/sessionscreenshotertest.qml"));
33+ view->setSource(QUrl::fromLocalFile(CURRENT_SOURCE_DIR "/sessiongrabbertest.qml"));
34 view->show();
34 view->show();
35 QTest::qWaitForWindowExposed(view);
35 QTest::qWaitForWindowExposed(view);
36 }
36 }
37
37
38− void testSessionScreenshoter()
38+ void testSessionGrabber()
39 {
39 {
40− SessionScreenshoter s;
40+ SessionGrabber s;
41 s.setAppdId("test-app-id");
41 s.setAppdId("test-app-id");
42 s.setTarget(view->rootObject());
42 s.setTarget(view->rootObject());
43− QSignalSpy spy(&s, &SessionScreenshoter::screenshotTaken);
43+ QSignalSpy spy(&s, &SessionGrabber::screenshotTaken);
44
44
45 QVERIFY(!QFile::exists(s.path()));
45 QVERIFY(!QFile::exists(s.path()));
46
46
@@ -74,6 +74,6 @@ private:
74 QQuickView *view;
74 QQuickView *view;
75};
75};
76
76
77−QTEST_MAIN(SessionScreenshoterTest)
77+QTEST_MAIN(SessionGrabberTest)
78
78
79−#include "sessionscreenshotertest.moc"
79+#include "sessiongrabbertest.moc"
tests/plugins/SessionScreenshoter/sessionscreenshotertest.qml → tests/plugins/SessionGrabber/sessiongrabbertest.qmlrenamed

The content is the same.

tests/plugins/SessionScreenshoter/CMakeLists.txtdeleted−14
@@ -1,14 +0,0 @@
1−add_executable(SessionScreenshoterTestExec
2− sessionscreenshotertest.cpp
3− ${CMAKE_SOURCE_DIR}/plugins/SessionScreenshoter/sessionscreenshoter.cpp
4− )
5−qt5_use_modules(SessionScreenshoterTestExec Core Quick Test Concurrent)
6−
7−add_definitions(-DCURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
8−
9−include_directories(
10− ${CMAKE_CURRENT_BINARY_DIR}
11− ${CMAKE_SOURCE_DIR}/plugins/SessionScreenshoter
12− )
13−
14−add_binary_qml_test(SessionScreenshoter "" "" "")