Skip to content

Commit

Permalink
- Fixed the MainWindow title changes when user switches between diffe…
Browse files Browse the repository at this point in the history
…rent models, plots & perspectives.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22858 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Oct 21, 2014
1 parent 2cd7fe4 commit 6705932
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 42 deletions.
51 changes: 15 additions & 36 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -171,15 +171,16 @@ MainWindow::MainWindow(QSplashScreen *pSplashScreen, QWidget *parent)
mpInfoBar->hide();
//Create a centralwidget for the main window
QWidget *pCentralwidget = new QWidget;
mpCentralStackedWidget = new QStackedWidget;
mpCentralStackedWidget->addWidget(mpWelcomePageWidget);
mpCentralStackedWidget->addWidget(mpModelWidgetContainer);
mpCentralStackedWidget->addWidget(mpPlotWindowContainer);
// set the layout
QGridLayout *pCentralgrid = new QGridLayout;
pCentralgrid->setVerticalSpacing(4);
pCentralgrid->setContentsMargins(0, 1, 0, 0);
pCentralgrid->addWidget(mpInfoBar, 0, 0);
pCentralgrid->addWidget(mpWelcomePageWidget, 1, 0);
pCentralgrid->addWidget(mpModelWidgetContainer, 1, 0);
pCentralgrid->addWidget(mpPlotWindowContainer, 1, 0);
//pCentralgrid->addWidget(mpInteractiveSimualtionTabWidget, 1, 0);
pCentralgrid->addWidget(mpCentralStackedWidget, 1, 0);
pCentralwidget->setLayout(pCentralgrid);
//Set the centralwidget
setCentralWidget(pCentralwidget);
Expand Down Expand Up @@ -207,9 +208,6 @@ MainWindow::MainWindow(QSplashScreen *pSplashScreen, QWidget *parent)
mpPerspectiveTabbar->addTab(QIcon(":/Resources/icons/omedit.png"), tr("Welcome"));
mpPerspectiveTabbar->addTab(QIcon(":/Resources/icons/modeling.png"), tr("Modeling"));
mpPerspectiveTabbar->addTab(QIcon(":/Resources/icons/omplot.png"), tr("Plotting"));
/* Remove the interactive simulation tab until we make it run again. */
// mpPerspectiveTabbar->addTab(QIcon(":/Resources/icons/interactive-simulation.png"), tr("Interactive Simulation"));
// mpPerspectiveTabbar->setTabEnabled(3, false);
connect(mpPerspectiveTabbar, SIGNAL(currentChanged(int)), SLOT(perspectiveTabChanged(int)));
mpStatusBar->addPermanentWidget(mpPerspectiveTabbar);
// set status bar for MainWindow
Expand Down Expand Up @@ -1050,7 +1048,7 @@ TransformationsWidget *MainWindow::showTransformationsWidget(QString fileName)
void MainWindow::createNewModelicaClass()
{
ModelicaClassDialog *pModelicaClassDialog = new ModelicaClassDialog(this);
pModelicaClassDialog->show();
pModelicaClassDialog->exec();
}

void MainWindow::createNewTLMFile()
Expand Down Expand Up @@ -1798,9 +1796,6 @@ void MainWindow::perspectiveTabChanged(int tabIndex)
case 2:
switchToPlottingPerspective();
break;
// case 3:
// switchToInteractiveSimulationPerspective();
// break;
default:
switchToWelcomePerspective();
break;
Expand Down Expand Up @@ -2315,53 +2310,37 @@ void MainWindow::createMenus()

void MainWindow::switchToWelcomePerspective()
{
mpWelcomePageWidget->setVisible(true);
mpModelWidgetContainer->setVisible(false);
mpPlotWindowContainer->tileSubWindows();
mpCentralStackedWidget->setCurrentWidget(mpWelcomePageWidget);
mpModelWidgetContainer->currentModelWidgetChanged(0);
mpModelSwitcherToolButton->setEnabled(false);
mpPlotWindowContainer->setVisible(false);
mpVariablesDockWidget->hide();
mpPlotToolBar->setEnabled(false);
//mpInteractiveSimualtionTabWidget->setVisible(false);
}

void MainWindow::switchToModelingPerspective()
{
mpWelcomePageWidget->setVisible(false);
mpModelWidgetContainer->setVisible(true);
mpPlotWindowContainer->tileSubWindows();
mpCentralStackedWidget->setCurrentWidget(mpModelWidgetContainer);
mpModelWidgetContainer->currentModelWidgetChanged(mpModelWidgetContainer->getCurrentMdiSubWindow());
mpModelSwitcherToolButton->setEnabled(true);
mpPlotWindowContainer->setVisible(false);
mpVariablesDockWidget->hide();
mpPlotToolBar->setEnabled(false);
//mpInteractiveSimualtionTabWidget->setVisible(false);
}

void MainWindow::switchToPlottingPerspective()
{
mpWelcomePageWidget->setVisible(false);
mpModelWidgetContainer->setVisible(false);
mpCentralStackedWidget->setCurrentWidget(mpPlotWindowContainer);
mpModelWidgetContainer->currentModelWidgetChanged(0);
mpModelSwitcherToolButton->setEnabled(false);
// if not plotwindow is opened then open one for user
if (mpPlotWindowContainer->subWindowList().size() == 0)
if (mpPlotWindowContainer->subWindowList().size() == 0) {
mpPlotWindowContainer->addPlotWindow();
mpPlotWindowContainer->setVisible(true);
} else {
mpPlotWindowContainer->getCurrentWindow()->setWindowState(Qt::WindowMaximized);
}
mpVariablesDockWidget->show();
mpPlotToolBar->setEnabled(true);
//mpInteractiveSimualtionTabWidget->setVisible(false);
}

void MainWindow::switchToInteractiveSimulationPerspective()
{
mpWelcomePageWidget->setVisible(false);
mpModelWidgetContainer->setVisible(false);
mpModelWidgetContainer->currentModelWidgetChanged(0);
mpModelSwitcherToolButton->setEnabled(false);
mpPlotWindowContainer->setVisible(false);
mpVariablesDockWidget->hide();
mpPlotToolBar->setEnabled(false);
//mpInteractiveSimualtionTabWidget->setVisible(true);
}

//! Creates the toolbars
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/MainWindow.h
Expand Up @@ -192,6 +192,7 @@ class MainWindow : public QMainWindow
WelcomePageWidget *mpWelcomePageWidget;
AboutOMEditWidget *mpAboutOMEditDialog;
InfoBar *mpInfoBar;
QStackedWidget *mpCentralStackedWidget;
QStatusBar *mpStatusBar;
QProgressBar *mpProgressBar;
Label *mpPointerXPositionLabel;
Expand Down
3 changes: 1 addition & 2 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -1854,8 +1854,7 @@ void LibraryTreeWidget::showModelWidget(LibraryTreeNode *pLibraryTreeNode, bool
{
QApplication::setOverrideCursor(Qt::WaitCursor);
QList<QTreeWidgetItem*> selectedItemsList = selectedItems();
if (pLibraryTreeNode == 0)
{
if (pLibraryTreeNode == 0) {
if (selectedItemsList.isEmpty()) {
QApplication::restoreOverrideCursor();
return;
Expand Down
1 change: 0 additions & 1 deletion OMEdit/OMEditGUI/Modeling/ModelicaClassDialog.cpp
Expand Up @@ -201,7 +201,6 @@ ModelicaClassDialog::ModelicaClassDialog(MainWindow *pParent)
setWindowTitle(QString(Helper::applicationName).append(" - ").append(Helper::createNewModelicaClass));
setMinimumWidth(400);
mpMainWindow = pParent;
setModal(true);
// Create the name label and text box
mpNameLabel = new Label(Helper::name);
mpNameTextBox = new QLineEdit;
Expand Down
5 changes: 2 additions & 3 deletions OMEdit/OMEditGUI/Plotting/PlotWindowContainer.cpp
Expand Up @@ -44,7 +44,6 @@ using namespace OMPlot;
PlotWindowContainer::PlotWindowContainer(MainWindow *pParent)
: MdiArea(pParent)
{
mpMainWindow = pParent;
setActivationOrder(QMdiArea::CreationOrder);
if (mpMainWindow->getOptionsDialog()->getGeneralSettingsPage()->getPlottingViewMode().compare(Helper::subWindow) == 0)
setViewMode(QMdiArea::SubWindowView);
Expand Down Expand Up @@ -81,14 +80,14 @@ PlotWindow* PlotWindowContainer::getCurrentWindow()
bool PlotWindowContainer::eventFilter(QObject *pObject, QEvent *pEvent)
{
PlotWindow *pPlotWindow = qobject_cast<PlotWindow*>(pObject);
if (pPlotWindow && pEvent->type() == QEvent::Paint)
{
if (pPlotWindow && pEvent->type() == QEvent::Paint) {
QPainter painter (pPlotWindow);
painter.setPen(Qt::gray);
QRect rectangle = pPlotWindow->rect();
rectangle.setWidth(pPlotWindow->rect().width() - 1);
rectangle.setHeight(pPlotWindow->rect().height() - 1);
painter.drawRect(rectangle);
return true;
}
return QMdiArea::eventFilter(pObject, pEvent);
}
Expand Down

0 comments on commit 6705932

Please sign in to comment.