X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_MainWindow.cpp;h=1400fc0ccc7f4c502b092cbdae6bc5b93cd4532b;hb=037c2e978c242407cc2e4357a84c3ffead3e877d;hp=02971608f331e87376ad1045919c1a0643899ecf;hpb=277db1718bb7a3226515e4cc2272d83b463b3434;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_MainWindow.cpp b/src/XGUI/XGUI_MainWindow.cpp index 02971608f..1400fc0cc 100644 --- a/src/XGUI/XGUI_MainWindow.cpp +++ b/src/XGUI/XGUI_MainWindow.cpp @@ -13,6 +13,8 @@ #include #include #include +#include +#include XGUI_MainWindow::XGUI_MainWindow(QWidget* parent) : QMainWindow(parent), @@ -40,11 +42,15 @@ XGUI_MainWindow::XGUI_MainWindow(QWidget* parent) aMdiArea->addAction(aAction); connect(aAction, SIGNAL(triggered(bool)), this, SLOT(cascadeWindows())); + aAction = new QAction(aMdiArea); + aAction->setSeparator(true); + aMdiArea->addAction(aAction); + myViewer = new XGUI_Viewer(this); connect(myViewer, SIGNAL(viewCreated(XGUI_ViewWindow*)), this, SLOT(onViewCreated(XGUI_ViewWindow*))); connect(myViewer, SIGNAL(deleteView(XGUI_ViewWindow*)), - this, SLOT(onViewCreated(XGUI_ViewWindow*))); + this, SLOT(onDeleteView(XGUI_ViewWindow*))); } XGUI_MainWindow::~XGUI_MainWindow(void) @@ -129,13 +135,8 @@ void XGUI_MainWindow::onViewCreated(XGUI_ViewWindow* theWindow) { QWidget* aSubWindow = theWindow->parentWidget(); QWidget* aMDIWidget = centralWidget(); - QAction* aAction; - if (aMDIWidget->actions().size() == 3) { - aAction = new QAction(aMDIWidget); - aAction->setSeparator(true); - aMDIWidget->addAction(aAction); - } - aAction = new QAction(aSubWindow->windowTitle(), aMDIWidget); + + QAction* aAction = new QAction(aSubWindow->windowTitle(), aMDIWidget); aAction->setCheckable(true); connect(aAction, SIGNAL(triggered(bool)), this, SLOT(activateView())); aMDIWidget->addAction(aAction); @@ -172,15 +173,18 @@ void XGUI_MainWindow::activateView() QMdiArea* aMdiArea = static_cast(centralWidget()); QList aWndList = aMdiArea->subWindowList(); + QMdiSubWindow* aTargetView = 0; foreach(QMdiSubWindow* aWnd, aWndList) { if (aWnd->windowTitle() == aWndTitle) { aWnd->raise(); aWnd->activateWindow(); - aWnd->setFocus(); + aTargetView = aWnd; break; } } QApplication::processEvents(); + if (aTargetView) + QTimer::singleShot(20, aTargetView, SLOT(setFocus())); } void XGUI_MainWindow::onViewActivated(QMdiSubWindow* theSubWnd) @@ -194,4 +198,10 @@ void XGUI_MainWindow::onViewActivated(QMdiSubWindow* theSubWnd) if (aAct->isCheckable()) aAct->setChecked(aAct->text() == aWndTitle); } -} \ No newline at end of file +} + +void XGUI_MainWindow::closeEvent(QCloseEvent * event) +{ + emit exitKeySequence(); + event->ignore(); +}