Merge lp:~fboucault/camera-app/empty_photo_roll into lp:camera-app

Proposed by Florian Boucault
Status: Merged
Approved by: Florian Boucault
Approved revision: 406
Merged at revision: 410
Proposed branch: lp:~fboucault/camera-app/empty_photo_roll
Merge into: lp:camera-app
Prerequisite: lp:~fboucault/camera-app/photo_roll_hint
Diff against target: 192 lines (+80/-4)
5 files modified
CameraApp/foldersmodel.cpp (+7/-0)
CameraApp/foldersmodel.h (+3/-0)
GalleryView.qml (+32/-4)
tests/autopilot/camera_app/emulators/main_window.py (+4/-0)
tests/autopilot/camera_app/tests/test_gallery_view.py (+34/-0)
To merge this branch: bzr merge lp:~fboucault/camera-app/empty_photo_roll
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Pending
Ubuntu Phablet Team Pending
Review via email: mp+239915@code.launchpad.net

This proposal supersedes a proposal from 2014-10-10.

Commit message

Display message when no media present in photo roll.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CameraApp/foldersmodel.cpp'
2--- CameraApp/foldersmodel.cpp 2014-09-02 13:19:22 +0000
3+++ CameraApp/foldersmodel.cpp 2014-10-28 21:44:01 +0000
4@@ -75,6 +75,10 @@
5 }
6 }
7
8+int FoldersModel::count() const
9+{
10+ return m_fileInfoList.count();
11+}
12
13 void FoldersModel::updateFileInfoList()
14 {
15@@ -94,6 +98,7 @@
16 }
17 endResetModel();
18 m_selectedFiles.clear();
19+ Q_EMIT countChanged();
20 Q_EMIT selectedFilesChanged();
21 }
22
23@@ -138,6 +143,7 @@
24 beginInsertRows(QModelIndex(), index, index);
25 m_fileInfoList.append(newFileInfo);
26 endInsertRows();
27+ Q_EMIT countChanged();
28 } else {
29 m_fileInfoList.append(newFileInfo);
30 }
31@@ -251,6 +257,7 @@
32 beginRemoveRows(QModelIndex(), fileIndex, fileIndex);
33 m_fileInfoList.removeAt(fileIndex);
34 endRemoveRows();
35+ Q_EMIT countChanged();
36 }
37 }
38 }
39
40=== modified file 'CameraApp/foldersmodel.h'
41--- CameraApp/foldersmodel.h 2014-09-02 13:19:22 +0000
42+++ CameraApp/foldersmodel.h 2014-10-28 21:44:01 +0000
43@@ -31,6 +31,7 @@
44 Q_PROPERTY (QStringList typeFilters READ typeFilters WRITE setTypeFilters NOTIFY typeFiltersChanged)
45 Q_PROPERTY (QList<int> selectedFiles READ selectedFiles NOTIFY selectedFilesChanged)
46 Q_PROPERTY (bool singleSelectionOnly READ singleSelectionOnly WRITE setSingleSelectionOnly NOTIFY singleSelectionOnlyChanged)
47+ Q_PROPERTY(int count READ count NOTIFY countChanged)
48
49 public:
50 enum Roles {
51@@ -50,6 +51,7 @@
52 QList<int> selectedFiles() const;
53 bool singleSelectionOnly() const;
54 void setSingleSelectionOnly(bool singleSelectionOnly);
55+ int count() const;
56
57 void updateFileInfoList();
58 bool fileMatchesTypeFilters(const QFileInfo& newFileInfo);
59@@ -71,6 +73,7 @@
60 void typeFiltersChanged();
61 void selectedFilesChanged();
62 void singleSelectionOnlyChanged();
63+ void countChanged();
64
65 private:
66 QStringList m_folders;
67
68=== modified file 'GalleryView.qml'
69--- GalleryView.qml 2014-09-02 13:19:22 +0000
70+++ GalleryView.qml 2014-10-28 21:44:01 +0000
71@@ -15,7 +15,7 @@
72 */
73
74 import QtQuick 2.2
75-import Ubuntu.Components 1.0
76+import Ubuntu.Components 1.1
77 import Ubuntu.Content 0.1
78 import CameraApp 0.1
79 import "MimeTypeMapper.js" as MimeTypeMapper
80@@ -115,10 +115,38 @@
81 }
82 }
83
84- Label {
85- anchors.centerIn: parent
86+ Rectangle {
87+ objectName: "noMediaHint"
88+ anchors.fill: parent
89 visible: model.count === 0
90- text: i18n.tr("No media available.")
91+ color: "#0F0F0F"
92+
93+ Icon {
94+ id: noMediaIcon
95+ anchors {
96+ horizontalCenter: parent.horizontalCenter
97+ verticalCenter: parent.verticalCenter
98+ verticalCenterOffset: -units.gu(1)
99+ }
100+ height: units.gu(9)
101+ width: units.gu(9)
102+ color: "white"
103+ opacity: 0.2
104+ name: "camera-app-symbolic"
105+ }
106+
107+ Label {
108+ id: noMediaLabel
109+ anchors {
110+ horizontalCenter: parent.horizontalCenter
111+ top: noMediaIcon.bottom
112+ topMargin: units.gu(4)
113+ }
114+ text: i18n.tr("No media available.")
115+ color: "white"
116+ opacity: 0.2
117+ fontSize: "large"
118+ }
119 }
120
121 state: galleryView.gridMode || main.contentExportMode ? "GRID" : "SLIDESHOW"
122
123=== modified file 'tests/autopilot/camera_app/emulators/main_window.py'
124--- tests/autopilot/camera_app/emulators/main_window.py 2014-10-28 21:44:01 +0000
125+++ tests/autopilot/camera_app/emulators/main_window.py 2014-10-28 21:44:01 +0000
126@@ -32,6 +32,10 @@
127 """Returns the gallery view"""
128 return self.app.wait_select_single("GalleryView")
129
130+ def get_no_media_hint(self):
131+ """Returns the Item representing the hint that no media is available"""
132+ return self.app.wait_select_single(objectName="noMediaHint")
133+
134 def get_focus_ring(self):
135 """Returns the focus ring of the camera"""
136 return self.app.wait_select_single("FocusRing")
137
138=== modified file 'tests/autopilot/camera_app/tests/test_gallery_view.py'
139--- tests/autopilot/camera_app/tests/test_gallery_view.py 2014-10-28 21:44:01 +0000
140+++ tests/autopilot/camera_app/tests/test_gallery_view.py 2014-10-28 21:44:01 +0000
141@@ -13,6 +13,7 @@
142 from camera_app.tests import CameraAppTestCase
143
144 import unittest
145+import os
146
147
148 class TestCameraGalleryView(CameraAppTestCase):
149@@ -24,6 +25,8 @@
150 super(TestCameraGalleryView, self).setUp()
151 self.assertThat(
152 self.main_window.get_qml_view().visible, Eventually(Equals(True)))
153+ self.pictures_dir = os.path.expanduser("~/Pictures/com.ubuntu.camera")
154+ self.videos_dir = os.path.expanduser("~/Videos/com.ubuntu.camera")
155
156 def tearDown(self):
157 super(TestCameraGalleryView, self).tearDown()
158@@ -65,3 +68,34 @@
159
160 self.assertThat(slideshow_view.visible, Eventually(Equals(False)))
161 self.assertThat(photogrid_view.visible, Eventually(Equals(True)))
162+
163+ def delete_all_media(self):
164+ picture_files = os.listdir(self.pictures_dir)
165+ for f in picture_files:
166+ os.remove(os.path.join(self.pictures_dir, f))
167+
168+ video_files = os.listdir(self.videos_dir)
169+ for f in video_files:
170+ os.remove(os.path.join(self.videos_dir, f))
171+
172+ """Tests swiping to the gallery/photo roll with no media in it"""
173+ def test_swipe_to_empty_gallery(self):
174+ self.delete_all_media()
175+ viewfinder = self.main_window.get_viewfinder()
176+ gallery = self.main_window.get_gallery()
177+
178+ self.main_window.swipe_to_gallery(self)
179+
180+ self.assertThat(viewfinder.inView, Eventually(Equals(False)))
181+ self.assertThat(gallery.inView, Eventually(Equals(True)))
182+
183+ hint = self.main_window.get_no_media_hint()
184+
185+ self.assertThat(hint.visible, Eventually(Equals(True)))
186+
187+ # add a fake photo to pictures_dir
188+ photo_path = os.path.join(self.pictures_dir, "fake_photo.jpg")
189+ with open(photo_path, 'a'):
190+ os.utime(photo_path, None)
191+
192+ self.assertThat(hint.visible, Eventually(Equals(False)))

Subscribers

People subscribed via source and target branches