kmail

kcursorsaver.h

00001 #ifndef kcursorsaver_h
00002 #define kcursorsaver_h
00003 
00004 #include <tqcursor.h>
00005 #include <tqapplication.h>
00006 
00013 class KCursorSaver : public TQt
00014 {
00015 public:
00017     KCursorSaver(TQt::CursorShape shape) {
00018         TQApplication::setOverrideCursor( TQCursor(shape) );
00019         inited = true;
00020     }
00021 
00023     KCursorSaver( const KCursorSaver &rhs ) {
00024         *this = rhs;
00025     }
00026 
00028     ~KCursorSaver() {
00029         if (inited)
00030             TQApplication::restoreOverrideCursor();
00031     }
00032 
00034     inline void restoreCursor(void) {
00035         TQApplication::restoreOverrideCursor();
00036         inited = false;
00037     }
00038 
00039 protected:
00040     void operator=( const KCursorSaver &rhs ) {
00041         inited = rhs.inited;
00042         rhs.inited = false;
00043     }
00044 
00045 private:
00046     mutable bool inited;
00047 };
00048 
00052 namespace KBusyPtr {
00053     inline KCursorSaver idle() {
00054         return KCursorSaver(TQCursor::ArrowCursor);
00055     }
00056     inline KCursorSaver busy() {
00057         return KCursorSaver(TQCursor::WaitCursor);
00058     }
00059 }
00060 
00061 #endif /*kbusyptr_h_*/