akregator/src

kcursorsaver.h

00001 // taken from kmail/, moved to Akregator namespace to avoid clashes
00002 
00003 #ifndef kcursorsaver_h
00004 #define kcursorsaver_h
00005 
00006 #include <qcursor.h>
00007 #include <qapplication.h>
00008 
00009 namespace Akregator {
00010 
00017 class KCursorSaver : public Qt
00018 {
00019 public:
00021     KCursorSaver(Qt::CursorShape shape) {
00022         QApplication::setOverrideCursor( QCursor(shape) );
00023         inited = true;
00024     }
00025 
00027     KCursorSaver( const KCursorSaver &rhs ) {
00028         *this = rhs;
00029     }
00030 
00032     ~KCursorSaver() {
00033         if (inited)
00034             QApplication::restoreOverrideCursor();
00035     }
00036 
00038     inline void restoreCursor(void) {
00039         QApplication::restoreOverrideCursor();
00040         inited = false;
00041     }
00042 
00043 protected:
00044     void operator=( const KCursorSaver &rhs ) {
00045         inited = rhs.inited;
00046         rhs.inited = false;
00047     }
00048 
00049 private:
00050     mutable bool inited;
00051 };
00052 
00056 namespace KBusyPtr {
00057     inline KCursorSaver idle() {
00058         return KCursorSaver(QCursor::ArrowCursor);
00059     }
00060     inline KCursorSaver busy() {
00061         return KCursorSaver(QCursor::WaitCursor);
00062     }
00063 }
00064 
00065 } // namespace Akregator
00066 
00067 #endif /*kbusyptr_h_*/
KDE Home | KDE Accessibility Home | Description of Access Keys