Back to index

salome-gui  6.5.0
LightApp_FullScreenHelper.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File:      LightApp_FullScreenHelper.h
00024 // Created:   04/10/2011 18:44:25 PM
00025 // Author:    OCC team
00026 //
00027 #include <QAction>
00028 #include <QMenuBar>
00029 #include <QStatusBar>
00030 
00031 #include <PyConsole_Console.h>
00032 
00033 #include <STD_Application.h>
00034 
00035 #include <SUIT_Session.h>
00036 #include <SUIT_Desktop.h>
00037 #include <SUIT_DataBrowser.h>
00038 
00039 #include "LightApp_FullScreenHelper.h"
00040 #include "LightApp_Application.h"
00041 
00042 
00046 LightApp_FullScreenHelper::LightApp_FullScreenHelper() 
00047 {
00048   myStatusBarVisibility = false;
00049 }
00050 
00054 LightApp_FullScreenHelper::~LightApp_FullScreenHelper()
00055 {
00056   
00057 }
00058 
00059 
00063 void LightApp_FullScreenHelper::switchToFullScreen() {
00064   
00065   SUIT_Session* session = SUIT_Session::session();
00066   if(!session)
00067     return;
00068   
00069   LightApp_Application* app = dynamic_cast<LightApp_Application*>( session->activeApplication() );
00070 
00071   if(!app)
00072     return;
00073   
00074   SUIT_Desktop* desktop = app->desktop();
00075 
00076   if(!desktop)
00077     return;
00078   
00079   desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen);
00080 
00081   if(desktop->menuBar())
00082     desktop->menuBar()->hide();
00083 
00084   if(desktop->statusBar()) {
00085     myStatusBarVisibility = desktop->statusBar()->isVisible();
00086     desktop->statusBar()->hide();
00087     QAction *act = app->action(STD_Application::ViewStatusBarId);
00088     if(act)
00089       act->setEnabled(false);
00090   }
00091 
00092 
00093   QList<QDockWidget*> aDocWidgets = desktop->findChildren<QDockWidget*>();
00094   myDocWidgetMap.clear();
00095 
00096   QWidget* ob = app->objectBrowser();
00097   QObject* obParent = ob ? ob->parent() : 0;
00098 
00099   foreach(QDockWidget* aWidget, aDocWidgets) {
00100     if(aWidget && aWidget->parent() == desktop) {
00101       if( aWidget->isVisible() && aWidget != obParent ) {
00102        aWidget->hide();
00103        QAction* act = aWidget->toggleViewAction();
00104        bool isActionEnabled = false;
00105        if(act) {
00106          isActionEnabled = act->isEnabled();
00107          if( isActionEnabled ) {
00108            act->setEnabled(false);
00109          }
00110        }
00111        
00112        myDocWidgetMap.insert(aWidget, isActionEnabled);
00113       }
00114     }    
00115   }
00116   
00117   QList<QToolBar*> aToolBars = desktop->findChildren<QToolBar*>();
00118   myToolBarMap.clear();
00119   foreach(QToolBar* aWidget, aToolBars )  {
00120     if( aWidget && aWidget->parent() == desktop ) {
00121       if( aWidget->isVisible()) {
00122        aWidget->hide();
00123        QAction* act = aWidget->toggleViewAction();
00124        bool isActionEnabled = false;
00125        if(act) {
00126          isActionEnabled = act->isEnabled();
00127          if( isActionEnabled ) {
00128            act->setEnabled(false);
00129          }
00130        }      
00131        myToolBarMap.insert(aWidget, isActionEnabled);
00132       }
00133     }    
00134   }  
00135 }
00136 
00140 void LightApp_FullScreenHelper::switchToNormalScreen() {
00141 
00142   SUIT_Session* session = SUIT_Session::session();
00143   if(!session)
00144     return;
00145   
00146   LightApp_Application* app = dynamic_cast<LightApp_Application*>( session->activeApplication() );
00147 
00148   if(!app)
00149     return;
00150   
00151   SUIT_Desktop* desktop = app->desktop();
00152 
00153   if(!desktop)
00154     return;
00155   
00156   desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen);
00157 
00158 
00159   DocWidgetMap::iterator it = myDocWidgetMap.begin();
00160   for( ;it != myDocWidgetMap.end() ; it++ ) {
00161     QDockWidget* aWidget = it.key();
00162     bool state = it.value();
00163     aWidget->show();
00164     QAction* act = aWidget->toggleViewAction();
00165     if(act && state)
00166       act->setEnabled(true);
00167   }
00168 
00169   ToolBarMap::iterator it1 = myToolBarMap.begin();
00170   for( ;it1 != myToolBarMap.end() ; it1++ ) {
00171     QToolBar* aWidget = it1.key();
00172     bool state = it1.value();
00173     aWidget->show();
00174     QAction* act = aWidget->toggleViewAction();
00175     if(act && state)
00176       act->setEnabled(true);
00177   }
00178 
00179   if(desktop->menuBar())
00180     desktop->menuBar()->show();
00181 
00182   if(desktop->statusBar() && myStatusBarVisibility) {
00183     desktop->statusBar()->show();
00184     QAction *act = app->action(STD_Application::ViewStatusBarId);
00185     if(act)
00186       act->setEnabled(true);
00187   }
00188   
00189 }