~artmello/gallery-app/gallery-app-start_on_event

« back to all changes in this revision

Viewing changes to src/medialoader/preview-manager.h

  • Committer: CI bot
  • Author(s): Arthur Mello, Bill Filler, Ugo Riboni
  • Date: 2014-03-19 20:19:57 UTC
  • mfrom: (912.3.20 multiple-bug-fixes)
  • Revision ID: ps-jenkins@lists.canonical.com-20140319201957-32sglr01gx1xx9e0
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" Fixes: 907870, 1221968, 1268748, 1271327, 1287272

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
30
 
class QImage;
31
 
class DataObject;
32
 
class 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
 
 */
45
 
class PreviewManager : public QObject
46
 
{
47
 
    Q_OBJECT
48
 
 
49
 
public:
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
 
 
66
 
public slots:
67
 
    void onMediaAddedRemoved(const QSet<DataObject*>* added,
68
 
                                const QSet<DataObject*>* removed);
69
 
    void onMediaDestroying(const QSet<DataObject*>* destroying);
70
 
 
71
 
private slots:
72
 
    void updatePreview();
73
 
 
74
 
private:
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_