on xenial help sign in
some work on bringing the fake application plugin up to date with the new api
commita2c47a60aadaff62c310700c5ffa6f4c32effa2c authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 20 Jan 2014, 12:34 (13 years ago) parentd8f6d1a
7 files changed+61−10
qml/Shell.qml+1−1 qml/Stages/PhoneStage.qml+15−4 tests/mocks/Unity/Application/ApplicationInfo.h+2 tests/mocks/Unity/Application/ApplicationManager.cpp+23−2 tests/mocks/Unity/Application/CMakeLists.txt+1 tests/mocks/Unity/Application/plugin.cpp+18−3 tests/mocks/Unity/Application/plugin.h+1
qml/Shell.qml+1−1
@@ -130,7 +130,7 @@ FocusScope {
130130 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
131131
132132 onVisibleChanged: print("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", visible, fullyCovered, applicationSurfaceShouldBeSeen,
133− applicationRunning, stages.fullyHidden, stages.usingScreenshots)
133+ applicationRunning, stages.fullyHidden, stages.painting)
134134
135135 CrossFadeImage {
136136 id: backgroundImage
qml/Stages/PhoneStage.qml+15−4
@@ -20,6 +20,7 @@ Item {
2020 // State information propagated to the outside
2121 readonly property bool painting: mainScreenshotImage.visible || fadeInScreenshotImage.visible || appSplash.visible
2222 onPaintingChanged: print("**********************+ painting changed", painting)
23+ onShownChanged: print("*********************** shown changed", shown)
2324
2425 onMovingChanged: {
2526 if (moving) {
@@ -37,6 +38,7 @@ Item {
3738 }
3839
3940 onFocusedApplicationIdChanged: {
41+ print("foooooooooooooo")
4042 if (ApplicationManager.focusedApplicationId.length > 0) {
4143 if (priv.secondApplicationStarting || priv.applicationStarting) {
4244 appSplashTimer.start();
@@ -65,7 +67,7 @@ Item {
6567
6668 property string focusedAppId: ApplicationManager.focusedApplicationId
6769 property var focusedApplication: ApplicationManager.findApplication(focusedAppId)
68− property url focusedScreenshot: focusedApplication ? focusedApplication.screenshot : ""
70+ property url focusedScreenshot: focusedApplication.screenshot
6971
7072 property bool waitingForScreenshot: false
7173
@@ -74,7 +76,10 @@ Item {
7476
7577 property string newFocusedAppId
7678
79+ onFocusedAppIdChanged: print("focusedappidchanged")
80+
7781 onFocusedScreenshotChanged: {
82+ print("focusedscreenshotchanged")
7883 if (root.moving && priv.waitingForScreenshot) {
7984 mainScreenshotImage.anchors.leftMargin = 0;
8085 mainScreenshotImage.src = ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).screenshot;
@@ -86,6 +91,7 @@ Item {
8691 }
8792
8893 function requestNewScreenshot() {
94+ print("requesting new screenshot", focusedAppId, focusedScreenshot, focusedApplication, focusedApplication.screenshot)
8995 waitingForScreenshot = true;
9096 ApplicationManager.updateScreenshot(ApplicationManager.focusedApplicationId);
9197 }
@@ -306,8 +312,8 @@ Item {
306312
307313 SequentialAnimation {
308314 id: snapAnimation
309− property var targetContentX
310− property var targetAppId
315+ property int targetContentX: 0
316+ property string targetAppId
311317
312318 UbuntuNumberAnimation {
313319 target: coverFlickable
@@ -508,7 +514,7 @@ Item {
508514 }
509515 EasingCurve {
510516 id: scaleEasing
511− type: EasingCurve.Linear
517+ type: EasingCurve.OutQuad
512518 period: coverFlip.maxScale - coverFlip.minScale
513519 progress: appImage.translatedProgress
514520 }
@@ -556,4 +562,9 @@ Item {
556562 }
557563 }
558564 }
565+ Rectangle {
566+ anchors.fill: parent
567+ color: "green"
568+ opacity: .5
569+ }
559570}
tests/mocks/Unity/Application/ApplicationInfo.h+2
@@ -19,6 +19,7 @@
1919
2020#include <QObject>
2121#include <QQmlComponent>
22+#include <QDebug>
2223
2324class QQuickItem;
2425
@@ -56,6 +57,7 @@ class ApplicationInfo : public ApplicationInfoInterface {
5657 { \
5758 if (m_##name != value) { \
5859 m_##name = value; \
60+ qDebug() << "emitting changed" << this << Q_FUNC_INFO; \
5961 Q_EMIT name##Changed(); \
6062 } \
6163 } \
tests/mocks/Unity/Application/ApplicationManager.cpp+23−2
@@ -66,6 +66,8 @@ QVariant ApplicationManager::data(const QModelIndex& index, int role) const {
6666 return app->state();
6767 case RoleFocused:
6868 return app->focused();
69+ case RoleScreenshot:
70+ return app->screenshot();
6971 default:
7072 return QVariant();
7173 }
@@ -78,7 +80,9 @@ ApplicationInfo *ApplicationManager::get(int row) const {
7880}
7981
8082ApplicationInfo *ApplicationManager::findApplication(const QString &appId) const {
83+ qDebug() << "findapp called";
8184 for (ApplicationInfo *app : m_runningApplications) {
85+ qDebug() << "searching app"<< app->appId();
8286 if (app->appId() == appId) {
8387 return app;
8488 }
@@ -87,8 +91,10 @@ ApplicationInfo *ApplicationManager::findApplication(const QString &appId) const
8791}
8892
8993void ApplicationManager::add(ApplicationInfo *application) {
90− if (!application)
94+ qDebug() << "add() " << application->appId();
95+ if (!application) {
9196 return;
97+ }
9298
9399 beginInsertRows(QModelIndex(), m_runningApplications.size(), m_runningApplications.size());
94100 m_runningApplications.append(application);
@@ -207,7 +213,9 @@ void ApplicationManager::updateScreenshot(const QString &appId)
207213 return;
208214 }
209215
216+ qDebug() << "setting new screenshot" << application->screenshot() << application;
210217 application->setScreenshot(QString("image://application/%1/%2").arg(appId).arg(QDateTime::currentMSecsSinceEpoch()));
218+ qDebug() << "set new screenshot" << application->screenshot();
211219 QModelIndex appIndex = index(idx);
212220 Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << RoleScreenshot);
213221}
@@ -272,7 +280,7 @@ bool ApplicationManager::focusApplication(const QString &appId)
272280
273281void ApplicationManager::activateApplication(const QString &appId)
274282{
275− QMetaObject::invokeMethod(this, "requestFocus", Qt::QueuedConnection, Q_ARG(QString, appId));
283+ QMetaObject::invokeMethod(this, "focusRequested", Qt::QueuedConnection, Q_ARG(QString, appId));
276284}
277285
278286void ApplicationManager::unfocusCurrentApplication()
@@ -333,6 +341,7 @@ void ApplicationManager::buildListOfAvailableApplications()
333341 application->setName("Phone");
334342 application->setIcon(QUrl("phone"));
335343 application->setStage(ApplicationInfo::SideStage);
344+ application->setScreenshot(QString("image://application/%1/123456789").arg(application->appId()));
336345 generateQmlStrings(application);
337346 m_availableApplications.append(application);
338347
@@ -341,6 +350,7 @@ void ApplicationManager::buildListOfAvailableApplications()
341350 application->setName("Camera");
342351 application->setIcon(QUrl("camera"));
343352 application->setFullscreen(true);
353+ application->setScreenshot(QUrl("image://application/phone/123456789"));
344354 generateQmlStrings(application);
345355 m_availableApplications.append(application);
346356
@@ -348,6 +358,7 @@ void ApplicationManager::buildListOfAvailableApplications()
348358 application->setAppId("gallery-app");
349359 application->setName("Gallery");
350360 application->setIcon(QUrl("gallery"));
361+ application->setScreenshot(QUrl("image://application/phone/123456789"));
351362 generateQmlStrings(application);
352363 m_availableApplications.append(application);
353364
@@ -356,6 +367,7 @@ void ApplicationManager::buildListOfAvailableApplications()
356367 application->setName("Facebook");
357368 application->setIcon(QUrl("facebook"));
358369 application->setStage(ApplicationInfo::SideStage);
370+ application->setScreenshot(QUrl("image://application/phone/123456789"));
359371 generateQmlStrings(application);
360372 m_availableApplications.append(application);
361373
@@ -363,6 +375,7 @@ void ApplicationManager::buildListOfAvailableApplications()
363375 application->setAppId("webbrowser-app");
364376 application->setName("Browser");
365377 application->setIcon(QUrl("browser"));
378+ application->setScreenshot(QUrl("image://application/phone/123456789"));
366379 generateQmlStrings(application);
367380 m_availableApplications.append(application);
368381
@@ -371,6 +384,7 @@ void ApplicationManager::buildListOfAvailableApplications()
371384 application->setName("Twitter");
372385 application->setIcon(QUrl("twitter"));
373386 application->setStage(ApplicationInfo::SideStage);
387+ application->setScreenshot(QUrl("image://application/phone/123456789"));
374388 generateQmlStrings(application);
375389 m_availableApplications.append(application);
376390
@@ -378,6 +392,7 @@ void ApplicationManager::buildListOfAvailableApplications()
378392 application->setAppId("gmail-webapp");
379393 application->setName("GMail");
380394 application->setIcon(QUrl("gmail"));
395+ application->setScreenshot(QUrl("image://application/phone/123456789"));
381396 m_availableApplications.append(application);
382397
383398 application = new ApplicationInfo(this);
@@ -385,6 +400,7 @@ void ApplicationManager::buildListOfAvailableApplications()
385400 application->setName("Weather");
386401 application->setIcon(QUrl("weather"));
387402 application->setStage(ApplicationInfo::SideStage);
403+ application->setScreenshot(QUrl("image://application/phone/123456789"));
388404 generateQmlStrings(application);
389405 m_availableApplications.append(application);
390406
@@ -393,6 +409,7 @@ void ApplicationManager::buildListOfAvailableApplications()
393409 application->setName("Notepad");
394410 application->setIcon(QUrl("notepad"));
395411 application->setStage(ApplicationInfo::SideStage);
412+ application->setScreenshot(QUrl("image://application/phone/123456789"));
396413 m_availableApplications.append(application);
397414
398415 application = new ApplicationInfo(this);
@@ -400,6 +417,7 @@ void ApplicationManager::buildListOfAvailableApplications()
400417 application->setName("Calendar");
401418 application->setIcon(QUrl("calendar"));
402419 application->setStage(ApplicationInfo::SideStage);
420+ application->setScreenshot(QUrl("image://application/phone/123456789"));
403421 m_availableApplications.append(application);
404422
405423 application = new ApplicationInfo(this);
@@ -407,18 +425,21 @@ void ApplicationManager::buildListOfAvailableApplications()
407425 application->setName("Media Player");
408426 application->setIcon(QUrl("mediaplayer-app"));
409427 application->setFullscreen(true);
428+ application->setScreenshot(QUrl("image://application/phone/123456789"));
410429 m_availableApplications.append(application);
411430
412431 application = new ApplicationInfo(this);
413432 application->setAppId("evernote");
414433 application->setName("Evernote");
415434 application->setIcon(QUrl("evernote"));
435+ application->setScreenshot(QUrl("image://application/phone/123456789"));
416436 m_availableApplications.append(application);
417437
418438 application = new ApplicationInfo(this);
419439 application->setAppId("map");
420440 application->setName("Map");
421441 application->setIcon(QUrl("map"));
442+ application->setScreenshot(QUrl("image://application/phone/123456789"));
422443 generateQmlStrings(application);
423444 m_availableApplications.append(application);
424445
tests/mocks/Unity/Application/CMakeLists.txt+1
@@ -5,6 +5,7 @@ set(FakeUnityApplicationQml_SOURCES
55 ApplicationInfo.cpp
66 ApplicationImage.cpp
77 ApplicationManager.cpp
8+ ApplicationScreenshotProvider.cpp
89 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
910 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
1011)
tests/mocks/Unity/Application/plugin.cpp+18−3
@@ -18,13 +18,20 @@
1818#include "ApplicationInfo.h"
1919#include "ApplicationImage.h"
2020#include "ApplicationManager.h"
21+#include "ApplicationScreenshotProvider.h"
2122
2223#include <qqml.h>
24+#include <QQmlEngine>
25+
26+ApplicationManager *s_appManager = 0;
2327
2428static QObject* applicationManagerSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
25− Q_UNUSED(engine);
26− Q_UNUSED(scriptEngine);
27− return new ApplicationManager();
29+ Q_UNUSED(engine);
30+ Q_UNUSED(scriptEngine);
31+ if (!s_appManager) {
32+ s_appManager = new ApplicationManager();
33+ }
34+ return s_appManager;
2835}
2936
3037void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
@@ -37,3 +44,11 @@ void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
3744
3845 qmlRegisterType<ApplicationImage>(uri, 0, 1, "ApplicationImage");
3946}
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
2525 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
2626public:
2727 void registerTypes(const char *uri);
28+ void initializeEngine(QQmlEngine *engine, const char *uri);
2829};
2930
3031#endif