on xenial help sign in
some work on bringing the fake application plugin up to date with the new api
a2c47a6Michael Zanetti
qml/Shell.qml+1−1
@@ -130,7 +130,7 @@ FocusScope {
130 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
130 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
131
131
132 onVisibleChanged: print("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", visible, fullyCovered, applicationSurfaceShouldBeSeen,
132 onVisibleChanged: print("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", visible, fullyCovered, applicationSurfaceShouldBeSeen,
133− applicationRunning, stages.fullyHidden, stages.usingScreenshots)
133+ applicationRunning, stages.fullyHidden, stages.painting)
134
134
135 CrossFadeImage {
135 CrossFadeImage {
136 id: backgroundImage
136 id: backgroundImage
qml/Stages/PhoneStage.qml+15−4
@@ -20,6 +20,7 @@ Item {
20 // State information propagated to the outside
20 // State information propagated to the outside
21 readonly property bool painting: mainScreenshotImage.visible || fadeInScreenshotImage.visible || appSplash.visible
21 readonly property bool painting: mainScreenshotImage.visible || fadeInScreenshotImage.visible || appSplash.visible
22 onPaintingChanged: print("**********************+ painting changed", painting)
22 onPaintingChanged: print("**********************+ painting changed", painting)
23+ onShownChanged: print("*********************** shown changed", shown)
23
24
24 onMovingChanged: {
25 onMovingChanged: {
25 if (moving) {
26 if (moving) {
@@ -37,6 +38,7 @@ Item {
37 }
38 }
38
39
39 onFocusedApplicationIdChanged: {
40 onFocusedApplicationIdChanged: {
41+ print("foooooooooooooo")
40 if (ApplicationManager.focusedApplicationId.length > 0) {
42 if (ApplicationManager.focusedApplicationId.length > 0) {
41 if (priv.secondApplicationStarting || priv.applicationStarting) {
43 if (priv.secondApplicationStarting || priv.applicationStarting) {
42 appSplashTimer.start();
44 appSplashTimer.start();
@@ -65,7 +67,7 @@ Item {
65
67
66 property string focusedAppId: ApplicationManager.focusedApplicationId
68 property string focusedAppId: ApplicationManager.focusedApplicationId
67 property var focusedApplication: ApplicationManager.findApplication(focusedAppId)
69 property var focusedApplication: ApplicationManager.findApplication(focusedAppId)
68− property url focusedScreenshot: focusedApplication ? focusedApplication.screenshot : ""
70+ property url focusedScreenshot: focusedApplication.screenshot
69
71
70 property bool waitingForScreenshot: false
72 property bool waitingForScreenshot: false
71
73
@@ -74,7 +76,10 @@ Item {
74
76
75 property string newFocusedAppId
77 property string newFocusedAppId
76
78
79+ onFocusedAppIdChanged: print("focusedappidchanged")
80+
77 onFocusedScreenshotChanged: {
81 onFocusedScreenshotChanged: {
82+ print("focusedscreenshotchanged")
78 if (root.moving && priv.waitingForScreenshot) {
83 if (root.moving && priv.waitingForScreenshot) {
79 mainScreenshotImage.anchors.leftMargin = 0;
84 mainScreenshotImage.anchors.leftMargin = 0;
80 mainScreenshotImage.src = ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).screenshot;
85 mainScreenshotImage.src = ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).screenshot;
@@ -86,6 +91,7 @@ Item {
86 }
91 }
87
92
88 function requestNewScreenshot() {
93 function requestNewScreenshot() {
94+ print("requesting new screenshot", focusedAppId, focusedScreenshot, focusedApplication, focusedApplication.screenshot)
89 waitingForScreenshot = true;
95 waitingForScreenshot = true;
90 ApplicationManager.updateScreenshot(ApplicationManager.focusedApplicationId);
96 ApplicationManager.updateScreenshot(ApplicationManager.focusedApplicationId);
91 }
97 }
@@ -306,8 +312,8 @@ Item {
306
312
307 SequentialAnimation {
313 SequentialAnimation {
308 id: snapAnimation
314 id: snapAnimation
309− property var targetContentX
315+ property int targetContentX: 0
310− property var targetAppId
316+ property string targetAppId
311
317
312 UbuntuNumberAnimation {
318 UbuntuNumberAnimation {
313 target: coverFlickable
319 target: coverFlickable
@@ -508,7 +514,7 @@ Item {
508 }
514 }
509 EasingCurve {
515 EasingCurve {
510 id: scaleEasing
516 id: scaleEasing
511− type: EasingCurve.Linear
517+ type: EasingCurve.OutQuad
512 period: coverFlip.maxScale - coverFlip.minScale
518 period: coverFlip.maxScale - coverFlip.minScale
513 progress: appImage.translatedProgress
519 progress: appImage.translatedProgress
514 }
520 }
@@ -556,4 +562,9 @@ Item {
556 }
562 }
557 }
563 }
558 }
564 }
565+ Rectangle {
566+ anchors.fill: parent
567+ color: "green"
568+ opacity: .5
569+ }
559}
570}
tests/mocks/Unity/Application/ApplicationInfo.h+2
@@ -19,6 +19,7 @@
19
19
20#include <QObject>
20#include <QObject>
21#include <QQmlComponent>
21#include <QQmlComponent>
22+#include <QDebug>
22
23
23class QQuickItem;
24class QQuickItem;
24
25
@@ -56,6 +57,7 @@ class ApplicationInfo : public ApplicationInfoInterface {
56 { \
57 { \
57 if (m_##name != value) { \
58 if (m_##name != value) { \
58 m_##name = value; \
59 m_##name = value; \
60+ qDebug() << "emitting changed" << this << Q_FUNC_INFO; \
59 Q_EMIT name##Changed(); \
61 Q_EMIT name##Changed(); \
60 } \
62 } \
61 } \
63 } \
tests/mocks/Unity/Application/ApplicationManager.cpp+23−2
@@ -66,6 +66,8 @@ QVariant ApplicationManager::data(const QModelIndex& index, int role) const {
66 return app->state();
66 return app->state();
67 case RoleFocused:
67 case RoleFocused:
68 return app->focused();
68 return app->focused();
69+ case RoleScreenshot:
70+ return app->screenshot();
69 default:
71 default:
70 return QVariant();
72 return QVariant();
71 }
73 }
@@ -78,7 +80,9 @@ ApplicationInfo *ApplicationManager::get(int row) const {
78}
80}
79
81
80ApplicationInfo *ApplicationManager::findApplication(const QString &appId) const {
82ApplicationInfo *ApplicationManager::findApplication(const QString &appId) const {
83+ qDebug() << "findapp called";
81 for (ApplicationInfo *app : m_runningApplications) {
84 for (ApplicationInfo *app : m_runningApplications) {
85+ qDebug() << "searching app"<< app->appId();
82 if (app->appId() == appId) {
86 if (app->appId() == appId) {
83 return app;
87 return app;
84 }
88 }
@@ -87,8 +91,10 @@ ApplicationInfo *ApplicationManager::findApplication(const QString &appId) const
87}
91}
88
92
89void ApplicationManager::add(ApplicationInfo *application) {
93void ApplicationManager::add(ApplicationInfo *application) {
94+ qDebug() << "add() " << application->appId();
90− if (!application)
95+ if (!application) {
91 return;
96 return;
97+ }
92
98
93 beginInsertRows(QModelIndex(), m_runningApplications.size(), m_runningApplications.size());
99 beginInsertRows(QModelIndex(), m_runningApplications.size(), m_runningApplications.size());
94 m_runningApplications.append(application);
100 m_runningApplications.append(application);
@@ -207,7 +213,9 @@ void ApplicationManager::updateScreenshot(const QString &appId)
207 return;
213 return;
208 }
214 }
209
215
216+ qDebug() << "setting new screenshot" << application->screenshot() << application;
210 application->setScreenshot(QString("image://application/%1/%2").arg(appId).arg(QDateTime::currentMSecsSinceEpoch()));
217 application->setScreenshot(QString("image://application/%1/%2").arg(appId).arg(QDateTime::currentMSecsSinceEpoch()));
218+ qDebug() << "set new screenshot" << application->screenshot();
211 QModelIndex appIndex = index(idx);
219 QModelIndex appIndex = index(idx);
212 Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << RoleScreenshot);
220 Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << RoleScreenshot);
213}
221}
@@ -272,7 +280,7 @@ bool ApplicationManager::focusApplication(const QString &appId)
272
280
273void ApplicationManager::activateApplication(const QString &appId)
281void ApplicationManager::activateApplication(const QString &appId)
274{
282{
275− QMetaObject::invokeMethod(this, "requestFocus", Qt::QueuedConnection, Q_ARG(QString, appId));
283+ QMetaObject::invokeMethod(this, "focusRequested", Qt::QueuedConnection, Q_ARG(QString, appId));
276}
284}
277
285
278void ApplicationManager::unfocusCurrentApplication()
286void ApplicationManager::unfocusCurrentApplication()
@@ -333,6 +341,7 @@ void ApplicationManager::buildListOfAvailableApplications()
333 application->setName("Phone");
341 application->setName("Phone");
334 application->setIcon(QUrl("phone"));
342 application->setIcon(QUrl("phone"));
335 application->setStage(ApplicationInfo::SideStage);
343 application->setStage(ApplicationInfo::SideStage);
344+ application->setScreenshot(QString("image://application/%1/123456789").arg(application->appId()));
336 generateQmlStrings(application);
345 generateQmlStrings(application);
337 m_availableApplications.append(application);
346 m_availableApplications.append(application);
338
347
@@ -341,6 +350,7 @@ void ApplicationManager::buildListOfAvailableApplications()
341 application->setName("Camera");
350 application->setName("Camera");
342 application->setIcon(QUrl("camera"));
351 application->setIcon(QUrl("camera"));
343 application->setFullscreen(true);
352 application->setFullscreen(true);
353+ application->setScreenshot(QUrl("image://application/phone/123456789"));
344 generateQmlStrings(application);
354 generateQmlStrings(application);
345 m_availableApplications.append(application);
355 m_availableApplications.append(application);
346
356
@@ -348,6 +358,7 @@ void ApplicationManager::buildListOfAvailableApplications()
348 application->setAppId("gallery-app");
358 application->setAppId("gallery-app");
349 application->setName("Gallery");
359 application->setName("Gallery");
350 application->setIcon(QUrl("gallery"));
360 application->setIcon(QUrl("gallery"));
361+ application->setScreenshot(QUrl("image://application/phone/123456789"));
351 generateQmlStrings(application);
362 generateQmlStrings(application);
352 m_availableApplications.append(application);
363 m_availableApplications.append(application);
353
364
@@ -356,6 +367,7 @@ void ApplicationManager::buildListOfAvailableApplications()
356 application->setName("Facebook");
367 application->setName("Facebook");
357 application->setIcon(QUrl("facebook"));
368 application->setIcon(QUrl("facebook"));
358 application->setStage(ApplicationInfo::SideStage);
369 application->setStage(ApplicationInfo::SideStage);
370+ application->setScreenshot(QUrl("image://application/phone/123456789"));
359 generateQmlStrings(application);
371 generateQmlStrings(application);
360 m_availableApplications.append(application);
372 m_availableApplications.append(application);
361
373
@@ -363,6 +375,7 @@ void ApplicationManager::buildListOfAvailableApplications()
363 application->setAppId("webbrowser-app");
375 application->setAppId("webbrowser-app");
364 application->setName("Browser");
376 application->setName("Browser");
365 application->setIcon(QUrl("browser"));
377 application->setIcon(QUrl("browser"));
378+ application->setScreenshot(QUrl("image://application/phone/123456789"));
366 generateQmlStrings(application);
379 generateQmlStrings(application);
367 m_availableApplications.append(application);
380 m_availableApplications.append(application);
368
381
@@ -371,6 +384,7 @@ void ApplicationManager::buildListOfAvailableApplications()
371 application->setName("Twitter");
384 application->setName("Twitter");
372 application->setIcon(QUrl("twitter"));
385 application->setIcon(QUrl("twitter"));
373 application->setStage(ApplicationInfo::SideStage);
386 application->setStage(ApplicationInfo::SideStage);
387+ application->setScreenshot(QUrl("image://application/phone/123456789"));
374 generateQmlStrings(application);
388 generateQmlStrings(application);
375 m_availableApplications.append(application);
389 m_availableApplications.append(application);
376
390
@@ -378,6 +392,7 @@ void ApplicationManager::buildListOfAvailableApplications()
378 application->setAppId("gmail-webapp");
392 application->setAppId("gmail-webapp");
379 application->setName("GMail");
393 application->setName("GMail");
380 application->setIcon(QUrl("gmail"));
394 application->setIcon(QUrl("gmail"));
395+ application->setScreenshot(QUrl("image://application/phone/123456789"));
381 m_availableApplications.append(application);
396 m_availableApplications.append(application);
382
397
383 application = new ApplicationInfo(this);
398 application = new ApplicationInfo(this);
@@ -385,6 +400,7 @@ void ApplicationManager::buildListOfAvailableApplications()
385 application->setName("Weather");
400 application->setName("Weather");
386 application->setIcon(QUrl("weather"));
401 application->setIcon(QUrl("weather"));
387 application->setStage(ApplicationInfo::SideStage);
402 application->setStage(ApplicationInfo::SideStage);
403+ application->setScreenshot(QUrl("image://application/phone/123456789"));
388 generateQmlStrings(application);
404 generateQmlStrings(application);
389 m_availableApplications.append(application);
405 m_availableApplications.append(application);
390
406
@@ -393,6 +409,7 @@ void ApplicationManager::buildListOfAvailableApplications()
393 application->setName("Notepad");
409 application->setName("Notepad");
394 application->setIcon(QUrl("notepad"));
410 application->setIcon(QUrl("notepad"));
395 application->setStage(ApplicationInfo::SideStage);
411 application->setStage(ApplicationInfo::SideStage);
412+ application->setScreenshot(QUrl("image://application/phone/123456789"));
396 m_availableApplications.append(application);
413 m_availableApplications.append(application);
397
414
398 application = new ApplicationInfo(this);
415 application = new ApplicationInfo(this);
@@ -400,6 +417,7 @@ void ApplicationManager::buildListOfAvailableApplications()
400 application->setName("Calendar");
417 application->setName("Calendar");
401 application->setIcon(QUrl("calendar"));
418 application->setIcon(QUrl("calendar"));
402 application->setStage(ApplicationInfo::SideStage);
419 application->setStage(ApplicationInfo::SideStage);
420+ application->setScreenshot(QUrl("image://application/phone/123456789"));
403 m_availableApplications.append(application);
421 m_availableApplications.append(application);
404
422
405 application = new ApplicationInfo(this);
423 application = new ApplicationInfo(this);
@@ -407,18 +425,21 @@ void ApplicationManager::buildListOfAvailableApplications()
407 application->setName("Media Player");
425 application->setName("Media Player");
408 application->setIcon(QUrl("mediaplayer-app"));
426 application->setIcon(QUrl("mediaplayer-app"));
409 application->setFullscreen(true);
427 application->setFullscreen(true);
428+ application->setScreenshot(QUrl("image://application/phone/123456789"));
410 m_availableApplications.append(application);
429 m_availableApplications.append(application);
411
430
412 application = new ApplicationInfo(this);
431 application = new ApplicationInfo(this);
413 application->setAppId("evernote");
432 application->setAppId("evernote");
414 application->setName("Evernote");
433 application->setName("Evernote");
415 application->setIcon(QUrl("evernote"));
434 application->setIcon(QUrl("evernote"));
435+ application->setScreenshot(QUrl("image://application/phone/123456789"));
416 m_availableApplications.append(application);
436 m_availableApplications.append(application);
417
437
418 application = new ApplicationInfo(this);
438 application = new ApplicationInfo(this);
419 application->setAppId("map");
439 application->setAppId("map");
420 application->setName("Map");
440 application->setName("Map");
421 application->setIcon(QUrl("map"));
441 application->setIcon(QUrl("map"));
442+ application->setScreenshot(QUrl("image://application/phone/123456789"));
422 generateQmlStrings(application);
443 generateQmlStrings(application);
423 m_availableApplications.append(application);
444 m_availableApplications.append(application);
424
445
tests/mocks/Unity/Application/CMakeLists.txt+1
@@ -5,6 +5,7 @@ set(FakeUnityApplicationQml_SOURCES
5 ApplicationInfo.cpp
5 ApplicationInfo.cpp
6 ApplicationImage.cpp
6 ApplicationImage.cpp
7 ApplicationManager.cpp
7 ApplicationManager.cpp
8+ ApplicationScreenshotProvider.cpp
8 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
9 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
9 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
10 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
10)
11)
tests/mocks/Unity/Application/plugin.cpp+18−3
@@ -18,13 +18,20 @@
18#include "ApplicationInfo.h"
18#include "ApplicationInfo.h"
19#include "ApplicationImage.h"
19#include "ApplicationImage.h"
20#include "ApplicationManager.h"
20#include "ApplicationManager.h"
21+#include "ApplicationScreenshotProvider.h"
21
22
22#include <qqml.h>
23#include <qqml.h>
24+#include <QQmlEngine>
25+
26+ApplicationManager *s_appManager = 0;
23
27
24static QObject* applicationManagerSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
28static QObject* applicationManagerSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
25− Q_UNUSED(engine);
29+ Q_UNUSED(engine);
26− Q_UNUSED(scriptEngine);
30+ Q_UNUSED(scriptEngine);
31+ if (!s_appManager) {
27− return new ApplicationManager();
32+ s_appManager = new ApplicationManager();
33+ }
34+ return s_appManager;
28}
35}
29
36
30void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
37void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
@@ -37,3 +44,11 @@ void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
37
44
38 qmlRegisterType<ApplicationImage>(uri, 0, 1, "ApplicationImage");
45 qmlRegisterType<ApplicationImage>(uri, 0, 1, "ApplicationImage");
39}
46}
47+
48+void FakeUnityApplicationQmlPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
49+{
50+ QQmlExtensionPlugin::initializeEngine(engine, uri);
51+
52+ ApplicationManager* appManager = static_cast<ApplicationManager*>(applicationManagerSingleton(engine, NULL));
53+ engine->addImageProvider(QLatin1String("application"), new ApplicationScreenshotProvider(appManager));
54+}
tests/mocks/Unity/Application/plugin.h+1
@@ -25,6 +25,7 @@ class FakeUnityApplicationQmlPlugin : public QQmlExtensionPlugin
25 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
25 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26public:
26public:
27 void registerTypes(const char *uri);
27 void registerTypes(const char *uri);
28+ void initializeEngine(QQmlEngine *engine, const char *uri);
28};
29};
29
30
30#endif
31#endif