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

Main application window. More...

#include <formmain.h>

Collaboration diagram for FormMain:
Collaboration graph

Public Slots

void switchVisibility (bool force_hide=false)
 Switches visibility of main window. More...
 
void show ()
 Displays window. More...
 
void display ()
 Displays the window. More...
 
void openNewProjectDialog ()
 Opens "New project" dialog. More...
 
void openSaveProjectDialog ()
 
void openSaveProjectAsDialog ()
 
void openLoadProjectDialog ()
 
void generateMobileApplication ()
 Generates mobile APK application from currently active project.
 
void uploadMobileApplicationToStore ()
 Displays dialog for uploading applications to store.
 
bool saveUnsavedProject ()
 Performs necessary steps to save active project if there is unsaved work. More...
 

Signals

void resized ()
 Emitted when window is resized.
 
void moved ()
 Emitted when window is moved.
 

Public Member Functions

 FormMain (QWidget *parent=0)
 Constructor. More...
 
QMenu * trayMenu () const
 Access to tray menu. More...
 
FormSimulatorsimulatorWindow () const
 Access to simulator window. More...
 
QList< QAction * > allActions ()
 Access to all actions provided by this window. More...
 

Protected Member Functions

void closeEvent (QCloseEvent *e)
 Executed when main application window is closed. More...
 
void moveEvent (QMoveEvent *e)
 Executed when window is moved. More...
 
void resizeEvent (QResizeEvent *e)
 Executed when window is resized. More...
 

Detailed Description

Main application window.

Definition at line 53 of file formmain.h.

Constructor & Destructor Documentation

FormMain::FormMain ( QWidget *  parent = 0)
explicit

Constructor.

Parameters
parentParent widget.

Definition at line 63 of file formmain.cpp.

64  : QMainWindow(parent),
65  m_statusProgress(new QProgressBar(this)),
66  m_statusLabel(new QLabel(this)),
67  m_centralArea(new QScrollArea(this)),
68  m_centralLayout(new QVBoxLayout(m_centralArea)),
69  m_firstTimeShow(true),
70  m_ui(new Ui::FormMain),
71  m_simulatorWindow(NULL) {
72  m_ui->setupUi(this);
73 
74  m_normalTitle = APP_LONG_NAME;
75  m_unsavedTitle = m_normalTitle + " *";
76 
77  m_statusProgress->setFixedHeight(m_ui->m_statusBar->sizeHint().height());
78 
79  // Addd necessary widgets to status.
80  m_ui->m_statusBar->addWidget(m_statusProgress);
81  m_ui->m_statusBar->addWidget(m_statusLabel, 1);
82  m_statusLabel->setVisible(false);
83  m_statusProgress->setVisible(false);
84 
85  setWindowTitle(m_normalTitle);
86 
87  // Disable "maximize" button.
88  setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint);
89 
90  m_centralArea->setFrameStyle(QFrame::NoFrame);
91 
92  setCentralWidget(m_centralArea);
93  setupSimulatorWindow();
94  setupActionShortcuts();
95  setupIcons();
96  setupTrayMenu();
97  setupToolbar();
98  loadSizeAndPosition();
99  createConnections();
100 
101  //#if !defined(DEBUG)
102 #if defined(DISABLE_STORE)
103  m_ui->m_actionUploadApplicationToStore->setVisible(false);
104 #else
105  if (!qApp->settings()->value(APP_CFG_GEN, "enable_store", true).toBool()) {
106  m_ui->m_actionUploadApplicationToStore->setVisible(false);
107  }
108 #endif
109 
110 #if defined(DISABLE_APK_GENERATION)
111  m_ui->m_actionGenerateMobileApplication->setVisible(false);
112 #else
113  if (!qApp->settings()->value(APP_CFG_GEN, "enable_apk_generation", true).toBool()) {
114  m_ui->m_actionGenerateMobileApplication->setVisible(false);
115  }
116 #endif
117  //#endif
118 
119  // Make sure simulator window is displayed.
120  m_ui->m_actionViewSimulatorWindow->setChecked(m_simulatorWindow->isVisibleOnStartup());
121  m_ui->m_actionStickSimulatorWindow->setChecked(m_simulatorWindow->isSticked());
122 }
bool isVisibleOnStartup() const
Indicates whether simulator window should be shown when application launches.
Definition: formsimulator.h:45
bool isSticked() const
Indicates whether simulator window is sticked to main window or not.
Definition: formsimulator.h:39

Here is the call graph for this function:

Member Function Documentation

QList< QAction * > FormMain::allActions ( )

Access to all actions provided by this window.

See also
DynamicShortcuts

Definition at line 130 of file formmain.cpp.

130  {
131  QList<QAction*> actions;
132 
133  actions.append(m_ui->m_actionCheckForUpdates);
134  actions.append(m_ui->m_actionGenerateMobileApplication);
135  actions.append(m_ui->m_actionUploadApplicationToStore);
136  actions.append(m_ui->m_actionLoadProject);
137  actions.append(m_ui->m_actionNewProject);
138  actions.append(m_ui->m_actionSaveProject);
139  actions.append(m_ui->m_actionSaveProjectAs);
140  actions.append(m_ui->m_actionSimulatorRun);
141  actions.append(m_ui->m_actionSimulatorStop);
142  actions.append(m_ui->m_actionSimulatorGoBack);
143  actions.append(m_ui->m_actionViewSimulatorWindow);
144  actions.append(m_ui->m_actionStickSimulatorWindow);
145  actions.append(m_ui->m_actionQuit);
146  actions.append( m_ui->m_actionSettings);
147  actions.append(m_ui->m_actionHelp);
148 
149  return actions;
150 }

Here is the caller graph for this function:

void FormMain::closeEvent ( QCloseEvent *  e)
protected

Executed when main application window is closed.

Parameters
eEvent message.

Definition at line 711 of file formmain.cpp.

711  {
712  if (!qApp->isClosing()) {
713  if (!saveUnsavedProject()) {
714  e->ignore();
715  return;
716  }
717  }
718 
720  qApp->trayIcon()->hide();
721  }
722 
723  e->accept();
724  qApp->quit();
725 }
bool saveUnsavedProject()
Performs necessary steps to save active project if there is unsaved work.
Definition: formmain.cpp:682
static bool isSystemTrayAvailable()
Indicates whether tray icon is supported.

Here is the call graph for this function:

void FormMain::display ( )
slot

Displays the window.

See also
show()

Definition at line 569 of file formmain.cpp.

569  {
570  // Make sure window is not minimized.
571  setWindowState(windowState() & ~Qt::WindowMinimized);
572 
573  // Display the window and make sure it is raised on top.
574  show();
575  activateWindow();
576  raise();
577 
578  // Raise alert event. Check the documentation for more info on this.
579  Application::alert(this);
580 }
void show()
Displays window.
Definition: formmain.cpp:557

Here is the call graph for this function:

Here is the caller graph for this function:

void FormMain::moveEvent ( QMoveEvent *  e)
protected

Executed when window is moved.

Parameters
eEvent message.

Definition at line 727 of file formmain.cpp.

727  {
728  e->accept();
729  emit moved();
730 }
void moved()
Emitted when window is moved.
void FormMain::openNewProjectDialog ( )
slot

Opens "New project" dialog.

See also
FormNewProject

Definition at line 640 of file formmain.cpp.

640  {
641  if (!saveUnsavedProject()) {
642  return;
643  }
644 
645  QPointer<FormNewProject> form_new_project = new FormNewProject(qApp->templateManager(), this);
646  TemplateEntryPoint *entry_point = form_new_project.data()->startNewTemplate();
647 
648  delete form_new_project.data();
649 
650  if (entry_point != NULL) {
651  // User selected proper template to start with.
652  // Load the template.
653  qApp->templateManager()->startNewProject(entry_point);
654  }
655 }
bool saveUnsavedProject()
Performs necessary steps to save active project if there is unsaved work.
Definition: formmain.cpp:682
The entry point for a template.
Dialog for creating new projects.

Here is the call graph for this function:

void FormMain::resizeEvent ( QResizeEvent *  e)
protected

Executed when window is resized.

Parameters
eEvent message.

Definition at line 732 of file formmain.cpp.

732  {
733  e->accept();
734  emit resized();
735 }
void resized()
Emitted when window is resized.
bool FormMain::saveUnsavedProject ( )
slot

Performs necessary steps to save active project if there is unsaved work.

Returns
Returns true if there is no opened project or current project is already saved, otherwise returns false.

Definition at line 682 of file formmain.cpp.

682  {
683  if (qApp->templateManager()->activeCore() != NULL) {
684  if (qApp->templateManager()->activeCore()->editor()->isDirty()) {
685  QMessageBox::StandardButton decision = CustomMessageBox::show(this,
686  QMessageBox::Warning,
687  tr("Unsaved work"),
688  tr("There is unsaved project. You might want to save your current project, unless you do not mind losing your unsaved work."),
689  tr("Do you want to save your unsaved project before proceeding?"), QString(),
690  QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
691  QMessageBox::Yes);
692 
693  switch (decision) {
694  case QMessageBox::Yes:
695  openSaveProjectDialog();
696  return true;
697 
698  case QMessageBox::No:
699  return true;
700 
701  case QMessageBox::Cancel:
702  default:
703  return false;
704  }
705  }
706  }
707 
708  return true;
709 }
static QMessageBox::StandardButton show(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, const QString &informative_text=QString(), const QString &detailed_text=QString(), QMessageBox::StandardButtons buttons=QMessageBox::Ok, QMessageBox::StandardButton default_button=QMessageBox::Ok)
Displays custom message box.

Here is the call graph for this function:

Here is the caller graph for this function:

void FormMain::show ( )
slot

Displays window.

See also
display(), switchVisibility()

Definition at line 557 of file formmain.cpp.

557  {
558  QMainWindow::show();
559 
560  if (m_firstTimeShow) {
561  m_firstTimeShow = false;
562 
563  if (qApp->settings()->value(APP_CFG_GUI, "show_help_startup", true).toBool()) {
564  showHelp(true);
565  }
566  }
567 }

Here is the caller graph for this function:

FormSimulator* FormMain::simulatorWindow ( ) const
inline

Access to simulator window.

See also
FormSimulator

Definition at line 70 of file formmain.h.

70  {
71  return m_simulatorWindow;
72  }
void FormMain::switchVisibility ( bool  force_hide = false)
slot

Switches visibility of main window.

Parameters
force_hideIf true, then window is not switched but hidden.

Definition at line 537 of file formmain.cpp.

537  {
538  if (force_hide || isVisible()) {
540  hide();
541  m_simulatorWindow->hide();
542  }
543  else {
544  // Window gets minimized in single-window mode.
545  showMinimized();
546  }
547  }
548  else {
549  display();
550 
552  m_simulatorWindow->show();
553  }
554  }
555 }
void show()
Displays simulator window.
void display()
Displays the window.
Definition: formmain.cpp:569
static bool isSystemTrayAvailable()
Indicates whether tray icon is supported.

Here is the call graph for this function:

QMenu* FormMain::trayMenu ( ) const
inline

Access to tray menu.

See also
SystemTrayIcon

Definition at line 64 of file formmain.h.

64  {
65  return m_trayMenu;
66  }

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