Salome HOME
updated copyright message
[modules/gui.git] / src / SUIT / SUIT_OverrideCursor.cxx
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "SUIT_OverrideCursor.h"
24
25 #include <QApplication>
26
27 /*!Constructor. Initialize wait cursor.*/
28 SUIT_OverrideCursor::SUIT_OverrideCursor()
29 {
30   QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
31 }
32
33 /*!Copy constructor.*/
34 SUIT_OverrideCursor::SUIT_OverrideCursor( const QCursor& cursor )
35 {
36   QApplication::setOverrideCursor( cursor );
37 }
38
39 /*!Destructor. restoring override cursor.*/
40 SUIT_OverrideCursor::~SUIT_OverrideCursor()
41 {
42   QApplication::restoreOverrideCursor();
43 }
44
45 /*! Check cursors is empty */
46 bool SUIT_OverrideCursor::isActive() const
47 {
48   return myCursors.isEmpty();
49 }
50
51 /*!Suspend cursors.*/
52 void SUIT_OverrideCursor::suspend()
53 {
54   if ( !isActive() )
55     return;
56
57   while ( QApplication::overrideCursor() )
58   {
59     myCursors.prepend( *QApplication::overrideCursor() );
60     QApplication::restoreOverrideCursor();
61   }
62 }
63
64 /*!Resume cursors.*/
65 void SUIT_OverrideCursor::resume()
66 {
67   if ( isActive() )
68     return;
69
70   for ( QList<QCursor>::const_iterator it = myCursors.begin(); it != myCursors.end(); ++it )
71     QApplication::setOverrideCursor( *it );
72
73   myCursors.clear();
74 }