Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Allow tiling of sub-windows horizontally and vertically.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23455 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Nov 19, 2014
1 parent e39ecdd commit 4e1ed68
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 16 deletions.
82 changes: 70 additions & 12 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -1305,7 +1305,7 @@ void MainWindow::showAlgorithmicDebugger()
Slot activated when mpCascadeWindowsAction triggered signal is raised.\n
Arranges all child windows in a cascade pattern.
*/
void MainWindow::cascadeWindows()
void MainWindow::cascadeSubWindows()
{
switch (mpCentralStackedWidget->currentIndex()) {
case 1:
Expand All @@ -1319,17 +1319,34 @@ void MainWindow::cascadeWindows()
}

/*!
Slot activated when mpCascadeWindowsAction triggered signal is raised.\n
Arranges all child windows in a tile pattern.
Slot activated when mpTileWindowsHorizontallyAction triggered signal is raised.\n
Arranges all child windows in a horizontally tiled pattern.
*/
void MainWindow::tileSubWindowsHorizontally()
{
switch (mpCentralStackedWidget->currentIndex()) {
case 1:
tileSubWindows(mpModelWidgetContainer, true);
break;
case 2:
tileSubWindows(mpPlotWindowContainer, true);
default:
break;
}
}

/*!
Slot activated when mpTileWindowsVerticallyAction triggered signal is raised.\n
Arranges all child windows in a vertically tiled pattern.
*/
void MainWindow::tileWindows()
void MainWindow::tileSubWindowsVertically()
{
switch (mpCentralStackedWidget->currentIndex()) {
case 1:
mpModelWidgetContainer->tileSubWindows();
tileSubWindows(mpModelWidgetContainer, false);
break;
case 2:
mpPlotWindowContainer->tileSubWindows();
tileSubWindows(mpPlotWindowContainer, false);
default:
break;
}
Expand Down Expand Up @@ -2045,11 +2062,15 @@ void MainWindow::createActions()
// Cascade windows action
mpCascadeWindowsAction = new QAction(tr("Cascade Windows"), this);
mpCascadeWindowsAction->setStatusTip(tr("Arranges all the child windows in a cascade pattern"));
connect(mpCascadeWindowsAction, SIGNAL(triggered()), SLOT(cascadeWindows()));
// Tile windows action
mpTileWindowsAction = new QAction(tr("Tile Windows"), this);
mpTileWindowsAction->setStatusTip(tr("Arranges all child windows in a tile pattern"));
connect(mpTileWindowsAction, SIGNAL(triggered()), SLOT(tileWindows()));
connect(mpCascadeWindowsAction, SIGNAL(triggered()), SLOT(cascadeSubWindows()));
// Tile windows Horizontally action
mpTileWindowsHorizontallyAction = new QAction(tr("Tile Windows Horizontally"), this);
mpTileWindowsHorizontallyAction->setStatusTip(tr("Arranges all child windows in a horizontally tiled pattern"));
connect(mpTileWindowsHorizontallyAction, SIGNAL(triggered()), SLOT(tileSubWindowsHorizontally()));
// Tile windows Vertically action
mpTileWindowsVerticallyAction = new QAction(tr("Tile Windows Vertically"), this);
mpTileWindowsVerticallyAction->setStatusTip(tr("Arranges all child windows in a vertically tiled pattern"));
connect(mpTileWindowsVerticallyAction, SIGNAL(triggered()), SLOT(tileSubWindowsVertically()));
// Simulation Menu
// instantiate model action
mpInstantiateModelAction = new QAction(QIcon(":/Resources/icons/flatmodel.svg"), tr("Instantiate Model"), this);
Expand Down Expand Up @@ -2332,7 +2353,8 @@ void MainWindow::createMenus()
pViewWindowsMenu->addAction(mpShowAlgorithmicDebuggerAction);
pViewWindowsMenu->addSeparator();
pViewWindowsMenu->addAction(mpCascadeWindowsAction);
pViewWindowsMenu->addAction(mpTileWindowsAction);
pViewWindowsMenu->addAction(mpTileWindowsHorizontallyAction);
pViewWindowsMenu->addAction(mpTileWindowsVerticallyAction);
pViewMenu->addAction(pViewToolbarsMenu->menuAction());
pViewMenu->addAction(pViewWindowsMenu->menuAction());
pViewMenu->addSeparator();
Expand Down Expand Up @@ -2466,6 +2488,42 @@ void MainWindow::switchToPlottingPerspective()
mpPlotToolBar->setEnabled(true);
}

/*!
Arranges all child windows in a horizontally tiled pattern.
\param pMdiArea - the subwindows parent mdi area.
*/
void MainWindow::tileSubWindows(QMdiArea *pMdiArea, bool horizontally)
{
QList<QMdiSubWindow*> subWindowsList = pMdiArea->subWindowList(QMdiArea::ActivationHistoryOrder);
if (subWindowsList.count() < 2) {
pMdiArea->tileSubWindows();
return;
}
QPoint position(0, 0);
for (int i = subWindowsList.size() - 1 ; i >= 0 ; i--) {
QMdiSubWindow *pSubWindow = subWindowsList[i];
if (!pSubWindow->isVisible() || (pSubWindow->isMinimized() && !pSubWindow->isShaded())) {
continue;
}
if (pSubWindow->isMaximized() || pSubWindow->isShaded()) {
pSubWindow->showNormal();
}
QRect rect;
if (horizontally) {
rect = QRect(0, 0, pMdiArea->width(), qMax(pSubWindow->minimumSizeHint().height(), pMdiArea->height() / subWindowsList.count()));
} else {
rect = QRect(0, 0, qMax(pSubWindow->minimumSizeHint().width(), pMdiArea->width() / subWindowsList.count()), pMdiArea->height());
}
pSubWindow->setGeometry(rect);
pSubWindow->move(position);
if (horizontally) {
position.setY(position.y() + pSubWindow->height());
} else {
position.setX(position.x() + pSubWindow->width());
}
}
}

//! Creates the toolbars
void MainWindow::createToolbars()
{
Expand Down
9 changes: 6 additions & 3 deletions OMEdit/OMEditGUI/MainWindow.h
Expand Up @@ -234,7 +234,8 @@ class MainWindow : public QMainWindow
QAction *mpZoomOutAction;
QAction *mpShowAlgorithmicDebuggerAction;
QAction *mpCascadeWindowsAction;
QAction *mpTileWindowsAction;
QAction *mpTileWindowsHorizontallyAction;
QAction *mpTileWindowsVerticallyAction;
// Simulation Menu
QAction *mpInstantiateModelAction;
QAction *mpCheckModelAction;
Expand Down Expand Up @@ -314,8 +315,9 @@ public slots:
void zoomIn();
void zoomOut();
void showAlgorithmicDebugger();
void cascadeWindows();
void tileWindows();
void cascadeSubWindows();
void tileSubWindowsHorizontally();
void tileSubWindowsVertically();
void instantiatesModel();
void checkModel();
void checkAllModels();
Expand Down Expand Up @@ -364,6 +366,7 @@ private slots:
void switchToWelcomePerspective();
void switchToModelingPerspective();
void switchToPlottingPerspective();
void tileSubWindows(QMdiArea *pMdiArea, bool horizontally);
protected:
virtual void dragEnterEvent(QDragEnterEvent *event);
virtual void dragMoveEvent(QDragMoveEvent *event);
Expand Down
1 change: 0 additions & 1 deletion OMEdit/OMEditGUI/Plotting/PlotWindowContainer.cpp
Expand Up @@ -44,7 +44,6 @@ using namespace OMPlot;
PlotWindowContainer::PlotWindowContainer(MainWindow *pParent)
: MdiArea(pParent)
{
setActivationOrder(QMdiArea::CreationOrder);
if (mpMainWindow->getOptionsDialog()->getGeneralSettingsPage()->getPlottingViewMode().compare(Helper::subWindow) == 0)
setViewMode(QMdiArea::SubWindowView);
else
Expand Down

0 comments on commit 4e1ed68

Please sign in to comment.