• Skip to content
  • Skip to link menu
KDE API Documentation - ApplicationInfo.h Source File (GCompris-qt)
  • KDE Home
  • Contact Us
 

GCompris-qt

  • src
  • core
ApplicationInfo.h
1 /* GCompris - ApplicationSettingsDefault.cpp
2  *
3  * Copyright (C) 2014 Bruno Coudoin <bruno.coudoin@gcompris.net>
4  *
5  * Authors:
6  * Bruno Coudoin <bruno.coudoin@gcompris.net>
7  *
8  * This file was originaly created from Digia example code under BSD licence
9  * and heavily modified since then.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, see <http://www.gnu.org/licenses/>.
23  */
24 #ifndef APPLICATIONINFO_H
25 #define APPLICATIONINFO_H
26 
27 #include <config.h>
28 #include "ApplicationSettings.h"
29 
30 #include <qqml.h>
31 #include <QtCore/QObject>
32 #include <QtQml/QQmlPropertyMap>
33 #include <QQmlEngine>
34 
35 class QQuickWindow;
36 
43 class ApplicationInfo : public QObject
44 {
45  Q_OBJECT
46 
47  Q_ENUMS(Platform)
48 
49 
52  Q_PROPERTY(int applicationWidth READ applicationWidth WRITE setApplicationWidth NOTIFY applicationWidthChanged)
53 
57  Q_PROPERTY(Platform platform READ platform CONSTANT)
58 
65  Q_PROPERTY(bool isMobile READ isMobile CONSTANT)
66 
77  Q_PROPERTY(bool hasShader READ hasShader CONSTANT)
78 
84  Q_PROPERTY(bool isPortraitMode READ isPortraitMode WRITE setIsPortraitMode NOTIFY portraitModeChanged)
85 
91  Q_PROPERTY(qreal ratio READ ratio NOTIFY ratioChanged)
92 
106  Q_PROPERTY(qreal fontRatio READ fontRatio NOTIFY fontRatioChanged)
107 
111  Q_PROPERTY(QString localeShort READ localeShort)
112 
116  Q_PROPERTY(QString GCVersion READ GCVersion CONSTANT)
117 
121  Q_PROPERTY(QString QTVersion READ QTVersion CONSTANT)
122 
129  Q_PROPERTY(QString CompressedAudio READ CompressedAudio CONSTANT)
130 
137  Q_PROPERTY(bool isDownloadAllowed READ isDownloadAllowed CONSTANT)
138 
139 public:
140 
144  enum Platform {
145  Linux,
146  Windows,
147  MacOSX,
148  Android,
149  Ios,
150  Blackberry,
151  SailfishOS
152  };
153 
161  static void init();
162 
169  static QString getFilePath(const QString &file);
170 
180  static QString localeShort(const QString &locale) {
181  QString _locale = locale;
182  if(_locale == GC_DEFAULT_LOCALE) {
183  _locale = QLocale::system().name();
184  }
185  // Can't use left(2) because of Asturian where there are 3 chars
186  return _locale.left(_locale.indexOf('_'));
187  }
188 
195  Q_INVOKABLE QString getVoicesLocale(const QString &locale);
196 
202  Q_INVOKABLE bool requestAudioFocus() const;
203 
209  Q_INVOKABLE void abandonAudioFocus() const;
210 
212 
213  static ApplicationInfo *getInstance() {
214  if(!m_instance) {
215  m_instance = new ApplicationInfo();
216  }
217  return m_instance;
218  }
219  static QObject *systeminfoProvider(QQmlEngine *engine,
220  QJSEngine *scriptEngine);
221  static void setWindow(QQuickWindow *window);
222  explicit ApplicationInfo(QObject *parent = 0);
223  ~ApplicationInfo();
224  int applicationWidth() const { return m_applicationWidth; }
225  void setApplicationWidth(const int newWidth);
226  Platform platform() const { return m_platform; }
227  bool isPortraitMode() const { return m_isPortraitMode; }
228  void setIsPortraitMode(const bool newMode);
229  bool isMobile() const { return m_isMobile; }
230  bool hasShader() const { return false; }
231  qreal ratio() const { return m_ratio; }
232  qreal fontRatio() const { return m_fontRatio; }
233  QString localeShort() const {
234  return localeShort( ApplicationSettings::getInstance()->locale() );
235  }
236  static QString GCVersion() { return VERSION; }
237  static QString QTVersion() { return qVersion(); }
238  static QString CompressedAudio() { return COMPRESSED_AUDIO; }
239  static bool isDownloadAllowed() { return DOWNLOAD_ALLOWED == "ON"; }
240 
242 
243 protected slots:
247  QString getResourceDataPath();
248 
261  Q_INVOKABLE QString getAudioFilePath(const QString &file);
262 
269  Q_INVOKABLE QString getLocaleFilePath(const QString &file);
270 
275  Q_INVOKABLE QStringList getSystemExcludedFonts();
276 
280  Q_INVOKABLE QStringList getFontsFromRcc();
281 
287  Q_INVOKABLE void screenshot(const QString &file);
288 
289  void notifyPortraitMode();
290  Q_INVOKABLE void notifyFullscreenChanged();
291 
292 protected:
293  qreal getSizeWithRatio(const qreal height) { return ratio() * height; }
294 
295 signals:
296  void applicationWidthChanged();
297  void portraitModeChanged();
298  void ratioChanged();
299  void fontRatioChanged();
300  void applicationSettingsChanged();
301  void fullscreenChanged();
302 
303 private:
304  static ApplicationInfo *m_instance;
305  int m_applicationWidth;
306  Platform m_platform;
307  QQmlPropertyMap *m_constants;
308  bool m_isPortraitMode;
309  bool m_isMobile;
310  qreal m_ratio;
311  qreal m_fontRatio;
312 
313  // Symbols fonts that user can't see
314  QStringList m_excludedFonts;
315  QStringList m_fontsFromRcc;
316 
317  static QQuickWindow *m_window;
318 };
319 
320 #endif // APPLICATIONINFO_H
ApplicationInfo::hasShader
bool hasShader
Whether the current platform supports fragment shaders.
Definition: ApplicationInfo.h:77
ApplicationInfo::SailfishOS
SailfishOS.
Definition: ApplicationInfo.h:151
ApplicationInfo::MacOSX
MacOSX.
Definition: ApplicationInfo.h:147
ApplicationInfo::Windows
Windows.
Definition: ApplicationInfo.h:146
ApplicationInfo::getFilePath
static QString getFilePath(const QString &file)
Returns an absolute and platform independent path to the passed file.
Definition: ApplicationInfo.cpp:116
ApplicationInfo::localeShort
static QString localeShort(const QString &locale)
Returns the short locale name for the passed locale.
Definition: ApplicationInfo.h:180
ApplicationInfo::getSystemExcludedFonts
Q_INVOKABLE QStringList getSystemExcludedFonts()
Definition: ApplicationInfo.cpp:150
ApplicationInfo::getLocaleFilePath
Q_INVOKABLE QString getLocaleFilePath(const QString &file)
Returns an absolute path to a langauge specific resource file.
Definition: ApplicationInfo.cpp:141
ApplicationInfo::getFontsFromRcc
Q_INVOKABLE QStringList getFontsFromRcc()
Definition: ApplicationInfo.cpp:155
ApplicationInfo::CompressedAudio
QString CompressedAudio
Audio codec used for voices resources.
Definition: ApplicationInfo.h:129
ApplicationInfo::QTVersion
QString QTVersion
Qt version string (runtime).
Definition: ApplicationInfo.h:121
ApplicationInfo::requestAudioFocus
Q_INVOKABLE bool requestAudioFocus() const
Request GCompris to take the Audio Focus at the system level.
Definition: ApplicationAndroid.cpp:55
ApplicationInfo::platform
Platform platform
Platform the application is currently running on.
Definition: ApplicationInfo.h:57
ApplicationInfo::GCVersion
QString GCVersion
GCompris version string (compile time).
Definition: ApplicationInfo.h:116
ApplicationInfo::Ios
IOS (not supported)
Definition: ApplicationInfo.h:149
ApplicationInfo::isPortraitMode
bool isPortraitMode
Whether currently in portrait mode, on mobile platforms.
Definition: ApplicationInfo.h:84
ApplicationInfo::isDownloadAllowed
bool isDownloadAllowed
Download allowed.
Definition: ApplicationInfo.h:137
ApplicationInfo::getAudioFilePath
Q_INVOKABLE QString getAudioFilePath(const QString &file)
Returns an absolute path to a language specific sound/voices file.
Definition: ApplicationInfo.cpp:127
ApplicationInfo::Linux
Linux (except Android)
Definition: ApplicationInfo.h:145
ApplicationInfo::Blackberry
Blackberry (not supported)
Definition: ApplicationInfo.h:150
ApplicationInfo::applicationWidth
int applicationWidth
Width of the application viewport.
Definition: ApplicationInfo.h:52
ApplicationInfo::localeShort
QString localeShort
Short (2-letter) locale string of the currently active language.
Definition: ApplicationInfo.h:111
ApplicationInfo::Platform
Platform
Known host platforms.
Definition: ApplicationInfo.h:144
ApplicationInfo::getResourceDataPath
QString getResourceDataPath()
Returns the resource root-path used for GCompris resources.
Definition: ApplicationInfo.cpp:111
ApplicationInfo::screenshot
Q_INVOKABLE void screenshot(const QString &file)
Stores a screenshot in the passed file.
Definition: ApplicationInfo.cpp:180
ApplicationInfo::Android
Android.
Definition: ApplicationInfo.h:148
ApplicationInfo::isMobile
bool isMobile
Whether the application is currently running on a mobile platform.
Definition: ApplicationInfo.h:65
ApplicationInfo::abandonAudioFocus
Q_INVOKABLE void abandonAudioFocus() const
Abandon the Audio Focus.
Definition: ApplicationAndroid.cpp:62
ApplicationInfo::init
static void init()
Registers singleton in the QML engine.
Definition: ApplicationInfo.cpp:224
ApplicationInfo
A general purpose singleton that exposes miscellaneous native functions to the QML layer...
Definition: ApplicationInfo.h:43
ApplicationInfo::fontRatio
qreal fontRatio
Ratio factor used for font scaling.
Definition: ApplicationInfo.h:106
ApplicationInfo::getVoicesLocale
Q_INVOKABLE QString getVoicesLocale(const QString &locale)
Returns a locale string that can be used in voices filenames.
Definition: ApplicationInfo.cpp:196
ApplicationInfo::ratio
qreal ratio
Ratio factor used for scaling of sizes on high-dpi devices.
Definition: ApplicationInfo.h:91
This file is part of the KDE documentation.
Documentation copyright © 1996-2015 The KDE developers.
Generated on Tue Jun 2 2015 21:47:47 by doxygen 1.8.9.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

GCompris-qt

Skip menu "GCompris-qt"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • File List
  • Modules

Class Picker

Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal