Changeset 14f3280 in OpenModelica


Ignore:
Timestamp:
2016-07-01T00:55:43+02:00 (8 years ago)
Author:
Adeel Asghar <adeel.asghar@…>
Branches:
Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
Children:
612047b
Parents:
4de91514
Message:

Only create dialogs when they are really needed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OMEdit/OMEditGUI/MainWindow.cpp

    r86dd3e9 r14f3280  
    6363   * Don't remove/move the following lines.
    6464   * Because RecentFile, FindTextOM and DebuggerConfiguration structs should be registered before reading the recentFilesList, FindTextOM and
    65      DebuggerConfiguration section respectively from the settings file.
     65   * DebuggerConfiguration section respectively from the settings file.
    6666   */
    6767  qRegisterMetaTypeStreamOperators<RecentFile>("RecentFile");
     
    251251  createToolbars();
    252252  createMenus();
    253   // Create simulation dialog
    254   mpSimulationDialog = new SimulationDialog(this);
    255   // Create TLM co-simulation dialog
    256   mpTLMCoSimulationDialog = new TLMCoSimulationDialog(this);
     253  // Create simulation dialog when needed
     254  mpSimulationDialog = 0;
     255  // Create TLM co-simulation dialog when needed
     256  mpTLMCoSimulationDialog = 0;
    257257  // Create an object of ModelWidgetContainer
    258258  mpModelWidgetContainer = new ModelWidgetContainer(this);
     
    260260  mpWelcomePageWidget = new WelcomePageWidget(this);
    261261  updateRecentFileActions();
    262   // create the OMEdit About widget
    263   mpAboutOMEditDialog = new AboutOMEditWidget(this);
    264   mpAboutOMEditDialog->hide();
     262  // create the OMEdit About widget when needed
     263  mpAboutOMEditDialog = 0;
    265264  // create an instance of InfoBar
    266265  mpInfoBar = new InfoBar(this);
     
    455454  delete mpOMCProxy;
    456455  delete mpModelWidgetContainer;
    457   delete mpSimulationDialog;
    458   delete mpTLMCoSimulationDialog;
     456  if (mpSimulationDialog) {
     457    delete mpSimulationDialog;
     458  }
     459  if (mpTLMCoSimulationDialog) {
     460    delete mpTLMCoSimulationDialog;
     461  }
     462  if (mpAboutOMEditDialog) {
     463    delete mpAboutOMEditDialog;
     464  }
    459465  /* save the TransformationsWidget last window geometry and splitters state. */
    460466  QSettings *pSettings = Utilities::getApplicationSettings();
     
    552558void MainWindow::simulate(LibraryTreeItem *pLibraryTreeItem)
    553559{
     560  if (!mpSimulationDialog) {
     561    mpSimulationDialog = new SimulationDialog(this);
     562  }
    554563  /* if Modelica text is changed manually by user then validate it before saving. */
    555564  if (pLibraryTreeItem->getModelWidget()) {
     
    563572void MainWindow::simulateWithTransformationalDebugger(LibraryTreeItem *pLibraryTreeItem)
    564573{
     574  if (!mpSimulationDialog) {
     575    mpSimulationDialog = new SimulationDialog(this);
     576  }
    565577  /* if Modelica text is changed manually by user then validate it before saving. */
    566578  if (pLibraryTreeItem->getModelWidget()) {
     
    574586void MainWindow::simulateWithAlgorithmicDebugger(LibraryTreeItem *pLibraryTreeItem)
    575587{
     588  if (!mpSimulationDialog) {
     589    mpSimulationDialog = new SimulationDialog(this);
     590  }
    576591  /* if Modelica text is changed manually by user then validate it before saving. */
    577592  if (pLibraryTreeItem->getModelWidget()) {
     
    585600void MainWindow::simulationSetup(LibraryTreeItem *pLibraryTreeItem)
    586601{
     602  if (!mpSimulationDialog) {
     603    mpSimulationDialog = new SimulationDialog(this);
     604  }
    587605  /* if Modelica text is changed manually by user then validate it before saving. */
    588606  if (pLibraryTreeItem->getModelWidget()) {
     
    802820void MainWindow::TLMSimulate(LibraryTreeItem *pLibraryTreeItem)
    803821{
     822  if (!mpTLMCoSimulationDialog) {
     823    mpTLMCoSimulationDialog = new TLMCoSimulationDialog(this);
     824  }
    804825  /* if MetaModel text is changed manually by user then validate it before starting the TLM co-simulation. */
    805826  if (pLibraryTreeItem->getModelWidget()) {
     
    20302051void MainWindow::openAboutOMEdit()
    20312052{
     2053  if (!mpAboutOMEditDialog) {
     2054    mpAboutOMEditDialog = new AboutOMEditWidget(this);
     2055  }
    20322056  mpAboutOMEditDialog->setGeometry(QRect(rect().center() - QPoint(262, 235), rect().center() + QPoint(262, 235)));
    20332057  mpAboutOMEditDialog->setFocus(Qt::ActiveWindowFocusReason);
     
    32933317
    32943318/*!
    3295   \class AboutOMEditWidget
    3296   \brief Creates a widget that shows the about text of OMEdit.
    3297 
    3298   Information about OpenModelica Connection Editor. Shows the list of OMEdit contributors.
    3299   */
    3300 
    3301 /*!
    3302   \param pParent - pointer to MainWindow
    3303   */
     3319 * \class AboutOMEditWidget
     3320 * \brief Creates a widget that shows the about text of OMEdit.
     3321 * Information about OpenModelica Connection Editor. Shows the list of OMEdit contributors.
     3322 */
     3323/*!
     3324 * \brief AboutOMEditWidget::AboutOMEditWidget
     3325 * \param pParent - pointer to MainWindow
     3326 */
    33043327AboutOMEditWidget::AboutOMEditWidget(MainWindow *pMainWindow)
    33053328  : QWidget(pMainWindow)
     
    33803403  // set the layout
    33813404  QGridLayout *pMainLayout = new QGridLayout;
    3382   pMainLayout->setContentsMargins(45, 200, 45, 20);
     3405  pMainLayout->setContentsMargins(25, 200, 25, 20);
    33833406  pMainLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
    33843407  pMainLayout->addWidget(pScrollArea, 0, 0);
     
    33883411
    33893412/*!
    3390   Reimplementation of paintEvent.\n
    3391   Draws the background image.
    3392   \param event - pointer to QPaintEvent
    3393   */
     3413 * \brief AboutOMEditWidget::paintEvent
     3414 * Reimplementation of paintEvent.\n
     3415 * Draws the background image.
     3416 * \param event - pointer to QPaintEvent
     3417 */
    33943418void AboutOMEditWidget::paintEvent(QPaintEvent *pEvent)
    33953419{
     
    34013425
    34023426/*!
    3403   Reimplementation of keyPressEvent.\n
    3404   Hides the widget.
    3405   */
     3427 * \brief AboutOMEditWidget::keyPressEvent
     3428 * Reimplementation of keyPressEvent.\n
     3429 * Hides the widget when ESC key is pressed.
     3430 * \param pEvent
     3431 */
    34063432void AboutOMEditWidget::keyPressEvent(QKeyEvent *pEvent)
    34073433{
    3408   if (pEvent->key() == Qt::Key_Escape)
     3434  if (pEvent->key() == Qt::Key_Escape) {
    34093435    hide();
     3436  }
    34103437  QWidget::keyPressEvent(pEvent);
    34113438}
Note: See TracChangeset for help on using the changeset viewer.