fix errors found while translating
[kdepim.git] / kmail / kcursorsaver.h
blobf5e16fe1df922c4548b19f414f3197f45697f9bb
1 #ifndef kcursorsaver_h
2 #define kcursorsaver_h
4 #include <QCursor>
5 #include <QApplication>
7 /**
8 * @short sets a cursor and makes sure it's restored on destruction
9 * Create a KCursorSaver object when you want to set the cursor.
10 * As soon as it gets out of scope, it will restore the original
11 * cursor.
13 class KCursorSaver
15 public:
16 /// constructor taking QCursor shapes
17 KCursorSaver(Qt::CursorShape shape) {
18 QApplication::setOverrideCursor( QCursor(shape) );
19 inited = true;
22 /// copy constructor. The right side won't restore the cursor
23 KCursorSaver( const KCursorSaver &rhs ) {
24 *this = rhs;
27 /// restore the cursor
28 ~KCursorSaver() {
29 if (inited)
30 QApplication::restoreOverrideCursor();
33 /// call this to explitly restore the cursor
34 inline void restoreCursor(void) {
35 QApplication::restoreOverrideCursor();
36 inited = false;
39 protected:
40 void operator=( const KCursorSaver &rhs ) {
41 inited = rhs.inited;
42 rhs.inited = false;
45 private:
46 mutable bool inited;
49 /**
50 * convenience functions
52 namespace KBusyPtr {
53 inline KCursorSaver idle() {
54 return KCursorSaver(Qt::ArrowCursor);
56 inline KCursorSaver busy() {
57 return KCursorSaver(Qt::WaitCursor);
61 #endif /*kbusyptr_h_*/