1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: LightApp_FullScreenHelper.h
24 // Created: 04/10/2011 18:44:25 PM
31 #include <PyConsole_Console.h>
33 #include <STD_Application.h>
35 #include <SUIT_Session.h>
36 #include <SUIT_Desktop.h>
37 #include <SUIT_DataBrowser.h>
39 #include "LightApp_FullScreenHelper.h"
40 #include "LightApp_Application.h"
46 LightApp_FullScreenHelper::LightApp_FullScreenHelper()
48 myStatusBarVisibility = false;
54 LightApp_FullScreenHelper::~LightApp_FullScreenHelper()
61 * Switch application to the full screen mode.
63 void LightApp_FullScreenHelper::switchToFullScreen() {
65 SUIT_Session* session = SUIT_Session::session();
69 LightApp_Application* app = dynamic_cast<LightApp_Application*>( session->activeApplication() );
74 SUIT_Desktop* desktop = app->desktop();
79 desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen);
81 if(desktop->menuBar())
82 desktop->menuBar()->hide();
84 if(desktop->statusBar()) {
85 myStatusBarVisibility = desktop->statusBar()->isVisible();
86 desktop->statusBar()->hide();
87 QAction *act = app->action(STD_Application::ViewStatusBarId);
89 act->setEnabled(false);
93 QList<QDockWidget*> aDocWidgets = desktop->findChildren<QDockWidget*>();
94 myDocWidgetMap.clear();
96 QWidget* ob = app->objectBrowser();
97 QObject* obParent = ob ? ob->parent() : 0;
99 foreach(QDockWidget* aWidget, aDocWidgets) {
100 if(aWidget && aWidget->parent() == desktop) {
101 if( aWidget->isVisible() && aWidget != obParent ) {
103 QAction* act = aWidget->toggleViewAction();
104 bool isActionEnabled = false;
106 isActionEnabled = act->isEnabled();
107 if( isActionEnabled ) {
108 act->setEnabled(false);
112 myDocWidgetMap.insert(aWidget, isActionEnabled);
117 QList<QToolBar*> aToolBars = desktop->findChildren<QToolBar*>();
118 myToolBarMap.clear();
119 foreach(QToolBar* aWidget, aToolBars ) {
120 if( aWidget && aWidget->parent() == desktop ) {
121 if( aWidget->isVisible()) {
123 QAction* act = aWidget->toggleViewAction();
124 bool isActionEnabled = false;
126 isActionEnabled = act->isEnabled();
127 if( isActionEnabled ) {
128 act->setEnabled(false);
131 myToolBarMap.insert(aWidget, isActionEnabled);
138 * Switch application to the normal screen mode.
140 void LightApp_FullScreenHelper::switchToNormalScreen() {
142 SUIT_Session* session = SUIT_Session::session();
146 LightApp_Application* app = dynamic_cast<LightApp_Application*>( session->activeApplication() );
151 SUIT_Desktop* desktop = app->desktop();
156 desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen);
159 DocWidgetMap::iterator it = myDocWidgetMap.begin();
160 for( ;it != myDocWidgetMap.end() ; it++ ) {
161 QDockWidget* aWidget = it.key();
162 bool state = it.value();
164 QAction* act = aWidget->toggleViewAction();
166 act->setEnabled(true);
169 ToolBarMap::iterator it1 = myToolBarMap.begin();
170 for( ;it1 != myToolBarMap.end() ; it1++ ) {
171 QToolBar* aWidget = it1.key();
172 bool state = it1.value();
174 QAction* act = aWidget->toggleViewAction();
176 act->setEnabled(true);
179 if(desktop->menuBar())
180 desktop->menuBar()->show();
182 if(desktop->statusBar() && myStatusBarVisibility) {
183 desktop->statusBar()->show();
184 QAction *act = app->action(STD_Application::ViewStatusBarId);
186 act->setEnabled(true);