2 * Copyright (C) 2016 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 as published by
6 * the Free Software Foundation; version 3.
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/>.
20#include <QImageReader>
21#include <QQuickImageProvider>
25 * This class accepts an id formulated like a URL. So you'd use something like:
28 * source: "image://unity8imagecache/file:///usr/share/..."
31 * Right now, we only support file:/// URLs. We do accept some flags though:
34 * - This will use NAME as the cache lookup key instead of the provided URL.
36 * We don't do any cleaning of old cached files yet. So you may want to always
37 * provide a name to avoid leaving lots of files around.
40class ImageCache: public QQuickImageProvider
45 QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override;
48 static QString imageCacheRoot();
49 static QFileInfo imagePath(const QUrl &image);
50 static bool needsUpdate(const QUrl &image, const QFileInfo &cachePath, const QSize &imageSize, const QSize &requestedSize, QSize &finalSize);
51 static QSize calculateSize(const QSize &imageSize, const QSize &requestedSize);
52 static QImage loadAndCacheImage(QImageReader &reader, const QFileInfo &cachePath, const QSize &finalSize);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list