~unity-team/+junk/dashboard-playground

« back to all changes in this revision

Viewing changes to tests/mocks/Ubuntu/Application/ApplicationImage.h

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 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 as published by
 
6
 * the Free Software Foundation; version 3.
 
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
 
 
17
#ifndef APPLICATION_IMAGE_H
 
18
#define APPLICATION_IMAGE_H
 
19
 
 
20
#include <QQuickItem>
 
21
 
 
22
class ApplicationInfo;
 
23
 
 
24
/* Fake implementation of ApplicationImage
 
25
 
 
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.
 
29
*/
 
30
class ApplicationImage : public QQuickItem {
 
31
    Q_OBJECT
 
32
    Q_ENUMS(FillMode)
 
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)
 
36
 
 
37
public:
 
38
    explicit ApplicationImage(QQuickItem* parent = 0);
 
39
    virtual ~ApplicationImage() {}
 
40
 
 
41
    enum FillMode { Stretch, PreserveAspectCrop };
 
42
 
 
43
    ApplicationInfo* source() const { return m_source; }
 
44
    void setSource(ApplicationInfo* source);
 
45
 
 
46
    FillMode fillMode() const  { return m_fillMode; }
 
47
    void setFillMode(FillMode);
 
48
 
 
49
    void setReady(bool value);
 
50
    bool ready() const { return m_ready; }
 
51
 
 
52
    Q_INVOKABLE void scheduleUpdate() {}
 
53
    Q_INVOKABLE void updateFromCache() {}
 
54
 
 
55
Q_SIGNALS:
 
56
    void sourceChanged();
 
57
    void fillModeChanged();
 
58
    void readyChanged();
 
59
 
 
60
private Q_SLOTS:
 
61
    void updateImage();
 
62
    void onImageComponentStatusChanged(QQmlComponent::Status status);
 
63
 
 
64
private:
 
65
    void createImageItem();
 
66
    void createImageComponent();
 
67
    void doCreateImageItem();
 
68
    void destroyImage();
 
69
 
 
70
    ApplicationInfo* m_source;
 
71
    FillMode m_fillMode;
 
72
    bool m_ready;
 
73
    QQmlComponent *m_imageComponent;
 
74
    QQuickItem* m_imageItem;
 
75
    // the QML script used to create the current m_imageItem
 
76
    QString m_qmlUsed;
 
77
};
 
78
 
 
79
#endif // APPLICATION_IMAGE_H