@@ -29,11 +29,11 @@ AbstractButton {
2929 signal requestedActivationMode()
3030 signal requestedTerminationMode()
3131
32− // Was: childrenRect.height
33− // To avoid "binding loop" warning
34− height: shapedApplicationImage.height + labelContainer.height
32+ width: thumbnail.width
33+ height: thumbnail.height + labelContainer.height
3534
36− width: shapedApplicationImage.width <= units.gu(11) ? units.gu(11) : height
35+ // Orientation angle of the Shell UI, relative to the scene (QQuickView's) root item.
36+ property int orientationAngle
3737
3838 property bool terminationModeEnabled: false
3939
@@ -50,42 +50,104 @@ AbstractButton {
5050 }
5151 }
5252
53− UbuntuShape {
54− id: shapedApplicationImage
55− anchors { top: parent.top; horizontalCenter: parent.horizontalCenter }
56−
57− height: units.gu(17)
58− width: applicationImage.width
59− radius: "medium"
60−
61− image: Image {
62− id: applicationImage
63− source: application.screenshot
64− // height : width = ss.height : ss.width
65− height: shapedApplicationImage.height
66− fillMode: Image.PreserveAspectCrop
67− width: Math.min(height, height * sourceSize.width / sourceSize.height)
68− }
53+ Item {
54+ id: thumbnail
55+
56+ width: thumbnailHelper.flippedDimensions ? shapedApplicationImage.height : shapedApplicationImage.width
57+ height: thumbnailHelper.flippedDimensions ? shapedApplicationImage.width : shapedApplicationImage.height
58+
59+ onWidthChanged: {console.log("thumbnail.width = " + width);}
60+ onHeightChanged: {console.log("thumbnail.height = " + height);}
61+
62+
63+ Item {
64+ id: thumbnailHelper
65+
66+ property bool flippedDimensions: root.orientationAngle == 90 || root.orientationAngle == 270
67+
68+ // Compensate for the UI rotation that is done by the application itself
69+ // TODO: Only counter-rotate if the application UI is rotated in the first place
70+ // Currently we don't have this info, so we just assume every single app rotate
71+ // its UI
72+ transformOrigin: Item.TopLeft
73+ state: orientationAngle.toString()
74+ states: [
75+ State {
76+ name: "0"
77+ PropertyChanges {
78+ target: thumbnailHelper
79+ rotation: 0
80+ x: 0
81+ y: 0
82+ }
83+ },
84+ State {
85+ name: "90"
86+ PropertyChanges {
87+ target: thumbnailHelper
88+ rotation: -90
89+ x: 0
90+ y: shapedApplicationImage.width
91+ }
92+ },
93+ State {
94+ name: "180"
95+ PropertyChanges {
96+ target: thumbnailHelper
97+ rotation: -180
98+ x: shapedApplicationImage.width
99+ y: shapedApplicationImage.height
100+ }
101+ },
102+ State {
103+ name: "270"
104+ PropertyChanges {
105+ target: thumbnailHelper
106+ rotation: -270
107+ x: shapedApplicationImage.height
108+ y: 0
109+ }
110+ }
111+ ]
112+
113+ UbuntuShape {
114+ id: shapedApplicationImage
115+ x: 0
116+ y: 0
117+ height: applicationImage.height
118+ width: applicationImage.width
119+ radius: "medium"
120+
121+ image: Image {
122+ id: applicationImage
123+ source: application.screenshot
124+ // height : width = ss.height : ss.width
125+ height: units.gu(17)
126+ fillMode: Image.PreserveAspectCrop
127+ width: Math.min(height, height * sourceSize.width / sourceSize.height)
128+ }
69129
70− }
130+ }
71131
72− UbuntuShape {
73− id: borderPressed
132+ UbuntuShape {
133+ id: borderPressed
74134
75− anchors.fill: shapedApplicationImage
76− radius: "medium"
77− borderSource: "radius_pressed.sci"
78− opacity: root.pressed ? 1.0 : 0.0
79− Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } }
135+ anchors.fill: shapedApplicationImage
136+ radius: "medium"
137+ borderSource: "radius_pressed.sci"
138+ opacity: root.pressed ? 1.0 : 0.0
139+ Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } }
140+ }
141+ }
80142 }
81143
82144 // FIXME: label code duplicated with Tile
83145 Item {
84146 id: labelContainer
85147 anchors {
86− left: parent.left
87− right: parent.right
88− top: shapedApplicationImage.bottom
148+ left: thumbnail.left
149+ right: thumbnail.right
150+ top: thumbnail.bottom
89151 }
90152 height: units.gu(2)
91153
@@ -110,9 +172,9 @@ AbstractButton {
110172 CloseIcon {
111173 objectName: "closeIcon " + model.name
112174 anchors {
113− left: shapedApplicationImage.left
175+ left: thumbnail.left
114176 leftMargin: -units.gu(1)
115− top: parent.top
177+ top: thumbnail.top
116178 topMargin: -units.gu(1)
117179 }
118180 height: units.gu(6)