1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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 <STD_Application.h>
33 #include <SUIT_Session.h>
34 #include <SUIT_Desktop.h>
35 #include <SUIT_DataBrowser.h>
37 #include "LightApp_FullScreenHelper.h"
38 #include "LightApp_Application.h"
44 LightApp_FullScreenHelper::LightApp_FullScreenHelper()
46 myStatusBarVisibility = false;
52 LightApp_FullScreenHelper::~LightApp_FullScreenHelper()
59 * Switch application to the full screen mode.
61 void LightApp_FullScreenHelper::switchToFullScreen() {
63 SUIT_Session* session = SUIT_Session::session();
67 LightApp_Application* app = dynamic_cast<LightApp_Application*>( session->activeApplication() );
72 SUIT_Desktop* desktop = app->desktop();
77 desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen);
79 if(desktop->menuBar())
80 desktop->menuBar()->hide();
82 if(desktop->statusBar()) {
83 myStatusBarVisibility = desktop->statusBar()->isVisible();
84 desktop->statusBar()->hide();
85 QAction *act = app->action(STD_Application::ViewStatusBarId);
87 act->setEnabled(false);
91 QList<QDockWidget*> aDocWidgets = desktop->findChildren<QDockWidget*>();
92 myDocWidgetMap.clear();
94 QWidget* ob = app->objectBrowser();
95 QObject* obParent = ob ? ob->parent() : 0;
97 foreach(QDockWidget* aWidget, aDocWidgets) {
98 if(aWidget && aWidget->parent() == desktop) {
99 if( aWidget->isVisible() && aWidget != obParent ) {
101 QAction* act = aWidget->toggleViewAction();
102 bool isActionEnabled = false;
104 isActionEnabled = act->isEnabled();
105 if( isActionEnabled ) {
106 act->setEnabled(false);
110 myDocWidgetMap.insert(aWidget, isActionEnabled);
115 QList<QToolBar*> aToolBars = desktop->findChildren<QToolBar*>();
116 myToolBarMap.clear();
117 foreach(QToolBar* aWidget, aToolBars ) {
118 if( aWidget && aWidget->parent() == desktop ) {
119 if( aWidget->isVisible()) {
121 QAction* act = aWidget->toggleViewAction();
122 bool isActionEnabled = false;
124 isActionEnabled = act->isEnabled();
125 if( isActionEnabled ) {
126 act->setEnabled(false);
129 myToolBarMap.insert(aWidget, isActionEnabled);
136 * Switch application to the normal screen mode.
138 void LightApp_FullScreenHelper::switchToNormalScreen() {
140 SUIT_Session* session = SUIT_Session::session();
144 LightApp_Application* app = dynamic_cast<LightApp_Application*>( session->activeApplication() );
149 SUIT_Desktop* desktop = app->desktop();
154 desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen);
157 DocWidgetMap::iterator it = myDocWidgetMap.begin();
158 for( ;it != myDocWidgetMap.end() ; it++ ) {
159 QDockWidget* aWidget = it.key();
160 bool state = it.value();
162 QAction* act = aWidget->toggleViewAction();
164 act->setEnabled(true);
167 ToolBarMap::iterator it1 = myToolBarMap.begin();
168 for( ;it1 != myToolBarMap.end() ; it1++ ) {
169 QToolBar* aWidget = it1.key();
170 bool state = it1.value();
172 QAction* act = aWidget->toggleViewAction();
174 act->setEnabled(true);
177 if(desktop->menuBar())
178 desktop->menuBar()->show();
180 if(desktop->statusBar() && myStatusBarVisibility) {
181 desktop->statusBar()->show();
182 QAction *act = app->action(STD_Application::ViewStatusBarId);
184 act->setEnabled(true);