Salome HOME
DCQ : Update msg File.
[modules/kernel.git] / src / SALOMEGUI / QAD_WaitCursor.h
1 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : QAD_WaitCursor.h
8 //  Author : Vadim SANDLER
9 //  Module : SALOME
10 //  $Header$
11
12 #ifndef QAD_WAITCURSOR_H
13 #define QAD_WAITCURSOR_H
14
15 #include <qapplication.h>
16 #include "QAD.h"
17
18 class QAD_EXPORT QAD_WaitCursor {
19  public:
20 // constructor
21      QAD_WaitCursor() : myStarted( false ), myDepth( 1 ) { start(); }
22 // destructor
23      ~QAD_WaitCursor()   { if ( !myStarted ) { myDepth--; start(); } else { QApplication::restoreOverrideCursor(); } }
24
25 // sets WAIT cursor if not set yet
26      void    start()     { if ( !myStarted ) { while( myDepth-- ) QApplication::setOverrideCursor( Qt::waitCursor ); myStarted = true; } myDepth = 0; }
27 // clears WAIT cursor if set
28      void    stop()      { if ( myStarted )  { while( QApplication::overrideCursor() ) { QApplication::restoreOverrideCursor(); myDepth++; } myStarted = false; } } 
29 // returns true if WAIT cursor is active
30      bool    isStarted() { return myStarted; }
31
32  private:
33      bool  myStarted;
34      int   myDepth;
35 };
36
37 #endif