Merge lp:~unity-team/unity8/rotateScreenshots into lp:unity8

Proposed by Michał Sawicz on 2015-10-16
Status: Merged
Approved by: Michał Sawicz on 2015-10-21
Approved revision: 2008
Merged at revision: 2009
Proposed branch: lp:~unity-team/unity8/rotateScreenshots
Merge into: lp:unity8
Prerequisite: lp:~unity-team/unity8/externalMonitor
Diff against target: 109 lines (+20/-6)
6 files modified
plugins/ScreenGrabber/screengrabber.cpp (+2/-2)
plugins/ScreenGrabber/screengrabber.h (+1/-1)
qml/Components/ScreenGrabber.qml (+4/-1)
qml/Shell.qml (+1/-1)
tests/plugins/ScreenGrabber/ScreenGrabberTest.cpp (+11/-0)
tests/plugins/ScreenGrabber/grabber.qml (+1/-1)
To merge this branch: bzr merge lp:~unity-team/unity8/rotateScreenshots
Reviewer Review Type Date Requested Status
Michał Sawicz Approve on 2015-10-21
PS Jenkins bot continuous-integration 2015-10-16 Needs Fixing on 2015-10-16
Review via email: mp+274743@code.launchpad.net

Commit Message

Rotate the screenshots according to the actual orientation

Description of the Change

Rotate the screenshots according to the actual orientation when saving them

Cf. https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1504538

* Are there any related MPs required for this MP to build/function as expected? Please list.

Yes, lp:~unity-team/unity8/externalMonitor

* Did you perform an exploratory manual test run of your code change and any related functionality?

Yes, see http://developer.kde.org/~lukas/screenshots/unity8/rotatedScreenshot.png

* Did you make sure that your branch does not contain spurious tags?

Yes

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

Yes

* If you changed the UI, has there been a design review?

N/A

To post a comment you must log in.
Michał Sawicz (saviq) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Y
 * Did CI run pass? If not, please explain why.
No, dependencies
 * Did you make sure that the branch does not contain spurious tags?
Y

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/ScreenGrabber/screengrabber.cpp'
2--- plugins/ScreenGrabber/screengrabber.cpp 2015-09-23 15:14:01 +0000
3+++ plugins/ScreenGrabber/screengrabber.cpp 2015-10-16 17:12:30 +0000
4@@ -60,7 +60,7 @@
5 }
6 }
7
8-void ScreenGrabber::captureAndSave()
9+void ScreenGrabber::captureAndSave(int angle)
10 {
11 if (fileNamePrefix.isEmpty())
12 {
13@@ -82,7 +82,7 @@
14 return;
15 }
16
17- const QImage screenshot = main_window->grabWindow();
18+ const QImage screenshot = main_window->grabWindow().transformed(QTransform().rotate(angle));
19 const QString filename = makeFileName();
20 qDebug() << "Saving screenshot to" << filename;
21 auto saveOp = QtConcurrent::run(saveScreenshot, screenshot, filename, getFormat(), screenshotQuality);
22
23=== modified file 'plugins/ScreenGrabber/screengrabber.h'
24--- plugins/ScreenGrabber/screengrabber.h 2015-07-17 19:59:31 +0000
25+++ plugins/ScreenGrabber/screengrabber.h 2015-10-16 17:12:30 +0000
26@@ -29,7 +29,7 @@
27 ~ScreenGrabber() = default;
28
29 public Q_SLOTS:
30- void captureAndSave();
31+ void captureAndSave(int angle = 0);
32
33 Q_SIGNALS:
34 void screenshotSaved(const QString &filename);
35
36=== modified file 'qml/Components/ScreenGrabber.qml'
37--- qml/Components/ScreenGrabber.qml 2015-08-24 15:39:53 +0000
38+++ qml/Components/ScreenGrabber.qml 2015-10-16 17:12:30 +0000
39@@ -26,6 +26,9 @@
40 anchors.fill: parent
41 opacity: 0.0
42
43+ // to be set from outside
44+ property int rotationAngle: 0
45+
46 ScreenGrabber {
47 id: screenGrabber
48 objectName: "screenGrabber"
49@@ -67,7 +70,7 @@
50 to: 0.0
51 onStopped: {
52 if (visible) {
53- screenGrabber.captureAndSave();
54+ screenGrabber.captureAndSave(root.rotationAngle);
55 visible = false;
56 }
57 }
58
59=== modified file 'qml/Shell.qml'
60--- qml/Shell.qml 2015-10-16 17:12:30 +0000
61+++ qml/Shell.qml 2015-10-16 17:12:30 +0000
62@@ -659,6 +659,7 @@
63
64 ScreenGrabber {
65 id: screenGrabber
66+ rotationAngle: -shell.orientationAngle
67 z: dialogs.z + 10
68 }
69
70@@ -687,5 +688,4 @@
71 }
72 }
73 }
74-
75 }
76
77=== modified file 'tests/plugins/ScreenGrabber/ScreenGrabberTest.cpp'
78--- tests/plugins/ScreenGrabber/ScreenGrabberTest.cpp 2015-07-20 15:06:46 +0000
79+++ tests/plugins/ScreenGrabber/ScreenGrabberTest.cpp 2015-10-16 17:12:30 +0000
80@@ -55,6 +55,17 @@
81 QVERIFY(!args.first().toString().isEmpty());
82 }
83
84+ void testRotatedScreenshot()
85+ {
86+ QSignalSpy grabberSpy(m_grabber, &ScreenGrabber::screenshotSaved);
87+ m_grabber->captureAndSave(90); // rotate by 90°
88+ const QVariantList args = grabberSpy.takeFirst();
89+ const QString filename = args.first().toString();
90+ QVERIFY(!filename.isEmpty());
91+ QImage img(filename);
92+ QVERIFY(img.height() > img.width()); // verify that the image got rotated by 90° (height > width)
93+ }
94+
95 private:
96 QQuickView *m_view;
97 ScreenGrabber *m_grabber = nullptr;
98
99=== modified file 'tests/plugins/ScreenGrabber/grabber.qml'
100--- tests/plugins/ScreenGrabber/grabber.qml 2015-07-17 19:59:31 +0000
101+++ tests/plugins/ScreenGrabber/grabber.qml 2015-10-16 17:12:30 +0000
102@@ -20,7 +20,7 @@
103 Rectangle {
104 property var grabber: screenGrabber
105
106- width: 100
107+ width: 101 // width intentionally bigger than height to test rotation
108 height: 100
109 color: "green"
110

Subscribers

People subscribed via source and target branches