summaryrefslogtreecommitdiff
authorwimpie <wimpie>2004-08-25 14:12:34 (UTC)
committer wimpie <wimpie>2004-08-25 14:12:34 (UTC)
commite3732f23f3ce7d5e2413827b8388fde723938d87 (patch) (unidiff)
tree9b4b3e5e562b5cf759d9af5d96a2e36619993717
parente71d630b32fc3ecd2213bd27742c3b7a9a943867 (diff)
downloadopie-e3732f23f3ce7d5e2413827b8388fde723938d87.zip
opie-e3732f23f3ce7d5e2413827b8388fde723938d87.tar.gz
opie-e3732f23f3ce7d5e2413827b8388fde723938d87.tar.bz2
LGPL-ing files
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/rohfeedback.cpp19
-rw-r--r--library/backend/rohfeedback.h19
2 files changed, 38 insertions, 0 deletions
diff --git a/library/backend/rohfeedback.cpp b/library/backend/rohfeedback.cpp
index 21aad34..9a19aac 100644
--- a/library/backend/rohfeedback.cpp
+++ b/library/backend/rohfeedback.cpp
@@ -1,125 +1,144 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
1#ifdef OPIE_WITHROHFEEDBACK 20#ifdef OPIE_WITHROHFEEDBACK
2 21
3#include <rohfeedback.h> 22#include <rohfeedback.h>
4#include <stdio.h> 23#include <stdio.h>
5#include <qpeapplication.h> 24#include <qpeapplication.h>
6#include <qevent.h> 25#include <qevent.h>
7#include <resource.h> 26#include <resource.h>
8#include <qpixmap.h> 27#include <qpixmap.h>
9#include <qbitmap.h> 28#include <qbitmap.h>
10 29
11#define SPEED 600 30#define SPEED 600
12#define DELAY 500 31#define DELAY 500
13 32
14namespace Opie { 33namespace Opie {
15namespace Internal { 34namespace Internal {
16/* 35/*
17 36
18 RightOnHold feedback 37 RightOnHold feedback
19 38
20*/ 39*/
21 40
22QPixmap * RoHFeedback::Imgs[NOOFICONS] = { 0, 0, 0, 0, 0 }; 41QPixmap * RoHFeedback::Imgs[NOOFICONS] = { 0, 0, 0, 0, 0 };
23QBitmap * RoHFeedback::Masks[NOOFICONS]; 42QBitmap * RoHFeedback::Masks[NOOFICONS];
24int RoHFeedback::IconWidth; 43int RoHFeedback::IconWidth;
25int RoHFeedback::IconHeight; 44int RoHFeedback::IconHeight;
26 45
27RoHFeedback::RoHFeedback() : 46RoHFeedback::RoHFeedback() :
28 QLabel( 0, 0, Qt::WType_Popup ), Timer() { 47 QLabel( 0, 0, Qt::WType_Popup ), Timer() {
29 48
30 Receiver = 0l; 49 Receiver = 0l;
31 connect( &Timer, SIGNAL( timeout() ), this, SLOT( iconShow() ) ); 50 connect( &Timer, SIGNAL( timeout() ), this, SLOT( iconShow() ) );
32 51
33 if( Imgs[0] == 0 ) { 52 if( Imgs[0] == 0 ) {
34 QString S; 53 QString S;
35 54
36 55
37 for( int i = 0; i < NOOFICONS ; i ++ ) { 56 for( int i = 0; i < NOOFICONS ; i ++ ) {
38 Imgs[i] = new QPixmap( Resource::loadPixmap( 57 Imgs[i] = new QPixmap( Resource::loadPixmap(
39 "RoH/star/"+ QString::number(i+1) + ".png" )); 58 "RoH/star/"+ QString::number(i+1) + ".png" ));
40 Masks[i] = new QBitmap(); 59 Masks[i] = new QBitmap();
41 (*Masks[i]) = Resource::loadPixmap( 60 (*Masks[i]) = Resource::loadPixmap(
42 "RoH/star/"+QString::number(i+1) + "-mask.png" ); 61 "RoH/star/"+QString::number(i+1) + "-mask.png" );
43 } 62 }
44 } 63 }
45 64
46 IconWidth = Imgs[0]->size().width(); 65 IconWidth = Imgs[0]->size().width();
47 IconHeight = Imgs[0]->size().height(); 66 IconHeight = Imgs[0]->size().height();
48 67
49 resize( IconWidth, IconHeight ); 68 resize( IconWidth, IconHeight );
50} 69}
51 70
52int RoHFeedback::delay( void ) { 71int RoHFeedback::delay( void ) {
53 return DELAY+SPEED+50; 72 return DELAY+SPEED+50;
54} 73}
55 74
56RoHFeedback::~RoHFeedback() { 75RoHFeedback::~RoHFeedback() {
57 for ( int i = 0; i < NOOFICONS; ++i ) { 76 for ( int i = 0; i < NOOFICONS; ++i ) {
58 delete Imgs [i]; 77 delete Imgs [i];
59 delete Masks[i]; 78 delete Masks[i];
60 } 79 }
61} 80}
62 81
63void RoHFeedback::init( const QPoint & P, QWidget* wid ) { 82void RoHFeedback::init( const QPoint & P, QWidget* wid ) {
64 if( ! IconWidth ) 83 if( ! IconWidth )
65 return; 84 return;
66 85
67 Receiver = wid; 86 Receiver = wid;
68 IconNr = FeedbackTimerStart; 87 IconNr = FeedbackTimerStart;
69 move( P.x()-IconWidth/2, P.y() - IconHeight/2 ); 88 move( P.x()-IconWidth/2, P.y() - IconHeight/2 );
70 // to initialize 89 // to initialize
71 Timer.start( DELAY ); 90 Timer.start( DELAY );
72} 91}
73 92
74void RoHFeedback::stop( void ) { 93void RoHFeedback::stop( void ) {
75 IconNr = FeedbackStopped; // stop 94 IconNr = FeedbackStopped; // stop
76} 95}
77 96
78bool RoHFeedback::event( QEvent * E ) { 97bool RoHFeedback::event( QEvent * E ) {
79 98
80 if( E->type() >= QEvent::MouseButtonPress && 99 if( E->type() >= QEvent::MouseButtonPress &&
81 E->type() <= QEvent::MouseMove ) { 100 E->type() <= QEvent::MouseMove ) {
82 // pass the event to the receiver with translated coord 101 // pass the event to the receiver with translated coord
83 QMouseEvent QME( ((QMouseEvent *)E)->type(), 102 QMouseEvent QME( ((QMouseEvent *)E)->type(),
84 Receiver->mapFromGlobal( 103 Receiver->mapFromGlobal(
85 ((QMouseEvent *)E)->globalPos() ), 104 ((QMouseEvent *)E)->globalPos() ),
86 ((QMouseEvent *)E)->globalPos(), 105 ((QMouseEvent *)E)->globalPos(),
87 ((QMouseEvent *)E)->button(), 106 ((QMouseEvent *)E)->button(),
88 ((QMouseEvent *)E)->state() 107 ((QMouseEvent *)E)->state()
89 ); 108 );
90 return QPEApplication::sendEvent( Receiver, &QME ); 109 return QPEApplication::sendEvent( Receiver, &QME );
91 } 110 }
92 111
93 // first let the label treat the event 112 // first let the label treat the event
94 return QLabel::event( E ); 113 return QLabel::event( E );
95} 114}
96 115
97void RoHFeedback::iconShow( void ) { 116void RoHFeedback::iconShow( void ) {
98 switch( IconNr ) { 117 switch( IconNr ) {
99 case FeedbackTimerStart: 118 case FeedbackTimerStart:
100 IconNr = FeedbackShow; 119 IconNr = FeedbackShow;
101 Timer.start( SPEED/NOOFICONS ); 120 Timer.start( SPEED/NOOFICONS );
102 break; 121 break;
103 case FeedbackStopped: 122 case FeedbackStopped:
104 // stopped 123 // stopped
105 IconNr = FeedbackTimerStart; 124 IconNr = FeedbackTimerStart;
106 hide(); 125 hide();
107 Timer.stop(); 126 Timer.stop();
108 break; 127 break;
109 case FeedbackShow: // first 128 case FeedbackShow: // first
110 show(); 129 show();
111 // FT 130 // FT
112 default : 131 default :
113 // show 132 // show
114 133
115 setPixmap( *(Imgs[IconNr]) ); 134 setPixmap( *(Imgs[IconNr]) );
116 setMask( *(Masks[IconNr]) ); 135 setMask( *(Masks[IconNr]) );
117 IconNr = (IconNr+1)%NOOFICONS; // rotate 136 IconNr = (IconNr+1)%NOOFICONS; // rotate
118 break; 137 break;
119 } 138 }
120} 139}
121 140
122} 141}
123} 142}
124 143
125#endif 144#endif
diff --git a/library/backend/rohfeedback.h b/library/backend/rohfeedback.h
index 9ffd35a..774ee85 100644
--- a/library/backend/rohfeedback.h
+++ b/library/backend/rohfeedback.h
@@ -1,65 +1,84 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
1#ifndef ROHFEEDBACK_H 20#ifndef ROHFEEDBACK_H
2#define ROHFEEDBACK_H 21#define ROHFEEDBACK_H
3 22
4#ifdef OPIE_WITHROHFEEDBACK 23#ifdef OPIE_WITHROHFEEDBACK
5 24
6/* 25/*
7 26
8 RightOnHold feedback show 27 RightOnHold feedback show
9 28
10*/ 29*/
11 30
12#define NOOFICONS 5 31#define NOOFICONS 5
13 32
14#include <qlabel.h> 33#include <qlabel.h>
15#include <qtimer.h> 34#include <qtimer.h>
16 35
17class QEvent; 36class QEvent;
18class QPixmap; 37class QPixmap;
19class QBitmap; 38class QBitmap;
20class QMouseEvent; 39class QMouseEvent;
21 40
22namespace Opie { 41namespace Opie {
23namespace Internal { 42namespace Internal {
24 43
25class RoHFeedback : public QLabel { 44class RoHFeedback : public QLabel {
26 45
27 Q_OBJECT 46 Q_OBJECT
28 47
29 enum Actions { 48 enum Actions {
30 FeedbackStopped = -2, 49 FeedbackStopped = -2,
31 FeedbackTimerStart = -1, 50 FeedbackTimerStart = -1,
32 FeedbackShow = 0 51 FeedbackShow = 0
33 }; 52 };
34public : 53public :
35 54
36 RoHFeedback(); 55 RoHFeedback();
37 ~RoHFeedback(); 56 ~RoHFeedback();
38 57
39 58
40 void init( const QPoint & P, QWidget* wid ); 59 void init( const QPoint & P, QWidget* wid );
41 void stop( void ); 60 void stop( void );
42 int delay( void ); 61 int delay( void );
43 62
44public slots : 63public slots :
45 64
46 void iconShow( void ); 65 void iconShow( void );
47 66
48protected : 67protected :
49 68
50 bool event( QEvent * E ); 69 bool event( QEvent * E );
51 70
52 QTimer Timer; 71 QTimer Timer;
53 int IconNr; 72 int IconNr;
54 QWidget * Receiver; 73 QWidget * Receiver;
55 74
56 static int IconWidth; 75 static int IconWidth;
57 static int IconHeight; 76 static int IconHeight;
58 static QPixmap * Imgs[NOOFICONS]; 77 static QPixmap * Imgs[NOOFICONS];
59 static QBitmap * Masks[NOOFICONS]; 78 static QBitmap * Masks[NOOFICONS];
60}; 79};
61} 80}
62} 81}
63 82
64#endif 83#endif
65#endif 84#endif