]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Implementation of the "0021318: EDF 1615 ALL: Display in full screen mode" issue.
authorrnv <rnv@opencascade.com>
Wed, 5 Oct 2011 11:48:10 +0000 (11:48 +0000)
committerrnv <rnv@opencascade.com>
Wed, 5 Oct 2011 11:48:10 +0000 (11:48 +0000)
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Application.h
src/LightApp/LightApp_FullScreenHelper.cxx [new file with mode: 0644]
src/LightApp/LightApp_FullScreenHelper.h [new file with mode: 0644]
src/LightApp/Makefile.am
src/LightApp/resources/LightApp_msg_en.ts
src/Qtx/QtxMainWindow.cxx
src/Qtx/QtxMainWindow.h

index d6fc2e5517ee3a510ceef5473dfe4efb3723c58b..f93f8c3cae6d22d61700ea7e4d5cb243d7684825 100644 (file)
@@ -54,6 +54,7 @@
 #include "LightApp_SelectionMgr.h"
 #include "LightApp_DataObject.h"
 #include "LightApp_WgViewModel.h"
+#include "LightApp_FullScreenHelper.h"
 
 #include <Basics_OCCTVersion.hxx>
 
 #include <QTimer>
 #include <QHeaderView>
 #include <QTreeView>
+#include <QShortcut>
 
 #include <utilities.h>
 
@@ -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<STD_TabDesktop*>( desktop() ) )
-      dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
+      dynamic_cast<STD_TabDesktop*>( 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
 */
index 2feae74ab5d408c6d6006b19462383eb40bf8734..8ac89400240a31b76f89b788757f1186a113980c 100644 (file)
@@ -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 (file)
index 0000000..780729c
--- /dev/null
@@ -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 <QAction>
+#include <QMenuBar>
+#include <QStatusBar>
+
+#include <PyConsole_Console.h>
+
+#include <STD_Application.h>
+
+#include <SUIT_Session.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_DataBrowser.h>
+
+#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<LightApp_Application*>( 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<QDockWidget*> aDocWidgets = desktop->findChildren<QDockWidget*>();
+  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<QToolBar*> aToolBars = desktop->findChildren<QToolBar*>();
+  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<LightApp_Application*>( 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 (file)
index 0000000..a50c2c7
--- /dev/null
@@ -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 <QMap>
+#include <QDockWidget>
+#include <QToolBar>
+
+
+class LIGHTAPP_EXPORT LightApp_FullScreenHelper {
+ public:
+  
+  LightApp_FullScreenHelper();
+  ~LightApp_FullScreenHelper();
+  
+  void switchToFullScreen();
+  void switchToNormalScreen();
+
+ private:
+  typedef QMap<QDockWidget*,bool> DocWidgetMap;
+  DocWidgetMap myDocWidgetMap;
+
+  typedef QMap<QToolBar*, bool> ToolBarMap;
+  ToolBarMap myToolBarMap;
+
+
+  bool myStatusBarVisibility;
+
+};
+
+
+#endif //LIGHTAPP_FULLSCREEN_H
index cafedf19be777ee2404636b9a4ef04049572c904..814e02bb9136f255d37c80a73c629128f8eb1df6 100755 (executable)
@@ -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
index e8c917a331b4bf0a130298efcd6d30a3fe70dfab..efd0a8d798bb5fd98326aa555968884fd8c3fe47 100644 (file)
@@ -70,6 +70,19 @@ The changes will be applied on the next application session.</translation>
         <source>PRP_THEME</source>
         <translation>Change style properties</translation>
     </message>
+
+    <message>
+        <source>TOT_FULLSCREEN</source>
+        <translation>Full screen</translation>
+    </message>
+    <message>
+        <source>MEN_DESK_FULLSCREEN</source>
+        <translation>Full screen</translation>
+    </message>
+    <message>
+        <source>PRP_FULLSCREEN</source>
+        <translation>Switch to full screen mode</translation>
+    </message>
     <message>
         <source>INF_TOOLBAR_MODULES</source>
         <translation>Modules</translation>
index 99da876f00644167281a1a76ba62b3979b93e33d..6153113445bbff486ce096a13817598dbcf96973 100644 (file)
@@ -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;
+}
index 64dd5abf648a14b3ef4a6d5d6243d317450f86ee..4ace2d28284af8abd55a63331208a86b0676fba0 100644 (file)
@@ -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;