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
Application Class Reference

Key application class containing all critical elements of the application. More...

#include <application.h>

Collaboration diagram for Application:
Collaboration graph

Public Slots

void checkForUpdatesOnBackground ()
 Schedules check for updates. More...
 

Signals

void externalApplicationsRechecked ()
 Emitted if external applications are rechecked which happens usually if path to some of external application changes.
 

Public Member Functions

 Application (int &argc, char **argv)
 Constructor. More...
 
UpdateCheck checkForUpdates ()
 Tries to download list with new updates. More...
 
Settingssettings ()
 Access to application-wide settings. More...
 
QMutex * closeLock () const
 Access to application-wide close lock. More...
 
SkinFactoryskinFactory ()
 Access to application-wide skin facilities. More...
 
QString zipUtilityPath ()
 Access to "zip" utility path. More...
 
void setZipUtilityPath (const QString &zip_path)
 Sets new path to "zip". More...
 
QString signApkUtlityPath ()
 Access to path to "signapk" utility. More...
 
void setSignApkUtilityPath (const QString &signapk_path)
 Sets new path to "signapk". More...
 
QString javaInterpreterPath ()
 Access to path to "java" interpreter. More...
 
void setJavaInterpreterPath (const QString &java_path)
 Sets new "java" interpreter path. More...
 
int checkJava (const QString &new_path=QString())
 Tests if binary in new_path is correct JAVA executable. More...
 
int checkSignApk (const QString &new_path=QString(), const QString &java_path=QString())
 Tests if binary in new_path is correct SIGNAPK executable. More...
 
int checkZip (const QString &new_path=QString())
 Tests if binary in new_path is correct ZIP executable. More...
 
void recheckExternalApplications (bool emit_signals)
 
QString interpretJava (int return_code)
 
QString interpretZip (int return_code)
 
QString interpretSignApk (int return_code)
 
FormMainmainForm ()
 Access to main application form. More...
 
void setMainForm (FormMain *main_form)
 Setter for main application form. More...
 
QList< QAction * > availableActions ()
 Access to all application-wide useable actions. More...
 
SystemTrayIcontrayIcon ()
 Access to application tray icon. More...
 
TemplateFactorytemplateManager ()
 Access to template high level manager. More...
 
bool externalApplicationsReady () const
 
QString externalApplicationsStatus () const
 
bool externalApplicationChecked () const
 
bool isClosing () const
 Application closing indication. More...
 

Static Public Member Functions

static Applicationinstance ()
 Main static getter of global Application instance. More...
 

Detailed Description

Key application class containing all critical elements of the application.

See also
Settings, FormMain, UpdateInfo, SystemTrayIcon

Definition at line 63 of file application.h.

Constructor & Destructor Documentation

Application::Application ( int &  argc,
char **  argv 
)
explicit

Constructor.

Parameters
argcCount of arguments passed to the executable file.
argvArray of strings of arguments.

Definition at line 51 of file application.cpp.

52  : QApplication(argc, argv),
53  m_externalApplicationChecked(false),
54  m_closeLock(new QMutex()),
55  m_availableActions(QList<QAction*>()),
56  m_settings(NULL),
57  m_skinFactory(NULL),
58  m_trayIcon(NULL),
59  m_templateManager(NULL),
60  m_closing(false) {
61  connect(this, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit()));
62  connect(this, SIGNAL(commitDataRequest(QSessionManager&)), this, SLOT(onCommitData(QSessionManager&)));
63  connect(this, SIGNAL(saveStateRequest(QSessionManager&)), this, SLOT(onSaveState(QSessionManager&)));
64 }

Member Function Documentation

QList< QAction * > Application::availableActions ( )

Access to all application-wide useable actions.

Returns
Return list of user actions.

Definition at line 233 of file application.cpp.

233  {
234  if (m_mainForm == NULL) {
235  return QList<QAction*>();
236  }
237  else {
238  if (m_availableActions.isEmpty()) {
239  m_availableActions = m_mainForm->allActions();
240  }
241 
242  return m_availableActions;
243  }
244 }
QList< QAction * > allActions()
Access to all actions provided by this window.
Definition: formmain.cpp:130

Here is the call graph for this function:

UpdateCheck Application::checkForUpdates ( )

Tries to download list with new updates.

Returns
Returns pair of information: metadata of update and network status of update.

Definition at line 70 of file application.cpp.

70  {
72 }
static QPair< UpdateInfo, QNetworkReply::NetworkError > checkForUpdates()
Tries to synchronously download list with new updates.

Here is the call graph for this function:

Here is the caller graph for this function:

void Application::checkForUpdatesOnBackground ( )
slot

Schedules check for updates.

Check for updates is executed in separate thread. Result is announced via tray icon balloon tip. If tray icon is not available, then result is not announced and is suppressed.

Definition at line 316 of file application.cpp.

316  {
317  if (!settings()->value(APP_CFG_GEN,
318  "check_for_updates_startup",
319  true).toBool()) {
320  qDebug("Checking for updates after application startup is not allowed.");
321  }
322  else {
323  qDebug("Checking for updates after application has started.");
324 
325  QFutureWatcher<UpdateCheck> *watcher_for_future = new QFutureWatcher<UpdateCheck>(this);
326 
327  connect(watcher_for_future, SIGNAL(finished()), this, SLOT(handleBackgroundUpdatesCheck()));
328  watcher_for_future->setFuture(QtConcurrent::run(this, &Application::checkForUpdates));
329  }
330 }
Settings * settings()
Access to application-wide settings.
Definition: application.h:80
UpdateCheck checkForUpdates()
Tries to download list with new updates.
Definition: application.cpp:70

Here is the call graph for this function:

int Application::checkJava ( const QString &  new_path = QString())

Tests if binary in new_path is correct JAVA executable.

Parameters
new_pathPath to JAVA executable.
Returns
Returns specific return code of JAVA executable.

Definition at line 90 of file application.cpp.

90  {
91  QString java_path = new_path.isEmpty() ? javaInterpreterPath() : new_path;
92 
93  if (java_path.isEmpty()) {
94  return EXIT_STATUS_NOT_STARTED;
95  }
96  else {
97  QProcess process;
98 
99  process.setReadChannelMode(QProcess::MergedChannels);
100  process.start(QDir::toNativeSeparators(java_path), QStringList() << "-version");
101  process.waitForFinished(-1);
102 
103  return process.exitCode();
104  }
105 }
QString javaInterpreterPath()
Access to path to "java" interpreter.
Definition: application.h:126

Here is the call graph for this function:

int Application::checkSignApk ( const QString &  new_path = QString(),
const QString &  java_path = QString() 
)

Tests if binary in new_path is correct SIGNAPK executable.

Parameters
new_pathPath to SIGNAPK executable.
java_pathPath to JAVA executable.
Returns
Returns specific return code of SIGNAPK executable.

Definition at line 107 of file application.cpp.

107  {
108  QString real_java_path = java_path.isEmpty() ? javaInterpreterPath() : java_path;
109  QString signapk_path = new_path.isEmpty() ? signApkUtlityPath() : new_path;
110 
111  if (signapk_path.isEmpty()) {
112  return EXIT_STATUS_NOT_STARTED;
113  }
114  else {
115  QProcess process;
116 
117  process.setReadChannelMode(QProcess::MergedChannels);
118  process.start(QDir::toNativeSeparators(real_java_path),
119  QStringList() << "-jar" << QDir::toNativeSeparators(signapk_path));
120  process.waitForFinished(-1);
121 
122  return process.exitCode();
123  }
124 }
QString javaInterpreterPath()
Access to path to "java" interpreter.
Definition: application.h:126
QString signApkUtlityPath()
Access to path to "signapk" utility.
Definition: application.h:114

Here is the call graph for this function:

int Application::checkZip ( const QString &  new_path = QString())

Tests if binary in new_path is correct ZIP executable.

Parameters
new_pathPath to ZIP executable.
Returns
Returns specific return code of ZIP executable.

Definition at line 126 of file application.cpp.

126  {
127  QString zip_path = new_path.isEmpty() ? zipUtilityPath() : new_path;
128 
129  if (zip_path.isEmpty()) {
130  return EXIT_STATUS_NOT_STARTED;
131  }
132  else {
133  QProcess process;
134 
135  process.setReadChannelMode(QProcess::MergedChannels);
136  process.start(QDir::toNativeSeparators(zip_path), QStringList() << "--version");
137  process.waitForFinished(-1);
138 
139  return process.exitCode();
140  }
141 }
QString zipUtilityPath()
Access to "zip" utility path.
Definition: application.h:102

Here is the call graph for this function:

QMutex* Application::closeLock ( ) const
inline

Access to application-wide close lock.

Returns
Returns pointer to application-wide close lock.
Remarks
Application-wide close lock is used to determine if application can be closed securely.

Definition at line 92 of file application.h.

92  {
93  return m_closeLock;
94  }
static Application* Application::instance ( )
inlinestatic

Main static getter of global Application instance.

Returns
Returns singleton for Application.

Definition at line 186 of file application.h.

186  {
187  return static_cast<Application*>(QCoreApplication::instance());
188  }
Key application class containing all critical elements of the application.
Definition: application.h:63
bool Application::isClosing ( ) const

Application closing indication.

Returns
Returns true, if application is closing, otherwise returns false.

Definition at line 300 of file application.cpp.

300  {
301  return m_closing;
302 }
QString Application::javaInterpreterPath ( )
inline

Access to path to "java" interpreter.

Returns
Returns path to "java" interpreter.

Definition at line 126 of file application.h.

126  {
127  return settings()->value(APP_CFG_GEN, "java_path", QString(APP_JAVA_PATH)).toString();
128  }
Settings * settings()
Access to application-wide settings.
Definition: application.h:80
QVariant value(const QString &section, const QString &key, const QVariant &default_value=QVariant())
Getter/setter for settings values.
Definition: settings.h:64

Here is the call graph for this function:

Here is the caller graph for this function:

FormMain* Application::mainForm ( )
inline

Access to main application form.

Returns
Returns pointer to main application form.

Definition at line 160 of file application.h.

160  {
161  return m_mainForm;
162  }
void Application::setJavaInterpreterPath ( const QString &  java_path)
inline

Sets new "java" interpreter path.

Parameters
java_pathNew path to "java".

Definition at line 132 of file application.h.

132  {
133  settings()->setValue(APP_CFG_GEN, "java_path", java_path);
134  }
Settings * settings()
Access to application-wide settings.
Definition: application.h:80
void setValue(const QString &section, const QString &key, const QVariant &value)
Sets new value into settings.
Definition: settings.h:74

Here is the call graph for this function:

void Application::setMainForm ( FormMain main_form)
inline

Setter for main application form.

Parameters
main_formPointer to main application form.

Definition at line 166 of file application.h.

166  {
167  m_mainForm = main_form;
168  }
void Application::setSignApkUtilityPath ( const QString &  signapk_path)

Sets new path to "signapk".

Parameters
signapk_pathNew path to "signapk".

Definition at line 86 of file application.cpp.

86  {
87  settings()->value(APP_CFG_GEN, "signapk_path", signapk_path);
88 }
Settings * settings()
Access to application-wide settings.
Definition: application.h:80
QVariant value(const QString &section, const QString &key, const QVariant &default_value=QVariant())
Getter/setter for settings values.
Definition: settings.h:64

Here is the call graph for this function:

Settings* Application::settings ( )
inline

Access to application-wide settings.

Returns

Definition at line 80 of file application.h.

80  {
81  if (m_settings == NULL) {
82  m_settings = Settings::setupSettings(this);
83  }
84 
85  return m_settings;
86  }
static Settings * setupSettings(QObject *parent)
Creates settings file in correct location.
Definition: settings.cpp:57

Here is the call graph for this function:

Here is the caller graph for this function:

void Application::setZipUtilityPath ( const QString &  zip_path)

Sets new path to "zip".

Parameters
zip_pathPath to "zip".

Definition at line 82 of file application.cpp.

82  {
83  settings()->setValue(APP_CFG_GEN, "zip_path", zip_path);
84 }
Settings * settings()
Access to application-wide settings.
Definition: application.h:80
void setValue(const QString &section, const QString &key, const QVariant &value)
Sets new value into settings.
Definition: settings.h:74

Here is the call graph for this function:

QString Application::signApkUtlityPath ( )
inline

Access to path to "signapk" utility.

Returns
Return path to "signapk".

Definition at line 114 of file application.h.

114  {
115  return settings()->value(APP_CFG_GEN,
116  "signapk_path",
117  QString(APP_SIGNAPK_PATH)).toString();
118  }
Settings * settings()
Access to application-wide settings.
Definition: application.h:80
QVariant value(const QString &section, const QString &key, const QVariant &default_value=QVariant())
Getter/setter for settings values.
Definition: settings.h:64

Here is the call graph for this function:

Here is the caller graph for this function:

SkinFactory * Application::skinFactory ( )

Access to application-wide skin facilities.

Returns
Returns pointer to skin facilities.

Definition at line 74 of file application.cpp.

74  {
75  if (m_skinFactory == NULL) {
76  m_skinFactory = new SkinFactory(this);
77  }
78 
79  return m_skinFactory;
80 }
Main features for skinning.
Definition: skinfactory.h:59
TemplateFactory * Application::templateManager ( )

Access to template high level manager.

See also
TemplateFactory

Definition at line 255 of file application.cpp.

255  {
256  if (m_templateManager == NULL) {
257  m_templateManager = new TemplateFactory(this);
258  }
259 
260  return m_templateManager;
261 }
The top-level manager of templates.
SystemTrayIcon * Application::trayIcon ( )

Access to application tray icon.

Returns
Returns pointer to application tray icon.
Warning
Always use this in cooperation with SystemTrayIcon::isSystemTrayActivated().

Definition at line 246 of file application.cpp.

246  {
247  if (m_trayIcon == NULL) {
248  m_trayIcon = new SystemTrayIcon(APP_ICON_PATH, m_mainForm);
249  m_trayIcon->setToolTip(APP_LONG_NAME);
250  }
251 
252  return m_trayIcon;
253 }
Application-wide tray icon.
QString Application::zipUtilityPath ( )
inline

Access to "zip" utility path.

Returns
Returns path to "zip" utlity.

Definition at line 102 of file application.h.

102  {
103  return settings()->value(APP_CFG_GEN,
104  "zip_path",
105  QString(APP_ZIP_PATH)).toString();
106  }
Settings * settings()
Access to application-wide settings.
Definition: application.h:80
QVariant value(const QString &section, const QString &key, const QVariant &default_value=QVariant())
Getter/setter for settings values.
Definition: settings.h:64

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: