on xenial help sign in
Rename to SessionGrabber
commit94a999bbe6e2e12249286c9287adac64fef37723 authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 24 Apr 2015, 13:06 (11 years ago) parent7046f30
16 files changed+73−73
debian/unity8-private.install+1−1 plugins/CMakeLists.txt+1−1 plugins/SessionGrabber/CMakeLists.txt+13 plugins/SessionScreenshoter/plugin.cpp → plugins/SessionGrabber/plugin.cpp+4−4 plugins/SessionScreenshoter/plugin.h → plugins/SessionGrabber/plugin.h+3−3 plugins/SessionGrabber/qmldir+2 plugins/SessionScreenshoter/sessionscreenshoter.cpp → plugins/SessionGrabber/sessiongrabber.cpp+14−14 plugins/SessionScreenshoter/sessionscreenshoter.h → plugins/SessionGrabber/sessiongrabber.h+5−5 plugins/SessionScreenshoter/CMakeLists.txt−13 plugins/SessionScreenshoter/qmldir−2 qml/Stages/ApplicationWindow.qml+7−7 tests/plugins/CMakeLists.txt+1−1 tests/plugins/SessionGrabber/CMakeLists.txt+14 tests/plugins/SessionScreenshoter/sessionscreenshotertest.cpp → tests/plugins/SessionGrabber/sessiongrabbertest.cpp+8−8 tests/plugins/SessionScreenshoter/sessionscreenshotertest.qml → tests/plugins/SessionGrabber/sessiongrabbertest.qml tests/plugins/SessionScreenshoter/CMakeLists.txt−14
debian/unity8-private.install+1−1
@@ -8,7 +8,7 @@ usr/lib/*/unity8/qml/Lights
88usr/lib/*/unity8/qml/Powerd
99usr/lib/*/unity8/qml/ScreenGrabber
1010usr/lib/*/unity8/qml/SessionBroadcast
11−usr/lib/*/unity8/qml/SessionScreenshoter
11+usr/lib/*/unity8/qml/SessionGrabber
1212usr/lib/*/unity8/qml/Ubuntu
1313usr/lib/*/unity8/qml/Unity
1414usr/lib/*/unity8/qml/Utils
plugins/CMakeLists.txt+1−1
@@ -18,7 +18,7 @@ add_subdirectory(Lights)
1818add_subdirectory(Dash)
1919add_subdirectory(Powerd)
2020add_subdirectory(SessionBroadcast)
21−add_subdirectory(SessionScreenshoter)
21+add_subdirectory(SessionGrabber)
2222add_subdirectory(ScreenGrabber)
2323add_subdirectory(Ubuntu)
2424add_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 @@
1616 */
1717
1818#include "plugin.h"
19−#include "sessionscreenshoter.h"
19+#include "sessiongrabber.h"
2020
2121#include <QtQml/qqml.h>
2222
23−void SessionScreenshoterPlugin::registerTypes(const char *uri)
23+void SessionGrabberPlugin::registerTypes(const char *uri)
2424{
25− Q_ASSERT(uri == QLatin1String("SessionScreenshoter"));
26− qmlRegisterType<SessionScreenshoter>(uri, 0, 1, "SessionScreenshoter");
25+ Q_ASSERT(uri == QLatin1String("SessionGrabber"));
26+ qmlRegisterType<SessionGrabber>(uri, 0, 1, "SessionGrabber");
2727}
plugins/SessionScreenshoter/plugin.h → plugins/SessionGrabber/plugin.hrenamed+3−3
@@ -15,12 +15,12 @@
1515 *
1616 */
1717
18−#ifndef SESSIONSCREENSHOTER_PLUGIN_H
19−#define SESSIONSCREENSHOTER_PLUGIN_H
18+#ifndef SESSIONGRABBER_PLUGIN_H
19+#define SESSIONGRABBER_PLUGIN_H
2020
2121#include <QtQml/QQmlExtensionPlugin>
2222
23−class SessionScreenshoterPlugin : public QQmlExtensionPlugin
23+class SessionGrabberPlugin : public QQmlExtensionPlugin
2424{
2525 Q_OBJECT
2626 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 @@
1515 *
1616 */
1717
18−#include "sessionscreenshoter.h"
18+#include "sessiongrabber.h"
1919
2020#include <QDebug>
2121#include <QQuickItem>
@@ -27,18 +27,18 @@ static QString cachePath()
2727 return QDir::homePath() + "/.cache/app_shots/";
2828}
2929
30−SessionScreenshoter::SessionScreenshoter(QObject *parent)
30+SessionGrabber::SessionGrabber(QObject *parent)
3131 : QObject(parent),
3232 m_target(nullptr)
3333{
3434}
3535
36−QString SessionScreenshoter::appId() const
36+QString SessionGrabber::appId() const
3737{
3838 return m_appId;
3939}
4040
41−void SessionScreenshoter::setAppdId(const QString &appId)
41+void SessionGrabber::setAppdId(const QString &appId)
4242{
4343 if (appId != m_appId) {
4444 m_appId = appId;
@@ -49,12 +49,12 @@ void SessionScreenshoter::setAppdId(const QString &appId)
4949 }
5050}
5151
52−QQuickItem *SessionScreenshoter::target() const
52+QQuickItem *SessionGrabber::target() const
5353{
5454 return m_target;
5555}
5656
57−void SessionScreenshoter::setTarget(QQuickItem *target)
57+void SessionGrabber::setTarget(QQuickItem *target)
5858{
5959 if (target != m_target) {
6060 m_target = target;
@@ -62,12 +62,12 @@ void SessionScreenshoter::setTarget(QQuickItem *target)
6262 }
6363}
6464
65−QString SessionScreenshoter::path() const
65+QString SessionGrabber::path() const
6666{
6767 return m_path;
6868}
6969
70−void SessionScreenshoter::setPath(const QString &path)
70+void SessionGrabber::setPath(const QString &path)
7171{
7272 if (path != m_path) {
7373 m_path = path;
@@ -90,7 +90,7 @@ static QString saveScreenshot(const QString &appId, const QSharedPointer<QQuickI
9090 }
9191}
9292
93−void SessionScreenshoter::take()
93+void SessionGrabber::take()
9494{
9595 if (!m_grabResult.isNull()) {
9696 qWarning() << "Asked to take a screenshot when there's one already being taken, ignoring";
@@ -100,27 +100,27 @@ void SessionScreenshoter::take()
100100 if (m_target && !m_appId.isEmpty()) {
101101 // grabToImage runs in a separate thread
102102 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);
104104 } else {
105105 qWarning() << "Can't take screnshot: appId:" << m_appId << " target:" << m_target;
106106 }
107107}
108108
109−void SessionScreenshoter::removeScreenshot()
109+void SessionGrabber::removeScreenshot()
110110{
111111 const QString path = cachePath() + m_appId + ".png";
112112 QFile::remove(path);
113113}
114114
115−void SessionScreenshoter::grabReady()
115+void SessionGrabber::grabReady()
116116{
117117 QFuture<QString> f = QtConcurrent::run(saveScreenshot, m_appId, m_grabResult);
118118 m_watcher.reset(new QFutureWatcher<QString>(this));
119119 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);
121121}
122122
123−void SessionScreenshoter::saveFinished()
123+void SessionGrabber::saveFinished()
124124{
125125 setPath(m_watcher->future().result());
126126 m_watcher.clear();
plugins/SessionScreenshoter/sessionscreenshoter.h → plugins/SessionGrabber/sessiongrabber.hrenamed+5−5
@@ -15,8 +15,8 @@
1515 *
1616 */
1717
18−#ifndef SESSIONSCREENSHOTER_H
19−#define SESSIONSCREENSHOTER_H
18+#ifndef SESSIONGRABBER_H
19+#define SESSIONGRABBER_H
2020
2121#include <QObject>
2222#include <QSharedPointer>
@@ -26,11 +26,11 @@ class QQuickItem;
2626class QQuickItemGrabResult;
2727
2828/**
29− * SessionScreenshoter saves to disk screenshots of the given item.
29+ * SessionGrabber saves to disk screenshots of the given item.
3030 * Images are saved into $HOME/.cache/app_shots/appId.png
3131 * It also handles giving back the screenshot path if it already exists (e.g. because a reboot)
3232 */
33−class SessionScreenshoter : public QObject
33+class SessionGrabber : public QObject
3434{
3535 Q_OBJECT
3636
@@ -44,7 +44,7 @@ class SessionScreenshoter : public QObject
4444 Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged)
4545
4646public:
47− explicit SessionScreenshoter(QObject *parent = 0);
47+ explicit SessionGrabber(QObject *parent = 0);
4848
4949 QString appId() const;
5050 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 @@
1717import QtQuick 2.0
1818import Ubuntu.Components 1.1
1919import Unity.Application 0.1
20−import SessionScreenshoter 0.1
20+import SessionGrabber 0.1
2121
2222FocusScope {
2323 id: root
@@ -31,7 +31,7 @@ FocusScope {
3131 property int orientation
3232
3333 function removeScreenshot() {
34− screenshoter.removeScreenshot();
34+ sessionGrabber.removeScreenshot();
3535 }
3636
3737 QtObject {
@@ -59,7 +59,7 @@ FocusScope {
5959 && (d.applicationState === ApplicationInfoInterface.Stopped || d.applicationState === ApplicationInfoInterface.Suspended)
6060 onNeedToTakeScreenshotChanged: {
6161 if (needToTakeScreenshot) {
62− screenshoter.take();
62+ sessionGrabber.take();
6363 }
6464 }
6565
@@ -79,7 +79,7 @@ FocusScope {
7979 Image {
8080 id: screenshotImage
8181 objectName: "screenshotImage"
82− source: screenshoter.path != "" ? screenshoter.path : d.defaultScreenshot
82+ source: sessionGrabber.path != "" ? sessionGrabber.path : d.defaultScreenshot
8383 anchors.fill: parent
8484 antialiasing: !root.interactive
8585 cache: false
@@ -90,14 +90,14 @@ FocusScope {
9090 sourceSize.height: root.height / 2
9191 }
9292
93− SessionScreenshoter {
94− id: screenshoter
93+ SessionGrabber {
94+ id: sessionGrabber
9595 appId: d.appId
9696 target: root
9797
9898 onScreenshotTaken: {
9999 screenshotImage.source = "";
100− screenshotImage.source = screenshoter.path;
100+ screenshotImage.source = sessionGrabber.path;
101101 }
102102 }
103103
tests/plugins/CMakeLists.txt+1−1
@@ -2,7 +2,7 @@ add_subdirectory(AccountsService)
22add_subdirectory(Greeter)
33add_subdirectory(LightDM)
44add_subdirectory(Dash)
5−add_subdirectory(SessionScreenshoter)
5+add_subdirectory(SessionGrabber)
66add_subdirectory(Ubuntu)
77add_subdirectory(Unity)
88add_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 @@
1919#include <QQuickView>
2020#include <QSignalSpy>
2121
22−#include "sessionscreenshoter.h"
22+#include "sessiongrabber.h"
2323
24−class SessionScreenshoterTest : public QObject
24+class SessionGrabberTest : public QObject
2525{
2626 Q_OBJECT
2727
@@ -30,17 +30,17 @@ private Q_SLOTS:
3030 void init()
3131 {
3232 view = new QQuickView();
33− view->setSource(QUrl::fromLocalFile(CURRENT_SOURCE_DIR "/sessionscreenshotertest.qml"));
33+ view->setSource(QUrl::fromLocalFile(CURRENT_SOURCE_DIR "/sessiongrabbertest.qml"));
3434 view->show();
3535 QTest::qWaitForWindowExposed(view);
3636 }
3737
38− void testSessionScreenshoter()
38+ void testSessionGrabber()
3939 {
40− SessionScreenshoter s;
40+ SessionGrabber s;
4141 s.setAppdId("test-app-id");
4242 s.setTarget(view->rootObject());
43− QSignalSpy spy(&s, &SessionScreenshoter::screenshotTaken);
43+ QSignalSpy spy(&s, &SessionGrabber::screenshotTaken);
4444
4545 QVERIFY(!QFile::exists(s.path()));
4646
@@ -74,6 +74,6 @@ private:
7474 QQuickView *view;
7575};
7676
77−QTEST_MAIN(SessionScreenshoterTest)
77+QTEST_MAIN(SessionGrabberTest)
7878
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 "" "" "")