VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
QmlUtil.h
1 /*
2  * Copyright (C) 2014 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef QMLUTIL_H
18 #define QMLUTIL_H
19 #include <QObject>
20 #include <QString>
21 #include <QUrl>
22 
29 class QmlUtil : public QObject {
30  Q_OBJECT
31 public:
36  Q_INVOKABLE QString getPathToAsset(const QString& assetPath);
37 
42  Q_INVOKABLE QUrl getUrlPathToAsset(const QString& assetPath);
43 
48  Q_INVOKABLE QString getPathToFont(const QString& fontPath);
49 
54  Q_INVOKABLE QString getPathToImage(const QString& imagePath);
55 
60  Q_INVOKABLE QString getPathToMovie(const QString& moviePath);
61 
66  Q_INVOKABLE QString getPathToSound(const QString& soundPath);
67 
71  Q_INVOKABLE bool deviceHasTouchScreen();
72 
76  static QmlUtil* getInstance();
77 
78 private:
79  QmlUtil(QObject* parent = nullptr);
80  static QmlUtil* sInstance;
81 };
82 #endif // QMLUTIL_H
QML accessible versions of the Util functions.
Definition: QmlUtil.h:29
Q_INVOKABLE QString getPathToFont(const QString &fontPath)
Returns the platform dependent path to the font in fontPath.
Q_INVOKABLE QString getPathToMovie(const QString &moviePath)
Returns the platform dependent path to the movie in moviePath.
Q_INVOKABLE bool deviceHasTouchScreen()
Returns true if the device on which the game is running has a touch screen.
Q_INVOKABLE QString getPathToSound(const QString &soundPath)
Returns the platform dependent path to the sound in soundPath.
Q_INVOKABLE QString getPathToImage(const QString &imagePath)
Returns the platform dependent path to the image in imagePath.
static QmlUtil * getInstance()
Returns the QmlUtil singleton instance of this object.
Q_INVOKABLE QString getPathToAsset(const QString &assetPath)
Returns the platform dependent path for assetPath.
QObject * parent() const
Q_INVOKABLE QUrl getUrlPathToAsset(const QString &assetPath)
Returns platform dependent path URL to assetPath.