2
* Copyright (C) 2012 Canonical Ltd
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.
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.
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/>.
17
* Jim Nelson <jim@yorba.org>
20
#ifndef GALLERY_PREVIEW_MANAGER_H_
21
#define GALLERY_PREVIEW_MANAGER_H_
35
* \brief The PreviewManager class creates and removes thumbnails
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
45
class PreviewManager : public QObject
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;
56
static const QString PREVIEW_DIR;
57
static const QString THUMBNAIL_DIR;
59
PreviewManager(const QString& thumbnailDirectory, QObject* parent = 0);
61
QString previewFileName(const QFileInfo& file) const;
62
QString thumbnailFileName(const QFileInfo& file) const;
64
bool ensurePreview(QFileInfo file, bool regen = false);
67
void onMediaAddedRemoved(const QSet<DataObject*>* added,
68
const QSet<DataObject*>* removed);
69
void onMediaDestroying(const QSet<DataObject*>* destroying);
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;
83
static QMutex m_createMutex;
84
QString m_thumbnailDir;
87
#endif // GALLERY_PREVIEW_MANAGER_H_