on xenial help sign in
more progress on the fake application manager
commit3570b4af6e5ea6431e132515650164eb7bc590d7 authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 20 Jan 2014, 18:41 (13 years ago) parentc969157
2 files changed+29−16
qml/Stages/PhoneStage.qml+16−16 tests/mocks/Unity/Application/ApplicationScreenshotProvider.cpp+13
qml/Stages/PhoneStage.qml+16−16
@@ -20,7 +20,6 @@ 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)
2423
2524 onMovingChanged: {
2625 if (moving) {
@@ -38,7 +37,6 @@ Item {
3837 }
3938
4039 onFocusedApplicationIdChanged: {
41− print("foooooooooooooo")
4240 if (ApplicationManager.focusedApplicationId.length > 0) {
4341 if (priv.secondApplicationStarting || priv.applicationStarting) {
4442 appSplashTimer.start();
@@ -67,7 +65,7 @@ Item {
6765
6866 property string focusedAppId: ApplicationManager.focusedApplicationId
6967 property var focusedApplication: ApplicationManager.findApplication(focusedAppId)
70− property url focusedScreenshot: focusedApplication.screenshot
68+ property url focusedScreenshot: focusedApplication ? focusedApplication.screenshot : ""
7169
7270 property bool waitingForScreenshot: false
7371
@@ -76,10 +74,7 @@ Item {
7674
7775 property string newFocusedAppId
7876
79− onFocusedAppIdChanged: print("focusedappidchanged")
80−
8177 onFocusedScreenshotChanged: {
82− print("focusedscreenshotchanged")
8378 if (root.moving && priv.waitingForScreenshot) {
8479 mainScreenshotImage.anchors.leftMargin = 0;
8580 mainScreenshotImage.src = ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).screenshot;
@@ -91,7 +86,6 @@ Item {
9186 }
9287
9388 function requestNewScreenshot() {
94− print("requesting new screenshot", focusedAppId, focusedScreenshot, focusedApplication, focusedApplication.screenshot)
9589 waitingForScreenshot = true;
9690 ApplicationManager.updateScreenshot(ApplicationManager.focusedApplicationId);
9791 }
@@ -104,6 +98,13 @@ Item {
10498
10599 }
106100
101+ // FIXME: the signal connection seems to get lost with the fake application manager.
102+ // Check with Qt 5.2, see if we can remove this Connections object
103+ Connections {
104+ target: priv.focusedApplication
105+ onScreenshotChanged: priv.focusedScreenshot = priv.focusedApplication.screenshot
106+ }
107+
107108 Timer {
108109 id: grantFocusTimer
109110 // Delay the actual switch to be covered by the animation for sure.
@@ -188,7 +189,7 @@ Item {
188189
189190 EdgeDragArea {
190191 id: coverFlipDragArea
191− direction: Direction.Rightwards
192+ direction: Direction.Leftwards
192193
193194 //enabled: root.available
194195 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
@@ -319,6 +320,7 @@ Item {
319320 target: coverFlickable
320321 properties: "contentX"
321322 to: snapAnimation.targetContentX
323+ duration: UbuntuAnimation.SnapDuration
322324 }
323325 ScriptAction {
324326 script: {
@@ -514,7 +516,7 @@ Item {
514516 }
515517 EasingCurve {
516518 id: scaleEasing
517− type: EasingCurve.OutQuad
519+ type: EasingCurve.Linear
518520 period: coverFlip.maxScale - coverFlip.minScale
519521 progress: appImage.translatedProgress
520522 }
@@ -546,8 +548,11 @@ Item {
546548 SequentialAnimation {
547549 id: switchToAppAnimation
548550 property int targetContentX
549− ParallelAnimation {
550− UbuntuNumberAnimation { target: coverFlickable; property: "contentX"; to: switchToAppAnimation.targetContentX }
551+ UbuntuNumberAnimation {
552+ target: coverFlickable;
553+ property: "contentX";
554+ to: switchToAppAnimation.targetContentX;
555+ duration: UbuntuAnimation.SnapDuration
551556 }
552557 ScriptAction {
553558 script: {
@@ -562,9 +567,4 @@ Item {
562567 }
563568 }
564569 }
565− Rectangle {
566− anchors.fill: parent
567− color: "green"
568− opacity: .5
569− }
570570}
tests/mocks/Unity/Application/ApplicationScreenshotProvider.cpp+13
@@ -21,6 +21,9 @@
2121#include "paths.h"
2222
2323#include <QDebug>
24+#include <QGuiApplication>
25+#include <QWindow>
26+#include <QQuickWindow>
2427
2528ApplicationScreenshotProvider::ApplicationScreenshotProvider(ApplicationManager *appManager)
2629 : QQuickImageProvider(QQuickImageProvider::Image)
@@ -49,8 +52,18 @@ QImage ApplicationScreenshotProvider::requestImage(const QString &imageId, QSize
4952 qDebug() << "failed loading app image" << filePath;
5053 }
5154
55+ QGuiApplication *unity = qobject_cast<QGuiApplication*>(qApp);
56+
57+ Q_FOREACH (QWindow *win, unity->allWindows()) {
58+ QQuickWindow *quickWin = qobject_cast<QQuickWindow*>(win);
59+ if (quickWin) {
60+ image = image.scaledToWidth(quickWin->width());
61+ }
62+ }
63+
5264 size->setWidth(image.width());
5365 size->setHeight(image.height());
66+ qDebug() << "got image of size" << size->width() << size->height() << requestedSize;
5467
5568 return image;
5669}