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
formmain.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 FORMMAIN_H
32 #define FORMMAIN_H
33 
34 #include "ui_formmain.h"
35 
36 #include "gui/formnewproject.h"
37 #include "core/templatecore.h"
38 
39 #include <QMainWindow>
40 #include <QHash>
41 #include <QtGui>
42 
43 
44 namespace Ui {
45  class FormMain;
46 }
47 
48 class FormSimulator;
49 class QProgressBar;
50 class QScrollArea;
51 
52 /// \brief Main application window.
53 class FormMain : public QMainWindow {
54  Q_OBJECT
55 
56  public:
57  /// \brief Constructor.
58  /// \param parent Parent widget.
59  explicit FormMain(QWidget *parent = 0);
60  virtual ~FormMain();
61 
62  /// \brief Access to tray menu.
63  /// \see SystemTrayIcon
64  inline QMenu *trayMenu() const {
65  return m_trayMenu;
66  }
67 
68  /// \brief Access to simulator window.
69  /// \see FormSimulator
70  inline FormSimulator *simulatorWindow() const {
71  return m_simulatorWindow;
72  }
73 
74  /// \brief Access to all actions provided by this window.
75  /// \see DynamicShortcuts
76  QList<QAction*> allActions();
77 
78  private:
79  void createConnections();
80  void setupSimulatorWindow();
81  void setupActionShortcuts();
82  void setupIcons();
83  void setupToolbar();
84  void setupTrayMenu();
85 
86  void loadSizeAndPosition();
87  void saveSizeAndPosition();
88 
89  private slots:
90  // Called when user hits "Quit" button.
91  void quit();
92 
93  // Starts new simulation.
94  void startSimulation();
95 
96  // Goes one step back on active simulation.
97  void takeSimulationOneStepBack();
98 
99  // Called when generation status of current template is changed by its editor part.
100  void onCanGenerateChanged(bool can_generate, const QString &informative_text);
101 
102  // Called when user/application changes some external applications.
103  void onExternalApplicationsChanged();
104 
105  // Called when contents of active editor is changed,
106  // thus there are new unsaved changes.
107  void onEditorChanged();
108 
109  void onGenerationProgress(int percentage_completed, const QString &message);
110  void onGenerationStarted();
111  void onGenerationDone(TemplateCore::GenerationResult result_code, const QString &output_file);
112 
113  // Opens output application/directory.
114  void openOutputDirectory();
115 
116  // Called when user opens new project or loads existing project.
117  // This should read "editor" from core and set it as central widget.
118  void setTemplateCore(TemplateCore *core);
119 
120  void onAboutToQuit();
121  void onSimulatorWindowClosed();
122  void switchSimulatorWindow(bool show);
123 
124  void showSimulator();
125  void showSettings();
126  void showAbout();
127  void showUpdates();
128  void showHelp(bool enable_do_not_show_again_option = false);
129  void showUpdatesAfterBubbleClick();
130 
131  public slots:
132  /// \brief Switches visibility of main window.
133  /// \param force_hide If true, then window is not switched but hidden.
134  void switchVisibility(bool force_hide = false);
135 
136  /// \brief Displays window.
137  /// \see display(), switchVisibility()
138  void show();
139 
140  /// \brief Displays the window.
141  /// \see show()
142  void display();
143 
144  /// \brief Opens "New project" dialog.
145  /// \see FormNewProject
146  void openNewProjectDialog();
147 
148  void openSaveProjectDialog();
149  void openSaveProjectAsDialog();
150  void openLoadProjectDialog();
151 
152  /// \brief Generates mobile APK application from currently active
153  /// project.
155 
156  /// \brief Displays dialog for uploading applications to store.
158 
159  /// \brief Performs necessary steps to save active project if there is unsaved work.
160  /// \return Returns true if there is no opened project or current project is already saved,
161  /// otherwise returns false.
162  bool saveUnsavedProject();
163 
164  protected:
165  /// \brief Executed when main application window is closed.
166  /// \param e Event message.
167  void closeEvent(QCloseEvent *e);
168 
169  /// \brief Executed when window is moved.
170  /// \param e Event message.
171  void moveEvent(QMoveEvent *e);
172 
173  /// \brief Executed when window is resized.
174  /// \param e Event message.
175  void resizeEvent(QResizeEvent *e);
176 
177  signals:
178  /// \brief Emitted when window is resized.
179  void resized();
180 
181  /// \brief Emitted when window is moved.
182  void moved();
183 
184  private:
185  QProgressBar *m_statusProgress;
186  QLabel *m_statusLabel;
187 
188  QScrollArea *m_centralArea;
189  QVBoxLayout *m_centralLayout;
190  bool m_firstTimeShow;
191  Ui::FormMain *m_ui;
192  QMenu *m_trayMenu;
193  FormSimulator *m_simulatorWindow;
194 
195  QString m_normalTitle;
196  QString m_unsavedTitle;
197 
198  QString m_generatedApplicationPath;
199 };
200 
201 #endif // FORMMAIN_H
void generateMobileApplication()
Generates mobile APK application from currently active project.
Definition: formmain.cpp:657
void switchVisibility(bool force_hide=false)
Switches visibility of main window.
Definition: formmain.cpp:537
void moved()
Emitted when window is moved.
Separate window which contains active simulator.
Definition: formsimulator.h:19
Main application window.
Definition: formmain.h:53
void resizeEvent(QResizeEvent *e)
Executed when window is resized.
Definition: formmain.cpp:732
FormSimulator * simulatorWindow() const
Access to simulator window.
Definition: formmain.h:70
void moveEvent(QMoveEvent *e)
Executed when window is moved.
Definition: formmain.cpp:727
void uploadMobileApplicationToStore()
Displays dialog for uploading applications to store.
Definition: formmain.cpp:668
void openNewProjectDialog()
Opens "New project" dialog.
Definition: formmain.cpp:640
void resized()
Emitted when window is resized.
void show()
Displays window.
Definition: formmain.cpp:557
void display()
Displays the window.
Definition: formmain.cpp:569
bool saveUnsavedProject()
Performs necessary steps to save active project if there is unsaved work.
Definition: formmain.cpp:682
FormMain(QWidget *parent=0)
Constructor.
Definition: formmain.cpp:63
void closeEvent(QCloseEvent *e)
Executed when main application window is closed.
Definition: formmain.cpp:711
QList< QAction * > allActions()
Access to all actions provided by this window.
Definition: formmain.cpp:130
The core class container for single template.
Definition: templatecore.h:43
GenerationResult
Possible results of generation of bundle data.
Definition: templatecore.h:48
QMenu * trayMenu() const
Access to tray menu.
Definition: formmain.h:64