From 56c8b1c1f2ccd1a92bfc11e50e33b4d3ee075a35 Mon Sep 17 00:00:00 2001 From: rnv Date: Wed, 5 Oct 2011 11:48:10 +0000 Subject: [PATCH] Implementation of the "0021318: EDF 1615 ALL: Display in full screen mode" issue. --- src/LightApp/LightApp_Application.cxx | 23 ++- src/LightApp/LightApp_Application.h | 6 +- src/LightApp/LightApp_FullScreenHelper.cxx | 189 +++++++++++++++++++++ src/LightApp/LightApp_FullScreenHelper.h | 59 +++++++ src/LightApp/Makefile.am | 6 +- src/LightApp/resources/LightApp_msg_en.ts | 13 ++ src/Qtx/QtxMainWindow.cxx | 24 ++- src/Qtx/QtxMainWindow.h | 5 + 8 files changed, 318 insertions(+), 7 deletions(-) create mode 100644 src/LightApp/LightApp_FullScreenHelper.cxx create mode 100644 src/LightApp/LightApp_FullScreenHelper.h diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index d6fc2e551..f93f8c3ca 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -54,6 +54,7 @@ #include "LightApp_SelectionMgr.h" #include "LightApp_DataObject.h" #include "LightApp_WgViewModel.h" +#include "LightApp_FullScreenHelper.h" #include @@ -173,6 +174,7 @@ #include #include #include +#include #include @@ -239,11 +241,13 @@ LightApp_Preferences* LightApp_Application::_prefs_ = 0; /*!Constructor.*/ LightApp_Application::LightApp_Application() : CAM_Application( false ), - myPrefs( 0 ) + myPrefs( 0 ), + myScreenHelper(new LightApp_FullScreenHelper()) { Q_INIT_RESOURCE( LightApp ); STD_TabDesktop* desk = new STD_TabDesktop(); + desk->setFullScreenAllowed(false); setDesktop( desk ); @@ -342,6 +346,7 @@ LightApp_Application::LightApp_Application() LightApp_Application::~LightApp_Application() { delete mySelMgr; + delete myScreenHelper; } /*!Start application.*/ @@ -660,9 +665,14 @@ void LightApp_Application::createActions() createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ), 0, desk, false, this, SLOT( onStylePreferences() ) ); + createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ), + Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) ); + + int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 ); createMenu( separator(), viewMenu, -1, 20, -1 ); createMenu( StyleId, viewMenu, 20, -1 ); + createMenu( FullScreenId, viewMenu, 20, -1 ); int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ) ); createTool( ModulesListId, modTBar ); @@ -2740,7 +2750,7 @@ void LightApp_Application::loadPreferences() desktop()->setDockOptions( dopts ); desktop()->setOpaqueResize( opaqueResize ); if ( dynamic_cast( desktop() ) ) - dynamic_cast( desktop() )->workstack()->setOpaqueResize( opaqueResize ); + dynamic_cast( desktop() )->workstack()->setOpaqueResize( opaqueResize ); } } @@ -3259,6 +3269,15 @@ void LightApp_Application::onStylePreferences() resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() ); } +void LightApp_Application::onFullScreen(){ + if(myScreenHelper) { + if(desktop()->isFullScreen()) + myScreenHelper->switchToNormalScreen(); + else + myScreenHelper->switchToFullScreen(); + } +} + /*! Connects just added view manager */ diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 2feae74ab..8ac894002 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -45,6 +45,7 @@ class PyConsole_Console; class LightApp_WidgetContainer; class LightApp_Preferences; class LightApp_SelectionMgr; +class LightApp_FullScreenHelper; class LightApp_DataObject; class SUIT_DataBrowser; class SUIT_Study; @@ -84,7 +85,7 @@ public: CloseId, CloseAllId, GroupAllId, PreferencesId, MRUId, ModulesListId, NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId, NewQxGraphViewId, - NewQxSceneViewId = NewQxGraphViewId, StyleId, + NewQxSceneViewId = NewQxGraphViewId, StyleId, FullScreenId, UserID }; protected: @@ -232,6 +233,7 @@ protected slots: void onMRUActivated( const QString& ); void onStylePreferences(); + void onFullScreen(); private slots: void onSelection(); @@ -289,6 +291,8 @@ protected: LightApp_Preferences* myPrefs; LightApp_SelectionMgr* mySelMgr; + LightApp_FullScreenHelper* myScreenHelper; + WinMap myWin; WinVis myWinVis; WinGeom myWinGeom; diff --git a/src/LightApp/LightApp_FullScreenHelper.cxx b/src/LightApp/LightApp_FullScreenHelper.cxx new file mode 100644 index 000000000..780729c07 --- /dev/null +++ b/src/LightApp/LightApp_FullScreenHelper.cxx @@ -0,0 +1,189 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File: LightApp_FullScreenHelper.h +// Created: 04/10/2011 18:44:25 PM +// Author: OCC team +// +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include "LightApp_FullScreenHelper.h" +#include "LightApp_Application.h" + + +/*! + * Constructor + */ +LightApp_FullScreenHelper::LightApp_FullScreenHelper() +{ + myStatusBarVisibility = false; +} + +/*! + * Destructor + */ +LightApp_FullScreenHelper::~LightApp_FullScreenHelper() +{ + +} + + +/*! + * Switch application to the full screen mode. + */ +void LightApp_FullScreenHelper::switchToFullScreen() { + + SUIT_Session* session = SUIT_Session::session(); + if(!session) + return; + + LightApp_Application* app = dynamic_cast( session->activeApplication() ); + + if(!app) + return; + + SUIT_Desktop* desktop = app->desktop(); + + if(!desktop) + return; + + desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen); + + if(desktop->menuBar()) + desktop->menuBar()->hide(); + + if(desktop->statusBar()) { + myStatusBarVisibility = desktop->statusBar()->isVisible(); + desktop->statusBar()->hide(); + QAction *act = app->action(STD_Application::ViewStatusBarId); + if(act) + act->setEnabled(false); + } + + + QList aDocWidgets = desktop->findChildren(); + myDocWidgetMap.clear(); + + QWidget* ob = app->objectBrowser(); + QObject* obParent = ob ? ob->parent() : 0; + + foreach(QDockWidget* aWidget, aDocWidgets) { + if(aWidget && aWidget->parent() == desktop) { + if( aWidget->isVisible() && aWidget != obParent ) { + aWidget->hide(); + QAction* act = aWidget->toggleViewAction(); + bool isActionEnabled = false; + if(act) { + isActionEnabled = act->isEnabled(); + if( isActionEnabled ) { + act->setEnabled(false); + } + } + + myDocWidgetMap.insert(aWidget, isActionEnabled); + } + } + } + + QList aToolBars = desktop->findChildren(); + myToolBarMap.clear(); + foreach(QToolBar* aWidget, aToolBars ) { + if( aWidget && aWidget->parent() == desktop ) { + if( aWidget->isVisible()) { + aWidget->hide(); + QAction* act = aWidget->toggleViewAction(); + bool isActionEnabled = false; + if(act) { + isActionEnabled = act->isEnabled(); + if( isActionEnabled ) { + act->setEnabled(false); + } + } + myToolBarMap.insert(aWidget, isActionEnabled); + } + } + } +} + +/*! + * Switch application to the normal screen mode. + */ +void LightApp_FullScreenHelper::switchToNormalScreen() { + + SUIT_Session* session = SUIT_Session::session(); + if(!session) + return; + + LightApp_Application* app = dynamic_cast( session->activeApplication() ); + + if(!app) + return; + + SUIT_Desktop* desktop = app->desktop(); + + if(!desktop) + return; + + desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen); + + + DocWidgetMap::iterator it = myDocWidgetMap.begin(); + for( ;it != myDocWidgetMap.end() ; it++ ) { + QDockWidget* aWidget = it.key(); + bool state = it.value(); + aWidget->show(); + QAction* act = aWidget->toggleViewAction(); + if(act && state) + act->setEnabled(true); + } + + ToolBarMap::iterator it1 = myToolBarMap.begin(); + for( ;it1 != myToolBarMap.end() ; it1++ ) { + QToolBar* aWidget = it1.key(); + bool state = it1.value(); + aWidget->show(); + QAction* act = aWidget->toggleViewAction(); + if(act && state) + act->setEnabled(true); + } + + if(desktop->menuBar()) + desktop->menuBar()->show(); + + if(desktop->statusBar() && myStatusBarVisibility) { + desktop->statusBar()->show(); + QAction *act = app->action(STD_Application::ViewStatusBarId); + if(act) + act->setEnabled(true); + } + +} diff --git a/src/LightApp/LightApp_FullScreenHelper.h b/src/LightApp/LightApp_FullScreenHelper.h new file mode 100644 index 000000000..a50c2c732 --- /dev/null +++ b/src/LightApp/LightApp_FullScreenHelper.h @@ -0,0 +1,59 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File: LightApp_FullScreenHelper.h +// Created: 04/10/2011 18:39:25 PM +// Author: OCC team +// +#ifndef LIGHTAPP_FULLSCREEN_H +#define LIGHTAPP_FULLSCREEN_H + +#include "LightApp.h" + +#include +#include +#include + + +class LIGHTAPP_EXPORT LightApp_FullScreenHelper { + public: + + LightApp_FullScreenHelper(); + ~LightApp_FullScreenHelper(); + + void switchToFullScreen(); + void switchToNormalScreen(); + + private: + typedef QMap DocWidgetMap; + DocWidgetMap myDocWidgetMap; + + typedef QMap ToolBarMap; + ToolBarMap myToolBarMap; + + + bool myStatusBarVisibility; + +}; + + +#endif //LIGHTAPP_FULLSCREEN_H diff --git a/src/LightApp/Makefile.am b/src/LightApp/Makefile.am index cafedf19b..814e02bb9 100755 --- a/src/LightApp/Makefile.am +++ b/src/LightApp/Makefile.am @@ -59,7 +59,8 @@ salomeinclude_HEADERS = \ LightApp_Preferences.h \ LightApp_PreferencesDlg.h \ LightApp_UpdateFlags.h \ - LightApp_WgViewModel.h + LightApp_WgViewModel.h \ + LightApp_FullScreenHelper.h if ENABLE_PYCONSOLE salomeinclude_HEADERS += LightApp_PyInterp.h @@ -107,7 +108,8 @@ dist_libLightApp_la_SOURCES = \ LightApp_SwitchOp.cxx \ LightApp_Preferences.cxx \ LightApp_PreferencesDlg.cxx \ - LightApp_WgViewModel.cxx + LightApp_WgViewModel.cxx \ + LightApp_FullScreenHelper.cxx if ENABLE_PYCONSOLE dist_libLightApp_la_SOURCES += LightApp_PyInterp.cxx diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index e8c917a33..efd0a8d79 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -70,6 +70,19 @@ The changes will be applied on the next application session. PRP_THEME Change style properties + + + TOT_FULLSCREEN + Full screen + + + MEN_DESK_FULLSCREEN + Full screen + + + PRP_FULLSCREEN + Switch to full screen mode + INF_TOOLBAR_MODULES Modules diff --git a/src/Qtx/QtxMainWindow.cxx b/src/Qtx/QtxMainWindow.cxx index 99da876f0..615311344 100644 --- a/src/Qtx/QtxMainWindow.cxx +++ b/src/Qtx/QtxMainWindow.cxx @@ -241,7 +241,8 @@ QtxMainWindow::QtxMainWindow( QWidget* parent, Qt::WindowFlags f ) myStatusBar( 0 ), myOpaque( true ), myResizer( 0 ), - myMouseMove( 0 ) + myMouseMove( 0 ), + myFullScreenAllowed(true) { //rnv: Enables tooltips for inactive windows. //rnv: For details see http://bugtracker.opencascade.com/show_bug.cgi?id=20893 @@ -400,7 +401,7 @@ QString QtxMainWindow::storeGeometry() const state = QString( "min" ); break; case Qt::WindowFullScreen: - state = QString( "full" ); + state = isFullScreenAllowed() ? QString( "full" ) : QString( "max" ); break; } @@ -624,3 +625,22 @@ bool QtxMainWindow::event( QEvent* e ) return ok; } + +/*! + \brief FullScreenAllowed flag allowed dump in the main window geometry + Qt::WindowFullScreen parameter. + \return \c fullScreenAllowed flag. +*/ +bool QtxMainWindow::isFullScreenAllowed() const { + return myFullScreenAllowed; +} + + +/*! + \brief Set FullScreenAllowed flag. + The default value is true. + \param f value of the fullScreenAllowed flag. +*/ +void QtxMainWindow::setFullScreenAllowed( const bool f ) { + myFullScreenAllowed = f; +} diff --git a/src/Qtx/QtxMainWindow.h b/src/Qtx/QtxMainWindow.h index 64dd5abf6..4ace2d282 100644 --- a/src/Qtx/QtxMainWindow.h +++ b/src/Qtx/QtxMainWindow.h @@ -54,6 +54,9 @@ public: QString storeGeometry() const; void retrieveGeometry( const QString& ); + bool isFullScreenAllowed() const; + void setFullScreenAllowed( const bool ); + protected: virtual bool event( QEvent* ); @@ -67,6 +70,8 @@ private: QToolBar* myMenuBar; //!< dockable menu bar QToolBar* myStatusBar; //!< dockable status bar + bool myFullScreenAllowed; + bool myOpaque; Resizer* myResizer; QMouseEvent* myMouseMove; -- 2.39.2