2
* Copyright (C) 2013 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/>.
17
#ifndef APPLICATION_IMAGE_H
18
#define APPLICATION_IMAGE_H
22
class ApplicationInfo;
24
/* Fake implementation of ApplicationImage
26
That fake implementation is not made in QML just because we can only declare
27
enumerations in C++. We can't even make readonly properties to mimic an enum
28
because properties must begin with a lower case letter.
30
class ApplicationImage : public QQuickItem {
33
Q_PROPERTY(ApplicationInfo* source READ source WRITE setSource NOTIFY sourceChanged)
34
Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
35
Q_PROPERTY(bool ready READ ready WRITE setReady NOTIFY readyChanged)
38
explicit ApplicationImage(QQuickItem* parent = 0);
39
virtual ~ApplicationImage() {}
41
enum FillMode { Stretch, PreserveAspectCrop };
43
ApplicationInfo* source() const { return m_source; }
44
void setSource(ApplicationInfo* source);
46
FillMode fillMode() const { return m_fillMode; }
47
void setFillMode(FillMode);
49
void setReady(bool value);
50
bool ready() const { return m_ready; }
52
Q_INVOKABLE void scheduleUpdate() {}
53
Q_INVOKABLE void updateFromCache() {}
57
void fillModeChanged();
62
void onImageComponentStatusChanged(QQmlComponent::Status status);
65
void createImageItem();
66
void createImageComponent();
67
void doCreateImageItem();
70
ApplicationInfo* m_source;
73
QQmlComponent *m_imageComponent;
74
QQuickItem* m_imageItem;
75
// the QML script used to create the current m_imageItem
79
#endif // APPLICATION_IMAGE_H