blob: a83787997863e9fc37c63b81fa451d9b72784a0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of Qt Enterprise Embedded.
**
** Licensees holding valid Qt Enterprise licenses may use this file in
** accordance with the Qt Enterprise License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
**
****************************************************************************/
#ifndef ENGINE_H
#define ENGINE_H
#include <QObject>
#include <QUrl>
#include <QSize>
#include <QColor>
class QQmlEngine;
class QQuickItem;
class FpsCounter;
class QQuickWindow;
class Engine : public QObject
{
Q_OBJECT
Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
Q_PROPERTY(bool bootAnimationEnabled READ isBootAnimationEnabled WRITE setBootAnimationEnabled NOTIFY bootAnimationEnabledChanged)
Q_PROPERTY(QUrl applicationMain READ applicationMain NOTIFY applicationMainChanged)
Q_PROPERTY(QUrl applicationUrl READ applicationUrl NOTIFY applicationUrlChanged)
Q_PROPERTY(QString applicationName READ applicationName NOTIFY applicationNameChanged)
Q_PROPERTY(bool fpsEnabled READ isFpsEnabled WRITE setFpsEnabled NOTIFY fpsEnabledChanged)
Q_PROPERTY(qreal fps READ fps NOTIFY fpsChanged)
Q_PROPERTY(const QString qtVersion READ qtVersion)
public:
explicit Engine(QObject *parent = 0);
QString state() const { return m_state; }
void setState(const QString &state);
bool isFpsEnabled() const { return m_fps_enabled; }
void setFpsEnabled(bool enabled);
qreal fps() const { return m_fps; }
QQmlEngine *qmlEngine() const { return m_qmlEngine; }
void setQmlEngine(QQmlEngine *engine) { m_qmlEngine = engine; }
bool isBootAnimationEnabled() const { return m_bootAnimationEnabled; }
void setBootAnimationEnabled(bool enabled);
QString qtVersion() const { return QT_VERSION_STR; }
QUrl applicationUrl() const { return m_applicationUrl; }
QUrl applicationMain() const { return m_applicationMain; }
QString applicationName() const { return m_applicationName; }
void setWindow(QQuickWindow *window) { m_window = window; }
Q_INVOKABLE QUrl fromUserInput(const QString& userInput) { return QUrl::fromUserInput(userInput); }
Q_INVOKABLE int sensibleButtonSize() const;
Q_INVOKABLE int titleBarSize() const;
Q_INVOKABLE int smallFontSize() const { return qMax<int>(m_dpcm * 0.4, 10); }
Q_INVOKABLE int fontSize() const { return qMax<int>(m_dpcm * 0.6, 14); }
Q_INVOKABLE int titleFontSize() const { return qMax<int>(m_dpcm * 0.9, 20); }
Q_INVOKABLE int centimeter() const { return m_dpcm; }
protected:
signals:
void stateChanged(const QString &state);
void activeIconChanged(QQuickItem *item);
void applicationUrlChanged(const QUrl &applicationUrl);
void applicationMainChanged(const QUrl &applicationMain);
void applicationNameChanged(const QString &applicationName);
void bootAnimationEnabledChanged(bool enabled);
void fpsChanged(qreal fps);
void fpsEnabledChanged(bool enabled);
public slots:
void markApplicationsModelReady() { m_apps_ready = true; updateReadyness(); }
void markIntroAnimationDone() { m_intro_done = true; updateReadyness(); }
void launchApplication(const QUrl &location, const QString &mainFile, const QString &name);
void closeApplication();
void setFps(qreal fps);
private:
void updateReadyness();
QQuickWindow *m_window;
QQmlEngine *m_qmlEngine;
QString m_state;
QUrl m_applicationUrl;
QUrl m_applicationMain;
QString m_applicationName;
QSize m_screenSize;
qreal m_dpcm;
FpsCounter *m_fpsCounter;
qreal m_fps;
uint m_intro_done : 1;
uint m_apps_ready : 1;
uint m_fps_enabled : 1;
uint m_bootAnimationEnabled : 1;
};
#endif // ENGINE_H
|