1 // Copyright (C) 2007-2016 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 #include "SUIT_Desktop.h"
25 #include "SUIT_ViewWindow.h"
27 #include <QtxLogoMgr.h>
28 #include <QtxActionMenuMgr.h>
29 #include <QtxActionToolMgr.h>
32 #include <QCloseEvent>
33 #include <QApplication>
35 /*!\class SUIT_Desktop
36 * Provide desktop management:\n
42 class SUIT_Desktop::ReparentEvent : public QEvent
45 ReparentEvent( Type t, QObject* obj ) : QEvent( t ), myObj( obj ) {};
47 QObject* object() const { return myObj; }
50 QPointer<QObject> myObj;
56 SUIT_Desktop::SUIT_Desktop()
59 myMenuMgr = new QtxActionMenuMgr( this );
60 myToolMgr = new QtxActionToolMgr( this );
61 myLogoMgr = new QtxLogoMgr( menuBar() );
67 SUIT_Desktop::~SUIT_Desktop()
74 bool SUIT_Desktop::event( QEvent* e )
81 case QEvent::WindowActivate:
84 case QEvent::WindowDeactivate:
94 return QtxMainWindow::event( e );
100 void SUIT_Desktop::closeEvent( QCloseEvent* e )
102 emit closing( this, e );
109 void SUIT_Desktop::childEvent( QChildEvent* e )
111 if ( e->type() == QEvent::ChildAdded && e->child()->isWidgetType() )
112 QApplication::postEvent( this, new ReparentEvent( QEvent::Type( Reparent ), e->child() ) );
114 QtxMainWindow::childEvent( e );
117 void SUIT_Desktop::customEvent( QEvent* e )
119 if ( (int)e->type() != Reparent )
122 ReparentEvent* re = (ReparentEvent*)e;
123 SUIT_ViewWindow* wid = ::qobject_cast<SUIT_ViewWindow*>( re->object() );
126 bool invis = wid->testAttribute( Qt::WA_WState_ExplicitShowHide ) &&
127 wid->testAttribute( Qt::WA_WState_Hidden );
130 wid->setVisible( !invis );
137 QtxActionMenuMgr* SUIT_Desktop::menuMgr() const
145 QtxActionToolMgr* SUIT_Desktop::toolMgr() const
153 QtxLogoMgr* SUIT_Desktop::logoMgr() const
159 Returns the count of the existed logos.
161 int SUIT_Desktop::logoCount() const
168 return myLogoMgr->count();
172 Adds new logo to the menu bar area
174 void SUIT_Desktop::logoInsert( const QString& logoID, QMovie* logo, const int idx )
177 myLogoMgr->insert( logoID, logo, idx );
181 Adds new logo to the menu bar area
183 void SUIT_Desktop::logoInsert( const QString& logoID, const QPixmap& logo, const int idx )
186 myLogoMgr->insert( logoID, logo, idx );
192 void SUIT_Desktop::logoRemove( const QString& logoID )
195 myLogoMgr->remove( logoID );
201 void SUIT_Desktop::logoClear()
208 Emits activated signal
210 void SUIT_Desktop::emitActivated()
218 void SUIT_Desktop::emitMessage( const QString& theMessage )
220 emit message( theMessage );
224 Activate window (default implementation just sets focus to the window.
226 void SUIT_Desktop::setActiveWindow(SUIT_ViewWindow* wnd)
228 if (wnd) wnd->setFocus();