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
32 #include <QtxWorkstack.h>
34 #include <STD_Application.h>
35 #include <STD_TabDesktop.h>
37 #include <SUIT_Session.h>
38 #include <SUIT_Desktop.h>
39 #include <SUIT_DataBrowser.h>
40 #include <SUIT_ViewWindow.h>
41 #include <SUIT_ResourceMgr.h>
43 #include "LightApp_FullScreenHelper.h"
44 #include "LightApp_Application.h"
50 LightApp_FullScreenHelper::LightApp_FullScreenHelper()
52 myStatusBarVisibility = false;
58 LightApp_FullScreenHelper::~LightApp_FullScreenHelper()
65 * Switch application to the full screen mode.
67 void LightApp_FullScreenHelper::switchToFullScreen() {
69 SUIT_Session* session = SUIT_Session::session();
73 LightApp_Application* app = dynamic_cast<LightApp_Application*>( session->activeApplication() );
78 SUIT_Desktop* desktop = app->desktop();
83 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop );
85 QtxWorkstack* wgStack = desk->workstack();
86 wgStack->showActiveTabBar(false);
87 myWindowsList.clear();
88 bool isHidding = false;
89 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
91 isHidding = resMgr->booleanValue( "OCCViewer", "automatic_hiding", true );
92 //Hide all toolbars and inactive window
93 QList<SUIT_ViewWindow*> aWindowList = desk->windows();
94 SUIT_ViewWindow* anActiveWindow = desk->activeWindow();
95 QList<SUIT_ViewWindow*>::const_iterator it = aWindowList.begin();
96 for ( ; it!=aWindowList.end(); it++ ) {
97 QList<QToolBar*> lst = (*it)->findChildren<QToolBar*>();
99 myWindowsList.push_back(*it);
103 QList<QToolBar*>::const_iterator iter = lst.begin();
104 for ( ; iter!=lst.end(); iter++ ) {
110 anActiveWindow->show();
112 desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen);
114 if(desktop->menuBar())
115 desktop->menuBar()->hide();
117 if(desktop->statusBar()) {
118 myStatusBarVisibility = desktop->statusBar()->isVisible();
119 desktop->statusBar()->hide();
120 QAction *act = app->action(STD_Application::ViewStatusBarId);
122 act->setEnabled(false);
126 QList<QDockWidget*> aDocWidgets = desktop->findChildren<QDockWidget*>();
127 myDocWidgetMap.clear();
129 QWidget* ob = app->objectBrowser();
130 QObject* obParent = (ob && !isHidding)? ob->parent() : 0;
132 foreach(QDockWidget* aWidget, aDocWidgets) {
133 if(aWidget && aWidget->parent() == desktop) {
134 if( aWidget->isVisible() && aWidget != obParent ) {
136 QAction* act = aWidget->toggleViewAction();
137 bool isActionEnabled = false;
139 isActionEnabled = act->isEnabled();
140 if( isActionEnabled ) {
141 act->setEnabled(false);
145 myDocWidgetMap.insert(aWidget, isActionEnabled);
150 QList<QToolBar*> aToolBars = desktop->findChildren<QToolBar*>();
151 myToolBarMap.clear();
152 foreach(QToolBar* aWidget, aToolBars ) {
153 if( aWidget && aWidget->parent() == desktop ) {
154 if( aWidget->isVisible()) {
156 QAction* act = aWidget->toggleViewAction();
157 bool isActionEnabled = false;
159 isActionEnabled = act->isEnabled();
160 if( isActionEnabled ) {
161 act->setEnabled(false);
164 myToolBarMap.insert(aWidget, isActionEnabled);
171 * Switch application to the normal screen mode.
173 void LightApp_FullScreenHelper::switchToNormalScreen() {
175 SUIT_Session* session = SUIT_Session::session();
179 LightApp_Application* app = dynamic_cast<LightApp_Application*>( session->activeApplication() );
184 SUIT_Desktop* desktop = app->desktop();
189 desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen);
191 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop );
193 QtxWorkstack* wgStack = desk->workstack();
194 wgStack->showActiveTabBar(true);
196 bool isHidding = false;
197 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
199 isHidding = resMgr->booleanValue( "OCCViewer", "automatic_hiding", true );
200 //Show all toolbars and windows
201 QList<SUIT_ViewWindow*>::const_iterator itr = myWindowsList.begin();
202 for ( ; itr!=myWindowsList.end(); itr++ ) {
203 QList<QToolBar*> lst = (*itr)->findChildren<QToolBar*>();
204 if (*itr && !(*itr)->isVisible())
207 QList<QToolBar*>::const_iterator iter = lst.begin();
208 for ( ; iter!=lst.end(); iter++ ) {
214 DocWidgetMap::iterator it = myDocWidgetMap.begin();
215 for( ;it != myDocWidgetMap.end() ; it++ ) {
216 QDockWidget* aWidget = it.key();
217 bool state = it.value();
219 QAction* act = aWidget->toggleViewAction();
221 act->setEnabled(true);
224 ToolBarMap::iterator it1 = myToolBarMap.begin();
225 for( ;it1 != myToolBarMap.end() ; it1++ ) {
226 QToolBar* aWidget = it1.key();
227 bool state = it1.value();
229 QAction* act = aWidget->toggleViewAction();
231 act->setEnabled(true);
234 if(desktop->menuBar())
235 desktop->menuBar()->show();
237 if(desktop->statusBar() && myStatusBarVisibility) {
238 desktop->statusBar()->show();
239 QAction *act = app->action(STD_Application::ViewStatusBarId);
241 act->setEnabled(true);