Merge lp:~bfiller/gallery-app/multiple-bug-fixes into lp:gallery-app

Proposed by Bill Filler
Status: Merged
Merged at revision: 928
Proposed branch: lp:~bfiller/gallery-app/multiple-bug-fixes
Merge into: lp:gallery-app
Diff against target: 2286 lines (+380/-1082)
44 files modified
CMakeLists.txt (+0/-1)
debian/control (+0/-3)
rc/qml/AlbumViewer/AlbumInternals/FramePortrait.qml (+16/-0)
rc/qml/AlbumsOverview.qml (+1/-0)
rc/qml/Components/MediaGrid.qml (+19/-0)
rc/qml/MediaViewer/PhotoViewerDelegate.qml (+21/-8)
rc/qml/MediaViewer/ZoomablePhotoComponent.qml (+2/-1)
rc/qml/OrganicView/OrganicMediaList.qml (+24/-0)
rc/qml/Utility/PhotosToolbarActions.qml (+1/-0)
src/album/CMakeLists.txt (+3/-0)
src/gallery-application.cpp (+2/-5)
src/gallery-manager.cpp (+0/-53)
src/gallery-manager.h (+0/-6)
src/media/media-monitor.cpp (+38/-3)
src/media/media-monitor.h (+1/-0)
src/media/media-source.cpp (+19/-4)
src/medialoader/CMakeLists.txt (+1/-4)
src/medialoader/gallery-standard-image-provider.cpp (+11/-49)
src/medialoader/gallery-standard-image-provider.h (+0/-4)
src/medialoader/gallery-thumbnail-image-provider.cpp (+0/-102)
src/medialoader/gallery-thumbnail-image-provider.h (+0/-59)
src/medialoader/preview-manager.cpp (+0/-423)
src/medialoader/preview-manager.h (+0/-87)
src/photo/photo-caches.cpp (+3/-0)
src/photo/photo.cpp (+2/-17)
src/video/video.cpp (+3/-2)
tests/autopilot/gallery_app/tests/__init__.py (+4/-1)
tests/autopilot/gallery_app/tests/test_albums_view.py (+29/-1)
tests/autopilot/gallery_app/tests/test_events_view.py (+26/-1)
tests/autopilot/gallery_app/tests/test_photo_viewer.py (+2/-2)
tests/autopilot/gallery_app/tests/test_photos_view.py (+16/-7)
tests/unittests/CMakeLists.txt (+1/-1)
tests/unittests/gallerystandardimageprovider/CMakeLists.txt (+0/-2)
tests/unittests/gallerystandardimageprovider/tst_gallerystandardimageprovidertest.cpp (+0/-5)
tests/unittests/gallerythumbnailimageprovider/CMakeLists.txt (+0/-34)
tests/unittests/gallerythumbnailimageprovider/tst_gallerythumbnailimageprovider.cpp (+0/-54)
tests/unittests/mediamonitor/CMakeLists.txt (+36/-0)
tests/unittests/mediamonitor/tst_mediamonitor.cpp (+96/-0)
tests/unittests/mediaobjectfactory/CMakeLists.txt (+0/-3)
tests/unittests/stubs/gallery-manager_stub.cpp (+0/-9)
tests/unittests/stubs/gallery-standard-image-provider_stub.cpp (+1/-9)
tests/unittests/stubs/gallery-thumbnail-image-provider_stub.cpp (+0/-55)
tests/unittests/stubs/preview-manager_stub.cpp (+0/-65)
tests/unittests/video/tst_video.cpp (+2/-2)
To merge this branch: bzr merge lp:~bfiller/gallery-app/multiple-bug-fixes
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+210013@code.launchpad.net

This proposal supersedes a proposal from 2014-03-07.

Commit message

multiple gallery-app bug fixes Bug #907870: [desktop] Gallery does not display photos in sub folders, Bug #1221968: use libthumbnailer for gallery thumbnails, Bug #1268748: videos are not displayed when running on desktop, Bug #1271327: disable switching between camera and gallery on desktop, Bug #1287272: Black flash at the end of the zoom animation"

Description of the change

[MERGE] lp:~amanzi-team/gallery-app/gallery-app-sdk-thumbnailer
Use the SDK thumbnailer to generate thumbnails instead of the custom internal one

[MERGE] lp:~artmello/gallery-app/display_photos_in_sub_folders/
Add support for monitoring media on sub folders of the target ones.

[MERGE] lp:~artmello/gallery-app/switching_to_camera
Disable Camera Button on every view when on Desktop Mode

[MERGE] lp:~artmello/gallery-app/gallery-app-not_display_video
Fix the check if a file is a video or a photo

[MERGE] lp:~artmello/gallery-app/gallery-app-overlay_video_icon
Add play icon if thumbnail is from video

[MERGE] lp:~amanzi-team/gallery-app/gallery-app-black-flash-zoom
Prevent a black flash at the end of the zoom animation by ensuring the transition image isn't hidden until the final one has fully loaded.

Remove gstreamer deps

To prevent issues while rotating one image the following branch should be used:
lp:~jpakkane/thumbnailer/manual-orient

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)
929. By Bill Filler

fixes lp:907870

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-01-11 21:58:24 +0000
+++ CMakeLists.txt 2014-03-07 20:39:27 +0000
@@ -41,7 +41,6 @@
41find_package(PkgConfig REQUIRED)41find_package(PkgConfig REQUIRED)
42pkg_check_modules(CONTENTHUB REQUIRED libcontent-hub)42pkg_check_modules(CONTENTHUB REQUIRED libcontent-hub)
43pkg_check_modules(EXIV2 REQUIRED exiv2)43pkg_check_modules(EXIV2 REQUIRED exiv2)
44pkg_check_modules(GSTLIB REQUIRED gstreamer-0.10)
45pkg_check_modules(MEDIAINFO REQUIRED libmediainfo)44pkg_check_modules(MEDIAINFO REQUIRED libmediainfo)
4645
47set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror")46set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror")
4847
=== modified file 'debian/control'
--- debian/control 2014-01-14 08:01:56 +0000
+++ debian/control 2014-03-07 20:39:27 +0000
@@ -7,7 +7,6 @@
7 pkg-config,7 pkg-config,
8 dh-translations,8 dh-translations,
9 libcontent-hub-dev (>= 0.0+13.10.20130930.1),9 libcontent-hub-dev (>= 0.0+13.10.20130930.1),
10 libgstreamer0.10-dev,
11 libexiv2-dev,10 libexiv2-dev,
12 libgl1-mesa-dev | libgl-dev,11 libgl1-mesa-dev | libgl-dev,
13 libgles2-mesa-dev,12 libgles2-mesa-dev,
@@ -30,8 +29,6 @@
30Conflicts: ubuntu-gallery29Conflicts: ubuntu-gallery
31Depends: ${misc:Depends},30Depends: ${misc:Depends},
32 ${shlibs:Depends},31 ${shlibs:Depends},
33 gstreamer0.10-plugins-base,
34 gstreamer0.10-plugins-good,
35 qtdeclarative5-accounts-plugin,32 qtdeclarative5-accounts-plugin,
36 libqt5sql5-sqlite,33 libqt5sql5-sqlite,
37 qtdeclarative5-qtquick2-plugin,34 qtdeclarative5-qtquick2-plugin,
3835
=== modified file 'rc/qml/AlbumViewer/AlbumInternals/FramePortrait.qml'
--- rc/qml/AlbumViewer/AlbumInternals/FramePortrait.qml 2013-04-08 14:55:34 +0000
+++ rc/qml/AlbumViewer/AlbumInternals/FramePortrait.qml 2014-03-07 20:39:27 +0000
@@ -18,6 +18,7 @@
18 */18 */
1919
20import QtQuick 2.020import QtQuick 2.0
21import Gallery 1.0
21import "../../../js/Gallery.js" as Gallery22import "../../../js/Gallery.js" as Gallery
2223
23/*!24/*!
@@ -45,6 +46,15 @@
45 visible: fullImage.opacity < 146 visible: fullImage.opacity < 1
46 source: load && mediaSource ? mediaSource.galleryPreviewPath : ""47 source: load && mediaSource ? mediaSource.galleryPreviewPath : ""
47 fillMode: fullImage.fillMode48 fillMode: fullImage.fillMode
49
50 Connections {
51 target: mediaSource ? mediaSource : null
52 onDataChanged: {
53 // data changed but filename didn't, so we need to bypass the qml image
54 // cache by tacking a timestamp to the filename so sees it as different.
55 preview.source = mediaSource.galleryPreviewPath + "?at=" + Date.now()
56 }
57 }
48 }58 }
49 Image {59 Image {
50 id: fullImage60 id: fullImage
@@ -62,4 +72,10 @@
62 NumberAnimation { duration: Gallery.SNAP_DURATION }72 NumberAnimation { duration: Gallery.SNAP_DURATION }
63 }73 }
64 }74 }
75 Image {
76 // Display a play icon if the thumbnail is from a video
77 source: "../../../img/icon_play.png"
78 anchors.centerIn: parent
79 visible: isLoaded && mediaSource.type === MediaSource.Video
80 }
65}81}
6682
=== modified file 'rc/qml/AlbumsOverview.qml'
--- rc/qml/AlbumsOverview.qml 2014-02-11 21:03:40 +0000
+++ rc/qml/AlbumsOverview.qml 2014-03-07 20:39:27 +0000
@@ -199,6 +199,7 @@
199 }199 }
200 ToolbarButton {200 ToolbarButton {
201 objectName: "cameraButton"201 objectName: "cameraButton"
202 visible: !APP.desktopMode
202 action: Action {203 action: Action {
203 text: i18n.tr("Camera")204 text: i18n.tr("Camera")
204 iconSource: Qt.resolvedUrl("../img/camera.png")205 iconSource: Qt.resolvedUrl("../img/camera.png")
205206
=== modified file 'rc/qml/Components/MediaGrid.qml'
--- rc/qml/Components/MediaGrid.qml 2013-06-26 08:59:08 +0000
+++ rc/qml/Components/MediaGrid.qml 2014-03-07 20:39:27 +0000
@@ -16,6 +16,7 @@
1616
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Components 0.118import Ubuntu.Components 0.1
19import Gallery 1.0
19import "../OrganicView"20import "../OrganicView"
20import "../Utility"21import "../Utility"
21import "../../js/Gallery.js" as Gallery22import "../../js/Gallery.js" as Gallery
@@ -80,8 +81,26 @@
80 radius: "medium"81 radius: "medium"
8182
82 image: Image {83 image: Image {
84 id: thumbImage
83 source: mediaSource.galleryThumbnailPath85 source: mediaSource.galleryThumbnailPath
84 asynchronous: true86 asynchronous: true
87 fillMode: Image.PreserveAspectCrop
88
89 Connections {
90 target: mediaSource
91 onDataChanged: {
92 // data changed but filename didn't, so we need to bypass the qml image
93 // cache by tacking a timestamp to the filename so sees it as different.
94 thumbImage.source = mediaSource.galleryThumbnailPath + "?at=" + Date.now()
95 }
96 }
97 }
98
99 Image {
100 // Display a play icon if the thumbnail is from a video
101 source: "../../img/icon_play.png"
102 anchors.centerIn: parent
103 visible: mediaSource.type === MediaSource.Video
85 }104 }
86105
87 OrganicItemInteraction {106 OrganicItemInteraction {
88107
=== modified file 'rc/qml/MediaViewer/PhotoViewerDelegate.qml'
--- rc/qml/MediaViewer/PhotoViewerDelegate.qml 2014-02-04 16:53:39 +0000
+++ rc/qml/MediaViewer/PhotoViewerDelegate.qml 2014-03-07 20:39:27 +0000
@@ -56,6 +56,15 @@
56 fullPhotoComponentLoader.item.unzoom();56 fullPhotoComponentLoader.item.unzoom();
57 }57 }
5858
59 Connections {
60 target: mediaSource
61 onDataChanged: {
62 // Force the image to be reloaded, to pick up the new thumbnail
63 interactivePreviewImage.active = false;
64 interactivePreviewImage.active = true;
65 }
66 }
67
59 // Note that we haven't defined a state set in this component, even though68 // Note that we haven't defined a state set in this component, even though
60 // we bind the "state" property here. This is intentional and is necessary69 // we bind the "state" property here. This is intentional and is necessary
61 // to work around a binding issue on Qt 5.0 beta 1. Given a later version70 // to work around a binding issue on Qt 5.0 beta 1. Given a later version
@@ -63,19 +72,23 @@
63 state: (fullPhotoComponentLoader.item &&72 state: (fullPhotoComponentLoader.item &&
64 !fullPhotoComponentLoader.item.fullyUnzoomed) ? "zoomed" :73 !fullPhotoComponentLoader.item.fullyUnzoomed) ? "zoomed" :
65 "unzoomed";74 "unzoomed";
6675 Component {
67 Image {76 id: interactivePreviewImageSource
77 Image {
78 fillMode: Image.PreserveAspectFit
79
80 source: mediaSource ? mediaSource.galleryPreviewPath : ""
81 cache: false
82 }
83 }
84
85 Loader {
68 id: interactivePreviewImage86 id: interactivePreviewImage
69
70 z: 087 z: 0
71
72 anchors.fill: parent88 anchors.fill: parent
7389
74 visible: photoViewerDelegate.state == "unzoomed"90 visible: photoViewerDelegate.state == "unzoomed"
7591 sourceComponent: interactivePreviewImageSource
76 fillMode: Image.PreserveAspectFit
77
78 source: mediaSource ? mediaSource.galleryPreviewPath : ""
79 }92 }
8093
81 Loader {94 Loader {
8295
=== modified file 'rc/qml/MediaViewer/ZoomablePhotoComponent.qml'
--- rc/qml/MediaViewer/ZoomablePhotoComponent.qml 2013-06-14 09:02:15 +0000
+++ rc/qml/MediaViewer/ZoomablePhotoComponent.qml 2014-03-07 20:39:27 +0000
@@ -389,7 +389,8 @@
389 transformOrigin: Item.TopLeft389 transformOrigin: Item.TopLeft
390390
391 visible: zoomablePhotoComponent.isZoomAnimationInProgress ||391 visible: zoomablePhotoComponent.isZoomAnimationInProgress ||
392 zoomablePhotoComponent.state == "pinching"392 zoomablePhotoComponent.state == "pinching" ||
393 !zoomedPhoto.isLoaded
393394
394 color: zoomablePhotoComponent.color395 color: zoomablePhotoComponent.color
395396
396397
=== modified file 'rc/qml/OrganicView/OrganicMediaList.qml'
--- rc/qml/OrganicView/OrganicMediaList.qml 2013-06-26 13:46:56 +0000
+++ rc/qml/OrganicView/OrganicMediaList.qml 2014-03-07 20:39:27 +0000
@@ -161,8 +161,32 @@
161 radius: "medium"161 radius: "medium"
162162
163 image: Image {163 image: Image {
164 id: thumbImage
164 source: model.mediaSource.galleryThumbnailPath165 source: model.mediaSource.galleryThumbnailPath
165 asynchronous: true166 asynchronous: true
167
168 /* The SDK thumbnailer respects the freedesktop.org standard and uses 128 for the small
169 * thumbnail size, while the previous thumbnailer used 216. To maintain the same visual
170 * result as the previous thumbnailer, we force it to generate a large thumbnail, which
171 * is closer to the older one in size and looks identical when downscaled */
172 sourceSize.width: 256
173 fillMode: Image.PreserveAspectCrop
174 }
175
176 Connections {
177 target: model.mediaSource
178 onDataChanged: {
179 // data changed but filename didn't, so we need to bypass the qml image
180 // cache by tacking a timestamp to the filename so sees it as different.
181 thumbImage.source = model.mediaSource.galleryThumbnailPath + "?at=" + Date.now()
182 }
183 }
184
185 Image {
186 // Display a play icon if the thumbnail is from a video
187 source: "../../img/icon_play.png"
188 anchors.centerIn: parent
189 visible: mediaSource.type === MediaSource.Video
166 }190 }
167191
168 OrganicItemInteraction {192 OrganicItemInteraction {
169193
=== modified file 'rc/qml/Utility/PhotosToolbarActions.qml'
--- rc/qml/Utility/PhotosToolbarActions.qml 2014-01-10 17:48:56 +0000
+++ rc/qml/Utility/PhotosToolbarActions.qml 2014-03-07 20:39:27 +0000
@@ -44,6 +44,7 @@
44 ToolbarButton {44 ToolbarButton {
45 objectName: "cameraButton"45 objectName: "cameraButton"
46 text: i18n.tr("Camera")46 text: i18n.tr("Camera")
47 visible: !APP.desktopMode
47 iconSource: Qt.resolvedUrl("../../img/camera.png")48 iconSource: Qt.resolvedUrl("../../img/camera.png")
48 onTriggered: Qt.openUrlExternally("appid://com.ubuntu.camera/camera/current-user-version")49 onTriggered: Qt.openUrlExternally("appid://com.ubuntu.camera/camera/current-user-version")
49 }50 }
5051
=== modified file 'src/album/CMakeLists.txt'
--- src/album/CMakeLists.txt 2013-08-15 06:40:15 +0000
+++ src/album/CMakeLists.txt 2014-03-07 20:39:27 +0000
@@ -36,3 +36,6 @@
3636
37qt5_use_modules(${GALLERY_ALBUM_LIB} Widgets Core Qml)37qt5_use_modules(${GALLERY_ALBUM_LIB} Widgets Core Qml)
3838
39target_link_libraries( ${GALLERY_ALBUM_LIB}
40 gallery-core
41 )
3942
=== modified file 'src/gallery-application.cpp'
--- src/gallery-application.cpp 2014-02-20 17:53:20 +0000
+++ src/gallery-application.cpp 2014-03-07 20:39:27 +0000
@@ -38,7 +38,6 @@
3838
39// qml39// qml
40#include "gallery-standard-image-provider.h"40#include "gallery-standard-image-provider.h"
41#include "gallery-thumbnail-image-provider.h"
42#include "qml-album-collection-model.h"41#include "qml-album-collection-model.h"
43#include "qml-event-collection-model.h"42#include "qml-event-collection-model.h"
44#include "qml-event-overview-model.h"43#include "qml-event-overview-model.h"
@@ -143,7 +142,7 @@
143 */142 */
144bool GalleryApplication::isDesktopMode() const143bool GalleryApplication::isDesktopMode() const
145{144{
146 return (qEnvironmentVariableIsSet("DESKTOP_MODE") && (qgetenv("DESKTOP_MODE") == "1"));145 return(qEnvironmentVariableIsSet("DESKTOP_MODE") && (qgetenv("DESKTOP_MODE") == "1"));
147}146}
148147
149/*!148/*!
@@ -169,7 +168,7 @@
169 size.transpose();168 size.transpose();
170169
171 m_view->setResizeMode(QQuickView::SizeRootObjectToView);170 m_view->setResizeMode(QQuickView::SizeRootObjectToView);
172 if (m_cmdLineParser->formFactor() == "desktop" || isDesktopMode()) {171 if (isDesktopMode()) {
173 m_view->setMinimumSize(QSize(60 * m_bguSize, 60 * m_bguSize));172 m_view->setMinimumSize(QSize(60 * m_bguSize, 60 * m_bguSize));
174 }173 }
175174
@@ -213,8 +212,6 @@
213 m_galleryManager->postInit();212 m_galleryManager->postInit();
214 m_view->engine()->addImageProvider(GalleryStandardImageProvider::PROVIDER_ID,213 m_view->engine()->addImageProvider(GalleryStandardImageProvider::PROVIDER_ID,
215 m_galleryManager->takeGalleryStandardImageProvider());214 m_galleryManager->takeGalleryStandardImageProvider());
216 m_view->engine()->addImageProvider(GalleryThumbnailImageProvider::PROVIDER_ID,
217 m_galleryManager->takeGalleryThumbnailImageProvider());
218215
219 QApplication::processEvents();216 QApplication::processEvents();
220 if (m_cmdLineParser->startupTimer())217 if (m_cmdLineParser->startupTimer())
221218
=== modified file 'src/gallery-manager.cpp'
--- src/gallery-manager.cpp 2013-09-06 16:10:25 +0000
+++ src/gallery-manager.cpp 2014-03-07 20:39:27 +0000
@@ -35,11 +35,9 @@
35// media35// media
36#include "media-collection.h"36#include "media-collection.h"
37#include "media-monitor.h"37#include "media-monitor.h"
38#include "preview-manager.h"
3938
40// qml39// qml
41#include "gallery-standard-image-provider.h"40#include "gallery-standard-image-provider.h"
42#include "gallery-thumbnail-image-provider.h"
43#include "qml-media-collection-model.h"41#include "qml-media-collection-model.h"
4442
45// util43// util
@@ -63,13 +61,11 @@
63 : collectionsInitialised(false),61 : collectionsInitialised(false),
64 m_resource(new Resource(picturesDir, view)),62 m_resource(new Resource(picturesDir, view)),
65 m_standardImageProvider(new GalleryStandardImageProvider()),63 m_standardImageProvider(new GalleryStandardImageProvider()),
66 m_thumbnailImageProvider(new GalleryThumbnailImageProvider()),
67 m_database(0),64 m_database(0),
68 m_defaultTemplate(0),65 m_defaultTemplate(0),
69 m_mediaCollection(0),66 m_mediaCollection(0),
70 m_albumCollection(0),67 m_albumCollection(0),
71 m_eventCollection(0),68 m_eventCollection(0),
72 m_previewManager(0),
73 m_monitor(0),69 m_monitor(0),
74 m_mediaLibrary(0)70 m_mediaLibrary(0)
75{71{
@@ -94,9 +90,7 @@
94 delete m_defaultTemplate;90 delete m_defaultTemplate;
95 delete m_resource;91 delete m_resource;
96 delete m_mediaCollection;92 delete m_mediaCollection;
97 delete m_previewManager;
98 delete m_standardImageProvider;93 delete m_standardImageProvider;
99 delete m_thumbnailImageProvider;
100}94}
10195
102/*!96/*!
@@ -145,7 +139,6 @@
145 m_defaultTemplate = new AlbumDefaultTemplate();139 m_defaultTemplate = new AlbumDefaultTemplate();
146 m_mediaCollection = new MediaCollection(m_database->getMediaTable());140 m_mediaCollection = new MediaCollection(m_database->getMediaTable());
147141
148 initPreviewManager();
149 fillMediaCollection();142 fillMediaCollection();
150 startFileMonitoring();143 startFileMonitoring();
151144
@@ -219,41 +212,6 @@
219void GalleryManager::logImageLoading(bool log)212void GalleryManager::logImageLoading(bool log)
220{213{
221 m_standardImageProvider->setLogging(log);214 m_standardImageProvider->setLogging(log);
222 m_thumbnailImageProvider->setLogging(log);
223}
224
225/*!
226 * \brief GalleryManager::initPreviewManager creates the PreviewManager,
227 * assigns it to all needed objects and creates all signal slot connection.
228 */
229void GalleryManager::initPreviewManager()
230{
231 Q_ASSERT(m_resource);
232 Q_ASSERT(m_mediaCollection);
233 Q_ASSERT(m_standardImageProvider);
234 Q_ASSERT(m_thumbnailImageProvider);
235
236 if (m_previewManager)
237 return;
238
239 m_previewManager = new PreviewManager(m_resource->thumbnailDirectory());
240
241 m_standardImageProvider->setPreviewManager(m_previewManager);
242 m_thumbnailImageProvider->setPreviewManager(m_previewManager);
243
244 // Monitor MediaCollection for all new MediaSources
245 QObject::connect(m_mediaCollection,
246 SIGNAL(contentsChanged(const QSet<DataObject*>*,const QSet<DataObject*>*)),
247 m_previewManager,
248 SLOT(onMediaAddedRemoved(const QSet<DataObject*>*,const QSet<DataObject*>*)));
249
250 QObject::connect(m_mediaCollection,
251 SIGNAL(destroying(const QSet<DataObject*>*)),
252 m_previewManager,
253 SLOT(onMediaDestroying(const QSet<DataObject*>*)));
254
255 // Verify previews for all existing added MediaSources
256 m_previewManager->onMediaAddedRemoved(&m_mediaCollection->getAsSet(), NULL);
257}215}
258216
259/*!217/*!
@@ -324,14 +282,3 @@
324 m_standardImageProvider = 0;282 m_standardImageProvider = 0;
325 return provider;283 return provider;
326}284}
327
328/*!
329 * \brief GalleryManager::takeGalleryThumbnailImageProvider returns the thumbnail image provider
330 * and gives up the owndership
331 */
332GalleryThumbnailImageProvider* GalleryManager::takeGalleryThumbnailImageProvider()
333{
334 GalleryThumbnailImageProvider *provider = m_thumbnailImageProvider;
335 m_thumbnailImageProvider = 0;
336 return provider;
337}
338285
=== modified file 'src/gallery-manager.h'
--- src/gallery-manager.h 2013-09-06 16:10:25 +0000
+++ src/gallery-manager.h 2014-03-07 20:39:27 +0000
@@ -36,11 +36,9 @@
36class EventCollection;36class EventCollection;
37class GalleryManager;37class GalleryManager;
38class GalleryStandardImageProvider;38class GalleryStandardImageProvider;
39class GalleryThumbnailImageProvider;
40class MediaCollection;39class MediaCollection;
41class MediaMonitor;40class MediaMonitor;
42class MediaObjectFactory;41class MediaObjectFactory;
43class PreviewManager;
44class QmlMediaCollectionModel;42class QmlMediaCollectionModel;
45class Resource;43class Resource;
4644
@@ -68,7 +66,6 @@
68 EventCollection *eventCollection();66 EventCollection *eventCollection();
69 Resource *resource() { return m_resource; }67 Resource *resource() { return m_resource; }
70 GalleryStandardImageProvider *takeGalleryStandardImageProvider();68 GalleryStandardImageProvider *takeGalleryStandardImageProvider();
71 GalleryThumbnailImageProvider *takeGalleryThumbnailImageProvider();
7269
73 void logImageLoading(bool log);70 void logImageLoading(bool log);
7471
@@ -85,7 +82,6 @@
85 GalleryManager(const GalleryManager&);82 GalleryManager(const GalleryManager&);
86 void operator=(const GalleryManager&);83 void operator=(const GalleryManager&);
8784
88 void initPreviewManager();
89 void fillMediaCollection();85 void fillMediaCollection();
90 void startFileMonitoring();86 void startFileMonitoring();
9187
@@ -95,13 +91,11 @@
9591
96 Resource* m_resource;92 Resource* m_resource;
97 GalleryStandardImageProvider* m_standardImageProvider;93 GalleryStandardImageProvider* m_standardImageProvider;
98 GalleryThumbnailImageProvider* m_thumbnailImageProvider;
99 Database* m_database;94 Database* m_database;
100 AlbumDefaultTemplate* m_defaultTemplate;95 AlbumDefaultTemplate* m_defaultTemplate;
101 MediaCollection* m_mediaCollection;96 MediaCollection* m_mediaCollection;
102 AlbumCollection* m_albumCollection;97 AlbumCollection* m_albumCollection;
103 EventCollection* m_eventCollection;98 EventCollection* m_eventCollection;
104 PreviewManager* m_previewManager;
105 MediaObjectFactory *m_mediaFactory;99 MediaObjectFactory *m_mediaFactory;
106 MediaMonitor *m_monitor;100 MediaMonitor *m_monitor;
107101
108102
=== modified file 'src/media/media-monitor.cpp'
--- src/media/media-monitor.cpp 2013-08-09 15:13:08 +0000
+++ src/media/media-monitor.cpp 2014-03-07 20:39:27 +0000
@@ -135,15 +135,50 @@
135}135}
136136
137/*!137/*!
138 * \brief MediaMonitor::expandSubDirectories List all sub directories under
139 * the base one. Use it to add to watch list
140 * \param dirPath
141 */
142QStringList MediaMonitorWorker::expandSubDirectories(const QString& dirPath)
143{
144 QStack<QString> dirStack;
145 dirStack.push(dirPath);
146
147 QStringList dirList;
148 while(!dirStack.isEmpty()) {
149 QDir dir(dirStack.pop());
150 dirList.append(dir.absolutePath());
151
152 foreach(const QFileInfo &info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs)) {
153 QString path(info.absoluteFilePath());
154 if (info.isSymLink() && info.exists()) {
155 // If it's a SymLink and points to a valid target need to get the target path
156 path = info.symLinkTarget();
157 }
158 if(!dirList.contains(path)) {
159 // In case we already visited the folder we didn't expand it anymore
160 dirStack.push(path);
161 }
162 }
163 }
164
165 return dirList;
166}
167
168/*!
138 * \brief MediaMonitor::startMonitoring169 * \brief MediaMonitor::startMonitoring
139 * \param targetDirectories170 * \param targetDirectories
140 */171 */
141void MediaMonitorWorker::startMonitoring(const QStringList &targetDirectories)172void MediaMonitorWorker::startMonitoring(const QStringList &targetDirectories)
142{173{
143 QStringList newDirectories;174 QStringList newDirectories;
144 foreach (const QString& dir, targetDirectories) {175 foreach (const QString& dirPath, targetDirectories) {
145 if (!m_targetDirectories.contains(dir))176 foreach (const QString& d, expandSubDirectories(dirPath)) {
146 newDirectories.append(dir);177 // Add all sub folders from target directory on watch list
178 if (!m_targetDirectories.contains(d)) {
179 newDirectories.append(d);
180 }
181 }
147 }182 }
148 m_targetDirectories += newDirectories;183 m_targetDirectories += newDirectories;
149 m_manifest = getManifest(m_targetDirectories);184 m_manifest = getManifest(m_targetDirectories);
150185
=== modified file 'src/media/media-monitor.h'
--- src/media/media-monitor.h 2013-07-05 08:12:31 +0000
+++ src/media/media-monitor.h 2014-03-07 20:39:27 +0000
@@ -75,6 +75,7 @@
7575
76public slots:76public slots:
77 void startMonitoring(const QStringList& targetDirectories);77 void startMonitoring(const QStringList& targetDirectories);
78 QStringList expandSubDirectories(const QString& dirPath);
78 void checkConsitency();79 void checkConsitency();
7980
80signals:81signals:
8182
=== modified file 'src/media/media-source.cpp'
--- src/media/media-source.cpp 2013-08-16 12:55:55 +0000
+++ src/media/media-source.cpp 2014-03-07 20:39:27 +0000
@@ -25,7 +25,8 @@
2525
26// qml26// qml
27#include "gallery-standard-image-provider.h"27#include "gallery-standard-image-provider.h"
28#include "gallery-thumbnail-image-provider.h"28
29#include <QUrl>
2930
30/*!31/*!
31 * \brief MediaSource::MediaSource32 * \brief MediaSource::MediaSource
@@ -84,7 +85,17 @@
84 */85 */
85QUrl MediaSource::galleryPath() const86QUrl MediaSource::galleryPath() const
86{87{
87 return GalleryStandardImageProvider::toURL(m_file);88 /* At the moment the only video files we recognize are mp4
89 * files. This was maintained hardcoded from the previous
90 * version of gallery app, and should be fixed in the future.
91 * For those files the full image is the thumbnail/preview itself */
92 if (m_file.suffix().toLower() == "mp4") {
93 QString path("image://thumbnailer/");
94 path.append(m_file.absoluteFilePath());
95 return QUrl(path);
96 } else {
97 return GalleryStandardImageProvider::toURL(m_file);
98 }
88}99}
89100
90/*!101/*!
@@ -93,7 +104,9 @@
93 */104 */
94QUrl MediaSource::galleryPreviewPath() const105QUrl MediaSource::galleryPreviewPath() const
95{106{
96 return GalleryStandardImageProvider::toURL(m_file);107 QString path("image://thumbnailer/");
108 path.append(m_file.absoluteFilePath());
109 return QUrl(path);
97}110}
98111
99/*!112/*!
@@ -102,7 +115,9 @@
102 */115 */
103QUrl MediaSource::galleryThumbnailPath() const116QUrl MediaSource::galleryThumbnailPath() const
104{117{
105 return GalleryThumbnailImageProvider::toURL(m_file);118 QString path("image://thumbnailer/");
119 path.append(m_file.absoluteFilePath());
120 return QUrl(path);
106}121}
107122
108/*!123/*!
109124
=== modified file 'src/medialoader/CMakeLists.txt'
--- src/medialoader/CMakeLists.txt 2013-08-19 06:45:36 +0000
+++ src/medialoader/CMakeLists.txt 2014-03-07 20:39:27 +0000
@@ -16,17 +16,13 @@
1616
17set(gallery_medialoader_HDRS17set(gallery_medialoader_HDRS
18 gallery-standard-image-provider.h18 gallery-standard-image-provider.h
19 gallery-thumbnail-image-provider.h
20 photo-metadata.h19 photo-metadata.h
21 preview-manager.h
22 video-metadata.h20 video-metadata.h
23 )21 )
2422
25set(gallery_medialoader_SRCS23set(gallery_medialoader_SRCS
26 gallery-standard-image-provider.cpp24 gallery-standard-image-provider.cpp
27 gallery-thumbnail-image-provider.cpp
28 photo-metadata.cpp25 photo-metadata.cpp
29 preview-manager.cpp
30 video-metadata.cpp26 video-metadata.cpp
31 )27 )
3228
@@ -43,4 +39,5 @@
43 ${EXIV2_LIBRARIES}39 ${EXIV2_LIBRARIES}
44 ${GSTLIB_LDFLAGS}40 ${GSTLIB_LDFLAGS}
45 ${MEDIAINFO_LIBRARIES}41 ${MEDIAINFO_LIBRARIES}
42 gallery-util
46 )43 )
4744
=== modified file 'src/medialoader/gallery-standard-image-provider.cpp'
--- src/medialoader/gallery-standard-image-provider.cpp 2013-08-12 08:51:09 +0000
+++ src/medialoader/gallery-standard-image-provider.cpp 2014-03-07 20:39:27 +0000
@@ -20,7 +20,6 @@
2020
21#include "gallery-standard-image-provider.h"21#include "gallery-standard-image-provider.h"
22#include "photo-metadata.h"22#include "photo-metadata.h"
23#include "preview-manager.h"
2423
25#include <QDebug>24#include <QDebug>
26#include <QElapsedTimer>25#include <QElapsedTimer>
@@ -38,9 +37,7 @@
3837
39const long MAX_CACHE_BYTES = 20L * 1024L * 1024L;38const long MAX_CACHE_BYTES = 20L * 1024L * 1024L;
4039
41// fully load previews into memory when requested40const int SCALED_LOAD_FLOOR_DIM_PIXELS = 360;
42const int SCALED_LOAD_FLOOR_DIM_PIXELS =
43 qMax(PreviewManager::PREVIEW_SIZE, PreviewManager::PREVIEW_SIZE);
4441
45/*!42/*!
46 * \brief GalleryStandardImageProvider::GalleryStandardImageProvider43 * \brief GalleryStandardImageProvider::GalleryStandardImageProvider
@@ -48,7 +45,6 @@
48GalleryStandardImageProvider::GalleryStandardImageProvider()45GalleryStandardImageProvider::GalleryStandardImageProvider()
49 : QQuickImageProvider(QQuickImageProvider::Image),46 : QQuickImageProvider(QQuickImageProvider::Image),
50 m_cachedBytes(0),47 m_cachedBytes(0),
51 m_previewManager(0),
52 m_logImageLoading(false),48 m_logImageLoading(false),
53 m_maxLoadResolution(INT_MAX)49 m_maxLoadResolution(INT_MAX)
54{50{
@@ -89,11 +85,6 @@
89QImage GalleryStandardImageProvider::requestImage(const QString& id,85QImage GalleryStandardImageProvider::requestImage(const QString& id,
90 QSize* size, const QSize& requestedSize)86 QSize* size, const QSize& requestedSize)
91{87{
92 if (!m_previewManager) {
93 qWarning() << Q_FUNC_INFO << "no PreviewManager set";
94 return QImage();
95 }
96
97 // for LOG_IMAGE_STATUS88 // for LOG_IMAGE_STATUS
98 QString loggingStr = "";89 QString loggingStr = "";
99 QElapsedTimer timer;90 QElapsedTimer timer;
@@ -101,26 +92,21 @@
10192
102 QUrl url(id);93 QUrl url(id);
103 QFileInfo photoFile(url.path());94 QFileInfo photoFile(url.path());
104 m_previewManager->ensurePreview(photoFile);
10595
106 QImage readyImage;96 QImage readyImage;
107 uint bytesLoaded = 0;97 uint bytesLoaded = 0;
108 long currentCachedBytes = 0;98 long currentCachedBytes = 0;
109 int currentCacheEntries = 0;99 int currentCacheEntries = 0;
110100
111 if (photoFile.suffix().compare("mp4", Qt::CaseInsensitive) == 0) {101 CachedImage* cachedImage = claimCachedImageEntry(id, loggingStr);
112 readyImage = QImage(m_previewManager->previewFileName(photoFile.absoluteFilePath()));102 Q_ASSERT(cachedImage != NULL);
113 } else {103
114 CachedImage* cachedImage = claimCachedImageEntry(id, loggingStr);104 readyImage = fetchCachedImage(cachedImage, requestedSize, &bytesLoaded,
115 Q_ASSERT(cachedImage != NULL);105 loggingStr);
116106 if (readyImage.isNull())
117 readyImage = fetchCachedImage(cachedImage, requestedSize, &bytesLoaded,107 LOG_IMAGE_STATUS("load-failure ");
118 loggingStr);108
119 if (readyImage.isNull())109 releaseCachedImageEntry(cachedImage, bytesLoaded, &currentCachedBytes, &currentCacheEntries);
120 LOG_IMAGE_STATUS("load-failure ");
121
122 releaseCachedImageEntry(cachedImage, bytesLoaded, &currentCachedBytes, &currentCacheEntries);
123 }
124110
125 if (m_logImageLoading) {111 if (m_logImageLoading) {
126 if (bytesLoaded > 0) {112 if (bytesLoaded > 0) {
@@ -142,15 +128,6 @@
142}128}
143129
144/*!130/*!
145 * \brief GalleryStandardImageProvider::setPreviewManager
146 * \param previewManager
147 */
148void GalleryStandardImageProvider::setPreviewManager(PreviewManager *previewManager)
149{
150 m_previewManager = previewManager;
151}
152
153/*!
154 * \brief GalleryStandardImageProvider::setLogging enables to print photo loading131 * \brief GalleryStandardImageProvider::setLogging enables to print photo loading
155 * times to stout132 * times to stout
156 * \param enableLogging133 * \param enableLogging
@@ -414,30 +391,15 @@
414 */391 */
415QString GalleryStandardImageProvider::idToFile(const QString& id) const392QString GalleryStandardImageProvider::idToFile(const QString& id) const
416{393{
417 if (!m_previewManager) {
418 qWarning() << Q_FUNC_INFO << "no PreviewManager set";
419 return QString();
420 }
421
422 QUrl url = QUrl(id);394 QUrl url = QUrl(id);
423 QString fileName = url.path();395 QString fileName = url.path();
424
425 //Get our item value from our query by it's key.
426 QUrlQuery url_query(url);
427 url_query.hasQueryItem(GalleryStandardImageProvider::SIZE_KEY);
428 QString value = url_query.queryItemValue(GalleryStandardImageProvider::SIZE_KEY);
429
430 if (value == "1") {
431 fileName = m_previewManager->previewFileName(fileName);
432 }
433
434 return fileName;396 return fileName;
435}397}
436398
437/*!399/*!
438 * \brief GalleryStandardImageProvider::CachedImage::CachedImage400 * \brief GalleryStandardImageProvider::CachedImage::CachedImage
439 * \param id the full URI of the image401 * \param id the full URI of the image
440 * \param fileName the filename for the URI (can be the file itself or the preview)402 * \param fileName the filename for the URI (the file itself)
441 */403 */
442GalleryStandardImageProvider::CachedImage::CachedImage(const QString& fileId,404GalleryStandardImageProvider::CachedImage::CachedImage(const QString& fileId,
443 const QString& filename)405 const QString& filename)
444406
=== modified file 'src/medialoader/gallery-standard-image-provider.h'
--- src/medialoader/gallery-standard-image-provider.h 2013-06-10 10:59:47 +0000
+++ src/medialoader/gallery-standard-image-provider.h 2014-03-07 20:39:27 +0000
@@ -34,8 +34,6 @@
34#include <QString>34#include <QString>
35#include <QUrl>35#include <QUrl>
3636
37class PreviewManager;
38
39/*!37/*!
40 * Gallery uses a custom image provider for three reasons:38 * Gallery uses a custom image provider for three reasons:
41 *39 *
@@ -73,7 +71,6 @@
73 virtual QImage requestImage(const QString& id, QSize* size,71 virtual QImage requestImage(const QString& id, QSize* size,
74 const QSize& requestedSize);72 const QSize& requestedSize);
7573
76 void setPreviewManager(PreviewManager* previewManager);
77 void setLogging(bool enableLogging);74 void setLogging(bool enableLogging);
78 void setMaxLoadResolution(int resolution);75 void setMaxLoadResolution(int resolution);
7976
@@ -109,7 +106,6 @@
109 QList<QString> m_fifo;106 QList<QString> m_fifo;
110 QMutex m_cacheMutex;107 QMutex m_cacheMutex;
111 long m_cachedBytes;108 long m_cachedBytes;
112 PreviewManager* m_previewManager;
113 bool m_logImageLoading;109 bool m_logImageLoading;
114 int m_maxLoadResolution;110 int m_maxLoadResolution;
115111
116112
=== removed file 'src/medialoader/gallery-thumbnail-image-provider.cpp'
--- src/medialoader/gallery-thumbnail-image-provider.cpp 2013-06-10 06:20:05 +0000
+++ src/medialoader/gallery-thumbnail-image-provider.cpp 1970-01-01 00:00:00 +0000
@@ -1,102 +0,0 @@
1/*
2 * Copyright (C) 2012 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Guenter Schwann <guenter.schwann@canonical.com>
18*/
19
20#include "gallery-thumbnail-image-provider.h"
21
22// media
23#include "preview-manager.h"
24
25#include <QDebug>
26#include <QElapsedTimer>
27
28const char* GalleryThumbnailImageProvider::PROVIDER_ID = "gallery-thumbnail";
29const char* GalleryThumbnailImageProvider::PROVIDER_ID_SCHEME = "image://gallery-thumbnail/";
30const char* GalleryThumbnailImageProvider::REVISION_PARAM_NAME = "edit";
31
32/*!
33 * @brief GalleryThumbnailImageProvider::GalleryThumbnailImageProvider
34 */
35GalleryThumbnailImageProvider::GalleryThumbnailImageProvider()
36 : QQuickImageProvider(QQuickImageProvider::Image),
37 m_previewManager(0),
38 m_logImageLoading(false)
39{
40}
41
42/*!
43 * \brief GalleryThumbnailImageProvider::toURL return the URL to this image provider for a local file
44 * \param file is the file that you want the url for
45 * \return URL to be used to load a local image usign this image provider
46 */
47QUrl GalleryThumbnailImageProvider::toURL(const QFileInfo &file)
48{
49 return QUrl::fromUserInput(PROVIDER_ID_SCHEME + file.absoluteFilePath());
50}
51
52/*!
53 * @brief GalleryThumbnailImageProvider::requestImage @reimp of QQuickImageProvider::requestImage
54 * @param id is the requested image source
55 * @param size must be set to the original size of the image
56 * @param requestedSize is not used here, as thumbnails have a fixed size
57 * @return the image with id
58 */
59QImage GalleryThumbnailImageProvider::requestImage(const QString &id, QSize *size,
60 const QSize &requestedSize)
61{
62 Q_UNUSED(requestedSize);
63
64 if (!m_previewManager) {
65 qWarning() << Q_FUNC_INFO << "no PreviewManager set";
66 return QImage();
67 }
68
69 QElapsedTimer timer;
70 timer.start();
71
72 QUrl url(id);
73 QFileInfo photoFile(url.path());
74 m_previewManager->ensurePreview(photoFile);
75
76 QString fileName = m_previewManager->thumbnailFileName(photoFile);
77
78 QImage thumbnail;
79 thumbnail.load(fileName);
80 if (thumbnail.isNull()) {
81 qWarning() << "Could not load thumbnail:" << id;
82 }
83
84 if (size != NULL)
85 *size = thumbnail.size();
86
87 if (m_logImageLoading) {
88 qDebug() << id << thumbnail.size() << "time:" << timer.elapsed() << "ms";
89 }
90
91 return thumbnail;
92}
93
94void GalleryThumbnailImageProvider::setPreviewManager(PreviewManager *previewManager)
95{
96 m_previewManager = previewManager;
97}
98
99void GalleryThumbnailImageProvider::setLogging(bool enableLogging)
100{
101 m_logImageLoading = enableLogging;
102}
1030
=== removed file 'src/medialoader/gallery-thumbnail-image-provider.h'
--- src/medialoader/gallery-thumbnail-image-provider.h 2013-06-10 06:20:05 +0000
+++ src/medialoader/gallery-thumbnail-image-provider.h 1970-01-01 00:00:00 +0000
@@ -1,59 +0,0 @@
1/*
2 * Copyright (C) 2012 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Guenter Schwann <guenter.schwann@canonical.com>
18*/
19
20#ifndef GALLERYTHUMBNAILIMAGEPROVIDER_H
21#define GALLERYTHUMBNAILIMAGEPROVIDER_H
22
23#include <QFileInfo>
24#include <QQuickImageProvider>
25#include <QSize>
26#include <QString>
27
28class PreviewManager;
29
30/*!
31 * @brief The GalleryThumbailImageProvider class is used to load the small square thumbnails
32 *
33 * An extra image provider is used, so the image can be updated by adding parameters to the URL,
34 * to update the image. As for local URL, no parameters are used (internally).
35 * In future it might be used for more functionality, like custom caching of images.
36 */
37class GalleryThumbnailImageProvider : public QQuickImageProvider
38{
39public:
40 static const char* PROVIDER_ID;
41 static const char* PROVIDER_ID_SCHEME;
42 static const char* REVISION_PARAM_NAME;
43
44 GalleryThumbnailImageProvider();
45
46 static QUrl toURL(const QFileInfo& file);
47
48 virtual QImage requestImage(const QString& id, QSize* size,
49 const QSize& requestedSize);
50
51 void setPreviewManager(PreviewManager* previewManager);
52 void setLogging(bool enableLogging);
53
54private:
55 PreviewManager* m_previewManager;
56 bool m_logImageLoading;
57};
58
59#endif // GALLERYTHUMBNAILIMAGEPROVIDER_H
600
=== removed file 'src/medialoader/preview-manager.cpp'
--- src/medialoader/preview-manager.cpp 2013-09-04 14:39:39 +0000
+++ src/medialoader/preview-manager.cpp 1970-01-01 00:00:00 +0000
@@ -1,423 +0,0 @@
1/*
2 * Copyright (C) 2012 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Jim Nelson <jim@yorba.org>
18 */
19
20#include "preview-manager.h"
21#include "photo-metadata.h"
22#include "video-metadata.h"
23
24// media
25#include "media-source.h"
26
27#include <QCryptographicHash>
28#include <QDir>
29#include <QImageReader>
30#include <QMutexLocker>
31
32#include <gst/gst.h>
33
34// FIXME adapt to different sizes. This is fixed size for the demo device
35const int PreviewManager::PREVIEW_SIZE = 360; // in pixel
36const int PreviewManager::THUMBNAIL_SIZE = 216; // in pixel
37const int PreviewManager::PREVIEW_QUALITY = 70;
38const char* PreviewManager::PREVIEW_FILE_FORMAT = "JPEG";
39const char* PreviewManager::PREVIEW_FILE_EXT = ".jpg";
40const QString PreviewManager::PREVIEW_DIR = "preview";
41const QString PreviewManager::THUMBNAIL_DIR = "square";
42
43QMutex PreviewManager::m_createMutex;
44
45/*!
46 * \brief PreviewManager::PreviewManager
47 */
48PreviewManager::PreviewManager(const QString &thumbnailDirectory, QObject *parent)
49 : QObject(parent),
50 m_thumbnailDir(thumbnailDirectory)
51{
52 if (m_thumbnailDir.right(1) != QDir::separator())
53 m_thumbnailDir += QDir::separator();
54
55 // create the thumbnail directory if not already present
56 QDir dir;
57 dir.mkpath(m_thumbnailDir + PREVIEW_DIR);
58 dir.mkpath(m_thumbnailDir + THUMBNAIL_DIR);
59
60 gst_init(0, 0);
61}
62
63/*!
64 * \brief PreviewManager::onMediaAddedRemoved
65 * \param added
66 * \param removed
67 */
68void PreviewManager::onMediaAddedRemoved(const QSet<DataObject*>* added,
69 const QSet<DataObject*>* removed)
70{
71 if (added != NULL) {
72 DataObject* object;
73 foreach (object, *added) {
74 MediaSource* source = qobject_cast<MediaSource*>(object);
75
76 QObject::connect(source, SIGNAL(dataChanged()),
77 this, SLOT(updatePreview()), Qt::UniqueConnection);
78 }
79 }
80
81 if (removed != NULL) {
82 DataObject* object;
83 foreach (object, *removed) {
84 MediaSource* source = qobject_cast<MediaSource*>(object);
85 QObject::disconnect(source, SIGNAL(dataChanged()),
86 this, SLOT(updatePreview()));
87 }
88 }
89}
90
91/*!
92 * \brief PreviewManager::onMediaDestroying
93 * \param destroying
94 */
95void PreviewManager::onMediaDestroying(const QSet<DataObject*>* destroying)
96{
97 if (destroying != NULL) {
98 DataObject* object;
99 foreach (object, *destroying)
100 destroyPreviews(qobject_cast<MediaSource*>(object));
101 }
102}
103
104/*!
105 * \brief PreviewManager::updatePreview
106 */
107void PreviewManager::updatePreview()
108{
109 QObject* object = QObject::sender();
110 MediaSource* source = qobject_cast<MediaSource*>(object);
111
112 ensurePreview(source->file(), true);
113}
114
115/*!
116 * \brief PreviewManager::previewFileName
117 * \param file
118 * \return
119 */
120QString PreviewManager::previewFileName(const QFileInfo& file) const
121{
122 return thumbnailFileName(file.canonicalFilePath(), PREVIEW_DIR);
123}
124
125/*!
126 * \brief PreviewManager::thumbnailFileName
127 * \param file
128 * \return
129 */
130QString PreviewManager::thumbnailFileName(const QFileInfo& file) const
131{
132 return thumbnailFileName(file.canonicalFilePath(), THUMBNAIL_DIR);
133}
134
135/*!
136 * \brief PreviewManager::ensurePreview
137 * \param file
138 * \param regen
139 * \return
140 */
141bool PreviewManager::ensurePreview(QFileInfo file, bool regen)
142{
143 QMutexLocker locker(&m_createMutex);
144
145 // If preview file exists, considered valid (unless we're regenerating it).
146 QString preview = previewFileName(file);
147 QString thumbnail = thumbnailFileName(file);
148
149 QImage thumbMaster;
150 if (updateNeeded(file, QFileInfo(preview)) || regen) {
151 QSize previewSize(PREVIEW_SIZE, PREVIEW_SIZE);
152 QImage fullsized;
153 if (file.suffix().compare("mp4", Qt::CaseInsensitive) == 0) {
154 fullsized = grabVideoThumbnail(file.canonicalFilePath());
155 } else {
156 fullsized = loadPhoto(file.canonicalFilePath(), previewSize);
157 }
158 if (fullsized.isNull()) {
159 qDebug() << "Unable to generate fullsized image for " << file.filePath()
160 << "not generating preview";
161 return false;
162 }
163
164 fullsized.setText("Thumb::URI", QUrl::fromLocalFile(file.canonicalFilePath()).toEncoded());
165 // scale the preview so it will fill the viewport specified by PREVIEW_*_MAX
166 // these values are replicated in the QML so that the preview will fill each
167 // grid cell, cropping down to the center of the image if necessary
168 QImage scaled = (fullsized.height() > fullsized.width())
169 ? fullsized.scaledToWidth(PREVIEW_SIZE, Qt::SmoothTransformation)
170 : fullsized.scaledToHeight(PREVIEW_SIZE, Qt::SmoothTransformation);
171
172 if (scaled.isNull()) {
173 qDebug() << "Unable to scale " << file.filePath() << "for preview";
174 return false;
175 }
176
177 if (!saveThumbnail(scaled, preview)) {
178 qDebug("Unable to save preview %s", qPrintable(preview));
179 return false;
180 }
181 thumbMaster = scaled;
182 }
183
184 if (updateNeeded(file, QFileInfo(thumbnail)) || regen) {
185 if (thumbMaster.isNull()) {
186 thumbMaster.load(preview);
187 if (thumbMaster.isNull()) {
188 qDebug("Unable load preview image for %s, not generating thumbnail",
189 qPrintable(preview));
190 return false;
191 }
192 }
193
194 QImage square = generateThumbnail(thumbMaster);
195 if (!saveThumbnail(square, thumbnail)) {
196 qDebug("Unable to save preview %s", qPrintable(thumbnail));
197 return false;
198 }
199 }
200
201 return true;
202}
203
204/*!
205 * \brief PreviewManager::saveThumbnail saves the thumbnail in a safe way
206 * The image is written to a temporary file, and then moved (the move is atomic)
207 * \param image thumbnail to save
208 * \param fileName filename of the thumbnail
209 * \return true, if saving the file was successful
210 */
211bool PreviewManager::saveThumbnail(const QImage &image, const QString &fileName) const
212{
213 QString temporaryName(fileName+".tmp");
214 bool ok;
215 ok = image.save(temporaryName, PREVIEW_FILE_FORMAT, PREVIEW_QUALITY);
216 if (!ok) {
217 qWarning() << "Unanble to save the thumbnail" << temporaryName;
218 return false;
219 }
220
221 if (QFile::exists(fileName)) {
222 QFile::remove(fileName);
223 }
224
225 QFile thumbnail(temporaryName);
226 return thumbnail.rename(fileName);
227}
228
229/*!
230 * \brief PreviewManager::destroyPreviews
231 * \param media
232 */
233void PreviewManager::destroyPreviews(MediaSource* media)
234{
235 QString filename = previewFileName(media->file());
236 if (!QFile::remove(filename))
237 qDebug("Unable to remove preview %s", qPrintable(filename));
238 filename = thumbnailFileName(media->file());
239 if (!QFile::remove(filename))
240 qDebug("Unable to remove thumbnail %s", qPrintable(filename));
241}
242
243/*!
244 * \brief PreviewManager::generateThumbnail
245 * \param master
246 * \return
247 */
248QImage PreviewManager::generateThumbnail(const QImage &master) const
249{
250 int xOffset = 0;
251 int yOffset = 0;
252 int size = 0;
253 if (master.width() > master.height()) {
254 size = master.height();
255 xOffset = (master.width() - size) / 2;
256 } else {
257 size = master.width();
258 yOffset = (master.height() - size) / 2;
259 }
260 QImage square = master.copy(xOffset, yOffset, size, size);
261
262 QImage thumbnail = square.scaled(THUMBNAIL_SIZE, THUMBNAIL_SIZE);
263 return thumbnail;
264}
265
266/*!
267 * \brief PreviewManager::thumbnailFileName generates the file name for a given
268 * file and it's level (size/type)
269 * \param fileName full filename URI (file:///directory/file.name.png)
270 * \param levelName correclates to the sub directory inside of the thumbnail directory
271 * \return full filePath of the thumbnail
272 */
273QString PreviewManager::thumbnailFileName(const QString &fileName,
274 const QString &levelName) const
275{
276 QCryptographicHash md5(QCryptographicHash::Md5);
277 md5.addData(QUrl::fromLocalFile(fileName).toEncoded());
278 QString previewDir = m_thumbnailDir + levelName + QDir::separator();
279 return QString(previewDir + md5.result().toHex() + PREVIEW_FILE_EXT);
280}
281
282/*!
283 * \brief PreviewManager::updateNeeded checks if the thumbnail needs to be (re-)created
284 * \param mediaFile the original photo/video
285 * \param previewFile the preview file
286 * \return true if the thumbnail needs to be created
287 */
288bool PreviewManager::updateNeeded(const QFileInfo &mediaFile, const QFileInfo &previewFile) const
289{
290 if (!previewFile.exists())
291 return true;
292
293 return mediaFile.lastModified() > previewFile.lastModified();
294}
295
296/*!
297 * \brief PreviewManager::loadPhoto load a photo with correct orientation
298 * The size can be limited as well, to speed upt the loading
299 * \param fileName file name of the photo
300 * \param maxSize limits the size, so that one side fits into maxSize. If an
301 * invalid size is passed, the image is loaded in full size.
302 * \return the photo corrctly sized and oriented
303 */
304QImage PreviewManager::loadPhoto(const QString &fileName, const QSize& maxSize) const
305{
306 QImageReader imageReader(fileName);
307
308 QSize imageSize = imageReader.size();
309 if (maxSize.isValid()) {
310 QSize size = imageSize;
311 size.scale(maxSize, Qt::KeepAspectRatioByExpanding);
312 imageReader.setScaledSize(size);
313 }
314
315 QImage image = imageReader.read();
316 if (!image.isNull()) {
317 PhotoMetadata* metadata = PhotoMetadata::fromFile(fileName.toStdString().c_str());
318 image = image.transformed(
319 OrientationCorrection::fromOrientation(metadata->orientation())
320 .toTransform());
321 delete metadata;
322 } else {
323 qWarning() << "Could not load the image" << fileName << "for thumbnail generation";
324 }
325
326 return image;
327}
328
329/*!
330 * \brief destroyFrameData cleanup function for the video thumbnail QImage
331 * \param data
332 */
333static void destroyFrameData (void *data)
334{
335 gst_buffer_unref(GST_BUFFER (data));
336}
337
338/*!
339 * \brief PreviewManager::grabVideoThumbnail grabs a frame from the given video file
340 * \param fileName
341 * \return
342 */
343QImage PreviewManager::grabVideoThumbnail(const QString &fileName) const
344{
345 QUrl url("file://"+fileName);
346 gchar *guri = g_strdup(url.toString().toUtf8().data());
347
348 GstElement *asink;
349 GstElement *vsink;
350
351 GstElement *pipeline = gst_element_factory_make("playbin2", "play");
352 GstCaps *caps = gst_caps_new_simple("video/x-raw-rgb",
353 "bpp", G_TYPE_INT, 24,
354 "depth", G_TYPE_INT, 24,
355 "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
356 "endianness", G_TYPE_INT, G_BIG_ENDIAN,
357 "red_mask", G_TYPE_INT, 0xff0000,
358 "green_mask", G_TYPE_INT, 0x00ff00,
359 "blue_mask", G_TYPE_INT, 0x0000ff,
360 NULL);
361 asink = gst_element_factory_make("fakesink", "audio-fake-sink");
362 vsink = gst_element_factory_make("fakesink", "video-fake-sink");
363 g_object_set(vsink, "sync", TRUE, NULL);
364 g_object_set(pipeline,
365 "flags", 0x00000001, // Make sure to render only the video stream (we do not need audio here)
366 "audio-sink", asink,
367 "video-sink", vsink,
368 NULL);
369
370 g_object_set(pipeline, "uri", guri, NULL);
371 GstStateChangeReturn ret = gst_element_set_state(pipeline, GST_STATE_PAUSED);
372 switch (ret)
373 {
374 case GST_STATE_CHANGE_FAILURE:
375 qWarning() << "Fail to start thumbnail pipeline";
376 return QImage();
377 case GST_STATE_CHANGE_NO_PREROLL:
378 qWarning() << "Thumbnail not supported for live sources";
379 return QImage();
380 default:
381 break;
382 }
383
384 gst_element_seek(pipeline, 1.0,
385 GST_FORMAT_TIME, static_cast<GstSeekFlags>(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT),
386 GST_SEEK_TYPE_SET, 100 * GST_MSECOND,
387 GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
388 /* And wait for this seek to complete */
389 gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
390
391 GstBuffer *buf = 0;
392 g_signal_emit_by_name(pipeline, "convert-frame", caps, &buf);
393
394 QImage thumb;
395 if (buf && GST_BUFFER_CAPS(buf)) {
396 gint width, height;
397 GstStructure *s = gst_caps_get_structure(GST_BUFFER_CAPS (buf), 0);
398 gboolean res = gst_structure_get_int(s, "width", &width);
399 res |= gst_structure_get_int (s, "height", &height);
400 if (!res) {
401 qWarning() << "could not get snapshot dimension";
402 return QImage();
403 }
404
405 thumb = QImage(GST_BUFFER_DATA(buf), width, height, QImage::Format_RGB888, destroyFrameData, buf);
406 }
407
408 gst_caps_unref(caps);
409 gst_element_set_state(pipeline, GST_STATE_NULL);
410 gst_object_unref(pipeline);
411 g_free(guri);
412
413 VideoMetadata metadata;
414 metadata.parseMetadata(QFileInfo(fileName));
415 int rotation = metadata.rotation();
416 if (rotation != 0) {
417 QTransform transform;
418 transform.rotate(rotation);
419 thumb = thumb.transformed(transform);
420 }
421
422 return thumb;
423}
4240
=== removed file 'src/medialoader/preview-manager.h'
--- src/medialoader/preview-manager.h 2013-08-12 08:51:09 +0000
+++ src/medialoader/preview-manager.h 1970-01-01 00:00:00 +0000
@@ -1,87 +0,0 @@
1/*
2 * Copyright (C) 2012 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Jim Nelson <jim@yorba.org>
18 */
19
20#ifndef GALLERY_PREVIEW_MANAGER_H_
21#define GALLERY_PREVIEW_MANAGER_H_
22
23#include <QFileInfo>
24#include <QMutex>
25#include <QObject>
26#include <QSet>
27#include <QSize>
28#include <QString>
29
30class QImage;
31class DataObject;
32class MediaSource;
33
34/*!
35 * \brief The PreviewManager class creates and removes thumbnails
36 *
37 * The thumbnail storage and creation is inspired by
38 * http://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html
39 * But it uses jpeg (for performance),
40 * uses different sizes,
41 * not the standard sub directoy name (because of the sizes),
42 * does not save any meta information in the thumbnails,
43 * does not use the fail directory
44 */
45class PreviewManager : public QObject
46{
47 Q_OBJECT
48
49public:
50 static const int PREVIEW_SIZE;
51 static const int THUMBNAIL_SIZE;
52 static const int PREVIEW_QUALITY;
53 static const char* PREVIEW_FILE_FORMAT;
54 static const char* PREVIEW_FILE_EXT;
55
56 static const QString PREVIEW_DIR;
57 static const QString THUMBNAIL_DIR;
58
59 PreviewManager(const QString& thumbnailDirectory, QObject* parent = 0);
60
61 QString previewFileName(const QFileInfo& file) const;
62 QString thumbnailFileName(const QFileInfo& file) const;
63
64 bool ensurePreview(QFileInfo file, bool regen = false);
65
66public slots:
67 void onMediaAddedRemoved(const QSet<DataObject*>* added,
68 const QSet<DataObject*>* removed);
69 void onMediaDestroying(const QSet<DataObject*>* destroying);
70
71private slots:
72 void updatePreview();
73
74private:
75 bool saveThumbnail(const QImage& image, const QString& fileName) const;
76 void destroyPreviews(MediaSource* media);
77 QImage generateThumbnail(const QImage& master) const;
78 QString thumbnailFileName(const QString& fileName, const QString& levelName) const;
79 bool updateNeeded(const QFileInfo& mediaFile, const QFileInfo& previewFile) const;
80 QImage loadPhoto(const QString& fileName, const QSize &maxSize) const;
81 QImage grabVideoThumbnail(const QString& fileName) const;
82
83 static QMutex m_createMutex;
84 QString m_thumbnailDir;
85};
86
87#endif // GALLERY_PREVIEW_MANAGER_H_
880
=== modified file 'src/photo/photo-caches.cpp'
--- src/photo/photo-caches.cpp 2013-07-05 08:12:31 +0000
+++ src/photo/photo-caches.cpp 2014-03-07 20:39:27 +0000
@@ -20,6 +20,7 @@
20#include "photo-caches.h"20#include "photo-caches.h"
2121
22#include <QDir>22#include <QDir>
23#include <utime.h>
2324
24const QString PhotoCaches::ORIGINAL_DIR = ".original";25const QString PhotoCaches::ORIGINAL_DIR = ".original";
25const QString PhotoCaches::ENHANCED_DIR = ".enhanced";26const QString PhotoCaches::ENHANCED_DIR = ".enhanced";
@@ -118,6 +119,8 @@
118 }119 }
119120
120 remove(m_file);121 remove(m_file);
122 // touch the file so that the thumbnails will correctly regenerate
123 utime(m_originalFile.absoluteFilePath().toUtf8(), NULL);
121 return rename(m_originalFile, m_file);124 return rename(m_originalFile, m_file);
122}125}
123126
124127
=== modified file 'src/photo/photo.cpp'
--- src/photo/photo.cpp 2013-07-26 16:06:14 +0000
+++ src/photo/photo.cpp 2014-03-07 20:39:27 +0000
@@ -35,7 +35,6 @@
3535
36// medialoader36// medialoader
37#include "gallery-standard-image-provider.h"37#include "gallery-standard-image-provider.h"
38#include "gallery-thumbnail-image-provider.h"
39#include "photo-metadata.h"38#include "photo-metadata.h"
4039
41// util40// util
@@ -274,12 +273,7 @@
274 */273 */
275QUrl Photo::galleryPreviewPath() const274QUrl Photo::galleryPreviewPath() const
276{275{
277 QUrl url = MediaSource::galleryPreviewPath();276 return MediaSource::galleryPreviewPath();
278 // previews are always stored fully transformed
279
280 appendPathParams(&url, TOP_LEFT_ORIGIN, 1);
281
282 return url;
283}277}
284278
285/*!279/*!
@@ -287,16 +281,7 @@
287 */281 */
288QUrl Photo::galleryThumbnailPath() const282QUrl Photo::galleryThumbnailPath() const
289{283{
290 QUrl url = MediaSource::galleryThumbnailPath();284 return MediaSource::galleryThumbnailPath();
291 // same as in append_path_params() this is needed to trigger an update of the image in QML
292 // so the URL is changed by adding/chageing the edit parameter
293 QUrlQuery query;
294 if (m_editRevision != 0) {
295 query.addQueryItem(GalleryThumbnailImageProvider::REVISION_PARAM_NAME,
296 QString::number(m_editRevision));
297 }
298 url.setQuery(query);
299 return url;
300}285}
301286
302/*!287/*!
303288
=== modified file 'src/video/video.cpp'
--- src/video/video.cpp 2013-08-12 08:51:09 +0000
+++ src/video/video.cpp 2014-03-07 20:39:27 +0000
@@ -56,8 +56,9 @@
56 */56 */
57bool Video::isCameraVideo(const QFileInfo &file)57bool Video::isCameraVideo(const QFileInfo &file)
58{58{
59 if (file.suffix() == QLatin1String("mp4") &&59 QMimeDatabase mimedb;
60 file.baseName().startsWith("video")) {60 QMimeType mimeType = mimedb.mimeTypeForFile(file);
61 if (mimeType.name().contains("video")) {
61 return true;62 return true;
62 }63 }
6364
6465
=== added file 'tests/autopilot/gallery_app/data/option01/clip_0001.mkv'
65Binary files tests/autopilot/gallery_app/data/option01/clip_0001.mkv 1970-01-01 00:00:00 +0000 and tests/autopilot/gallery_app/data/option01/clip_0001.mkv 2014-03-07 20:39:27 +0000 differ66Binary files tests/autopilot/gallery_app/data/option01/clip_0001.mkv 1970-01-01 00:00:00 +0000 and tests/autopilot/gallery_app/data/option01/clip_0001.mkv 2014-03-07 20:39:27 +0000 differ
=== modified file 'tests/autopilot/gallery_app/tests/__init__.py'
--- tests/autopilot/gallery_app/tests/__init__.py 2014-03-07 10:57:54 +0000
+++ tests/autopilot/gallery_app/tests/__init__.py 2014-03-07 20:39:27 +0000
@@ -320,9 +320,12 @@
320 video_file = "video20130618_0002.mp4"320 video_file = "video20130618_0002.mp4"
321 shutil.copyfile(self.sample_dir+"/option01/"+video_file,321 shutil.copyfile(self.sample_dir+"/option01/"+video_file,
322 self.sample_destination_dir+"/"+video_file)322 self.sample_destination_dir+"/"+video_file)
323 video_file = "clip_0001.mkv"
324 shutil.copyfile(self.sample_dir+"/option01/"+video_file,
325 self.sample_destination_dir+"/"+video_file)
323 self.assertThat(326 self.assertThat(
324 lambda: self.gallery_utils.number_of_photos_in_events(),327 lambda: self.gallery_utils.number_of_photos_in_events(),
325 Eventually(Equals(3)))328 Eventually(Equals(4)))
326329
327 def get_delete_dialog(self):330 def get_delete_dialog(self):
328 """Raises StateNotFoundError if get_delete_dialog fails."""331 """Raises StateNotFoundError if get_delete_dialog fails."""
329332
=== modified file 'tests/autopilot/gallery_app/tests/test_albums_view.py'
--- tests/autopilot/gallery_app/tests/test_albums_view.py 2013-08-09 13:55:35 +0000
+++ tests/autopilot/gallery_app/tests/test_albums_view.py 2014-03-07 20:39:27 +0000
@@ -11,14 +11,16 @@
11from __future__ import absolute_import11from __future__ import absolute_import
1212
13from testtools.matchers import Equals13from testtools.matchers import Equals
14from autopilot.platform import model
1415
15from gallery_app.tests import GalleryTestCase16from gallery_app.tests import GalleryTestCase
16from gallery_app.emulators.albums_view import AlbumsView17from gallery_app.emulators.albums_view import AlbumsView
1718
18from time import sleep19from time import sleep
1920from os import environ as env
2021
21class TestAlbumsView(GalleryTestCase):22class TestAlbumsView(GalleryTestCase):
23 envDesktopMode = None
2224
23 @property25 @property
24 def albums_view(self):26 def albums_view(self):
@@ -26,9 +28,25 @@
2628
27 def setUp(self):29 def setUp(self):
28 self.ARGS = []30 self.ARGS = []
31
32 self.envDesktopMode = env.get("DESKTOP_MODE")
33
34 if model() == "Desktop":
35 env["DESKTOP_MODE"] = "1"
36 else:
37 env["DESKTOP_MODE"] = "0"
38
29 super(TestAlbumsView, self).setUp()39 super(TestAlbumsView, self).setUp()
30 self.switch_to_albums_tab()40 self.switch_to_albums_tab()
3141
42 def tearDown(self):
43 if self.envDesktopMode:
44 env["DESKTOP_MODE"] = self.envDesktopMode
45 else:
46 del env["DESKTOP_MODE"]
47
48 super(TestAlbumsView, self).tearDown()
49
32 def compare_number_of_albums(self, target):50 def compare_number_of_albums(self, target):
33 """Test if the number of albums is correct. For robustness (timing51 """Test if the number of albums is correct. For robustness (timing
34 issues), the test is repeated after one second in case it fails"""52 issues), the test is repeated after one second in case it fails"""
@@ -44,3 +62,13 @@
44 self.compare_number_of_albums(1)62 self.compare_number_of_albums(1)
45 self.main_view.open_toolbar().click_button("addButton")63 self.main_view.open_toolbar().click_button("addButton")
46 self.compare_number_of_albums(2)64 self.compare_number_of_albums(2)
65
66 # Check if Camera Button is not visible at Desktop mode
67 def test_camera_button_visible(self):
68 self.main_view.open_toolbar()
69 toolbar = self.main_view.get_toolbar()
70 cameraButton = toolbar.select_single("ActionItem", objectName="cameraButton")
71 if model() == "Desktop":
72 self.assertThat(cameraButton.visible, Equals(False))
73 else:
74 self.assertThat(cameraButton.visible, Equals(True))
4775
=== modified file 'tests/autopilot/gallery_app/tests/test_events_view.py'
--- tests/autopilot/gallery_app/tests/test_events_view.py 2013-10-30 05:01:48 +0000
+++ tests/autopilot/gallery_app/tests/test_events_view.py 2014-03-07 20:39:27 +0000
@@ -12,22 +12,37 @@
1212
13from testtools.matchers import Equals, Is13from testtools.matchers import Equals, Is
14from autopilot.matchers import Eventually14from autopilot.matchers import Eventually
15from autopilot.platform import model
1516
16from gallery_app.tests import GalleryTestCase17from gallery_app.tests import GalleryTestCase
1718
18from os.path import exists19from os.path import exists
1920from os import environ as env
2021
21class TestEventsView(GalleryTestCase):22class TestEventsView(GalleryTestCase):
22 """Tests the main gallery features"""23 """Tests the main gallery features"""
24 envDesktopMode = None
2325
24 def setUp(self):26 def setUp(self):
25 self.ARGS = []27 self.ARGS = []
28
29 self.envDesktopMode = env.get("DESKTOP_MODE")
30
31 if model() == "Desktop":
32 env["DESKTOP_MODE"] = "1"
33 else:
34 env["DESKTOP_MODE"] = "0"
35
26 # This is needed to wait for the application to start.36 # This is needed to wait for the application to start.
27 # In the testfarm, the application may take some time to show up.37 # In the testfarm, the application may take some time to show up.
28 super(TestEventsView, self).setUp()38 super(TestEventsView, self).setUp()
2939
30 def tearDown(self):40 def tearDown(self):
41 if self.envDesktopMode:
42 env["DESKTOP_MODE"] = self.envDesktopMode
43 else:
44 del env["DESKTOP_MODE"]
45
31 super(TestEventsView, self).tearDown()46 super(TestEventsView, self).tearDown()
3247
33 def get_events_view(self):48 def get_events_view(self):
@@ -102,3 +117,13 @@
102117
103 def test_adding_a_video(self):118 def test_adding_a_video(self):
104 self.add_video_sample()119 self.add_video_sample()
120
121 # Check if Camera Button is not visible at Desktop mode
122 def test_camera_button_visible(self):
123 self.main_view.open_toolbar()
124 toolbar = self.main_view.get_toolbar()
125 cameraButton = toolbar.select_single("ActionItem", objectName="cameraButton")
126 if model() == "Desktop":
127 self.assertThat(cameraButton.visible, Equals(False))
128 else:
129 self.assertThat(cameraButton.visible, Equals(True))
105130
=== modified file 'tests/autopilot/gallery_app/tests/test_photo_viewer.py'
--- tests/autopilot/gallery_app/tests/test_photo_viewer.py 2014-02-05 11:15:13 +0000
+++ tests/autopilot/gallery_app/tests/test_photo_viewer.py 2014-03-07 20:39:27 +0000
@@ -261,8 +261,8 @@
261 # wait for new photo being set/reloaded, so saving thumbnailing etc.261 # wait for new photo being set/reloaded, so saving thumbnailing etc.
262 # is done262 # is done
263 edit_preview = self.photo_viewer.get_edit_preview()263 edit_preview = self.photo_viewer.get_edit_preview()
264 new_source = "image://gallery-standard/" + self.sample_file + \264 new_source = "image://thumbnailer/" + self.sample_file
265 "?size_level=1&orientation=1&edit=2"265
266 self.assertThat(edit_preview.source, Eventually(Equals(new_source)))266 self.assertThat(edit_preview.source, Eventually(Equals(new_source)))
267267
268 new_file_size = os.path.getsize(self.sample_file)268 new_file_size = os.path.getsize(self.sample_file)
269269
=== modified file 'tests/autopilot/gallery_app/tests/test_photos_view.py'
--- tests/autopilot/gallery_app/tests/test_photos_view.py 2014-02-14 10:43:17 +0000
+++ tests/autopilot/gallery_app/tests/test_photos_view.py 2014-03-07 20:39:27 +0000
@@ -19,8 +19,7 @@
19from gallery_app.emulators.photos_view import PhotosView19from gallery_app.emulators.photos_view import PhotosView
2020
21from os.path import exists21from os.path import exists
22from os import environ22from os import environ as env
23
24import unittest23import unittest
2524
26class TestPhotosView(GalleryTestCase):25class TestPhotosView(GalleryTestCase):
@@ -32,21 +31,21 @@
3231
33 def setUp(self):32 def setUp(self):
34 self.ARGS = []33 self.ARGS = []
35 self.envDesktopMode = environ.get("DESKTOP_MODE")34 self.envDesktopMode = env.get("DESKTOP_MODE")
3635
37 if model() == "Desktop":36 if model() == "Desktop":
38 environ["DESKTOP_MODE"] = "1"37 env["DESKTOP_MODE"] = "1"
39 else:38 else:
40 environ["DESKTOP_MODE"] = "0"39 env["DESKTOP_MODE"] = "0"
4140
42 super(TestPhotosView, self).setUp()41 super(TestPhotosView, self).setUp()
43 self.switch_to_photos_tab()42 self.switch_to_photos_tab()
4443
45 def tearDown(self):44 def tearDown(self):
46 if self.envDesktopMode:45 if self.envDesktopMode:
47 environ["DESKTOP_MODE"] = self.envDesktopMode46 env["DESKTOP_MODE"] = self.envDesktopMode
48 else:47 else:
49 del environ["DESKTOP_MODE"]48 del env["DESKTOP_MODE"]
5049
51 super(TestPhotosView, self).tearDown()50 super(TestPhotosView, self).tearDown()
5251
@@ -152,3 +151,13 @@
152 self.assertThat(view.fullScreen, Eventually(Equals(False)))151 self.assertThat(view.fullScreen, Eventually(Equals(False)))
153 self.keyboard.press_and_release('Escape')152 self.keyboard.press_and_release('Escape')
154 self.assertThat(view.fullScreen, Eventually(Equals(False)))153 self.assertThat(view.fullScreen, Eventually(Equals(False)))
154
155 # Check if Camera Button is not visible at Desktop mode
156 def test_camera_button_visible(self):
157 self.main_view.open_toolbar()
158 toolbar = self.main_view.get_toolbar()
159 cameraButton = toolbar.select_single("ActionItem", objectName="cameraButton")
160 if model() == "Desktop":
161 self.assertThat(cameraButton.visible, Equals(False))
162 else:
163 self.assertThat(cameraButton.visible, Equals(True))
155164
=== modified file 'tests/unittests/CMakeLists.txt'
--- tests/unittests/CMakeLists.txt 2013-06-14 17:59:27 +0000
+++ tests/unittests/CMakeLists.txt 2014-03-07 20:39:27 +0000
@@ -1,7 +1,7 @@
1add_subdirectory(command-line-parser)1add_subdirectory(command-line-parser)
2add_subdirectory(gallerystandardimageprovider)2add_subdirectory(gallerystandardimageprovider)
3add_subdirectory(gallerythumbnailimageprovider)
4add_subdirectory(imaging)3add_subdirectory(imaging)
4add_subdirectory(mediamonitor)
5add_subdirectory(mediaobjectfactory)5add_subdirectory(mediaobjectfactory)
6add_subdirectory(resource)6add_subdirectory(resource)
7add_subdirectory(video)7add_subdirectory(video)
88
=== modified file 'tests/unittests/gallerystandardimageprovider/CMakeLists.txt'
--- tests/unittests/gallerystandardimageprovider/CMakeLists.txt 2013-12-16 21:49:56 +0000
+++ tests/unittests/gallerystandardimageprovider/CMakeLists.txt 2014-03-07 20:39:27 +0000
@@ -14,7 +14,6 @@
14 )14 )
1515
16QT5_WRAP_CPP(GALLERYSTANDARDIMAGEPROVIDIER_MOCS16QT5_WRAP_CPP(GALLERYSTANDARDIMAGEPROVIDIER_MOCS
17 ${gallery_medialoader_src_SOURCE_DIR}/preview-manager.h
18 ${gallery_medialoader_src_SOURCE_DIR}/photo-metadata.h17 ${gallery_medialoader_src_SOURCE_DIR}/photo-metadata.h
19 )18 )
2019
@@ -22,7 +21,6 @@
22 tst_gallerystandardimageprovidertest.cpp21 tst_gallerystandardimageprovidertest.cpp
23 ${gallery_src_SOURCE_DIR}/medialoader/gallery-standard-image-provider.cpp22 ${gallery_src_SOURCE_DIR}/medialoader/gallery-standard-image-provider.cpp
24 ../stubs/orientation_stub.cpp23 ../stubs/orientation_stub.cpp
25 ../stubs/preview-manager_stub.cpp
26 ../stubs/photometa-data_stub.cpp24 ../stubs/photometa-data_stub.cpp
27 ${GALLERYSTANDARDIMAGEPROVIDIER_MOCS}25 ${GALLERYSTANDARDIMAGEPROVIDIER_MOCS}
28 )26 )
2927
=== modified file 'tests/unittests/gallerystandardimageprovider/tst_gallerystandardimageprovidertest.cpp'
--- tests/unittests/gallerystandardimageprovider/tst_gallerystandardimageprovidertest.cpp 2013-07-03 11:53:48 +0000
+++ tests/unittests/gallerystandardimageprovider/tst_gallerystandardimageprovidertest.cpp 2014-03-07 20:39:27 +0000
@@ -24,7 +24,6 @@
24#include <QUrl>24#include <QUrl>
2525
26#include "gallery-standard-image-provider.h"26#include "gallery-standard-image-provider.h"
27#include "preview-manager.h"
28#include "media-collection.h"27#include "media-collection.h"
2928
30class tst_GalleryStandardImageProvider : public QObject29class tst_GalleryStandardImageProvider : public QObject
@@ -63,8 +62,6 @@
6362
64 QTest::newRow("FullSize") << "/home/user/Pictures/logo.jpg?size_level=0&orientation=1" <<63 QTest::newRow("FullSize") << "/home/user/Pictures/logo.jpg?size_level=0&orientation=1" <<
65 "/home/user/Pictures/logo.jpg";64 "/home/user/Pictures/logo.jpg";
66 QTest::newRow("Thumbnail") << "/home/user/Pictures/logo.jpg?size_level=1&orientation=1" <<
67 "/home/user/Pictures/.thumbs/logo_th.JPG";
68}65}
6966
70void tst_GalleryStandardImageProvider::idToFile()67void tst_GalleryStandardImageProvider::idToFile()
@@ -72,9 +69,7 @@
72 QFETCH(QString, id);69 QFETCH(QString, id);
73 QFETCH(QString, fileName);70 QFETCH(QString, fileName);
7471
75 PreviewManager previewManager("/home/user/thumbnails");
76 GalleryStandardImageProvider provider;72 GalleryStandardImageProvider provider;
77 provider.setPreviewManager(&previewManager);
78 QCOMPARE(provider.idToFile(id), fileName);73 QCOMPARE(provider.idToFile(id), fileName);
79}74}
8075
8176
=== removed directory 'tests/unittests/gallerythumbnailimageprovider'
=== removed file 'tests/unittests/gallerythumbnailimageprovider/CMakeLists.txt'
--- tests/unittests/gallerythumbnailimageprovider/CMakeLists.txt 2013-12-16 21:49:56 +0000
+++ tests/unittests/gallerythumbnailimageprovider/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,34 +0,0 @@
1add_definitions(-DTEST_SUITE)
2
3if(NOT CTEST_TESTING_TIMEOUT)
4 set(CTEST_TESTING_TIMEOUT 60)
5endif()
6
7include_directories(
8 ${gallery_core_src_SOURCE_DIR}
9 ${gallery_media_src_SOURCE_DIR}
10 ${gallery_medialoader_src_SOURCE_DIR}
11 ${gallery_util_src_SOURCE_DIR}
12 ${CMAKE_BINARY_DIR}
13 )
14
15QT5_WRAP_CPP(GALLERYTHUMBNAILIMAGEPROVIDIER_MOCS
16 ${gallery_medialoader_src_SOURCE_DIR}/preview-manager.h
17 )
18
19add_executable(gallerythumbnailimageprovider
20 tst_gallerythumbnailimageprovider.cpp
21 ../stubs/preview-manager_stub.cpp
22 ${gallery_src_SOURCE_DIR}/medialoader/gallery-thumbnail-image-provider.cpp
23 ${GALLERYTHUMBNAILIMAGEPROVIDIER_MOCS}
24 )
25
26qt5_use_modules(gallerythumbnailimageprovider Quick Test)
27add_test(gallerythumbnailimageprovider gallerythumbnailimageprovider
28 -xunitxml -o test_gallerythumbnailimageprovider.xml
29 )
30set_tests_properties(gallerythumbnailimageprovider PROPERTIES
31 TIMEOUT ${CTEST_TESTING_TIMEOUT}
32 ENVIRONMENT "QT_QPA_PLATFORM=minimal"
33 )
34
350
=== removed file 'tests/unittests/gallerythumbnailimageprovider/tst_gallerythumbnailimageprovider.cpp'
--- tests/unittests/gallerythumbnailimageprovider/tst_gallerythumbnailimageprovider.cpp 2013-06-10 06:20:05 +0000
+++ tests/unittests/gallerythumbnailimageprovider/tst_gallerythumbnailimageprovider.cpp 1970-01-01 00:00:00 +0000
@@ -1,54 +0,0 @@
1/*
2 * Copyright (C) 2012 Canonical, Ltd.
3 *
4 * Authors:
5 * Guenter Schwann <guenter.schwann@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <QtTest/QtTest>
21#include <QFileInfo>
22#include <QUrl>
23
24#include "gallery-thumbnail-image-provider.h"
25
26class tst_GalleryThumbnailImageProvider : public QObject
27{
28 Q_OBJECT
29public:
30 tst_GalleryThumbnailImageProvider();
31
32private slots:
33 void ToURL();
34
35private:
36 GalleryThumbnailImageProvider gallery_thumbnail_image_provider;
37};
38
39tst_GalleryThumbnailImageProvider::tst_GalleryThumbnailImageProvider()
40 : gallery_thumbnail_image_provider()
41{
42}
43
44void tst_GalleryThumbnailImageProvider::ToURL()
45{
46 QFileInfo fi("/tmp/test.jpg");
47 QUrl url = gallery_thumbnail_image_provider.toURL(fi);
48 QUrl expect("image://gallery-thumbnail//tmp/test.jpg");
49 QCOMPARE(url, expect);
50}
51
52QTEST_MAIN(tst_GalleryThumbnailImageProvider);
53
54#include "tst_gallerythumbnailimageprovider.moc"
550
=== added directory 'tests/unittests/mediamonitor'
=== added file 'tests/unittests/mediamonitor/CMakeLists.txt'
--- tests/unittests/mediamonitor/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/unittests/mediamonitor/CMakeLists.txt 2014-03-07 20:39:27 +0000
@@ -0,0 +1,36 @@
1add_definitions(-DTEST_SUITE)
2
3if(NOT CTEST_TESTING_TIMEOUT)
4 set(CTEST_TESTING_TIMEOUT 60)
5endif()
6
7include_directories(
8 ${gallery_media_src_SOURCE_DIR}
9 ${gallery_core_src_SOURCE_DIR}
10 ${gallery_util_src_SOURCE_DIR}
11 ${gallery_medialoader_src_SOURCE_DIR}
12 ${gallery_database_src_SOURCE_DIR}
13 ${gallery_album_src_SOURCE_DIR}
14 ${gallery_src_SOURCE_DIR}
15 ${CMAKE_BINARY_DIR}
16 )
17
18add_executable(mediamonitor tst_mediamonitor.cpp)
19
20qt5_use_modules(mediamonitor Quick Test)
21
22add_test(mediamonitor mediamonitor -xunitxml -o test_mediamonitor.xml)
23
24set_tests_properties(mediamonitor PROPERTIES
25 TIMEOUT ${CTEST_TESTING_TIMEOUT}
26 ENVIRONMENT "QT_QPA_PLATFORM=minimal"
27 )
28
29target_link_libraries(mediamonitor
30 gallery-util
31 gallery-media
32 gallery-core
33 gallery-medialoader
34 gallery-database
35 gallery-album
36 )
037
=== added file 'tests/unittests/mediamonitor/tst_mediamonitor.cpp'
--- tests/unittests/mediamonitor/tst_mediamonitor.cpp 1970-01-01 00:00:00 +0000
+++ tests/unittests/mediamonitor/tst_mediamonitor.cpp 2014-03-07 20:39:27 +0000
@@ -0,0 +1,96 @@
1/* * Copyright (C) 2014 Canonical, Ltd. *
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; version 3.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program. If not, see <http://www.gnu.org/licenses/>.
13 *
14 */
15
16#include <QtTest>
17
18#include <QDir>
19#include <QTemporaryDir>
20#include <QImage>
21#include <QColor>
22#include <QStringList>
23
24#include "media-monitor.h"
25
26class tst_MediaMonitor : public QObject
27{
28 Q_OBJECT
29
30private slots:
31 void initTestCase();
32 void tst_scanning_sub_folders();
33 void cleanupTestCase();
34
35private:
36 QTemporaryDir *m_tmpDir;
37 QImage *m_sampleImage;
38 MediaMonitor *m_monitor;
39};
40
41void tst_MediaMonitor::initTestCase()
42{
43 m_tmpDir = new QTemporaryDir();
44
45 // Create a simple directories tree
46 QDir *dir = new QDir(m_tmpDir->path());
47 dir->mkpath("A/A");
48 dir->mkpath("A/B");
49 dir->mkpath("B/A");
50 dir->mkpath("B/B");
51
52 // Create sample image
53 m_sampleImage = new QImage(400, 600, QImage::Format_RGB32);
54 m_sampleImage->fill(QColor(Qt::red));
55}
56
57void tst_MediaMonitor::tst_scanning_sub_folders()
58{
59 // Create a Media Monitor
60 m_monitor = new MediaMonitor();
61
62 // Emitted every time a new photo/video found
63 QSignalSpy filesFound(m_monitor, SIGNAL(mediaItemAdded(QString)));
64
65 // Add some debug to check which media was found
66 connect(m_monitor, &MediaMonitor::mediaItemAdded, [](const QString &file) {
67 qDebug() << "File Found:" << file;
68 });
69
70 // Launch the monitoring process
71 m_monitor->startMonitoring(QStringList(m_tmpDir->path()));
72
73 // Save sample image allover the tree
74 m_sampleImage->save(m_tmpDir->path() + "/A/A/sample_AA.jpg", "JPG");
75 m_sampleImage->save(m_tmpDir->path() + "/A/B/sample_AB.jpg", "JPG");
76 m_sampleImage->save(m_tmpDir->path() + "/B/A/sample_BA.jpg", "JPG");
77 m_sampleImage->save(m_tmpDir->path() + "/B/B/sample_BB.jpg", "JPG");
78
79 m_sampleImage->save(m_tmpDir->path() + "/A/sample_A.jpg", "JPG");
80 m_sampleImage->save(m_tmpDir->path() + "/B/sample_B.jpg", "JPG");
81
82 m_sampleImage->save(m_tmpDir->path() + "/sample.jpg", "JPG");
83
84 QTRY_COMPARE_WITH_TIMEOUT(filesFound.count(), 7, 10000);
85}
86
87void tst_MediaMonitor::cleanupTestCase()
88{
89 //Remove the previously created files
90 QDir *dir = new QDir(m_tmpDir->path());
91 dir->removeRecursively();
92}
93
94QTEST_MAIN(tst_MediaMonitor)
95
96#include "tst_mediamonitor.moc"
097
=== modified file 'tests/unittests/mediaobjectfactory/CMakeLists.txt'
--- tests/unittests/mediaobjectfactory/CMakeLists.txt 2013-12-16 21:49:56 +0000
+++ tests/unittests/mediaobjectfactory/CMakeLists.txt 2014-03-07 20:39:27 +0000
@@ -26,7 +26,6 @@
26 ${gallery_database_src_SOURCE_DIR}/photo-edit-table.h26 ${gallery_database_src_SOURCE_DIR}/photo-edit-table.h
27 ${gallery_medialoader_src_SOURCE_DIR}/gallery-standard-image-provider.h27 ${gallery_medialoader_src_SOURCE_DIR}/gallery-standard-image-provider.h
28 ${gallery_medialoader_src_SOURCE_DIR}/photo-metadata.h28 ${gallery_medialoader_src_SOURCE_DIR}/photo-metadata.h
29 ${gallery_medialoader_src_SOURCE_DIR}/preview-manager.h
30 ${gallery_medialoader_src_SOURCE_DIR}/video-metadata.h29 ${gallery_medialoader_src_SOURCE_DIR}/video-metadata.h
31 ${gallery_photo_src_SOURCE_DIR}/photo.h30 ${gallery_photo_src_SOURCE_DIR}/photo.h
32 )31 )
@@ -41,10 +40,8 @@
41 ../stubs/photo-caches_stub.cpp40 ../stubs/photo-caches_stub.cpp
42 ../stubs/photo-edit-table_stub.cpp41 ../stubs/photo-edit-table_stub.cpp
43 ../stubs/photometa-data_stub.cpp42 ../stubs/photometa-data_stub.cpp
44 ../stubs/preview-manager_stub.cpp
45 ../stubs/video-metadata_stub.cpp43 ../stubs/video-metadata_stub.cpp
46 ../stubs/gallery-standard-image-provider_stub.cpp44 ../stubs/gallery-standard-image-provider_stub.cpp
47 ../stubs/gallery-thumbnail-image-provider_stub.cpp
48 ../stubs/gallery-manager_stub.cpp45 ../stubs/gallery-manager_stub.cpp
49 ${MEDIAOBJECTFACTORY_MOCS}46 ${MEDIAOBJECTFACTORY_MOCS}
50 )47 )
5148
=== modified file 'tests/unittests/stubs/gallery-manager_stub.cpp'
--- tests/unittests/stubs/gallery-manager_stub.cpp 2013-09-06 16:10:25 +0000
+++ tests/unittests/stubs/gallery-manager_stub.cpp 2014-03-07 20:39:27 +0000
@@ -35,7 +35,6 @@
3535
36// qml36// qml
37#include "gallery-standard-image-provider.h"37#include "gallery-standard-image-provider.h"
38#include "gallery-thumbnail-image-provider.h"
3938
40GalleryManager* GalleryManager::m_galleryManager = NULL;39GalleryManager* GalleryManager::m_galleryManager = NULL;
4140
@@ -43,13 +42,11 @@
43 : collectionsInitialised(false),42 : collectionsInitialised(false),
44 m_resource(0),43 m_resource(0),
45 m_standardImageProvider(new GalleryStandardImageProvider()),44 m_standardImageProvider(new GalleryStandardImageProvider()),
46 m_thumbnailImageProvider(new GalleryThumbnailImageProvider()),
47 m_database(0),45 m_database(0),
48 m_defaultTemplate(0),46 m_defaultTemplate(0),
49 m_mediaCollection(0),47 m_mediaCollection(0),
50 m_albumCollection(0),48 m_albumCollection(0),
51 m_eventCollection(0),49 m_eventCollection(0),
52 m_previewManager(0),
53 m_monitor(0),50 m_monitor(0),
54 m_mediaLibrary(0)51 m_mediaLibrary(0)
55{52{
@@ -93,7 +90,6 @@
93GalleryManager::~GalleryManager()90GalleryManager::~GalleryManager()
94{91{
95 delete m_standardImageProvider;92 delete m_standardImageProvider;
96 delete m_thumbnailImageProvider;
97 delete m_defaultTemplate;93 delete m_defaultTemplate;
98 delete m_mediaCollection;94 delete m_mediaCollection;
99 delete m_albumCollection;95 delete m_albumCollection;
@@ -114,8 +110,3 @@
114{110{
115 return 0;111 return 0;
116}112}
117
118GalleryThumbnailImageProvider* GalleryManager::takeGalleryThumbnailImageProvider()
119{
120 return 0;
121}
122113
=== modified file 'tests/unittests/stubs/gallery-standard-image-provider_stub.cpp'
--- tests/unittests/stubs/gallery-standard-image-provider_stub.cpp 2013-06-14 17:59:27 +0000
+++ tests/unittests/stubs/gallery-standard-image-provider_stub.cpp 2014-03-07 20:39:27 +0000
@@ -19,7 +19,6 @@
19 */19 */
2020
21#include "gallery-standard-image-provider.h"21#include "gallery-standard-image-provider.h"
22#include "preview-manager.h"
2322
24const char* GalleryStandardImageProvider::PROVIDER_ID = "gallery-standard";23const char* GalleryStandardImageProvider::PROVIDER_ID = "gallery-standard";
25const char* GalleryStandardImageProvider::PROVIDER_ID_SCHEME = "image://gallery-standard/";24const char* GalleryStandardImageProvider::PROVIDER_ID_SCHEME = "image://gallery-standard/";
@@ -32,13 +31,11 @@
32const long MAX_CACHE_BYTES = 20L * 1024L * 1024L;31const long MAX_CACHE_BYTES = 20L * 1024L * 1024L;
3332
34// fully load previews into memory when requested33// fully load previews into memory when requested
35const int SCALED_LOAD_FLOOR_DIM_PIXELS =34const int SCALED_LOAD_FLOOR_DIM_PIXELS = 360;
36 qMax(PreviewManager::PREVIEW_SIZE, PreviewManager::PREVIEW_SIZE);
3735
38GalleryStandardImageProvider::GalleryStandardImageProvider()36GalleryStandardImageProvider::GalleryStandardImageProvider()
39 : QQuickImageProvider(QQuickImageProvider::Image),37 : QQuickImageProvider(QQuickImageProvider::Image),
40 m_cachedBytes(0),38 m_cachedBytes(0),
41 m_previewManager(0),
42 m_logImageLoading(false),39 m_logImageLoading(false),
43 m_maxLoadResolution(INT_MAX)40 m_maxLoadResolution(INT_MAX)
44{41{
@@ -62,11 +59,6 @@
62 return QUrl::fromUserInput(PROVIDER_ID_SCHEME + file.absoluteFilePath());59 return QUrl::fromUserInput(PROVIDER_ID_SCHEME + file.absoluteFilePath());
63}60}
6461
65void GalleryStandardImageProvider::setPreviewManager(PreviewManager *previewManager)
66{
67 m_previewManager = previewManager;
68}
69
70void GalleryStandardImageProvider::setLogging(bool enableLogging)62void GalleryStandardImageProvider::setLogging(bool enableLogging)
71{63{
72 m_logImageLoading = enableLogging;64 m_logImageLoading = enableLogging;
7365
=== removed file 'tests/unittests/stubs/gallery-thumbnail-image-provider_stub.cpp'
--- tests/unittests/stubs/gallery-thumbnail-image-provider_stub.cpp 2013-06-14 17:59:27 +0000
+++ tests/unittests/stubs/gallery-thumbnail-image-provider_stub.cpp 1970-01-01 00:00:00 +0000
@@ -1,55 +0,0 @@
1/*
2 * Copyright (C) 2012 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Guenter Schwann <guenter.schwann@canonical.com>
18*/
19
20#include "gallery-thumbnail-image-provider.h"
21
22const char* GalleryThumbnailImageProvider::PROVIDER_ID = "gallery-thumbnail";
23const char* GalleryThumbnailImageProvider::PROVIDER_ID_SCHEME = "image://gallery-thumbnail/";
24const char* GalleryThumbnailImageProvider::REVISION_PARAM_NAME = "edit";
25
26GalleryThumbnailImageProvider::GalleryThumbnailImageProvider()
27 : QQuickImageProvider(QQuickImageProvider::Image),
28 m_previewManager(0),
29 m_logImageLoading(false)
30{
31}
32
33QImage GalleryThumbnailImageProvider::requestImage(const QString& id,
34 QSize* size, const QSize& requestedSize)
35{
36 Q_UNUSED(id);
37 Q_UNUSED(size);
38 Q_UNUSED(requestedSize);
39 return QImage();
40}
41
42QUrl GalleryThumbnailImageProvider::toURL(const QFileInfo &file)
43{
44 return QUrl::fromUserInput(PROVIDER_ID_SCHEME + file.absoluteFilePath());
45}
46
47void GalleryThumbnailImageProvider::setPreviewManager(PreviewManager *previewManager)
48{
49 m_previewManager = previewManager;
50}
51
52void GalleryThumbnailImageProvider::setLogging(bool enableLogging)
53{
54 m_logImageLoading = enableLogging;
55}
560
=== removed file 'tests/unittests/stubs/preview-manager_stub.cpp'
--- tests/unittests/stubs/preview-manager_stub.cpp 2013-06-18 06:16:55 +0000
+++ tests/unittests/stubs/preview-manager_stub.cpp 1970-01-01 00:00:00 +0000
@@ -1,65 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * Authors:
5 * Nicolas d'Offay <nicolas.doffay@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#include <QDir>
22
23#include "preview-manager.h"
24#include "media-collection.h"
25
26const int PreviewManager::PREVIEW_SIZE = 360;
27const QString PreviewManager::PREVIEW_DIR = ".thumbs";
28const char* PreviewManager::PREVIEW_FILE_EXT = "JPG";
29
30PreviewManager::PreviewManager(const QString &thumbnailDirectory, QObject *parent)
31{
32 Q_UNUSED(thumbnailDirectory);
33}
34
35bool PreviewManager::ensurePreview(QFileInfo file, bool regen)
36{
37 file = QFileInfo();
38 regen = false;
39
40 return regen;
41}
42
43void PreviewManager::onMediaAddedRemoved(const QSet<DataObject *> *, const QSet<DataObject *> *)
44{
45}
46
47void PreviewManager::onMediaDestroying(const QSet<DataObject *> *)
48{
49}
50
51void PreviewManager::updatePreview()
52{
53}
54
55QString PreviewManager::previewFileName(const QFileInfo &file) const
56{
57 return QString(file.absolutePath() + QDir::separator() + PREVIEW_DIR +
58 QDir::separator() + file.completeBaseName() + "_th." + PREVIEW_FILE_EXT);
59}
60
61QString PreviewManager::thumbnailFileName(const QFileInfo& file) const
62{
63 return QString(file.absolutePath() + PREVIEW_DIR + QDir::separator() +
64 file.completeBaseName() + "_th_s." + PREVIEW_FILE_EXT);
65}
660
=== modified file 'tests/unittests/video/tst_video.cpp'
--- tests/unittests/video/tst_video.cpp 2013-08-12 09:29:34 +0000
+++ tests/unittests/video/tst_video.cpp 2014-03-07 20:39:27 +0000
@@ -33,10 +33,10 @@
33 QVERIFY(Video::isCameraVideo(fi));33 QVERIFY(Video::isCameraVideo(fi));
3434
35 fi.setFileName("/dir/video20130612_0001.avi");35 fi.setFileName("/dir/video20130612_0001.avi");
36 QVERIFY(!Video::isCameraVideo(fi));36 QVERIFY(Video::isCameraVideo(fi));
3737
38 fi.setFileName("/dir/home_video.mp4");38 fi.setFileName("/dir/home_video.mp4");
39 QVERIFY(!Video::isCameraVideo(fi));39 QVERIFY(Video::isCameraVideo(fi));
40}40}
4141
42QTEST_MAIN(tst_Video);42QTEST_MAIN(tst_Video);

Subscribers

People subscribed via source and target branches