kmail
kcursorsaver.h00001 #ifndef kcursorsaver_h
00002 #define kcursorsaver_h
00003
00004 #include <qcursor.h>
00005 #include <qapplication.h>
00006
00013 class KCursorSaver : public Qt
00014 {
00015 public:
00017 KCursorSaver(Qt::CursorShape shape) {
00018 QApplication::setOverrideCursor( QCursor(shape) );
00019 inited = true;
00020 }
00021
00023 KCursorSaver( const KCursorSaver &rhs ) {
00024 *this = rhs;
00025 }
00026
00028 ~KCursorSaver() {
00029 if (inited)
00030 QApplication::restoreOverrideCursor();
00031 }
00032
00034 inline void restoreCursor(void) {
00035 QApplication::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(QCursor::ArrowCursor);
00055 }
00056 inline KCursorSaver busy() {
00057 return KCursorSaver(QCursor::WaitCursor);
00058 }
00059 }
00060
00061 #endif
|