blob: da38eec577a695ffea3b6a44936cf5fffdb7fa61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// taken from kmail/, moved to Akregator namespace to avoid clashes
#ifndef kcursorsaver_h
#define kcursorsaver_h
#include <tqcursor.h>
#include <tqapplication.h>
namespace Akregator {
/**
* @short sets a cursor and makes sure it's restored on destruction
* Create a KCursorSaver object when you want to set the cursor.
* As soon as it gets out of scope, it will restore the original
* cursor.
*/
class KCursorSaver : public Qt
{
public:
/// constructor taking TQCursor tqshapes
KCursorSaver(Qt::tqCursorShape tqshape) {
TQApplication::setOverrideCursor( TQCursor(tqshape) );
inited = true;
}
/// copy constructor. The right side won't restore the cursor
KCursorSaver( const KCursorSaver &rhs ) {
*this = rhs;
}
/// restore the cursor
~KCursorSaver() {
if (inited)
TQApplication::restoreOverrideCursor();
}
/// call this to explitly restore the cursor
inline void restoreCursor(void) {
TQApplication::restoreOverrideCursor();
inited = false;
}
protected:
void operator=( const KCursorSaver &rhs ) {
inited = rhs.inited;
rhs.inited = false;
}
private:
mutable bool inited;
};
/**
* convenience functions
*/
namespace KBusyPtr {
inline KCursorSaver idle() {
return KCursorSaver(TQCursor::ArrowCursor);
}
inline KCursorSaver busy() {
return KCursorSaver(TQCursor::WaitCursor);
}
}
} // namespace Akregator
#endif /*kbusyptr_h_*/
|