kmail

kcursorsaver.h
1 #ifndef kcursorsaver_h
2 #define kcursorsaver_h
3 
4 #include <tqcursor.h>
5 #include <tqapplication.h>
6 
13 class KCursorSaver : public TQt
14 {
15 public:
17  KCursorSaver(TQt::CursorShape shape) {
18  TQApplication::setOverrideCursor( TQCursor(shape) );
19  inited = true;
20  }
21 
23  KCursorSaver( const KCursorSaver &rhs ) {
24  *this = rhs;
25  }
26 
29  if (inited)
30  TQApplication::restoreOverrideCursor();
31  }
32 
34  inline void restoreCursor(void) {
35  TQApplication::restoreOverrideCursor();
36  inited = false;
37  }
38 
39 protected:
40  void operator=( const KCursorSaver &rhs ) {
41  inited = rhs.inited;
42  rhs.inited = false;
43  }
44 
45 private:
46  mutable bool inited;
47 };
48 
52 namespace KBusyPtr {
53  inline KCursorSaver idle() {
54  return KCursorSaver(TQCursor::ArrowCursor);
55  }
56  inline KCursorSaver busy() {
57  return KCursorSaver(TQCursor::WaitCursor);
58  }
59 }
60 
61 #endif /*kbusyptr_h_*/
sets a cursor and makes sure it's restored on destruction Create a KCursorSaver object when you want ...
Definition: kcursorsaver.h:14
~KCursorSaver()
restore the cursor
Definition: kcursorsaver.h:28
KCursorSaver(TQt::CursorShape shape)
constructor taking TQCursor shapes
Definition: kcursorsaver.h:17
void restoreCursor(void)
call this to explitly restore the cursor
Definition: kcursorsaver.h:34
KCursorSaver(const KCursorSaver &rhs)
copy constructor. The right side won't restore the cursor
Definition: kcursorsaver.h:23
convenience functions
Definition: kcursorsaver.h:52