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
=== modified file 'CameraApp/foldersmodel.cpp'
--- CameraApp/foldersmodel.cpp 2014-09-02 13:19:22 +0000
+++ CameraApp/foldersmodel.cpp 2014-10-28 21:44:01 +0000
@@ -75,6 +75,10 @@
75 }75 }
76}76}
7777
78int FoldersModel::count() const
79{
80 return m_fileInfoList.count();
81}
7882
79void FoldersModel::updateFileInfoList()83void FoldersModel::updateFileInfoList()
80{84{
@@ -94,6 +98,7 @@
94 }98 }
95 endResetModel();99 endResetModel();
96 m_selectedFiles.clear();100 m_selectedFiles.clear();
101 Q_EMIT countChanged();
97 Q_EMIT selectedFilesChanged();102 Q_EMIT selectedFilesChanged();
98}103}
99104
@@ -138,6 +143,7 @@
138 beginInsertRows(QModelIndex(), index, index);143 beginInsertRows(QModelIndex(), index, index);
139 m_fileInfoList.append(newFileInfo);144 m_fileInfoList.append(newFileInfo);
140 endInsertRows();145 endInsertRows();
146 Q_EMIT countChanged();
141 } else {147 } else {
142 m_fileInfoList.append(newFileInfo);148 m_fileInfoList.append(newFileInfo);
143 }149 }
@@ -251,6 +257,7 @@
251 beginRemoveRows(QModelIndex(), fileIndex, fileIndex);257 beginRemoveRows(QModelIndex(), fileIndex, fileIndex);
252 m_fileInfoList.removeAt(fileIndex);258 m_fileInfoList.removeAt(fileIndex);
253 endRemoveRows();259 endRemoveRows();
260 Q_EMIT countChanged();
254 }261 }
255 }262 }
256}263}
257264
=== modified file 'CameraApp/foldersmodel.h'
--- CameraApp/foldersmodel.h 2014-09-02 13:19:22 +0000
+++ CameraApp/foldersmodel.h 2014-10-28 21:44:01 +0000
@@ -31,6 +31,7 @@
31 Q_PROPERTY (QStringList typeFilters READ typeFilters WRITE setTypeFilters NOTIFY typeFiltersChanged)31 Q_PROPERTY (QStringList typeFilters READ typeFilters WRITE setTypeFilters NOTIFY typeFiltersChanged)
32 Q_PROPERTY (QList<int> selectedFiles READ selectedFiles NOTIFY selectedFilesChanged)32 Q_PROPERTY (QList<int> selectedFiles READ selectedFiles NOTIFY selectedFilesChanged)
33 Q_PROPERTY (bool singleSelectionOnly READ singleSelectionOnly WRITE setSingleSelectionOnly NOTIFY singleSelectionOnlyChanged)33 Q_PROPERTY (bool singleSelectionOnly READ singleSelectionOnly WRITE setSingleSelectionOnly NOTIFY singleSelectionOnlyChanged)
34 Q_PROPERTY(int count READ count NOTIFY countChanged)
3435
35public:36public:
36 enum Roles {37 enum Roles {
@@ -50,6 +51,7 @@
50 QList<int> selectedFiles() const;51 QList<int> selectedFiles() const;
51 bool singleSelectionOnly() const;52 bool singleSelectionOnly() const;
52 void setSingleSelectionOnly(bool singleSelectionOnly);53 void setSingleSelectionOnly(bool singleSelectionOnly);
54 int count() const;
5355
54 void updateFileInfoList();56 void updateFileInfoList();
55 bool fileMatchesTypeFilters(const QFileInfo& newFileInfo);57 bool fileMatchesTypeFilters(const QFileInfo& newFileInfo);
@@ -71,6 +73,7 @@
71 void typeFiltersChanged();73 void typeFiltersChanged();
72 void selectedFilesChanged();74 void selectedFilesChanged();
73 void singleSelectionOnlyChanged();75 void singleSelectionOnlyChanged();
76 void countChanged();
7477
75private:78private:
76 QStringList m_folders;79 QStringList m_folders;
7780
=== modified file 'GalleryView.qml'
--- GalleryView.qml 2014-09-02 13:19:22 +0000
+++ GalleryView.qml 2014-10-28 21:44:01 +0000
@@ -15,7 +15,7 @@
15 */15 */
1616
17import QtQuick 2.217import QtQuick 2.2
18import Ubuntu.Components 1.018import Ubuntu.Components 1.1
19import Ubuntu.Content 0.119import Ubuntu.Content 0.1
20import CameraApp 0.120import CameraApp 0.1
21import "MimeTypeMapper.js" as MimeTypeMapper21import "MimeTypeMapper.js" as MimeTypeMapper
@@ -115,10 +115,38 @@
115 }115 }
116 }116 }
117117
118 Label {118 Rectangle {
119 anchors.centerIn: parent119 objectName: "noMediaHint"
120 anchors.fill: parent
120 visible: model.count === 0121 visible: model.count === 0
121 text: i18n.tr("No media available.")122 color: "#0F0F0F"
123
124 Icon {
125 id: noMediaIcon
126 anchors {
127 horizontalCenter: parent.horizontalCenter
128 verticalCenter: parent.verticalCenter
129 verticalCenterOffset: -units.gu(1)
130 }
131 height: units.gu(9)
132 width: units.gu(9)
133 color: "white"
134 opacity: 0.2
135 name: "camera-app-symbolic"
136 }
137
138 Label {
139 id: noMediaLabel
140 anchors {
141 horizontalCenter: parent.horizontalCenter
142 top: noMediaIcon.bottom
143 topMargin: units.gu(4)
144 }
145 text: i18n.tr("No media available.")
146 color: "white"
147 opacity: 0.2
148 fontSize: "large"
149 }
122 }150 }
123151
124 state: galleryView.gridMode || main.contentExportMode ? "GRID" : "SLIDESHOW"152 state: galleryView.gridMode || main.contentExportMode ? "GRID" : "SLIDESHOW"
125153
=== modified file 'tests/autopilot/camera_app/emulators/main_window.py'
--- tests/autopilot/camera_app/emulators/main_window.py 2014-10-28 21:44:01 +0000
+++ tests/autopilot/camera_app/emulators/main_window.py 2014-10-28 21:44:01 +0000
@@ -32,6 +32,10 @@
32 """Returns the gallery view"""32 """Returns the gallery view"""
33 return self.app.wait_select_single("GalleryView")33 return self.app.wait_select_single("GalleryView")
3434
35 def get_no_media_hint(self):
36 """Returns the Item representing the hint that no media is available"""
37 return self.app.wait_select_single(objectName="noMediaHint")
38
35 def get_focus_ring(self):39 def get_focus_ring(self):
36 """Returns the focus ring of the camera"""40 """Returns the focus ring of the camera"""
37 return self.app.wait_select_single("FocusRing")41 return self.app.wait_select_single("FocusRing")
3842
=== modified file 'tests/autopilot/camera_app/tests/test_gallery_view.py'
--- tests/autopilot/camera_app/tests/test_gallery_view.py 2014-10-28 21:44:01 +0000
+++ tests/autopilot/camera_app/tests/test_gallery_view.py 2014-10-28 21:44:01 +0000
@@ -13,6 +13,7 @@
13from camera_app.tests import CameraAppTestCase13from camera_app.tests import CameraAppTestCase
1414
15import unittest15import unittest
16import os
1617
1718
18class TestCameraGalleryView(CameraAppTestCase):19class TestCameraGalleryView(CameraAppTestCase):
@@ -24,6 +25,8 @@
24 super(TestCameraGalleryView, self).setUp()25 super(TestCameraGalleryView, self).setUp()
25 self.assertThat(26 self.assertThat(
26 self.main_window.get_qml_view().visible, Eventually(Equals(True)))27 self.main_window.get_qml_view().visible, Eventually(Equals(True)))
28 self.pictures_dir = os.path.expanduser("~/Pictures/com.ubuntu.camera")
29 self.videos_dir = os.path.expanduser("~/Videos/com.ubuntu.camera")
2730
28 def tearDown(self):31 def tearDown(self):
29 super(TestCameraGalleryView, self).tearDown()32 super(TestCameraGalleryView, self).tearDown()
@@ -65,3 +68,34 @@
6568
66 self.assertThat(slideshow_view.visible, Eventually(Equals(False)))69 self.assertThat(slideshow_view.visible, Eventually(Equals(False)))
67 self.assertThat(photogrid_view.visible, Eventually(Equals(True)))70 self.assertThat(photogrid_view.visible, Eventually(Equals(True)))
71
72 def delete_all_media(self):
73 picture_files = os.listdir(self.pictures_dir)
74 for f in picture_files:
75 os.remove(os.path.join(self.pictures_dir, f))
76
77 video_files = os.listdir(self.videos_dir)
78 for f in video_files:
79 os.remove(os.path.join(self.videos_dir, f))
80
81 """Tests swiping to the gallery/photo roll with no media in it"""
82 def test_swipe_to_empty_gallery(self):
83 self.delete_all_media()
84 viewfinder = self.main_window.get_viewfinder()
85 gallery = self.main_window.get_gallery()
86
87 self.main_window.swipe_to_gallery(self)
88
89 self.assertThat(viewfinder.inView, Eventually(Equals(False)))
90 self.assertThat(gallery.inView, Eventually(Equals(True)))
91
92 hint = self.main_window.get_no_media_hint()
93
94 self.assertThat(hint.visible, Eventually(Equals(True)))
95
96 # add a fake photo to pictures_dir
97 photo_path = os.path.join(self.pictures_dir, "fake_photo.jpg")
98 with open(photo_path, 'a'):
99 os.utime(photo_path, None)
100
101 self.assertThat(hint.visible, Eventually(Equals(False)))

Subscribers

People subscribed via source and target branches