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

Proposed by Arthur Mello
Status: Merged
Approved by: Bill Filler
Approved revision: 932
Merged at revision: 928
Proposed branch: lp:~artmello/gallery-app/gallery-app-multiple-bug-fixes
Merge into: lp:gallery-app
Diff against target: 2348 lines (+394/-1087)
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 (+57/-7)
src/media/media-monitor.h (+4/-1)
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 (+88/-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:~artmello/gallery-app/gallery-app-multiple-bug-fixes
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+211154@code.launchpad.net

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

Fix the mediamonitor unit test.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
YES

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/<package-name>) on device or emulator?
YES

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-01-11 21:58:24 +0000
3+++ CMakeLists.txt 2014-03-14 23:42:35 +0000
4@@ -41,7 +41,6 @@
5 find_package(PkgConfig REQUIRED)
6 pkg_check_modules(CONTENTHUB REQUIRED libcontent-hub)
7 pkg_check_modules(EXIV2 REQUIRED exiv2)
8-pkg_check_modules(GSTLIB REQUIRED gstreamer-0.10)
9 pkg_check_modules(MEDIAINFO REQUIRED libmediainfo)
10
11 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror")
12
13=== modified file 'debian/control'
14--- debian/control 2014-01-14 08:01:56 +0000
15+++ debian/control 2014-03-14 23:42:35 +0000
16@@ -7,7 +7,6 @@
17 pkg-config,
18 dh-translations,
19 libcontent-hub-dev (>= 0.0+13.10.20130930.1),
20- libgstreamer0.10-dev,
21 libexiv2-dev,
22 libgl1-mesa-dev | libgl-dev,
23 libgles2-mesa-dev,
24@@ -30,8 +29,6 @@
25 Conflicts: ubuntu-gallery
26 Depends: ${misc:Depends},
27 ${shlibs:Depends},
28- gstreamer0.10-plugins-base,
29- gstreamer0.10-plugins-good,
30 qtdeclarative5-accounts-plugin,
31 libqt5sql5-sqlite,
32 qtdeclarative5-qtquick2-plugin,
33
34=== modified file 'rc/qml/AlbumViewer/AlbumInternals/FramePortrait.qml'
35--- rc/qml/AlbumViewer/AlbumInternals/FramePortrait.qml 2013-04-08 14:55:34 +0000
36+++ rc/qml/AlbumViewer/AlbumInternals/FramePortrait.qml 2014-03-14 23:42:35 +0000
37@@ -18,6 +18,7 @@
38 */
39
40 import QtQuick 2.0
41+import Gallery 1.0
42 import "../../../js/Gallery.js" as Gallery
43
44 /*!
45@@ -45,6 +46,15 @@
46 visible: fullImage.opacity < 1
47 source: load && mediaSource ? mediaSource.galleryPreviewPath : ""
48 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+ }
58 }
59 Image {
60 id: fullImage
61@@ -62,4 +72,10 @@
62 NumberAnimation { duration: Gallery.SNAP_DURATION }
63 }
64 }
65+ Image {
66+ // Display a play icon if the thumbnail is from a video
67+ source: "../../../img/icon_play.png"
68+ anchors.centerIn: parent
69+ visible: isLoaded && mediaSource.type === MediaSource.Video
70+ }
71 }
72
73=== modified file 'rc/qml/AlbumsOverview.qml'
74--- rc/qml/AlbumsOverview.qml 2014-02-11 21:03:40 +0000
75+++ rc/qml/AlbumsOverview.qml 2014-03-14 23:42:35 +0000
76@@ -199,6 +199,7 @@
77 }
78 ToolbarButton {
79 objectName: "cameraButton"
80+ visible: !APP.desktopMode
81 action: Action {
82 text: i18n.tr("Camera")
83 iconSource: Qt.resolvedUrl("../img/camera.png")
84
85=== modified file 'rc/qml/Components/MediaGrid.qml'
86--- rc/qml/Components/MediaGrid.qml 2013-06-26 08:59:08 +0000
87+++ rc/qml/Components/MediaGrid.qml 2014-03-14 23:42:35 +0000
88@@ -16,6 +16,7 @@
89
90 import QtQuick 2.0
91 import Ubuntu.Components 0.1
92+import Gallery 1.0
93 import "../OrganicView"
94 import "../Utility"
95 import "../../js/Gallery.js" as Gallery
96@@ -80,8 +81,26 @@
97 radius: "medium"
98
99 image: Image {
100+ id: thumbImage
101 source: mediaSource.galleryThumbnailPath
102 asynchronous: true
103+ fillMode: Image.PreserveAspectCrop
104+
105+ Connections {
106+ target: mediaSource
107+ onDataChanged: {
108+ // data changed but filename didn't, so we need to bypass the qml image
109+ // cache by tacking a timestamp to the filename so sees it as different.
110+ thumbImage.source = mediaSource.galleryThumbnailPath + "?at=" + Date.now()
111+ }
112+ }
113+ }
114+
115+ Image {
116+ // Display a play icon if the thumbnail is from a video
117+ source: "../../img/icon_play.png"
118+ anchors.centerIn: parent
119+ visible: mediaSource.type === MediaSource.Video
120 }
121
122 OrganicItemInteraction {
123
124=== modified file 'rc/qml/MediaViewer/PhotoViewerDelegate.qml'
125--- rc/qml/MediaViewer/PhotoViewerDelegate.qml 2014-02-04 16:53:39 +0000
126+++ rc/qml/MediaViewer/PhotoViewerDelegate.qml 2014-03-14 23:42:35 +0000
127@@ -56,6 +56,15 @@
128 fullPhotoComponentLoader.item.unzoom();
129 }
130
131+ Connections {
132+ target: mediaSource
133+ onDataChanged: {
134+ // Force the image to be reloaded, to pick up the new thumbnail
135+ interactivePreviewImage.active = false;
136+ interactivePreviewImage.active = true;
137+ }
138+ }
139+
140 // Note that we haven't defined a state set in this component, even though
141 // we bind the "state" property here. This is intentional and is necessary
142 // to work around a binding issue on Qt 5.0 beta 1. Given a later version
143@@ -63,19 +72,23 @@
144 state: (fullPhotoComponentLoader.item &&
145 !fullPhotoComponentLoader.item.fullyUnzoomed) ? "zoomed" :
146 "unzoomed";
147-
148- Image {
149+ Component {
150+ id: interactivePreviewImageSource
151+ Image {
152+ fillMode: Image.PreserveAspectFit
153+
154+ source: mediaSource ? mediaSource.galleryPreviewPath : ""
155+ cache: false
156+ }
157+ }
158+
159+ Loader {
160 id: interactivePreviewImage
161-
162 z: 0
163-
164 anchors.fill: parent
165
166 visible: photoViewerDelegate.state == "unzoomed"
167-
168- fillMode: Image.PreserveAspectFit
169-
170- source: mediaSource ? mediaSource.galleryPreviewPath : ""
171+ sourceComponent: interactivePreviewImageSource
172 }
173
174 Loader {
175
176=== modified file 'rc/qml/MediaViewer/ZoomablePhotoComponent.qml'
177--- rc/qml/MediaViewer/ZoomablePhotoComponent.qml 2013-06-14 09:02:15 +0000
178+++ rc/qml/MediaViewer/ZoomablePhotoComponent.qml 2014-03-14 23:42:35 +0000
179@@ -389,7 +389,8 @@
180 transformOrigin: Item.TopLeft
181
182 visible: zoomablePhotoComponent.isZoomAnimationInProgress ||
183- zoomablePhotoComponent.state == "pinching"
184+ zoomablePhotoComponent.state == "pinching" ||
185+ !zoomedPhoto.isLoaded
186
187 color: zoomablePhotoComponent.color
188
189
190=== modified file 'rc/qml/OrganicView/OrganicMediaList.qml'
191--- rc/qml/OrganicView/OrganicMediaList.qml 2013-06-26 13:46:56 +0000
192+++ rc/qml/OrganicView/OrganicMediaList.qml 2014-03-14 23:42:35 +0000
193@@ -161,8 +161,32 @@
194 radius: "medium"
195
196 image: Image {
197+ id: thumbImage
198 source: model.mediaSource.galleryThumbnailPath
199 asynchronous: true
200+
201+ /* The SDK thumbnailer respects the freedesktop.org standard and uses 128 for the small
202+ * thumbnail size, while the previous thumbnailer used 216. To maintain the same visual
203+ * result as the previous thumbnailer, we force it to generate a large thumbnail, which
204+ * is closer to the older one in size and looks identical when downscaled */
205+ sourceSize.width: 256
206+ fillMode: Image.PreserveAspectCrop
207+ }
208+
209+ Connections {
210+ target: model.mediaSource
211+ onDataChanged: {
212+ // data changed but filename didn't, so we need to bypass the qml image
213+ // cache by tacking a timestamp to the filename so sees it as different.
214+ thumbImage.source = model.mediaSource.galleryThumbnailPath + "?at=" + Date.now()
215+ }
216+ }
217+
218+ Image {
219+ // Display a play icon if the thumbnail is from a video
220+ source: "../../img/icon_play.png"
221+ anchors.centerIn: parent
222+ visible: mediaSource.type === MediaSource.Video
223 }
224
225 OrganicItemInteraction {
226
227=== modified file 'rc/qml/Utility/PhotosToolbarActions.qml'
228--- rc/qml/Utility/PhotosToolbarActions.qml 2014-01-10 17:48:56 +0000
229+++ rc/qml/Utility/PhotosToolbarActions.qml 2014-03-14 23:42:35 +0000
230@@ -44,6 +44,7 @@
231 ToolbarButton {
232 objectName: "cameraButton"
233 text: i18n.tr("Camera")
234+ visible: !APP.desktopMode
235 iconSource: Qt.resolvedUrl("../../img/camera.png")
236 onTriggered: Qt.openUrlExternally("appid://com.ubuntu.camera/camera/current-user-version")
237 }
238
239=== modified file 'src/album/CMakeLists.txt'
240--- src/album/CMakeLists.txt 2013-08-15 06:40:15 +0000
241+++ src/album/CMakeLists.txt 2014-03-14 23:42:35 +0000
242@@ -36,3 +36,6 @@
243
244 qt5_use_modules(${GALLERY_ALBUM_LIB} Widgets Core Qml)
245
246+target_link_libraries( ${GALLERY_ALBUM_LIB}
247+ gallery-core
248+ )
249
250=== modified file 'src/gallery-application.cpp'
251--- src/gallery-application.cpp 2014-02-20 17:53:20 +0000
252+++ src/gallery-application.cpp 2014-03-14 23:42:35 +0000
253@@ -38,7 +38,6 @@
254
255 // qml
256 #include "gallery-standard-image-provider.h"
257-#include "gallery-thumbnail-image-provider.h"
258 #include "qml-album-collection-model.h"
259 #include "qml-event-collection-model.h"
260 #include "qml-event-overview-model.h"
261@@ -143,7 +142,7 @@
262 */
263 bool GalleryApplication::isDesktopMode() const
264 {
265- return (qEnvironmentVariableIsSet("DESKTOP_MODE") && (qgetenv("DESKTOP_MODE") == "1"));
266+ return(qEnvironmentVariableIsSet("DESKTOP_MODE") && (qgetenv("DESKTOP_MODE") == "1"));
267 }
268
269 /*!
270@@ -169,7 +168,7 @@
271 size.transpose();
272
273 m_view->setResizeMode(QQuickView::SizeRootObjectToView);
274- if (m_cmdLineParser->formFactor() == "desktop" || isDesktopMode()) {
275+ if (isDesktopMode()) {
276 m_view->setMinimumSize(QSize(60 * m_bguSize, 60 * m_bguSize));
277 }
278
279@@ -213,8 +212,6 @@
280 m_galleryManager->postInit();
281 m_view->engine()->addImageProvider(GalleryStandardImageProvider::PROVIDER_ID,
282 m_galleryManager->takeGalleryStandardImageProvider());
283- m_view->engine()->addImageProvider(GalleryThumbnailImageProvider::PROVIDER_ID,
284- m_galleryManager->takeGalleryThumbnailImageProvider());
285
286 QApplication::processEvents();
287 if (m_cmdLineParser->startupTimer())
288
289=== modified file 'src/gallery-manager.cpp'
290--- src/gallery-manager.cpp 2013-09-06 16:10:25 +0000
291+++ src/gallery-manager.cpp 2014-03-14 23:42:35 +0000
292@@ -35,11 +35,9 @@
293 // media
294 #include "media-collection.h"
295 #include "media-monitor.h"
296-#include "preview-manager.h"
297
298 // qml
299 #include "gallery-standard-image-provider.h"
300-#include "gallery-thumbnail-image-provider.h"
301 #include "qml-media-collection-model.h"
302
303 // util
304@@ -63,13 +61,11 @@
305 : collectionsInitialised(false),
306 m_resource(new Resource(picturesDir, view)),
307 m_standardImageProvider(new GalleryStandardImageProvider()),
308- m_thumbnailImageProvider(new GalleryThumbnailImageProvider()),
309 m_database(0),
310 m_defaultTemplate(0),
311 m_mediaCollection(0),
312 m_albumCollection(0),
313 m_eventCollection(0),
314- m_previewManager(0),
315 m_monitor(0),
316 m_mediaLibrary(0)
317 {
318@@ -94,9 +90,7 @@
319 delete m_defaultTemplate;
320 delete m_resource;
321 delete m_mediaCollection;
322- delete m_previewManager;
323 delete m_standardImageProvider;
324- delete m_thumbnailImageProvider;
325 }
326
327 /*!
328@@ -145,7 +139,6 @@
329 m_defaultTemplate = new AlbumDefaultTemplate();
330 m_mediaCollection = new MediaCollection(m_database->getMediaTable());
331
332- initPreviewManager();
333 fillMediaCollection();
334 startFileMonitoring();
335
336@@ -219,41 +212,6 @@
337 void GalleryManager::logImageLoading(bool log)
338 {
339 m_standardImageProvider->setLogging(log);
340- m_thumbnailImageProvider->setLogging(log);
341-}
342-
343-/*!
344- * \brief GalleryManager::initPreviewManager creates the PreviewManager,
345- * assigns it to all needed objects and creates all signal slot connection.
346- */
347-void GalleryManager::initPreviewManager()
348-{
349- Q_ASSERT(m_resource);
350- Q_ASSERT(m_mediaCollection);
351- Q_ASSERT(m_standardImageProvider);
352- Q_ASSERT(m_thumbnailImageProvider);
353-
354- if (m_previewManager)
355- return;
356-
357- m_previewManager = new PreviewManager(m_resource->thumbnailDirectory());
358-
359- m_standardImageProvider->setPreviewManager(m_previewManager);
360- m_thumbnailImageProvider->setPreviewManager(m_previewManager);
361-
362- // Monitor MediaCollection for all new MediaSources
363- QObject::connect(m_mediaCollection,
364- SIGNAL(contentsChanged(const QSet<DataObject*>*,const QSet<DataObject*>*)),
365- m_previewManager,
366- SLOT(onMediaAddedRemoved(const QSet<DataObject*>*,const QSet<DataObject*>*)));
367-
368- QObject::connect(m_mediaCollection,
369- SIGNAL(destroying(const QSet<DataObject*>*)),
370- m_previewManager,
371- SLOT(onMediaDestroying(const QSet<DataObject*>*)));
372-
373- // Verify previews for all existing added MediaSources
374- m_previewManager->onMediaAddedRemoved(&m_mediaCollection->getAsSet(), NULL);
375 }
376
377 /*!
378@@ -324,14 +282,3 @@
379 m_standardImageProvider = 0;
380 return provider;
381 }
382-
383-/*!
384- * \brief GalleryManager::takeGalleryThumbnailImageProvider returns the thumbnail image provider
385- * and gives up the owndership
386- */
387-GalleryThumbnailImageProvider* GalleryManager::takeGalleryThumbnailImageProvider()
388-{
389- GalleryThumbnailImageProvider *provider = m_thumbnailImageProvider;
390- m_thumbnailImageProvider = 0;
391- return provider;
392-}
393
394=== modified file 'src/gallery-manager.h'
395--- src/gallery-manager.h 2013-09-06 16:10:25 +0000
396+++ src/gallery-manager.h 2014-03-14 23:42:35 +0000
397@@ -36,11 +36,9 @@
398 class EventCollection;
399 class GalleryManager;
400 class GalleryStandardImageProvider;
401-class GalleryThumbnailImageProvider;
402 class MediaCollection;
403 class MediaMonitor;
404 class MediaObjectFactory;
405-class PreviewManager;
406 class QmlMediaCollectionModel;
407 class Resource;
408
409@@ -68,7 +66,6 @@
410 EventCollection *eventCollection();
411 Resource *resource() { return m_resource; }
412 GalleryStandardImageProvider *takeGalleryStandardImageProvider();
413- GalleryThumbnailImageProvider *takeGalleryThumbnailImageProvider();
414
415 void logImageLoading(bool log);
416
417@@ -85,7 +82,6 @@
418 GalleryManager(const GalleryManager&);
419 void operator=(const GalleryManager&);
420
421- void initPreviewManager();
422 void fillMediaCollection();
423 void startFileMonitoring();
424
425@@ -95,13 +91,11 @@
426
427 Resource* m_resource;
428 GalleryStandardImageProvider* m_standardImageProvider;
429- GalleryThumbnailImageProvider* m_thumbnailImageProvider;
430 Database* m_database;
431 AlbumDefaultTemplate* m_defaultTemplate;
432 MediaCollection* m_mediaCollection;
433 AlbumCollection* m_albumCollection;
434 EventCollection* m_eventCollection;
435- PreviewManager* m_previewManager;
436 MediaObjectFactory *m_mediaFactory;
437 MediaMonitor *m_monitor;
438
439
440=== modified file 'src/media/media-monitor.cpp'
441--- src/media/media-monitor.cpp 2013-08-09 15:13:08 +0000
442+++ src/media/media-monitor.cpp 2014-03-14 23:42:35 +0000
443@@ -88,6 +88,13 @@
444 m_worker->setMonitoringOnHold(onHold);
445 }
446
447+/*!
448+ * \brief MediaMonitor::manifest return a list of all files found on monitoring process.
449+ * It is beeing used on unit tests to check if monitoring process is correct.
450+ */
451+QStringList MediaMonitor::manifest() {
452+ return m_worker->getManifest();
453+}
454
455 /*!
456 * \brief MediaMonitor::MediaMonitor
457@@ -135,18 +142,61 @@
458 }
459
460 /*!
461+ * \brief MediaMonitor::getManifest is a getter for m_manifest
462+ */
463+QStringList MediaMonitorWorker::getManifest()
464+{
465+ return m_manifest;
466+}
467+
468+/*!
469+ * \brief MediaMonitor::expandSubDirectories List all sub directories under
470+ * the base one. Use it to add to watch list
471+ * \param dirPath
472+ */
473+QStringList MediaMonitorWorker::expandSubDirectories(const QString& dirPath)
474+{
475+ QStack<QString> dirStack;
476+ dirStack.push(dirPath);
477+
478+ QStringList dirList;
479+ while(!dirStack.isEmpty()) {
480+ QDir dir(dirStack.pop());
481+ dirList.append(dir.absolutePath());
482+
483+ foreach(const QFileInfo &info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs)) {
484+ QString path(info.absoluteFilePath());
485+ if (info.isSymLink() && info.exists()) {
486+ // If it's a SymLink and points to a valid target need to get the target path
487+ path = info.symLinkTarget();
488+ }
489+ if(!dirList.contains(path)) {
490+ // In case we already visited the folder we didn't expand it anymore
491+ dirStack.push(path);
492+ }
493+ }
494+ }
495+
496+ return dirList;
497+}
498+
499+/*!
500 * \brief MediaMonitor::startMonitoring
501 * \param targetDirectories
502 */
503 void MediaMonitorWorker::startMonitoring(const QStringList &targetDirectories)
504 {
505 QStringList newDirectories;
506- foreach (const QString& dir, targetDirectories) {
507- if (!m_targetDirectories.contains(dir))
508- newDirectories.append(dir);
509+ foreach (const QString& dirPath, targetDirectories) {
510+ foreach (const QString& d, expandSubDirectories(dirPath)) {
511+ // Add all sub folders from target directory on watch list
512+ if (!m_targetDirectories.contains(d)) {
513+ newDirectories.append(d);
514+ }
515+ }
516 }
517 m_targetDirectories += newDirectories;
518- m_manifest = getManifest(m_targetDirectories);
519+ m_manifest = generateManifest(m_targetDirectories);
520 m_watcher.addPaths(newDirectories);
521 }
522
523@@ -179,7 +229,7 @@
524 return;
525 }
526
527- QStringList new_manifest = getManifest(m_targetDirectories);
528+ QStringList new_manifest = generateManifest(m_targetDirectories);
529
530 QStringList added = subtractManifest(new_manifest, m_manifest);
531 for (int i = 0; i < added.size(); i++)
532@@ -197,11 +247,11 @@
533 }
534
535 /*!
536- * \brief MediaMonitor::getManifest
537+ * \brief MediaMonitor::generateManifest
538 * \param dir
539 * \return
540 */
541-QStringList MediaMonitorWorker::getManifest(const QStringList &dirs)
542+QStringList MediaMonitorWorker::generateManifest(const QStringList &dirs)
543 {
544 QStringList allFiles;
545 foreach (const QString &dirName, dirs) {
546
547=== modified file 'src/media/media-monitor.h'
548--- src/media/media-monitor.h 2013-07-05 08:12:31 +0000
549+++ src/media/media-monitor.h 2014-03-14 23:42:35 +0000
550@@ -44,6 +44,7 @@
551
552 void startMonitoring(const QStringList& targetDirectories);
553 void checkConsitency(const MediaCollection *mediaCollection);
554+ QStringList manifest();
555
556 public slots:
557 void setMonitoringOnHold(bool onHold);
558@@ -72,9 +73,11 @@
559
560 void setMediaCollection(const MediaCollection *mediaCollection);
561 void setMonitoringOnHold(bool onHold);
562+ QStringList getManifest();
563
564 public slots:
565 void startMonitoring(const QStringList& targetDirectories);
566+ QStringList expandSubDirectories(const QString& dirPath);
567 void checkConsitency();
568
569 signals:
570@@ -86,7 +89,7 @@
571 void onFileActivityCeased();
572
573 private:
574- QStringList getManifest(const QStringList& dirs);
575+ QStringList generateManifest(const QStringList& dirs);
576 QStringList subtractManifest(const QStringList& m1, const QStringList& m2);
577 void checkForNewMedias();
578 void checkForRemovedMedias();
579
580=== modified file 'src/media/media-source.cpp'
581--- src/media/media-source.cpp 2013-08-16 12:55:55 +0000
582+++ src/media/media-source.cpp 2014-03-14 23:42:35 +0000
583@@ -25,7 +25,8 @@
584
585 // qml
586 #include "gallery-standard-image-provider.h"
587-#include "gallery-thumbnail-image-provider.h"
588+
589+#include <QUrl>
590
591 /*!
592 * \brief MediaSource::MediaSource
593@@ -84,7 +85,17 @@
594 */
595 QUrl MediaSource::galleryPath() const
596 {
597- return GalleryStandardImageProvider::toURL(m_file);
598+ /* At the moment the only video files we recognize are mp4
599+ * files. This was maintained hardcoded from the previous
600+ * version of gallery app, and should be fixed in the future.
601+ * For those files the full image is the thumbnail/preview itself */
602+ if (m_file.suffix().toLower() == "mp4") {
603+ QString path("image://thumbnailer/");
604+ path.append(m_file.absoluteFilePath());
605+ return QUrl(path);
606+ } else {
607+ return GalleryStandardImageProvider::toURL(m_file);
608+ }
609 }
610
611 /*!
612@@ -93,7 +104,9 @@
613 */
614 QUrl MediaSource::galleryPreviewPath() const
615 {
616- return GalleryStandardImageProvider::toURL(m_file);
617+ QString path("image://thumbnailer/");
618+ path.append(m_file.absoluteFilePath());
619+ return QUrl(path);
620 }
621
622 /*!
623@@ -102,7 +115,9 @@
624 */
625 QUrl MediaSource::galleryThumbnailPath() const
626 {
627- return GalleryThumbnailImageProvider::toURL(m_file);
628+ QString path("image://thumbnailer/");
629+ path.append(m_file.absoluteFilePath());
630+ return QUrl(path);
631 }
632
633 /*!
634
635=== modified file 'src/medialoader/CMakeLists.txt'
636--- src/medialoader/CMakeLists.txt 2013-08-19 06:45:36 +0000
637+++ src/medialoader/CMakeLists.txt 2014-03-14 23:42:35 +0000
638@@ -16,17 +16,13 @@
639
640 set(gallery_medialoader_HDRS
641 gallery-standard-image-provider.h
642- gallery-thumbnail-image-provider.h
643 photo-metadata.h
644- preview-manager.h
645 video-metadata.h
646 )
647
648 set(gallery_medialoader_SRCS
649 gallery-standard-image-provider.cpp
650- gallery-thumbnail-image-provider.cpp
651 photo-metadata.cpp
652- preview-manager.cpp
653 video-metadata.cpp
654 )
655
656@@ -43,4 +39,5 @@
657 ${EXIV2_LIBRARIES}
658 ${GSTLIB_LDFLAGS}
659 ${MEDIAINFO_LIBRARIES}
660+ gallery-util
661 )
662
663=== modified file 'src/medialoader/gallery-standard-image-provider.cpp'
664--- src/medialoader/gallery-standard-image-provider.cpp 2013-08-12 08:51:09 +0000
665+++ src/medialoader/gallery-standard-image-provider.cpp 2014-03-14 23:42:35 +0000
666@@ -20,7 +20,6 @@
667
668 #include "gallery-standard-image-provider.h"
669 #include "photo-metadata.h"
670-#include "preview-manager.h"
671
672 #include <QDebug>
673 #include <QElapsedTimer>
674@@ -38,9 +37,7 @@
675
676 const long MAX_CACHE_BYTES = 20L * 1024L * 1024L;
677
678-// fully load previews into memory when requested
679-const int SCALED_LOAD_FLOOR_DIM_PIXELS =
680- qMax(PreviewManager::PREVIEW_SIZE, PreviewManager::PREVIEW_SIZE);
681+const int SCALED_LOAD_FLOOR_DIM_PIXELS = 360;
682
683 /*!
684 * \brief GalleryStandardImageProvider::GalleryStandardImageProvider
685@@ -48,7 +45,6 @@
686 GalleryStandardImageProvider::GalleryStandardImageProvider()
687 : QQuickImageProvider(QQuickImageProvider::Image),
688 m_cachedBytes(0),
689- m_previewManager(0),
690 m_logImageLoading(false),
691 m_maxLoadResolution(INT_MAX)
692 {
693@@ -89,11 +85,6 @@
694 QImage GalleryStandardImageProvider::requestImage(const QString& id,
695 QSize* size, const QSize& requestedSize)
696 {
697- if (!m_previewManager) {
698- qWarning() << Q_FUNC_INFO << "no PreviewManager set";
699- return QImage();
700- }
701-
702 // for LOG_IMAGE_STATUS
703 QString loggingStr = "";
704 QElapsedTimer timer;
705@@ -101,26 +92,21 @@
706
707 QUrl url(id);
708 QFileInfo photoFile(url.path());
709- m_previewManager->ensurePreview(photoFile);
710
711 QImage readyImage;
712 uint bytesLoaded = 0;
713 long currentCachedBytes = 0;
714 int currentCacheEntries = 0;
715
716- if (photoFile.suffix().compare("mp4", Qt::CaseInsensitive) == 0) {
717- readyImage = QImage(m_previewManager->previewFileName(photoFile.absoluteFilePath()));
718- } else {
719- CachedImage* cachedImage = claimCachedImageEntry(id, loggingStr);
720- Q_ASSERT(cachedImage != NULL);
721-
722- readyImage = fetchCachedImage(cachedImage, requestedSize, &bytesLoaded,
723- loggingStr);
724- if (readyImage.isNull())
725- LOG_IMAGE_STATUS("load-failure ");
726-
727- releaseCachedImageEntry(cachedImage, bytesLoaded, &currentCachedBytes, &currentCacheEntries);
728- }
729+ CachedImage* cachedImage = claimCachedImageEntry(id, loggingStr);
730+ Q_ASSERT(cachedImage != NULL);
731+
732+ readyImage = fetchCachedImage(cachedImage, requestedSize, &bytesLoaded,
733+ loggingStr);
734+ if (readyImage.isNull())
735+ LOG_IMAGE_STATUS("load-failure ");
736+
737+ releaseCachedImageEntry(cachedImage, bytesLoaded, &currentCachedBytes, &currentCacheEntries);
738
739 if (m_logImageLoading) {
740 if (bytesLoaded > 0) {
741@@ -142,15 +128,6 @@
742 }
743
744 /*!
745- * \brief GalleryStandardImageProvider::setPreviewManager
746- * \param previewManager
747- */
748-void GalleryStandardImageProvider::setPreviewManager(PreviewManager *previewManager)
749-{
750- m_previewManager = previewManager;
751-}
752-
753-/*!
754 * \brief GalleryStandardImageProvider::setLogging enables to print photo loading
755 * times to stout
756 * \param enableLogging
757@@ -414,30 +391,15 @@
758 */
759 QString GalleryStandardImageProvider::idToFile(const QString& id) const
760 {
761- if (!m_previewManager) {
762- qWarning() << Q_FUNC_INFO << "no PreviewManager set";
763- return QString();
764- }
765-
766 QUrl url = QUrl(id);
767 QString fileName = url.path();
768-
769- //Get our item value from our query by it's key.
770- QUrlQuery url_query(url);
771- url_query.hasQueryItem(GalleryStandardImageProvider::SIZE_KEY);
772- QString value = url_query.queryItemValue(GalleryStandardImageProvider::SIZE_KEY);
773-
774- if (value == "1") {
775- fileName = m_previewManager->previewFileName(fileName);
776- }
777-
778 return fileName;
779 }
780
781 /*!
782 * \brief GalleryStandardImageProvider::CachedImage::CachedImage
783 * \param id the full URI of the image
784- * \param fileName the filename for the URI (can be the file itself or the preview)
785+ * \param fileName the filename for the URI (the file itself)
786 */
787 GalleryStandardImageProvider::CachedImage::CachedImage(const QString& fileId,
788 const QString& filename)
789
790=== modified file 'src/medialoader/gallery-standard-image-provider.h'
791--- src/medialoader/gallery-standard-image-provider.h 2013-06-10 10:59:47 +0000
792+++ src/medialoader/gallery-standard-image-provider.h 2014-03-14 23:42:35 +0000
793@@ -34,8 +34,6 @@
794 #include <QString>
795 #include <QUrl>
796
797-class PreviewManager;
798-
799 /*!
800 * Gallery uses a custom image provider for three reasons:
801 *
802@@ -73,7 +71,6 @@
803 virtual QImage requestImage(const QString& id, QSize* size,
804 const QSize& requestedSize);
805
806- void setPreviewManager(PreviewManager* previewManager);
807 void setLogging(bool enableLogging);
808 void setMaxLoadResolution(int resolution);
809
810@@ -109,7 +106,6 @@
811 QList<QString> m_fifo;
812 QMutex m_cacheMutex;
813 long m_cachedBytes;
814- PreviewManager* m_previewManager;
815 bool m_logImageLoading;
816 int m_maxLoadResolution;
817
818
819=== removed file 'src/medialoader/gallery-thumbnail-image-provider.cpp'
820--- src/medialoader/gallery-thumbnail-image-provider.cpp 2013-06-10 06:20:05 +0000
821+++ src/medialoader/gallery-thumbnail-image-provider.cpp 1970-01-01 00:00:00 +0000
822@@ -1,102 +0,0 @@
823-/*
824- * Copyright (C) 2012 Canonical Ltd
825- *
826- * This program is free software: you can redistribute it and/or modify
827- * it under the terms of the GNU General Public License version 3 as
828- * published by the Free Software Foundation.
829- *
830- * This program is distributed in the hope that it will be useful,
831- * but WITHOUT ANY WARRANTY; without even the implied warranty of
832- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
833- * GNU General Public License for more details.
834- *
835- * You should have received a copy of the GNU General Public License
836- * along with this program. If not, see <http://www.gnu.org/licenses/>.
837- *
838- * Authors:
839- * Guenter Schwann <guenter.schwann@canonical.com>
840-*/
841-
842-#include "gallery-thumbnail-image-provider.h"
843-
844-// media
845-#include "preview-manager.h"
846-
847-#include <QDebug>
848-#include <QElapsedTimer>
849-
850-const char* GalleryThumbnailImageProvider::PROVIDER_ID = "gallery-thumbnail";
851-const char* GalleryThumbnailImageProvider::PROVIDER_ID_SCHEME = "image://gallery-thumbnail/";
852-const char* GalleryThumbnailImageProvider::REVISION_PARAM_NAME = "edit";
853-
854-/*!
855- * @brief GalleryThumbnailImageProvider::GalleryThumbnailImageProvider
856- */
857-GalleryThumbnailImageProvider::GalleryThumbnailImageProvider()
858- : QQuickImageProvider(QQuickImageProvider::Image),
859- m_previewManager(0),
860- m_logImageLoading(false)
861-{
862-}
863-
864-/*!
865- * \brief GalleryThumbnailImageProvider::toURL return the URL to this image provider for a local file
866- * \param file is the file that you want the url for
867- * \return URL to be used to load a local image usign this image provider
868- */
869-QUrl GalleryThumbnailImageProvider::toURL(const QFileInfo &file)
870-{
871- return QUrl::fromUserInput(PROVIDER_ID_SCHEME + file.absoluteFilePath());
872-}
873-
874-/*!
875- * @brief GalleryThumbnailImageProvider::requestImage @reimp of QQuickImageProvider::requestImage
876- * @param id is the requested image source
877- * @param size must be set to the original size of the image
878- * @param requestedSize is not used here, as thumbnails have a fixed size
879- * @return the image with id
880- */
881-QImage GalleryThumbnailImageProvider::requestImage(const QString &id, QSize *size,
882- const QSize &requestedSize)
883-{
884- Q_UNUSED(requestedSize);
885-
886- if (!m_previewManager) {
887- qWarning() << Q_FUNC_INFO << "no PreviewManager set";
888- return QImage();
889- }
890-
891- QElapsedTimer timer;
892- timer.start();
893-
894- QUrl url(id);
895- QFileInfo photoFile(url.path());
896- m_previewManager->ensurePreview(photoFile);
897-
898- QString fileName = m_previewManager->thumbnailFileName(photoFile);
899-
900- QImage thumbnail;
901- thumbnail.load(fileName);
902- if (thumbnail.isNull()) {
903- qWarning() << "Could not load thumbnail:" << id;
904- }
905-
906- if (size != NULL)
907- *size = thumbnail.size();
908-
909- if (m_logImageLoading) {
910- qDebug() << id << thumbnail.size() << "time:" << timer.elapsed() << "ms";
911- }
912-
913- return thumbnail;
914-}
915-
916-void GalleryThumbnailImageProvider::setPreviewManager(PreviewManager *previewManager)
917-{
918- m_previewManager = previewManager;
919-}
920-
921-void GalleryThumbnailImageProvider::setLogging(bool enableLogging)
922-{
923- m_logImageLoading = enableLogging;
924-}
925
926=== removed file 'src/medialoader/gallery-thumbnail-image-provider.h'
927--- src/medialoader/gallery-thumbnail-image-provider.h 2013-06-10 06:20:05 +0000
928+++ src/medialoader/gallery-thumbnail-image-provider.h 1970-01-01 00:00:00 +0000
929@@ -1,59 +0,0 @@
930-/*
931- * Copyright (C) 2012 Canonical Ltd
932- *
933- * This program is free software: you can redistribute it and/or modify
934- * it under the terms of the GNU General Public License version 3 as
935- * published by the Free Software Foundation.
936- *
937- * This program is distributed in the hope that it will be useful,
938- * but WITHOUT ANY WARRANTY; without even the implied warranty of
939- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
940- * GNU General Public License for more details.
941- *
942- * You should have received a copy of the GNU General Public License
943- * along with this program. If not, see <http://www.gnu.org/licenses/>.
944- *
945- * Authors:
946- * Guenter Schwann <guenter.schwann@canonical.com>
947-*/
948-
949-#ifndef GALLERYTHUMBNAILIMAGEPROVIDER_H
950-#define GALLERYTHUMBNAILIMAGEPROVIDER_H
951-
952-#include <QFileInfo>
953-#include <QQuickImageProvider>
954-#include <QSize>
955-#include <QString>
956-
957-class PreviewManager;
958-
959-/*!
960- * @brief The GalleryThumbailImageProvider class is used to load the small square thumbnails
961- *
962- * An extra image provider is used, so the image can be updated by adding parameters to the URL,
963- * to update the image. As for local URL, no parameters are used (internally).
964- * In future it might be used for more functionality, like custom caching of images.
965- */
966-class GalleryThumbnailImageProvider : public QQuickImageProvider
967-{
968-public:
969- static const char* PROVIDER_ID;
970- static const char* PROVIDER_ID_SCHEME;
971- static const char* REVISION_PARAM_NAME;
972-
973- GalleryThumbnailImageProvider();
974-
975- static QUrl toURL(const QFileInfo& file);
976-
977- virtual QImage requestImage(const QString& id, QSize* size,
978- const QSize& requestedSize);
979-
980- void setPreviewManager(PreviewManager* previewManager);
981- void setLogging(bool enableLogging);
982-
983-private:
984- PreviewManager* m_previewManager;
985- bool m_logImageLoading;
986-};
987-
988-#endif // GALLERYTHUMBNAILIMAGEPROVIDER_H
989
990=== removed file 'src/medialoader/preview-manager.cpp'
991--- src/medialoader/preview-manager.cpp 2013-09-04 14:39:39 +0000
992+++ src/medialoader/preview-manager.cpp 1970-01-01 00:00:00 +0000
993@@ -1,423 +0,0 @@
994-/*
995- * Copyright (C) 2012 Canonical Ltd
996- *
997- * This program is free software: you can redistribute it and/or modify
998- * it under the terms of the GNU General Public License version 3 as
999- * published by the Free Software Foundation.
1000- *
1001- * This program is distributed in the hope that it will be useful,
1002- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1003- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1004- * GNU General Public License for more details.
1005- *
1006- * You should have received a copy of the GNU General Public License
1007- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1008- *
1009- * Authors:
1010- * Jim Nelson <jim@yorba.org>
1011- */
1012-
1013-#include "preview-manager.h"
1014-#include "photo-metadata.h"
1015-#include "video-metadata.h"
1016-
1017-// media
1018-#include "media-source.h"
1019-
1020-#include <QCryptographicHash>
1021-#include <QDir>
1022-#include <QImageReader>
1023-#include <QMutexLocker>
1024-
1025-#include <gst/gst.h>
1026-
1027-// FIXME adapt to different sizes. This is fixed size for the demo device
1028-const int PreviewManager::PREVIEW_SIZE = 360; // in pixel
1029-const int PreviewManager::THUMBNAIL_SIZE = 216; // in pixel
1030-const int PreviewManager::PREVIEW_QUALITY = 70;
1031-const char* PreviewManager::PREVIEW_FILE_FORMAT = "JPEG";
1032-const char* PreviewManager::PREVIEW_FILE_EXT = ".jpg";
1033-const QString PreviewManager::PREVIEW_DIR = "preview";
1034-const QString PreviewManager::THUMBNAIL_DIR = "square";
1035-
1036-QMutex PreviewManager::m_createMutex;
1037-
1038-/*!
1039- * \brief PreviewManager::PreviewManager
1040- */
1041-PreviewManager::PreviewManager(const QString &thumbnailDirectory, QObject *parent)
1042- : QObject(parent),
1043- m_thumbnailDir(thumbnailDirectory)
1044-{
1045- if (m_thumbnailDir.right(1) != QDir::separator())
1046- m_thumbnailDir += QDir::separator();
1047-
1048- // create the thumbnail directory if not already present
1049- QDir dir;
1050- dir.mkpath(m_thumbnailDir + PREVIEW_DIR);
1051- dir.mkpath(m_thumbnailDir + THUMBNAIL_DIR);
1052-
1053- gst_init(0, 0);
1054-}
1055-
1056-/*!
1057- * \brief PreviewManager::onMediaAddedRemoved
1058- * \param added
1059- * \param removed
1060- */
1061-void PreviewManager::onMediaAddedRemoved(const QSet<DataObject*>* added,
1062- const QSet<DataObject*>* removed)
1063-{
1064- if (added != NULL) {
1065- DataObject* object;
1066- foreach (object, *added) {
1067- MediaSource* source = qobject_cast<MediaSource*>(object);
1068-
1069- QObject::connect(source, SIGNAL(dataChanged()),
1070- this, SLOT(updatePreview()), Qt::UniqueConnection);
1071- }
1072- }
1073-
1074- if (removed != NULL) {
1075- DataObject* object;
1076- foreach (object, *removed) {
1077- MediaSource* source = qobject_cast<MediaSource*>(object);
1078- QObject::disconnect(source, SIGNAL(dataChanged()),
1079- this, SLOT(updatePreview()));
1080- }
1081- }
1082-}
1083-
1084-/*!
1085- * \brief PreviewManager::onMediaDestroying
1086- * \param destroying
1087- */
1088-void PreviewManager::onMediaDestroying(const QSet<DataObject*>* destroying)
1089-{
1090- if (destroying != NULL) {
1091- DataObject* object;
1092- foreach (object, *destroying)
1093- destroyPreviews(qobject_cast<MediaSource*>(object));
1094- }
1095-}
1096-
1097-/*!
1098- * \brief PreviewManager::updatePreview
1099- */
1100-void PreviewManager::updatePreview()
1101-{
1102- QObject* object = QObject::sender();
1103- MediaSource* source = qobject_cast<MediaSource*>(object);
1104-
1105- ensurePreview(source->file(), true);
1106-}
1107-
1108-/*!
1109- * \brief PreviewManager::previewFileName
1110- * \param file
1111- * \return
1112- */
1113-QString PreviewManager::previewFileName(const QFileInfo& file) const
1114-{
1115- return thumbnailFileName(file.canonicalFilePath(), PREVIEW_DIR);
1116-}
1117-
1118-/*!
1119- * \brief PreviewManager::thumbnailFileName
1120- * \param file
1121- * \return
1122- */
1123-QString PreviewManager::thumbnailFileName(const QFileInfo& file) const
1124-{
1125- return thumbnailFileName(file.canonicalFilePath(), THUMBNAIL_DIR);
1126-}
1127-
1128-/*!
1129- * \brief PreviewManager::ensurePreview
1130- * \param file
1131- * \param regen
1132- * \return
1133- */
1134-bool PreviewManager::ensurePreview(QFileInfo file, bool regen)
1135-{
1136- QMutexLocker locker(&m_createMutex);
1137-
1138- // If preview file exists, considered valid (unless we're regenerating it).
1139- QString preview = previewFileName(file);
1140- QString thumbnail = thumbnailFileName(file);
1141-
1142- QImage thumbMaster;
1143- if (updateNeeded(file, QFileInfo(preview)) || regen) {
1144- QSize previewSize(PREVIEW_SIZE, PREVIEW_SIZE);
1145- QImage fullsized;
1146- if (file.suffix().compare("mp4", Qt::CaseInsensitive) == 0) {
1147- fullsized = grabVideoThumbnail(file.canonicalFilePath());
1148- } else {
1149- fullsized = loadPhoto(file.canonicalFilePath(), previewSize);
1150- }
1151- if (fullsized.isNull()) {
1152- qDebug() << "Unable to generate fullsized image for " << file.filePath()
1153- << "not generating preview";
1154- return false;
1155- }
1156-
1157- fullsized.setText("Thumb::URI", QUrl::fromLocalFile(file.canonicalFilePath()).toEncoded());
1158- // scale the preview so it will fill the viewport specified by PREVIEW_*_MAX
1159- // these values are replicated in the QML so that the preview will fill each
1160- // grid cell, cropping down to the center of the image if necessary
1161- QImage scaled = (fullsized.height() > fullsized.width())
1162- ? fullsized.scaledToWidth(PREVIEW_SIZE, Qt::SmoothTransformation)
1163- : fullsized.scaledToHeight(PREVIEW_SIZE, Qt::SmoothTransformation);
1164-
1165- if (scaled.isNull()) {
1166- qDebug() << "Unable to scale " << file.filePath() << "for preview";
1167- return false;
1168- }
1169-
1170- if (!saveThumbnail(scaled, preview)) {
1171- qDebug("Unable to save preview %s", qPrintable(preview));
1172- return false;
1173- }
1174- thumbMaster = scaled;
1175- }
1176-
1177- if (updateNeeded(file, QFileInfo(thumbnail)) || regen) {
1178- if (thumbMaster.isNull()) {
1179- thumbMaster.load(preview);
1180- if (thumbMaster.isNull()) {
1181- qDebug("Unable load preview image for %s, not generating thumbnail",
1182- qPrintable(preview));
1183- return false;
1184- }
1185- }
1186-
1187- QImage square = generateThumbnail(thumbMaster);
1188- if (!saveThumbnail(square, thumbnail)) {
1189- qDebug("Unable to save preview %s", qPrintable(thumbnail));
1190- return false;
1191- }
1192- }
1193-
1194- return true;
1195-}
1196-
1197-/*!
1198- * \brief PreviewManager::saveThumbnail saves the thumbnail in a safe way
1199- * The image is written to a temporary file, and then moved (the move is atomic)
1200- * \param image thumbnail to save
1201- * \param fileName filename of the thumbnail
1202- * \return true, if saving the file was successful
1203- */
1204-bool PreviewManager::saveThumbnail(const QImage &image, const QString &fileName) const
1205-{
1206- QString temporaryName(fileName+".tmp");
1207- bool ok;
1208- ok = image.save(temporaryName, PREVIEW_FILE_FORMAT, PREVIEW_QUALITY);
1209- if (!ok) {
1210- qWarning() << "Unanble to save the thumbnail" << temporaryName;
1211- return false;
1212- }
1213-
1214- if (QFile::exists(fileName)) {
1215- QFile::remove(fileName);
1216- }
1217-
1218- QFile thumbnail(temporaryName);
1219- return thumbnail.rename(fileName);
1220-}
1221-
1222-/*!
1223- * \brief PreviewManager::destroyPreviews
1224- * \param media
1225- */
1226-void PreviewManager::destroyPreviews(MediaSource* media)
1227-{
1228- QString filename = previewFileName(media->file());
1229- if (!QFile::remove(filename))
1230- qDebug("Unable to remove preview %s", qPrintable(filename));
1231- filename = thumbnailFileName(media->file());
1232- if (!QFile::remove(filename))
1233- qDebug("Unable to remove thumbnail %s", qPrintable(filename));
1234-}
1235-
1236-/*!
1237- * \brief PreviewManager::generateThumbnail
1238- * \param master
1239- * \return
1240- */
1241-QImage PreviewManager::generateThumbnail(const QImage &master) const
1242-{
1243- int xOffset = 0;
1244- int yOffset = 0;
1245- int size = 0;
1246- if (master.width() > master.height()) {
1247- size = master.height();
1248- xOffset = (master.width() - size) / 2;
1249- } else {
1250- size = master.width();
1251- yOffset = (master.height() - size) / 2;
1252- }
1253- QImage square = master.copy(xOffset, yOffset, size, size);
1254-
1255- QImage thumbnail = square.scaled(THUMBNAIL_SIZE, THUMBNAIL_SIZE);
1256- return thumbnail;
1257-}
1258-
1259-/*!
1260- * \brief PreviewManager::thumbnailFileName generates the file name for a given
1261- * file and it's level (size/type)
1262- * \param fileName full filename URI (file:///directory/file.name.png)
1263- * \param levelName correclates to the sub directory inside of the thumbnail directory
1264- * \return full filePath of the thumbnail
1265- */
1266-QString PreviewManager::thumbnailFileName(const QString &fileName,
1267- const QString &levelName) const
1268-{
1269- QCryptographicHash md5(QCryptographicHash::Md5);
1270- md5.addData(QUrl::fromLocalFile(fileName).toEncoded());
1271- QString previewDir = m_thumbnailDir + levelName + QDir::separator();
1272- return QString(previewDir + md5.result().toHex() + PREVIEW_FILE_EXT);
1273-}
1274-
1275-/*!
1276- * \brief PreviewManager::updateNeeded checks if the thumbnail needs to be (re-)created
1277- * \param mediaFile the original photo/video
1278- * \param previewFile the preview file
1279- * \return true if the thumbnail needs to be created
1280- */
1281-bool PreviewManager::updateNeeded(const QFileInfo &mediaFile, const QFileInfo &previewFile) const
1282-{
1283- if (!previewFile.exists())
1284- return true;
1285-
1286- return mediaFile.lastModified() > previewFile.lastModified();
1287-}
1288-
1289-/*!
1290- * \brief PreviewManager::loadPhoto load a photo with correct orientation
1291- * The size can be limited as well, to speed upt the loading
1292- * \param fileName file name of the photo
1293- * \param maxSize limits the size, so that one side fits into maxSize. If an
1294- * invalid size is passed, the image is loaded in full size.
1295- * \return the photo corrctly sized and oriented
1296- */
1297-QImage PreviewManager::loadPhoto(const QString &fileName, const QSize& maxSize) const
1298-{
1299- QImageReader imageReader(fileName);
1300-
1301- QSize imageSize = imageReader.size();
1302- if (maxSize.isValid()) {
1303- QSize size = imageSize;
1304- size.scale(maxSize, Qt::KeepAspectRatioByExpanding);
1305- imageReader.setScaledSize(size);
1306- }
1307-
1308- QImage image = imageReader.read();
1309- if (!image.isNull()) {
1310- PhotoMetadata* metadata = PhotoMetadata::fromFile(fileName.toStdString().c_str());
1311- image = image.transformed(
1312- OrientationCorrection::fromOrientation(metadata->orientation())
1313- .toTransform());
1314- delete metadata;
1315- } else {
1316- qWarning() << "Could not load the image" << fileName << "for thumbnail generation";
1317- }
1318-
1319- return image;
1320-}
1321-
1322-/*!
1323- * \brief destroyFrameData cleanup function for the video thumbnail QImage
1324- * \param data
1325- */
1326-static void destroyFrameData (void *data)
1327-{
1328- gst_buffer_unref(GST_BUFFER (data));
1329-}
1330-
1331-/*!
1332- * \brief PreviewManager::grabVideoThumbnail grabs a frame from the given video file
1333- * \param fileName
1334- * \return
1335- */
1336-QImage PreviewManager::grabVideoThumbnail(const QString &fileName) const
1337-{
1338- QUrl url("file://"+fileName);
1339- gchar *guri = g_strdup(url.toString().toUtf8().data());
1340-
1341- GstElement *asink;
1342- GstElement *vsink;
1343-
1344- GstElement *pipeline = gst_element_factory_make("playbin2", "play");
1345- GstCaps *caps = gst_caps_new_simple("video/x-raw-rgb",
1346- "bpp", G_TYPE_INT, 24,
1347- "depth", G_TYPE_INT, 24,
1348- "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
1349- "endianness", G_TYPE_INT, G_BIG_ENDIAN,
1350- "red_mask", G_TYPE_INT, 0xff0000,
1351- "green_mask", G_TYPE_INT, 0x00ff00,
1352- "blue_mask", G_TYPE_INT, 0x0000ff,
1353- NULL);
1354- asink = gst_element_factory_make("fakesink", "audio-fake-sink");
1355- vsink = gst_element_factory_make("fakesink", "video-fake-sink");
1356- g_object_set(vsink, "sync", TRUE, NULL);
1357- g_object_set(pipeline,
1358- "flags", 0x00000001, // Make sure to render only the video stream (we do not need audio here)
1359- "audio-sink", asink,
1360- "video-sink", vsink,
1361- NULL);
1362-
1363- g_object_set(pipeline, "uri", guri, NULL);
1364- GstStateChangeReturn ret = gst_element_set_state(pipeline, GST_STATE_PAUSED);
1365- switch (ret)
1366- {
1367- case GST_STATE_CHANGE_FAILURE:
1368- qWarning() << "Fail to start thumbnail pipeline";
1369- return QImage();
1370- case GST_STATE_CHANGE_NO_PREROLL:
1371- qWarning() << "Thumbnail not supported for live sources";
1372- return QImage();
1373- default:
1374- break;
1375- }
1376-
1377- gst_element_seek(pipeline, 1.0,
1378- GST_FORMAT_TIME, static_cast<GstSeekFlags>(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT),
1379- GST_SEEK_TYPE_SET, 100 * GST_MSECOND,
1380- GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
1381- /* And wait for this seek to complete */
1382- gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
1383-
1384- GstBuffer *buf = 0;
1385- g_signal_emit_by_name(pipeline, "convert-frame", caps, &buf);
1386-
1387- QImage thumb;
1388- if (buf && GST_BUFFER_CAPS(buf)) {
1389- gint width, height;
1390- GstStructure *s = gst_caps_get_structure(GST_BUFFER_CAPS (buf), 0);
1391- gboolean res = gst_structure_get_int(s, "width", &width);
1392- res |= gst_structure_get_int (s, "height", &height);
1393- if (!res) {
1394- qWarning() << "could not get snapshot dimension";
1395- return QImage();
1396- }
1397-
1398- thumb = QImage(GST_BUFFER_DATA(buf), width, height, QImage::Format_RGB888, destroyFrameData, buf);
1399- }
1400-
1401- gst_caps_unref(caps);
1402- gst_element_set_state(pipeline, GST_STATE_NULL);
1403- gst_object_unref(pipeline);
1404- g_free(guri);
1405-
1406- VideoMetadata metadata;
1407- metadata.parseMetadata(QFileInfo(fileName));
1408- int rotation = metadata.rotation();
1409- if (rotation != 0) {
1410- QTransform transform;
1411- transform.rotate(rotation);
1412- thumb = thumb.transformed(transform);
1413- }
1414-
1415- return thumb;
1416-}
1417
1418=== removed file 'src/medialoader/preview-manager.h'
1419--- src/medialoader/preview-manager.h 2013-08-12 08:51:09 +0000
1420+++ src/medialoader/preview-manager.h 1970-01-01 00:00:00 +0000
1421@@ -1,87 +0,0 @@
1422-/*
1423- * Copyright (C) 2012 Canonical Ltd
1424- *
1425- * This program is free software: you can redistribute it and/or modify
1426- * it under the terms of the GNU General Public License version 3 as
1427- * published by the Free Software Foundation.
1428- *
1429- * This program is distributed in the hope that it will be useful,
1430- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1431- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1432- * GNU General Public License for more details.
1433- *
1434- * You should have received a copy of the GNU General Public License
1435- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1436- *
1437- * Authors:
1438- * Jim Nelson <jim@yorba.org>
1439- */
1440-
1441-#ifndef GALLERY_PREVIEW_MANAGER_H_
1442-#define GALLERY_PREVIEW_MANAGER_H_
1443-
1444-#include <QFileInfo>
1445-#include <QMutex>
1446-#include <QObject>
1447-#include <QSet>
1448-#include <QSize>
1449-#include <QString>
1450-
1451-class QImage;
1452-class DataObject;
1453-class MediaSource;
1454-
1455-/*!
1456- * \brief The PreviewManager class creates and removes thumbnails
1457- *
1458- * The thumbnail storage and creation is inspired by
1459- * http://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html
1460- * But it uses jpeg (for performance),
1461- * uses different sizes,
1462- * not the standard sub directoy name (because of the sizes),
1463- * does not save any meta information in the thumbnails,
1464- * does not use the fail directory
1465- */
1466-class PreviewManager : public QObject
1467-{
1468- Q_OBJECT
1469-
1470-public:
1471- static const int PREVIEW_SIZE;
1472- static const int THUMBNAIL_SIZE;
1473- static const int PREVIEW_QUALITY;
1474- static const char* PREVIEW_FILE_FORMAT;
1475- static const char* PREVIEW_FILE_EXT;
1476-
1477- static const QString PREVIEW_DIR;
1478- static const QString THUMBNAIL_DIR;
1479-
1480- PreviewManager(const QString& thumbnailDirectory, QObject* parent = 0);
1481-
1482- QString previewFileName(const QFileInfo& file) const;
1483- QString thumbnailFileName(const QFileInfo& file) const;
1484-
1485- bool ensurePreview(QFileInfo file, bool regen = false);
1486-
1487-public slots:
1488- void onMediaAddedRemoved(const QSet<DataObject*>* added,
1489- const QSet<DataObject*>* removed);
1490- void onMediaDestroying(const QSet<DataObject*>* destroying);
1491-
1492-private slots:
1493- void updatePreview();
1494-
1495-private:
1496- bool saveThumbnail(const QImage& image, const QString& fileName) const;
1497- void destroyPreviews(MediaSource* media);
1498- QImage generateThumbnail(const QImage& master) const;
1499- QString thumbnailFileName(const QString& fileName, const QString& levelName) const;
1500- bool updateNeeded(const QFileInfo& mediaFile, const QFileInfo& previewFile) const;
1501- QImage loadPhoto(const QString& fileName, const QSize &maxSize) const;
1502- QImage grabVideoThumbnail(const QString& fileName) const;
1503-
1504- static QMutex m_createMutex;
1505- QString m_thumbnailDir;
1506-};
1507-
1508-#endif // GALLERY_PREVIEW_MANAGER_H_
1509
1510=== modified file 'src/photo/photo-caches.cpp'
1511--- src/photo/photo-caches.cpp 2013-07-05 08:12:31 +0000
1512+++ src/photo/photo-caches.cpp 2014-03-14 23:42:35 +0000
1513@@ -20,6 +20,7 @@
1514 #include "photo-caches.h"
1515
1516 #include <QDir>
1517+#include <utime.h>
1518
1519 const QString PhotoCaches::ORIGINAL_DIR = ".original";
1520 const QString PhotoCaches::ENHANCED_DIR = ".enhanced";
1521@@ -118,6 +119,8 @@
1522 }
1523
1524 remove(m_file);
1525+ // touch the file so that the thumbnails will correctly regenerate
1526+ utime(m_originalFile.absoluteFilePath().toUtf8(), NULL);
1527 return rename(m_originalFile, m_file);
1528 }
1529
1530
1531=== modified file 'src/photo/photo.cpp'
1532--- src/photo/photo.cpp 2013-07-26 16:06:14 +0000
1533+++ src/photo/photo.cpp 2014-03-14 23:42:35 +0000
1534@@ -35,7 +35,6 @@
1535
1536 // medialoader
1537 #include "gallery-standard-image-provider.h"
1538-#include "gallery-thumbnail-image-provider.h"
1539 #include "photo-metadata.h"
1540
1541 // util
1542@@ -274,12 +273,7 @@
1543 */
1544 QUrl Photo::galleryPreviewPath() const
1545 {
1546- QUrl url = MediaSource::galleryPreviewPath();
1547- // previews are always stored fully transformed
1548-
1549- appendPathParams(&url, TOP_LEFT_ORIGIN, 1);
1550-
1551- return url;
1552+ return MediaSource::galleryPreviewPath();
1553 }
1554
1555 /*!
1556@@ -287,16 +281,7 @@
1557 */
1558 QUrl Photo::galleryThumbnailPath() const
1559 {
1560- QUrl url = MediaSource::galleryThumbnailPath();
1561- // same as in append_path_params() this is needed to trigger an update of the image in QML
1562- // so the URL is changed by adding/chageing the edit parameter
1563- QUrlQuery query;
1564- if (m_editRevision != 0) {
1565- query.addQueryItem(GalleryThumbnailImageProvider::REVISION_PARAM_NAME,
1566- QString::number(m_editRevision));
1567- }
1568- url.setQuery(query);
1569- return url;
1570+ return MediaSource::galleryThumbnailPath();
1571 }
1572
1573 /*!
1574
1575=== modified file 'src/video/video.cpp'
1576--- src/video/video.cpp 2013-08-12 08:51:09 +0000
1577+++ src/video/video.cpp 2014-03-14 23:42:35 +0000
1578@@ -56,8 +56,9 @@
1579 */
1580 bool Video::isCameraVideo(const QFileInfo &file)
1581 {
1582- if (file.suffix() == QLatin1String("mp4") &&
1583- file.baseName().startsWith("video")) {
1584+ QMimeDatabase mimedb;
1585+ QMimeType mimeType = mimedb.mimeTypeForFile(file);
1586+ if (mimeType.name().contains("video")) {
1587 return true;
1588 }
1589
1590
1591=== added file 'tests/autopilot/gallery_app/data/option01/clip_0001.mkv'
1592Binary 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-14 23:42:35 +0000 differ
1593=== modified file 'tests/autopilot/gallery_app/tests/__init__.py'
1594--- tests/autopilot/gallery_app/tests/__init__.py 2014-03-07 10:57:54 +0000
1595+++ tests/autopilot/gallery_app/tests/__init__.py 2014-03-14 23:42:35 +0000
1596@@ -320,9 +320,12 @@
1597 video_file = "video20130618_0002.mp4"
1598 shutil.copyfile(self.sample_dir+"/option01/"+video_file,
1599 self.sample_destination_dir+"/"+video_file)
1600+ video_file = "clip_0001.mkv"
1601+ shutil.copyfile(self.sample_dir+"/option01/"+video_file,
1602+ self.sample_destination_dir+"/"+video_file)
1603 self.assertThat(
1604 lambda: self.gallery_utils.number_of_photos_in_events(),
1605- Eventually(Equals(3)))
1606+ Eventually(Equals(4)))
1607
1608 def get_delete_dialog(self):
1609 """Raises StateNotFoundError if get_delete_dialog fails."""
1610
1611=== modified file 'tests/autopilot/gallery_app/tests/test_albums_view.py'
1612--- tests/autopilot/gallery_app/tests/test_albums_view.py 2013-08-09 13:55:35 +0000
1613+++ tests/autopilot/gallery_app/tests/test_albums_view.py 2014-03-14 23:42:35 +0000
1614@@ -11,14 +11,16 @@
1615 from __future__ import absolute_import
1616
1617 from testtools.matchers import Equals
1618+from autopilot.platform import model
1619
1620 from gallery_app.tests import GalleryTestCase
1621 from gallery_app.emulators.albums_view import AlbumsView
1622
1623 from time import sleep
1624-
1625+from os import environ as env
1626
1627 class TestAlbumsView(GalleryTestCase):
1628+ envDesktopMode = None
1629
1630 @property
1631 def albums_view(self):
1632@@ -26,9 +28,25 @@
1633
1634 def setUp(self):
1635 self.ARGS = []
1636+
1637+ self.envDesktopMode = env.get("DESKTOP_MODE")
1638+
1639+ if model() == "Desktop":
1640+ env["DESKTOP_MODE"] = "1"
1641+ else:
1642+ env["DESKTOP_MODE"] = "0"
1643+
1644 super(TestAlbumsView, self).setUp()
1645 self.switch_to_albums_tab()
1646
1647+ def tearDown(self):
1648+ if self.envDesktopMode:
1649+ env["DESKTOP_MODE"] = self.envDesktopMode
1650+ else:
1651+ del env["DESKTOP_MODE"]
1652+
1653+ super(TestAlbumsView, self).tearDown()
1654+
1655 def compare_number_of_albums(self, target):
1656 """Test if the number of albums is correct. For robustness (timing
1657 issues), the test is repeated after one second in case it fails"""
1658@@ -44,3 +62,13 @@
1659 self.compare_number_of_albums(1)
1660 self.main_view.open_toolbar().click_button("addButton")
1661 self.compare_number_of_albums(2)
1662+
1663+ # Check if Camera Button is not visible at Desktop mode
1664+ def test_camera_button_visible(self):
1665+ self.main_view.open_toolbar()
1666+ toolbar = self.main_view.get_toolbar()
1667+ cameraButton = toolbar.select_single("ActionItem", objectName="cameraButton")
1668+ if model() == "Desktop":
1669+ self.assertThat(cameraButton.visible, Equals(False))
1670+ else:
1671+ self.assertThat(cameraButton.visible, Equals(True))
1672
1673=== modified file 'tests/autopilot/gallery_app/tests/test_events_view.py'
1674--- tests/autopilot/gallery_app/tests/test_events_view.py 2013-10-30 05:01:48 +0000
1675+++ tests/autopilot/gallery_app/tests/test_events_view.py 2014-03-14 23:42:35 +0000
1676@@ -12,22 +12,37 @@
1677
1678 from testtools.matchers import Equals, Is
1679 from autopilot.matchers import Eventually
1680+from autopilot.platform import model
1681
1682 from gallery_app.tests import GalleryTestCase
1683
1684 from os.path import exists
1685-
1686+from os import environ as env
1687
1688 class TestEventsView(GalleryTestCase):
1689 """Tests the main gallery features"""
1690+ envDesktopMode = None
1691
1692 def setUp(self):
1693 self.ARGS = []
1694+
1695+ self.envDesktopMode = env.get("DESKTOP_MODE")
1696+
1697+ if model() == "Desktop":
1698+ env["DESKTOP_MODE"] = "1"
1699+ else:
1700+ env["DESKTOP_MODE"] = "0"
1701+
1702 # This is needed to wait for the application to start.
1703 # In the testfarm, the application may take some time to show up.
1704 super(TestEventsView, self).setUp()
1705
1706 def tearDown(self):
1707+ if self.envDesktopMode:
1708+ env["DESKTOP_MODE"] = self.envDesktopMode
1709+ else:
1710+ del env["DESKTOP_MODE"]
1711+
1712 super(TestEventsView, self).tearDown()
1713
1714 def get_events_view(self):
1715@@ -102,3 +117,13 @@
1716
1717 def test_adding_a_video(self):
1718 self.add_video_sample()
1719+
1720+ # Check if Camera Button is not visible at Desktop mode
1721+ def test_camera_button_visible(self):
1722+ self.main_view.open_toolbar()
1723+ toolbar = self.main_view.get_toolbar()
1724+ cameraButton = toolbar.select_single("ActionItem", objectName="cameraButton")
1725+ if model() == "Desktop":
1726+ self.assertThat(cameraButton.visible, Equals(False))
1727+ else:
1728+ self.assertThat(cameraButton.visible, Equals(True))
1729
1730=== modified file 'tests/autopilot/gallery_app/tests/test_photo_viewer.py'
1731--- tests/autopilot/gallery_app/tests/test_photo_viewer.py 2014-02-05 11:15:13 +0000
1732+++ tests/autopilot/gallery_app/tests/test_photo_viewer.py 2014-03-14 23:42:35 +0000
1733@@ -261,8 +261,8 @@
1734 # wait for new photo being set/reloaded, so saving thumbnailing etc.
1735 # is done
1736 edit_preview = self.photo_viewer.get_edit_preview()
1737- new_source = "image://gallery-standard/" + self.sample_file + \
1738- "?size_level=1&orientation=1&edit=2"
1739+ new_source = "image://thumbnailer/" + self.sample_file
1740+
1741 self.assertThat(edit_preview.source, Eventually(Equals(new_source)))
1742
1743 new_file_size = os.path.getsize(self.sample_file)
1744
1745=== modified file 'tests/autopilot/gallery_app/tests/test_photos_view.py'
1746--- tests/autopilot/gallery_app/tests/test_photos_view.py 2014-02-14 10:43:17 +0000
1747+++ tests/autopilot/gallery_app/tests/test_photos_view.py 2014-03-14 23:42:35 +0000
1748@@ -19,8 +19,7 @@
1749 from gallery_app.emulators.photos_view import PhotosView
1750
1751 from os.path import exists
1752-from os import environ
1753-
1754+from os import environ as env
1755 import unittest
1756
1757 class TestPhotosView(GalleryTestCase):
1758@@ -32,21 +31,21 @@
1759
1760 def setUp(self):
1761 self.ARGS = []
1762- self.envDesktopMode = environ.get("DESKTOP_MODE")
1763+ self.envDesktopMode = env.get("DESKTOP_MODE")
1764
1765 if model() == "Desktop":
1766- environ["DESKTOP_MODE"] = "1"
1767+ env["DESKTOP_MODE"] = "1"
1768 else:
1769- environ["DESKTOP_MODE"] = "0"
1770+ env["DESKTOP_MODE"] = "0"
1771
1772 super(TestPhotosView, self).setUp()
1773 self.switch_to_photos_tab()
1774
1775 def tearDown(self):
1776 if self.envDesktopMode:
1777- environ["DESKTOP_MODE"] = self.envDesktopMode
1778+ env["DESKTOP_MODE"] = self.envDesktopMode
1779 else:
1780- del environ["DESKTOP_MODE"]
1781+ del env["DESKTOP_MODE"]
1782
1783 super(TestPhotosView, self).tearDown()
1784
1785@@ -152,3 +151,13 @@
1786 self.assertThat(view.fullScreen, Eventually(Equals(False)))
1787 self.keyboard.press_and_release('Escape')
1788 self.assertThat(view.fullScreen, Eventually(Equals(False)))
1789+
1790+ # Check if Camera Button is not visible at Desktop mode
1791+ def test_camera_button_visible(self):
1792+ self.main_view.open_toolbar()
1793+ toolbar = self.main_view.get_toolbar()
1794+ cameraButton = toolbar.select_single("ActionItem", objectName="cameraButton")
1795+ if model() == "Desktop":
1796+ self.assertThat(cameraButton.visible, Equals(False))
1797+ else:
1798+ self.assertThat(cameraButton.visible, Equals(True))
1799
1800=== modified file 'tests/unittests/CMakeLists.txt'
1801--- tests/unittests/CMakeLists.txt 2013-06-14 17:59:27 +0000
1802+++ tests/unittests/CMakeLists.txt 2014-03-14 23:42:35 +0000
1803@@ -1,7 +1,7 @@
1804 add_subdirectory(command-line-parser)
1805 add_subdirectory(gallerystandardimageprovider)
1806-add_subdirectory(gallerythumbnailimageprovider)
1807 add_subdirectory(imaging)
1808+add_subdirectory(mediamonitor)
1809 add_subdirectory(mediaobjectfactory)
1810 add_subdirectory(resource)
1811 add_subdirectory(video)
1812
1813=== modified file 'tests/unittests/gallerystandardimageprovider/CMakeLists.txt'
1814--- tests/unittests/gallerystandardimageprovider/CMakeLists.txt 2013-12-16 21:49:56 +0000
1815+++ tests/unittests/gallerystandardimageprovider/CMakeLists.txt 2014-03-14 23:42:35 +0000
1816@@ -14,7 +14,6 @@
1817 )
1818
1819 QT5_WRAP_CPP(GALLERYSTANDARDIMAGEPROVIDIER_MOCS
1820- ${gallery_medialoader_src_SOURCE_DIR}/preview-manager.h
1821 ${gallery_medialoader_src_SOURCE_DIR}/photo-metadata.h
1822 )
1823
1824@@ -22,7 +21,6 @@
1825 tst_gallerystandardimageprovidertest.cpp
1826 ${gallery_src_SOURCE_DIR}/medialoader/gallery-standard-image-provider.cpp
1827 ../stubs/orientation_stub.cpp
1828- ../stubs/preview-manager_stub.cpp
1829 ../stubs/photometa-data_stub.cpp
1830 ${GALLERYSTANDARDIMAGEPROVIDIER_MOCS}
1831 )
1832
1833=== modified file 'tests/unittests/gallerystandardimageprovider/tst_gallerystandardimageprovidertest.cpp'
1834--- tests/unittests/gallerystandardimageprovider/tst_gallerystandardimageprovidertest.cpp 2013-07-03 11:53:48 +0000
1835+++ tests/unittests/gallerystandardimageprovider/tst_gallerystandardimageprovidertest.cpp 2014-03-14 23:42:35 +0000
1836@@ -24,7 +24,6 @@
1837 #include <QUrl>
1838
1839 #include "gallery-standard-image-provider.h"
1840-#include "preview-manager.h"
1841 #include "media-collection.h"
1842
1843 class tst_GalleryStandardImageProvider : public QObject
1844@@ -63,8 +62,6 @@
1845
1846 QTest::newRow("FullSize") << "/home/user/Pictures/logo.jpg?size_level=0&orientation=1" <<
1847 "/home/user/Pictures/logo.jpg";
1848- QTest::newRow("Thumbnail") << "/home/user/Pictures/logo.jpg?size_level=1&orientation=1" <<
1849- "/home/user/Pictures/.thumbs/logo_th.JPG";
1850 }
1851
1852 void tst_GalleryStandardImageProvider::idToFile()
1853@@ -72,9 +69,7 @@
1854 QFETCH(QString, id);
1855 QFETCH(QString, fileName);
1856
1857- PreviewManager previewManager("/home/user/thumbnails");
1858 GalleryStandardImageProvider provider;
1859- provider.setPreviewManager(&previewManager);
1860 QCOMPARE(provider.idToFile(id), fileName);
1861 }
1862
1863
1864=== removed directory 'tests/unittests/gallerythumbnailimageprovider'
1865=== removed file 'tests/unittests/gallerythumbnailimageprovider/CMakeLists.txt'
1866--- tests/unittests/gallerythumbnailimageprovider/CMakeLists.txt 2013-12-16 21:49:56 +0000
1867+++ tests/unittests/gallerythumbnailimageprovider/CMakeLists.txt 1970-01-01 00:00:00 +0000
1868@@ -1,34 +0,0 @@
1869-add_definitions(-DTEST_SUITE)
1870-
1871-if(NOT CTEST_TESTING_TIMEOUT)
1872- set(CTEST_TESTING_TIMEOUT 60)
1873-endif()
1874-
1875-include_directories(
1876- ${gallery_core_src_SOURCE_DIR}
1877- ${gallery_media_src_SOURCE_DIR}
1878- ${gallery_medialoader_src_SOURCE_DIR}
1879- ${gallery_util_src_SOURCE_DIR}
1880- ${CMAKE_BINARY_DIR}
1881- )
1882-
1883-QT5_WRAP_CPP(GALLERYTHUMBNAILIMAGEPROVIDIER_MOCS
1884- ${gallery_medialoader_src_SOURCE_DIR}/preview-manager.h
1885- )
1886-
1887-add_executable(gallerythumbnailimageprovider
1888- tst_gallerythumbnailimageprovider.cpp
1889- ../stubs/preview-manager_stub.cpp
1890- ${gallery_src_SOURCE_DIR}/medialoader/gallery-thumbnail-image-provider.cpp
1891- ${GALLERYTHUMBNAILIMAGEPROVIDIER_MOCS}
1892- )
1893-
1894-qt5_use_modules(gallerythumbnailimageprovider Quick Test)
1895-add_test(gallerythumbnailimageprovider gallerythumbnailimageprovider
1896- -xunitxml -o test_gallerythumbnailimageprovider.xml
1897- )
1898-set_tests_properties(gallerythumbnailimageprovider PROPERTIES
1899- TIMEOUT ${CTEST_TESTING_TIMEOUT}
1900- ENVIRONMENT "QT_QPA_PLATFORM=minimal"
1901- )
1902-
1903
1904=== removed file 'tests/unittests/gallerythumbnailimageprovider/tst_gallerythumbnailimageprovider.cpp'
1905--- tests/unittests/gallerythumbnailimageprovider/tst_gallerythumbnailimageprovider.cpp 2013-06-10 06:20:05 +0000
1906+++ tests/unittests/gallerythumbnailimageprovider/tst_gallerythumbnailimageprovider.cpp 1970-01-01 00:00:00 +0000
1907@@ -1,54 +0,0 @@
1908-/*
1909- * Copyright (C) 2012 Canonical, Ltd.
1910- *
1911- * Authors:
1912- * Guenter Schwann <guenter.schwann@canonical.com>
1913- *
1914- * This program is free software; you can redistribute it and/or modify
1915- * it under the terms of the GNU General Public License as published by
1916- * the Free Software Foundation; version 3.
1917- *
1918- * This program is distributed in the hope that it will be useful,
1919- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1920- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1921- * GNU General Public License for more details.
1922- *
1923- * You should have received a copy of the GNU General Public License
1924- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1925- */
1926-
1927-#include <QtTest/QtTest>
1928-#include <QFileInfo>
1929-#include <QUrl>
1930-
1931-#include "gallery-thumbnail-image-provider.h"
1932-
1933-class tst_GalleryThumbnailImageProvider : public QObject
1934-{
1935- Q_OBJECT
1936-public:
1937- tst_GalleryThumbnailImageProvider();
1938-
1939-private slots:
1940- void ToURL();
1941-
1942-private:
1943- GalleryThumbnailImageProvider gallery_thumbnail_image_provider;
1944-};
1945-
1946-tst_GalleryThumbnailImageProvider::tst_GalleryThumbnailImageProvider()
1947- : gallery_thumbnail_image_provider()
1948-{
1949-}
1950-
1951-void tst_GalleryThumbnailImageProvider::ToURL()
1952-{
1953- QFileInfo fi("/tmp/test.jpg");
1954- QUrl url = gallery_thumbnail_image_provider.toURL(fi);
1955- QUrl expect("image://gallery-thumbnail//tmp/test.jpg");
1956- QCOMPARE(url, expect);
1957-}
1958-
1959-QTEST_MAIN(tst_GalleryThumbnailImageProvider);
1960-
1961-#include "tst_gallerythumbnailimageprovider.moc"
1962
1963=== added directory 'tests/unittests/mediamonitor'
1964=== added file 'tests/unittests/mediamonitor/CMakeLists.txt'
1965--- tests/unittests/mediamonitor/CMakeLists.txt 1970-01-01 00:00:00 +0000
1966+++ tests/unittests/mediamonitor/CMakeLists.txt 2014-03-14 23:42:35 +0000
1967@@ -0,0 +1,36 @@
1968+add_definitions(-DTEST_SUITE)
1969+
1970+if(NOT CTEST_TESTING_TIMEOUT)
1971+ set(CTEST_TESTING_TIMEOUT 60)
1972+endif()
1973+
1974+include_directories(
1975+ ${gallery_media_src_SOURCE_DIR}
1976+ ${gallery_core_src_SOURCE_DIR}
1977+ ${gallery_util_src_SOURCE_DIR}
1978+ ${gallery_medialoader_src_SOURCE_DIR}
1979+ ${gallery_database_src_SOURCE_DIR}
1980+ ${gallery_album_src_SOURCE_DIR}
1981+ ${gallery_src_SOURCE_DIR}
1982+ ${CMAKE_BINARY_DIR}
1983+ )
1984+
1985+add_executable(mediamonitor tst_mediamonitor.cpp)
1986+
1987+qt5_use_modules(mediamonitor Quick Test)
1988+
1989+add_test(mediamonitor mediamonitor -xunitxml -o test_mediamonitor.xml)
1990+
1991+set_tests_properties(mediamonitor PROPERTIES
1992+ TIMEOUT ${CTEST_TESTING_TIMEOUT}
1993+ ENVIRONMENT "QT_QPA_PLATFORM=minimal"
1994+ )
1995+
1996+target_link_libraries(mediamonitor
1997+ gallery-util
1998+ gallery-media
1999+ gallery-core
2000+ gallery-medialoader
2001+ gallery-database
2002+ gallery-album
2003+ )
2004
2005=== added file 'tests/unittests/mediamonitor/tst_mediamonitor.cpp'
2006--- tests/unittests/mediamonitor/tst_mediamonitor.cpp 1970-01-01 00:00:00 +0000
2007+++ tests/unittests/mediamonitor/tst_mediamonitor.cpp 2014-03-14 23:42:35 +0000
2008@@ -0,0 +1,88 @@
2009+/* * Copyright (C) 2014 Canonical, Ltd. *
2010+ * This program is free software; you can redistribute it and/or modify
2011+ * it under the terms of the GNU General Public License as published by
2012+ * the Free Software Foundation; version 3.
2013+ *
2014+ * This program is distributed in the hope that it will be useful,
2015+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2016+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2017+ * GNU General Public License for more details.
2018+ *
2019+ * You should have received a copy of the GNU General Public License
2020+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2021+ *
2022+ */
2023+
2024+#include <QtTest>
2025+
2026+#include <QDir>
2027+#include <QTemporaryDir>
2028+#include <QImage>
2029+#include <QColor>
2030+#include <QStringList>
2031+
2032+#include "media-monitor.h"
2033+
2034+class tst_MediaMonitor : public QObject
2035+{
2036+ Q_OBJECT
2037+
2038+private slots:
2039+ void initTestCase();
2040+ void tst_scanning_sub_folders();
2041+ void cleanupTestCase();
2042+
2043+private:
2044+ QTemporaryDir *m_tmpDir;
2045+ QImage *m_sampleImage;
2046+ MediaMonitor *m_monitor;
2047+};
2048+
2049+void tst_MediaMonitor::initTestCase()
2050+{
2051+ m_tmpDir = new QTemporaryDir();
2052+
2053+ // Create a simple directories tree
2054+ QDir *dir = new QDir(m_tmpDir->path());
2055+ dir->mkpath("A/A");
2056+ dir->mkpath("A/B");
2057+ dir->mkpath("B/A");
2058+ dir->mkpath("B/B");
2059+
2060+ // Create sample image
2061+ m_sampleImage = new QImage(400, 600, QImage::Format_RGB32);
2062+ m_sampleImage->fill(QColor(Qt::red));
2063+}
2064+
2065+void tst_MediaMonitor::tst_scanning_sub_folders()
2066+{
2067+ // Create a Media Monitor
2068+ m_monitor = new MediaMonitor();
2069+
2070+ // Launch the monitoring process
2071+ m_monitor->startMonitoring(QStringList(m_tmpDir->path()));
2072+
2073+ // Save sample image allover the tree
2074+ m_sampleImage->save(m_tmpDir->path() + "/A/A/sample_AA.jpg", "JPG");
2075+ m_sampleImage->save(m_tmpDir->path() + "/A/B/sample_AB.jpg", "JPG");
2076+ m_sampleImage->save(m_tmpDir->path() + "/B/A/sample_BA.jpg", "JPG");
2077+ m_sampleImage->save(m_tmpDir->path() + "/B/B/sample_BB.jpg", "JPG");
2078+
2079+ m_sampleImage->save(m_tmpDir->path() + "/A/sample_A.jpg", "JPG");
2080+ m_sampleImage->save(m_tmpDir->path() + "/B/sample_B.jpg", "JPG");
2081+
2082+ m_sampleImage->save(m_tmpDir->path() + "/sample.jpg", "JPG");
2083+
2084+ QTRY_COMPARE_WITH_TIMEOUT(m_monitor->manifest().count(), 7, 10000);
2085+}
2086+
2087+void tst_MediaMonitor::cleanupTestCase()
2088+{
2089+ //Remove the previously created files
2090+ QDir *dir = new QDir(m_tmpDir->path());
2091+ dir->removeRecursively();
2092+}
2093+
2094+QTEST_MAIN(tst_MediaMonitor)
2095+
2096+#include "tst_mediamonitor.moc"
2097
2098=== modified file 'tests/unittests/mediaobjectfactory/CMakeLists.txt'
2099--- tests/unittests/mediaobjectfactory/CMakeLists.txt 2013-12-16 21:49:56 +0000
2100+++ tests/unittests/mediaobjectfactory/CMakeLists.txt 2014-03-14 23:42:35 +0000
2101@@ -26,7 +26,6 @@
2102 ${gallery_database_src_SOURCE_DIR}/photo-edit-table.h
2103 ${gallery_medialoader_src_SOURCE_DIR}/gallery-standard-image-provider.h
2104 ${gallery_medialoader_src_SOURCE_DIR}/photo-metadata.h
2105- ${gallery_medialoader_src_SOURCE_DIR}/preview-manager.h
2106 ${gallery_medialoader_src_SOURCE_DIR}/video-metadata.h
2107 ${gallery_photo_src_SOURCE_DIR}/photo.h
2108 )
2109@@ -41,10 +40,8 @@
2110 ../stubs/photo-caches_stub.cpp
2111 ../stubs/photo-edit-table_stub.cpp
2112 ../stubs/photometa-data_stub.cpp
2113- ../stubs/preview-manager_stub.cpp
2114 ../stubs/video-metadata_stub.cpp
2115 ../stubs/gallery-standard-image-provider_stub.cpp
2116- ../stubs/gallery-thumbnail-image-provider_stub.cpp
2117 ../stubs/gallery-manager_stub.cpp
2118 ${MEDIAOBJECTFACTORY_MOCS}
2119 )
2120
2121=== modified file 'tests/unittests/stubs/gallery-manager_stub.cpp'
2122--- tests/unittests/stubs/gallery-manager_stub.cpp 2013-09-06 16:10:25 +0000
2123+++ tests/unittests/stubs/gallery-manager_stub.cpp 2014-03-14 23:42:35 +0000
2124@@ -35,7 +35,6 @@
2125
2126 // qml
2127 #include "gallery-standard-image-provider.h"
2128-#include "gallery-thumbnail-image-provider.h"
2129
2130 GalleryManager* GalleryManager::m_galleryManager = NULL;
2131
2132@@ -43,13 +42,11 @@
2133 : collectionsInitialised(false),
2134 m_resource(0),
2135 m_standardImageProvider(new GalleryStandardImageProvider()),
2136- m_thumbnailImageProvider(new GalleryThumbnailImageProvider()),
2137 m_database(0),
2138 m_defaultTemplate(0),
2139 m_mediaCollection(0),
2140 m_albumCollection(0),
2141 m_eventCollection(0),
2142- m_previewManager(0),
2143 m_monitor(0),
2144 m_mediaLibrary(0)
2145 {
2146@@ -93,7 +90,6 @@
2147 GalleryManager::~GalleryManager()
2148 {
2149 delete m_standardImageProvider;
2150- delete m_thumbnailImageProvider;
2151 delete m_defaultTemplate;
2152 delete m_mediaCollection;
2153 delete m_albumCollection;
2154@@ -114,8 +110,3 @@
2155 {
2156 return 0;
2157 }
2158-
2159-GalleryThumbnailImageProvider* GalleryManager::takeGalleryThumbnailImageProvider()
2160-{
2161- return 0;
2162-}
2163
2164=== modified file 'tests/unittests/stubs/gallery-standard-image-provider_stub.cpp'
2165--- tests/unittests/stubs/gallery-standard-image-provider_stub.cpp 2013-06-14 17:59:27 +0000
2166+++ tests/unittests/stubs/gallery-standard-image-provider_stub.cpp 2014-03-14 23:42:35 +0000
2167@@ -19,7 +19,6 @@
2168 */
2169
2170 #include "gallery-standard-image-provider.h"
2171-#include "preview-manager.h"
2172
2173 const char* GalleryStandardImageProvider::PROVIDER_ID = "gallery-standard";
2174 const char* GalleryStandardImageProvider::PROVIDER_ID_SCHEME = "image://gallery-standard/";
2175@@ -32,13 +31,11 @@
2176 const long MAX_CACHE_BYTES = 20L * 1024L * 1024L;
2177
2178 // fully load previews into memory when requested
2179-const int SCALED_LOAD_FLOOR_DIM_PIXELS =
2180- qMax(PreviewManager::PREVIEW_SIZE, PreviewManager::PREVIEW_SIZE);
2181+const int SCALED_LOAD_FLOOR_DIM_PIXELS = 360;
2182
2183 GalleryStandardImageProvider::GalleryStandardImageProvider()
2184 : QQuickImageProvider(QQuickImageProvider::Image),
2185 m_cachedBytes(0),
2186- m_previewManager(0),
2187 m_logImageLoading(false),
2188 m_maxLoadResolution(INT_MAX)
2189 {
2190@@ -62,11 +59,6 @@
2191 return QUrl::fromUserInput(PROVIDER_ID_SCHEME + file.absoluteFilePath());
2192 }
2193
2194-void GalleryStandardImageProvider::setPreviewManager(PreviewManager *previewManager)
2195-{
2196- m_previewManager = previewManager;
2197-}
2198-
2199 void GalleryStandardImageProvider::setLogging(bool enableLogging)
2200 {
2201 m_logImageLoading = enableLogging;
2202
2203=== removed file 'tests/unittests/stubs/gallery-thumbnail-image-provider_stub.cpp'
2204--- tests/unittests/stubs/gallery-thumbnail-image-provider_stub.cpp 2013-06-14 17:59:27 +0000
2205+++ tests/unittests/stubs/gallery-thumbnail-image-provider_stub.cpp 1970-01-01 00:00:00 +0000
2206@@ -1,55 +0,0 @@
2207-/*
2208- * Copyright (C) 2012 Canonical Ltd
2209- *
2210- * This program is free software: you can redistribute it and/or modify
2211- * it under the terms of the GNU General Public License version 3 as
2212- * published by the Free Software Foundation.
2213- *
2214- * This program is distributed in the hope that it will be useful,
2215- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2216- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2217- * GNU General Public License for more details.
2218- *
2219- * You should have received a copy of the GNU General Public License
2220- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2221- *
2222- * Authors:
2223- * Guenter Schwann <guenter.schwann@canonical.com>
2224-*/
2225-
2226-#include "gallery-thumbnail-image-provider.h"
2227-
2228-const char* GalleryThumbnailImageProvider::PROVIDER_ID = "gallery-thumbnail";
2229-const char* GalleryThumbnailImageProvider::PROVIDER_ID_SCHEME = "image://gallery-thumbnail/";
2230-const char* GalleryThumbnailImageProvider::REVISION_PARAM_NAME = "edit";
2231-
2232-GalleryThumbnailImageProvider::GalleryThumbnailImageProvider()
2233- : QQuickImageProvider(QQuickImageProvider::Image),
2234- m_previewManager(0),
2235- m_logImageLoading(false)
2236-{
2237-}
2238-
2239-QImage GalleryThumbnailImageProvider::requestImage(const QString& id,
2240- QSize* size, const QSize& requestedSize)
2241-{
2242- Q_UNUSED(id);
2243- Q_UNUSED(size);
2244- Q_UNUSED(requestedSize);
2245- return QImage();
2246-}
2247-
2248-QUrl GalleryThumbnailImageProvider::toURL(const QFileInfo &file)
2249-{
2250- return QUrl::fromUserInput(PROVIDER_ID_SCHEME + file.absoluteFilePath());
2251-}
2252-
2253-void GalleryThumbnailImageProvider::setPreviewManager(PreviewManager *previewManager)
2254-{
2255- m_previewManager = previewManager;
2256-}
2257-
2258-void GalleryThumbnailImageProvider::setLogging(bool enableLogging)
2259-{
2260- m_logImageLoading = enableLogging;
2261-}
2262
2263=== removed file 'tests/unittests/stubs/preview-manager_stub.cpp'
2264--- tests/unittests/stubs/preview-manager_stub.cpp 2013-06-18 06:16:55 +0000
2265+++ tests/unittests/stubs/preview-manager_stub.cpp 1970-01-01 00:00:00 +0000
2266@@ -1,65 +0,0 @@
2267-/*
2268- * Copyright (C) 2013 Canonical, Ltd.
2269- *
2270- * Authors:
2271- * Nicolas d'Offay <nicolas.doffay@canonical.com>
2272- *
2273- * This program is free software; you can redistribute it and/or modify
2274- * it under the terms of the GNU General Public License as published by
2275- * the Free Software Foundation; version 3.
2276- *
2277- * This program is distributed in the hope that it will be useful,
2278- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2279- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2280- * GNU General Public License for more details.
2281- *
2282- * You should have received a copy of the GNU General Public License
2283- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2284- *
2285- */
2286-
2287-#include <QDir>
2288-
2289-#include "preview-manager.h"
2290-#include "media-collection.h"
2291-
2292-const int PreviewManager::PREVIEW_SIZE = 360;
2293-const QString PreviewManager::PREVIEW_DIR = ".thumbs";
2294-const char* PreviewManager::PREVIEW_FILE_EXT = "JPG";
2295-
2296-PreviewManager::PreviewManager(const QString &thumbnailDirectory, QObject *parent)
2297-{
2298- Q_UNUSED(thumbnailDirectory);
2299-}
2300-
2301-bool PreviewManager::ensurePreview(QFileInfo file, bool regen)
2302-{
2303- file = QFileInfo();
2304- regen = false;
2305-
2306- return regen;
2307-}
2308-
2309-void PreviewManager::onMediaAddedRemoved(const QSet<DataObject *> *, const QSet<DataObject *> *)
2310-{
2311-}
2312-
2313-void PreviewManager::onMediaDestroying(const QSet<DataObject *> *)
2314-{
2315-}
2316-
2317-void PreviewManager::updatePreview()
2318-{
2319-}
2320-
2321-QString PreviewManager::previewFileName(const QFileInfo &file) const
2322-{
2323- return QString(file.absolutePath() + QDir::separator() + PREVIEW_DIR +
2324- QDir::separator() + file.completeBaseName() + "_th." + PREVIEW_FILE_EXT);
2325-}
2326-
2327-QString PreviewManager::thumbnailFileName(const QFileInfo& file) const
2328-{
2329- return QString(file.absolutePath() + PREVIEW_DIR + QDir::separator() +
2330- file.completeBaseName() + "_th_s." + PREVIEW_FILE_EXT);
2331-}
2332
2333=== modified file 'tests/unittests/video/tst_video.cpp'
2334--- tests/unittests/video/tst_video.cpp 2013-08-12 09:29:34 +0000
2335+++ tests/unittests/video/tst_video.cpp 2014-03-14 23:42:35 +0000
2336@@ -33,10 +33,10 @@
2337 QVERIFY(Video::isCameraVideo(fi));
2338
2339 fi.setFileName("/dir/video20130612_0001.avi");
2340- QVERIFY(!Video::isCameraVideo(fi));
2341+ QVERIFY(Video::isCameraVideo(fi));
2342
2343 fi.setFileName("/dir/home_video.mp4");
2344- QVERIFY(!Video::isCameraVideo(fi));
2345+ QVERIFY(Video::isCameraVideo(fi));
2346 }
2347
2348 QTEST_MAIN(tst_Video);

Subscribers

People subscribed via source and target branches