BuildmLearn Toolkit  2.0.4
BuildmLearn Toolkit is an easy-to-use program that helps users make mobile apps without any knowledge of application development.
 All Classes Functions Enumerations Groups Pages
localization.h
1 /*
2  Copyright (c) 2012, BuildmLearn Contributors listed at http://buildmlearn.org/people/
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 
11  * Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15  * Neither the name of the BuildmLearn nor the names of its
16  contributors may be used to endorse or promote products derived from
17  this software without specific prior written permission.
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 
31 #ifndef LOCALIZATION_H
32 #define LOCALIZATION_H
33 
34 #include <QString>
35 #include <QObject>
36 #include <QPointer>
37 
38 
39 /// \brief Representation of single localization.
40 struct Language {
41  QString m_name;
42  QString m_code;
43  QString m_author;
44  QString m_email;
45 };
46 
47 /// \brief Localization facilities.
48 class Localization : public QObject {
49  Q_OBJECT
50 
51  private:
52  // Constructor.
53  explicit Localization(QObject *parent = 0);
54 
55  public:
56  // Destructor.
57  virtual ~Localization();
58 
59  /// \brief Singleton getter.
60  /// \return Returns singleton.
61  static Localization *instance();
62 
63  /// \brief Access to code of language that should
64  /// be loaded according to settings.
65  /// \return Returns code of language that should
66  /// be loaded according to settings.
67  QString desiredLanguage();
68 
69  /// \brief Loads currently active language.
70  void load();
71 
72  /// \brief Gets list of installed languages.
73  /// \return Returns list of installed application localizations.
74  /// This list is used ie. in settings dialog.
75  QList<Language> installedLanguages();
76 
77  /// \brief Access to code of loaded language.
78  /// \return Returns empty string or loaded language
79  /// name if it is really loaded.
80  inline QString loadedLanguage() const {
81  return m_loadedLanguage;
82  }
83 
84  private:
85  // Code of loaded language.
86  QString m_loadedLanguage;
87 
88  // Singleton.
89  static QPointer<Localization> s_instance;
90 };
91 
92 #endif // LOCALIZATION_H
QString loadedLanguage() const
Access to code of loaded language.
Definition: localization.h:80
static Localization * instance()
Singleton getter.
Localization facilities.
Definition: localization.h:48
QList< Language > installedLanguages()
Gets list of installed languages.
QString desiredLanguage()
Access to code of language that should be loaded according to settings.
Representation of single localization.
Definition: localization.h:40
void load()
Loads currently active language.