summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/rohfeedback.cpp2
-rw-r--r--library/backend/rohfeedback.h2
2 files changed, 0 insertions, 4 deletions
diff --git a/library/backend/rohfeedback.cpp b/library/backend/rohfeedback.cpp
index 9a19aac..fa2a636 100644
--- a/library/backend/rohfeedback.cpp
+++ b/library/backend/rohfeedback.cpp
@@ -1,144 +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#ifdef OPIE_WITHROHFEEDBACK
21 20
22#include <rohfeedback.h> 21#include <rohfeedback.h>
23#include <stdio.h> 22#include <stdio.h>
24#include <qpeapplication.h> 23#include <qpeapplication.h>
25#include <qevent.h> 24#include <qevent.h>
26#include <resource.h> 25#include <resource.h>
27#include <qpixmap.h> 26#include <qpixmap.h>
28#include <qbitmap.h> 27#include <qbitmap.h>
29 28
30#define SPEED 600 29#define SPEED 600
31#define DELAY 500 30#define DELAY 500
32 31
33namespace Opie { 32namespace Opie {
34namespace Internal { 33namespace Internal {
35/* 34/*
36 35
37 RightOnHold feedback 36 RightOnHold feedback
38 37
39*/ 38*/
40 39
41QPixmap * RoHFeedback::Imgs[NOOFICONS] = { 0, 0, 0, 0, 0 }; 40QPixmap * RoHFeedback::Imgs[NOOFICONS] = { 0, 0, 0, 0, 0 };
42QBitmap * RoHFeedback::Masks[NOOFICONS]; 41QBitmap * RoHFeedback::Masks[NOOFICONS];
43int RoHFeedback::IconWidth; 42int RoHFeedback::IconWidth;
44int RoHFeedback::IconHeight; 43int RoHFeedback::IconHeight;
45 44
46RoHFeedback::RoHFeedback() : 45RoHFeedback::RoHFeedback() :
47 QLabel( 0, 0, Qt::WType_Popup ), Timer() { 46 QLabel( 0, 0, Qt::WType_Popup ), Timer() {
48 47
49 Receiver = 0l; 48 Receiver = 0l;
50 connect( &Timer, SIGNAL( timeout() ), this, SLOT( iconShow() ) ); 49 connect( &Timer, SIGNAL( timeout() ), this, SLOT( iconShow() ) );
51 50
52 if( Imgs[0] == 0 ) { 51 if( Imgs[0] == 0 ) {
53 QString S; 52 QString S;
54 53
55 54
56 for( int i = 0; i < NOOFICONS ; i ++ ) { 55 for( int i = 0; i < NOOFICONS ; i ++ ) {
57 Imgs[i] = new QPixmap( Resource::loadPixmap( 56 Imgs[i] = new QPixmap( Resource::loadPixmap(
58 "RoH/star/"+ QString::number(i+1) + ".png" )); 57 "RoH/star/"+ QString::number(i+1) + ".png" ));
59 Masks[i] = new QBitmap(); 58 Masks[i] = new QBitmap();
60 (*Masks[i]) = Resource::loadPixmap( 59 (*Masks[i]) = Resource::loadPixmap(
61 "RoH/star/"+QString::number(i+1) + "-mask.png" ); 60 "RoH/star/"+QString::number(i+1) + "-mask.png" );
62 } 61 }
63 } 62 }
64 63
65 IconWidth = Imgs[0]->size().width(); 64 IconWidth = Imgs[0]->size().width();
66 IconHeight = Imgs[0]->size().height(); 65 IconHeight = Imgs[0]->size().height();
67 66
68 resize( IconWidth, IconHeight ); 67 resize( IconWidth, IconHeight );
69} 68}
70 69
71int RoHFeedback::delay( void ) { 70int RoHFeedback::delay( void ) {
72 return DELAY+SPEED+50; 71 return DELAY+SPEED+50;
73} 72}
74 73
75RoHFeedback::~RoHFeedback() { 74RoHFeedback::~RoHFeedback() {
76 for ( int i = 0; i < NOOFICONS; ++i ) { 75 for ( int i = 0; i < NOOFICONS; ++i ) {
77 delete Imgs [i]; 76 delete Imgs [i];
78 delete Masks[i]; 77 delete Masks[i];
79 } 78 }
80} 79}
81 80
82void RoHFeedback::init( const QPoint & P, QWidget* wid ) { 81void RoHFeedback::init( const QPoint & P, QWidget* wid ) {
83 if( ! IconWidth ) 82 if( ! IconWidth )
84 return; 83 return;
85 84
86 Receiver = wid; 85 Receiver = wid;
87 IconNr = FeedbackTimerStart; 86 IconNr = FeedbackTimerStart;
88 move( P.x()-IconWidth/2, P.y() - IconHeight/2 ); 87 move( P.x()-IconWidth/2, P.y() - IconHeight/2 );
89 // to initialize 88 // to initialize
90 Timer.start( DELAY ); 89 Timer.start( DELAY );
91} 90}
92 91
93void RoHFeedback::stop( void ) { 92void RoHFeedback::stop( void ) {
94 IconNr = FeedbackStopped; // stop 93 IconNr = FeedbackStopped; // stop
95} 94}
96 95
97bool RoHFeedback::event( QEvent * E ) { 96bool RoHFeedback::event( QEvent * E ) {
98 97
99 if( E->type() >= QEvent::MouseButtonPress && 98 if( E->type() >= QEvent::MouseButtonPress &&
100 E->type() <= QEvent::MouseMove ) { 99 E->type() <= QEvent::MouseMove ) {
101 // pass the event to the receiver with translated coord 100 // pass the event to the receiver with translated coord
102 QMouseEvent QME( ((QMouseEvent *)E)->type(), 101 QMouseEvent QME( ((QMouseEvent *)E)->type(),
103 Receiver->mapFromGlobal( 102 Receiver->mapFromGlobal(
104 ((QMouseEvent *)E)->globalPos() ), 103 ((QMouseEvent *)E)->globalPos() ),
105 ((QMouseEvent *)E)->globalPos(), 104 ((QMouseEvent *)E)->globalPos(),
106 ((QMouseEvent *)E)->button(), 105 ((QMouseEvent *)E)->button(),
107 ((QMouseEvent *)E)->state() 106 ((QMouseEvent *)E)->state()
108 ); 107 );
109 return QPEApplication::sendEvent( Receiver, &QME ); 108 return QPEApplication::sendEvent( Receiver, &QME );
110 } 109 }
111 110
112 // first let the label treat the event 111 // first let the label treat the event
113 return QLabel::event( E ); 112 return QLabel::event( E );
114} 113}
115 114
116void RoHFeedback::iconShow( void ) { 115void RoHFeedback::iconShow( void ) {
117 switch( IconNr ) { 116 switch( IconNr ) {
118 case FeedbackTimerStart: 117 case FeedbackTimerStart:
119 IconNr = FeedbackShow; 118 IconNr = FeedbackShow;
120 Timer.start( SPEED/NOOFICONS ); 119 Timer.start( SPEED/NOOFICONS );
121 break; 120 break;
122 case FeedbackStopped: 121 case FeedbackStopped:
123 // stopped 122 // stopped
124 IconNr = FeedbackTimerStart; 123 IconNr = FeedbackTimerStart;
125 hide(); 124 hide();
126 Timer.stop(); 125 Timer.stop();
127 break; 126 break;
128 case FeedbackShow: // first 127 case FeedbackShow: // first
129 show(); 128 show();
130 // FT 129 // FT
131 default : 130 default :
132 // show 131 // show
133 132
134 setPixmap( *(Imgs[IconNr]) ); 133 setPixmap( *(Imgs[IconNr]) );
135 setMask( *(Masks[IconNr]) ); 134 setMask( *(Masks[IconNr]) );
136 IconNr = (IconNr+1)%NOOFICONS; // rotate 135 IconNr = (IconNr+1)%NOOFICONS; // rotate
137 break; 136 break;
138 } 137 }
139} 138}
140 139
141} 140}
142} 141}
143 142
144#endif
diff --git a/library/backend/rohfeedback.h b/library/backend/rohfeedback.h
index 774ee85..2961d0e 100644
--- a/library/backend/rohfeedback.h
+++ b/library/backend/rohfeedback.h
@@ -1,84 +1,82 @@
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#ifndef ROHFEEDBACK_H 20#ifndef ROHFEEDBACK_H
21#define ROHFEEDBACK_H 21#define ROHFEEDBACK_H
22 22
23#ifdef OPIE_WITHROHFEEDBACK
24 23
25/* 24/*
26 25
27 RightOnHold feedback show 26 RightOnHold feedback show
28 27
29*/ 28*/
30 29
31#define NOOFICONS 5 30#define NOOFICONS 5
32 31
33#include <qlabel.h> 32#include <qlabel.h>
34#include <qtimer.h> 33#include <qtimer.h>
35 34
36class QEvent; 35class QEvent;
37class QPixmap; 36class QPixmap;
38class QBitmap; 37class QBitmap;
39class QMouseEvent; 38class QMouseEvent;
40 39
41namespace Opie { 40namespace Opie {
42namespace Internal { 41namespace Internal {
43 42
44class RoHFeedback : public QLabel { 43class RoHFeedback : public QLabel {
45 44
46 Q_OBJECT 45 Q_OBJECT
47 46
48 enum Actions { 47 enum Actions {
49 FeedbackStopped = -2, 48 FeedbackStopped = -2,
50 FeedbackTimerStart = -1, 49 FeedbackTimerStart = -1,
51 FeedbackShow = 0 50 FeedbackShow = 0
52 }; 51 };
53public : 52public :
54 53
55 RoHFeedback(); 54 RoHFeedback();
56 ~RoHFeedback(); 55 ~RoHFeedback();
57 56
58 57
59 void init( const QPoint & P, QWidget* wid ); 58 void init( const QPoint & P, QWidget* wid );
60 void stop( void ); 59 void stop( void );
61 int delay( void ); 60 int delay( void );
62 61
63public slots : 62public slots :
64 63
65 void iconShow( void ); 64 void iconShow( void );
66 65
67protected : 66protected :
68 67
69 bool event( QEvent * E ); 68 bool event( QEvent * E );
70 69
71 QTimer Timer; 70 QTimer Timer;
72 int IconNr; 71 int IconNr;
73 QWidget * Receiver; 72 QWidget * Receiver;
74 73
75 static int IconWidth; 74 static int IconWidth;
76 static int IconHeight; 75 static int IconHeight;
77 static QPixmap * Imgs[NOOFICONS]; 76 static QPixmap * Imgs[NOOFICONS];
78 static QBitmap * Masks[NOOFICONS]; 77 static QBitmap * Masks[NOOFICONS];
79}; 78};
80} 79}
81} 80}
82 81
83#endif 82#endif
84#endif