author | zecke <zecke> | 2005-02-24 21:05:58 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-24 21:05:58 (UTC) |
commit | 8cddb795296ddc1f9bd3203a9441c555a565f476 (patch) (unidiff) | |
tree | 7820686578c4b8dbd3c4b3b56f405f2fb21643d7 | |
parent | 5bb50abc6c40e815714676a4a1505bc393c49b13 (diff) | |
download | opie-8cddb795296ddc1f9bd3203a9441c555a565f476.zip opie-8cddb795296ddc1f9bd3203a9441c555a565f476.tar.gz opie-8cddb795296ddc1f9bd3203a9441c555a565f476.tar.bz2 |
.png will be appened and this way we force Resource to parse all
AppLnks
Stop that and improve speed and memory consumption
-rw-r--r-- | library/backend/rohfeedback.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/backend/rohfeedback.cpp b/library/backend/rohfeedback.cpp index fa2a636..32e77c8 100644 --- a/library/backend/rohfeedback.cpp +++ b/library/backend/rohfeedback.cpp | |||
@@ -1,142 +1,142 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <rohfeedback.h> | 21 | #include <rohfeedback.h> |
22 | #include <stdio.h> | 22 | #include <stdio.h> |
23 | #include <qpeapplication.h> | 23 | #include <qpeapplication.h> |
24 | #include <qevent.h> | 24 | #include <qevent.h> |
25 | #include <resource.h> | 25 | #include <resource.h> |
26 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
27 | #include <qbitmap.h> | 27 | #include <qbitmap.h> |
28 | 28 | ||
29 | #define SPEED 600 | 29 | #define SPEED 600 |
30 | #define DELAY 500 | 30 | #define DELAY 500 |
31 | 31 | ||
32 | namespace Opie { | 32 | namespace Opie { |
33 | namespace Internal { | 33 | namespace Internal { |
34 | /* | 34 | /* |
35 | 35 | ||
36 | RightOnHold feedback | 36 | RightOnHold feedback |
37 | 37 | ||
38 | */ | 38 | */ |
39 | 39 | ||
40 | QPixmap * RoHFeedback::Imgs[NOOFICONS] = { 0, 0, 0, 0, 0 }; | 40 | QPixmap * RoHFeedback::Imgs[NOOFICONS] = { 0, 0, 0, 0, 0 }; |
41 | QBitmap * RoHFeedback::Masks[NOOFICONS]; | 41 | QBitmap * RoHFeedback::Masks[NOOFICONS]; |
42 | int RoHFeedback::IconWidth; | 42 | int RoHFeedback::IconWidth; |
43 | int RoHFeedback::IconHeight; | 43 | int RoHFeedback::IconHeight; |
44 | 44 | ||
45 | RoHFeedback::RoHFeedback() : | 45 | RoHFeedback::RoHFeedback() : |
46 | QLabel( 0, 0, Qt::WType_Popup ), Timer() { | 46 | QLabel( 0, 0, Qt::WType_Popup ), Timer() { |
47 | 47 | ||
48 | Receiver = 0l; | 48 | Receiver = 0l; |
49 | connect( &Timer, SIGNAL( timeout() ), this, SLOT( iconShow() ) ); | 49 | connect( &Timer, SIGNAL( timeout() ), this, SLOT( iconShow() ) ); |
50 | 50 | ||
51 | if( Imgs[0] == 0 ) { | 51 | if( Imgs[0] == 0 ) { |
52 | QString S; | 52 | QString S; |
53 | 53 | ||
54 | 54 | ||
55 | for( int i = 0; i < NOOFICONS ; i ++ ) { | 55 | for( int i = 0; i < NOOFICONS ; i ++ ) { |
56 | Imgs[i] = new QPixmap( Resource::loadPixmap( | 56 | Imgs[i] = new QPixmap( Resource::loadPixmap( |
57 | "RoH/star/"+ QString::number(i+1) + ".png" )); | 57 | "RoH/star/"+ QString::number(i+1) )); |
58 | Masks[i] = new QBitmap(); | 58 | Masks[i] = new QBitmap(); |
59 | (*Masks[i]) = Resource::loadPixmap( | 59 | (*Masks[i]) = Resource::loadPixmap( |
60 | "RoH/star/"+QString::number(i+1) + "-mask.png" ); | 60 | "RoH/star/"+QString::number(i+1) + "-mask" ); |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
64 | IconWidth = Imgs[0]->size().width(); | 64 | IconWidth = Imgs[0]->size().width(); |
65 | IconHeight = Imgs[0]->size().height(); | 65 | IconHeight = Imgs[0]->size().height(); |
66 | 66 | ||
67 | resize( IconWidth, IconHeight ); | 67 | resize( IconWidth, IconHeight ); |
68 | } | 68 | } |
69 | 69 | ||
70 | int RoHFeedback::delay( void ) { | 70 | int RoHFeedback::delay( void ) { |
71 | return DELAY+SPEED+50; | 71 | return DELAY+SPEED+50; |
72 | } | 72 | } |
73 | 73 | ||
74 | RoHFeedback::~RoHFeedback() { | 74 | RoHFeedback::~RoHFeedback() { |
75 | for ( int i = 0; i < NOOFICONS; ++i ) { | 75 | for ( int i = 0; i < NOOFICONS; ++i ) { |
76 | delete Imgs [i]; | 76 | delete Imgs [i]; |
77 | delete Masks[i]; | 77 | delete Masks[i]; |
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | void RoHFeedback::init( const QPoint & P, QWidget* wid ) { | 81 | void RoHFeedback::init( const QPoint & P, QWidget* wid ) { |
82 | if( ! IconWidth ) | 82 | if( ! IconWidth ) |
83 | return; | 83 | return; |
84 | 84 | ||
85 | Receiver = wid; | 85 | Receiver = wid; |
86 | IconNr = FeedbackTimerStart; | 86 | IconNr = FeedbackTimerStart; |
87 | move( P.x()-IconWidth/2, P.y() - IconHeight/2 ); | 87 | move( P.x()-IconWidth/2, P.y() - IconHeight/2 ); |
88 | // to initialize | 88 | // to initialize |
89 | Timer.start( DELAY ); | 89 | Timer.start( DELAY ); |
90 | } | 90 | } |
91 | 91 | ||
92 | void RoHFeedback::stop( void ) { | 92 | void RoHFeedback::stop( void ) { |
93 | IconNr = FeedbackStopped; // stop | 93 | IconNr = FeedbackStopped; // stop |
94 | } | 94 | } |
95 | 95 | ||
96 | bool RoHFeedback::event( QEvent * E ) { | 96 | bool RoHFeedback::event( QEvent * E ) { |
97 | 97 | ||
98 | if( E->type() >= QEvent::MouseButtonPress && | 98 | if( E->type() >= QEvent::MouseButtonPress && |
99 | E->type() <= QEvent::MouseMove ) { | 99 | E->type() <= QEvent::MouseMove ) { |
100 | // pass the event to the receiver with translated coord | 100 | // pass the event to the receiver with translated coord |
101 | QMouseEvent QME( ((QMouseEvent *)E)->type(), | 101 | QMouseEvent QME( ((QMouseEvent *)E)->type(), |
102 | Receiver->mapFromGlobal( | 102 | Receiver->mapFromGlobal( |
103 | ((QMouseEvent *)E)->globalPos() ), | 103 | ((QMouseEvent *)E)->globalPos() ), |
104 | ((QMouseEvent *)E)->globalPos(), | 104 | ((QMouseEvent *)E)->globalPos(), |
105 | ((QMouseEvent *)E)->button(), | 105 | ((QMouseEvent *)E)->button(), |
106 | ((QMouseEvent *)E)->state() | 106 | ((QMouseEvent *)E)->state() |
107 | ); | 107 | ); |
108 | return QPEApplication::sendEvent( Receiver, &QME ); | 108 | return QPEApplication::sendEvent( Receiver, &QME ); |
109 | } | 109 | } |
110 | 110 | ||
111 | // first let the label treat the event | 111 | // first let the label treat the event |
112 | return QLabel::event( E ); | 112 | return QLabel::event( E ); |
113 | } | 113 | } |
114 | 114 | ||
115 | void RoHFeedback::iconShow( void ) { | 115 | void RoHFeedback::iconShow( void ) { |
116 | switch( IconNr ) { | 116 | switch( IconNr ) { |
117 | case FeedbackTimerStart: | 117 | case FeedbackTimerStart: |
118 | IconNr = FeedbackShow; | 118 | IconNr = FeedbackShow; |
119 | Timer.start( SPEED/NOOFICONS ); | 119 | Timer.start( SPEED/NOOFICONS ); |
120 | break; | 120 | break; |
121 | case FeedbackStopped: | 121 | case FeedbackStopped: |
122 | // stopped | 122 | // stopped |
123 | IconNr = FeedbackTimerStart; | 123 | IconNr = FeedbackTimerStart; |
124 | hide(); | 124 | hide(); |
125 | Timer.stop(); | 125 | Timer.stop(); |
126 | break; | 126 | break; |
127 | case FeedbackShow: // first | 127 | case FeedbackShow: // first |
128 | show(); | 128 | show(); |
129 | // FT | 129 | // FT |
130 | default : | 130 | default : |
131 | // show | 131 | // show |
132 | 132 | ||
133 | setPixmap( *(Imgs[IconNr]) ); | 133 | setPixmap( *(Imgs[IconNr]) ); |
134 | setMask( *(Masks[IconNr]) ); | 134 | setMask( *(Masks[IconNr]) ); |
135 | IconNr = (IconNr+1)%NOOFICONS; // rotate | 135 | IconNr = (IconNr+1)%NOOFICONS; // rotate |
136 | break; | 136 | break; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||