1 | /* |
2 | Large image displaying library. |
3 | |
4 | Copyright (C) 2004 Maks Orlovich (maksim@kde.org) |
5 | |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | of this software and associated documentation files (the "Software"), to deal |
8 | in the Software without restriction, including without limitation the rights |
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
10 | copies of the Software, and to permit persons to whom the Software is |
11 | furnished to do so, subject to the following conditions: |
12 | |
13 | The above copyright notice and this permission notice shall be included in |
14 | all copies or substantial portions of the Software. |
15 | |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
20 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | |
23 | */ |
24 | |
25 | #ifndef ANIM_TIMER_H |
26 | #define ANIM_TIMER_H |
27 | |
28 | #include <QDate> |
29 | #include <QObject> |
30 | #include <QMap> |
31 | |
32 | class QTimer; |
33 | |
34 | namespace khtmlImLoad |
35 | { |
36 | |
37 | class AnimProvider; |
38 | |
39 | /** |
40 | This class is used to manage animation frame change requests, to avoid creating multiple |
41 | QTimers for this purpose. |
42 | */ |
43 | class AnimTimer: public QObject |
44 | { |
45 | Q_OBJECT |
46 | public: |
47 | AnimTimer(); |
48 | |
49 | /** |
50 | This requests that a new frame notification be called at the given delay on the given AnimProvider. |
51 | Note that only the first request is honored, until the notification is given |
52 | */ |
53 | void nextFrameIn(AnimProvider *provider, int ms); |
54 | |
55 | void destroyed(AnimProvider *provider); |
56 | private Q_SLOTS: |
57 | void tick(); |
58 | private: |
59 | QTimer *animTicks; |
60 | QMap<AnimProvider *, int> pending; |
61 | QTime lastTime; |
62 | }; |
63 | |
64 | } |
65 | |
66 | #endif |
67 | |