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
main.cpp
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 #include "gui/formmain.h"
32 #include "definitions/definitions.h"
33 #include "gui/systemtrayicon.h"
34 #include "miscellaneous/application.h"
35 #include "miscellaneous/debugging.h"
36 #include "miscellaneous/settings.h"
37 #include "miscellaneous/iconfactory.h"
38 #include "miscellaneous/skinfactory.h"
39 #include "miscellaneous/localization.h"
40 #include "dynamic-shortcuts/dynamicshortcuts.h"
41 
42 
43 #include <QThread>
44 #include <QTranslator>
45 #include <QDebug>
46 #include <QTimer>
47 
48 
49 /// \mainpage Welcome to documentation!
50 /// The BuildmLearn Toolkit is an easy-to-use
51 /// program that helps users make mobile apps
52 /// without any knowledge of application development.
53 /// The toolkit helps creating mobile application with
54 /// various functionality and allows teachers to input
55 /// their custom content. Targeted at teachers, this program
56 /// helps them make learning fun and engaging through mobile apps.
57 ///
58 ///
59 /// Links
60 /// -----
61 /// * [www.buildmlearn.org](http://buildmlearn.org/) ~homepage,
62 /// * [www.buildmlearn.github.io/BuildmLearn-Toolkit/docs/](http://buildmlearn.github.io/BuildmLearn-Toolkit/docs/) ~API documentation,
63 /// * [www.martin-rotter.8u.cz](http://www.martin-rotter.8u.cz/) ~author's homepage,
64 /// * [www.transifex.com/projects/p/buildmlearn-toolkit](https://www.transifex.com/projects/p/buildmlearn-toolkit/) ~translations,
65 /// * [www.build.opensuse.org/project/show/home:skunkos:buildmlearn] (https://build.opensuse.org/project/show/home:skunkos:buildmlearn) ~OBS homepage,
66 /// * [www.cmake.org](http://www.cmake.org/) ~build system,
67 /// * [www.qt-project.org](http://qt-project.org/) ~Qt libraries.
68 ///
69 /// Packages
70 /// --------
71 /// You can use source code tarball available direct from here to build the software. Precompiled binary packages are available for some other platforms:
72 ///
73 /// * [OBS (Git version)](http://software.opensuse.org/download.html?project=home%3Askunkos%3Abuildmlearn&package=buildmlearn-toolkit-git) ~Archlinux, openSUSE, Fedora, *Ubuntu, Debian,
74 /// * [OBS (Stable version)](http://software.opensuse.org/download.html?project=home%3Askunkos%3Abuildmlearn&package=buildmlearn-toolkit) ~Archlinux, openSUSE, Fedora, *Ubuntu, Debian,
75 /// * [testing NSIS installers](https://drive.google.com/folderview?id=0B8XNkQ-jUoBYYjMzd3laRHROMnM&usp=drive_web) ~Windows (XP or newer),
76 /// * TBA ~OS/2 (eComStation),
77 /// * TBA ~OSX (Mac OS X).
78 ///
79 /// How to build
80 /// ------------
81 /// Information regarding build process can be found in CMakeLists.txt file.
82 ///
83 /// License for use and distribution
84 /// ---------------------------------
85 /// All the code in this repository (unless specified otherwise) is governed by the BSD (3-Clause) License quoted below.
86 ///
87 /// Copyright (c) 2012, BuildmLearn Contributors listed at http://buildmlearn.org/people/
88 /// All rights reserved.
89 ///
90 /// Redistribution and use in source and binary forms, with or without
91 /// modification, are permitted provided that the following conditions are met:
92 ///
93 /// * Redistributions of source code must retain the above copyright notice, this
94 /// list of conditions and the following disclaimer.
95 ///
96 /// * Redistributions in binary form must reproduce the above copyright notice,
97 /// this list of conditions and the following disclaimer in the documentation
98 /// and/or other materials provided with the distribution.
99 ///
100 /// * Neither the name of the BuildmLearn nor the names of its
101 /// contributors may be used to endorse or promote products derived from
102 /// this software without specific prior written permission.
103 ///
104 /// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
105 /// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
106 /// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
107 /// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
108 /// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
109 /// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
110 /// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
111 /// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
112 /// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
113 /// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
114 
115 /// \defgroup template-interfaces Template interfaces
116 /// \brief Base template interface classes.
117 ///
118 /// Template interfaces module contains all base classes which are
119 /// inherited by concrete templates.
120 ///
121 /// \defgroup keyboard-shortcuts Dynamic keyboard shortcuts
122 /// \brief Dynamic keyboard shortcuts classes.
123 ///
124 /// Dynamic keyboard shortcuts module contains classes related to
125 /// application-wide dynamic keyboard shortcuts facilities.
126 ///
127 /// \defgroup template-quiz Quiz template
128 /// \brief Quiz template classes.
129 ///
130 /// This module contains all classes related to Quiz template.
131 ///
132 /// \defgroup template-flashcards Flashcards template
133 /// \brief Flashcards template classes.
134 ///
135 /// This module contains all classes related to Flashcards template.
136 ///
137 /// \defgroup template-basicmlearn Basic m-learning template
138 /// \brief Basic m-learning template classes.
139 ///
140 /// This module contains all classes related to Basic m-learning template.
141 ///
142 /// \defgroup template-learnspellings Learn Spellings template
143 /// \brief Learn Spellings template classes.
144 ///
145 /// This module contains all classes related to Learn Spellings template.
146 /// Learn Spellings template helps its users to learn to pronunciate particular
147 /// words or phrases.
148 
149 /// \brief main Main entry point to the application.
150 ///
151 /// Main function is the "main" entry point to toolkit.
152 ///
153 /// \param argc Number of arguments passed to the program.
154 /// \param argv Array of strings passed to the program.
155 /// \return Function returns EXIT_SUCCESS when it succeedes
156 /// or another integer value when it fails.
157 int main(int argc, char *argv[]) {
158  //: Name of language, e.g. English.
159  QObject::tr("LANG_NAME");
160  //: Abbreviation of language.
161  //: Use ISO 639-1 code here combined with ISO 3166-1 (alpha-2) code.
162  //: Examples: "cs_CZ", "en_GB", "en_US".
163  QObject::tr("LANG_ABBREV");
164  //: Name of translator - optional.
165  QObject::tr("LANG_AUTHOR");
166  //: Email of translator - optional.
167  QObject::tr("LANG_EMAIL");
168 
169  // Ensure that ini format is used as application settings storage on Mac OS.
170 #ifdef Q_OS_MAC
171  QSettings::setDefaultFormat(QSettings::IniFormat);
172 #endif
173 
174  // Setup debug output system.
175 #if QT_VERSION >= 0x050000
176  qInstallMessageHandler(Debugging::debugHandler);
177 #else
178  qInstallMsgHandler(Debugging::debugHandler);
179 #endif
180 
181  Application application(argc, argv);
182 
183  // Add an extra path for non-system icon themes and set current icon theme
184  // and skin.
187 
188  // Load current skin.
189  application.skinFactory()->loadCurrentSkin();
190 
191  // Load localization and setup locale before any widget is constructed.
193 
194  // These settings needs to be set before any QSettings object.
195  Application::setApplicationName(APP_NAME);
196  Application::setApplicationVersion(APP_VERSION);
197  Application::setOrganizationName(APP_AUTHOR);
198  Application::setOrganizationDomain(APP_URL);
199  Application::setWindowIcon(QIcon(APP_ICON_PATH));
200 
201  qDebug().nospace() << "Creating main application form in thread: \'" <<
202  QThread::currentThreadId() << "\'.";
203 
204  FormMain main_form;
205 
206  application.setMainForm(&main_form);
207 
208  // Load keyboard shortcuts.
209  DynamicShortcuts::load(application.availableActions());
210 
211  main_form.show();
212 
214  QObject::connect(application.trayIcon(), SIGNAL(leftMouseClicked()),
215  &main_form, SLOT(switchVisibility()));
216  application.trayIcon()->setContextMenu(main_form.trayMenu());
217  application.trayIcon()->show();
218 
219  QTimer::singleShot(STARTUP_UPDATE_DELAY, &application,
220  SLOT(checkForUpdatesOnBackground()));
221  }
222  else {
223  qDebug("System tray icon is not available, quitting.");
224  return EXIT_FAILURE;
225  }
226 
227  // Check for availability of external generators.
228  application.recheckExternalApplications(true);
229 
230  return Application::exec();
231 }
Main application window.
Definition: formmain.h:53
void setupSearchPaths()
Adds custom application path to be search for icons.
Definition: iconfactory.cpp:56
static Localization * instance()
Singleton getter.
void loadCurrentIconTheme()
Loads name of selected icon theme (from settings) for the application and activates it...
Definition: iconfactory.cpp:69
void show()
Displays window.
Definition: formmain.cpp:557
Key application class containing all critical elements of the application.
Definition: application.h:63
static bool isSystemTrayAvailable()
Indicates whether tray icon is supported.
QMenu * trayMenu() const
Access to tray menu.
Definition: formmain.h:64
static void load(const QList< QAction * > &actions)
Checks the application settings and then initializes shortcut of each action from actions from the se...
void load()
Loads currently active language.
static IconFactory * instance()
Singleton getter.
Definition: iconfactory.cpp:48