summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/irdaapplet/irda.cpp8
-rw-r--r--core/applets/irdaapplet/irda.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp
index 03912aa..28a79d1 100644
--- a/core/applets/irdaapplet/irda.cpp
+++ b/core/applets/irdaapplet/irda.cpp
@@ -132,107 +132,107 @@ void IrdaApplet::mousePressEvent( QMouseEvent *) {
132 QPopupMenu *menu = new QPopupMenu(); 132 QPopupMenu *menu = new QPopupMenu();
133 QString cmd; 133 QString cmd;
134 int ret=0; 134 int ret=0;
135 135
136 /* Refresh active state */ 136 /* Refresh active state */
137 timerEvent(NULL); 137 timerEvent(NULL);
138 138
139 //menu->insertItem( tr("More..."), 4 ); 139 //menu->insertItem( tr("More..."), 4 );
140 if (irdaactive) 140 if (irdaactive)
141 menu->insertItem( tr("Disable IrDA"), 0 ); 141 menu->insertItem( tr("Disable IrDA"), 0 );
142 else 142 else
143 menu->insertItem( tr("Enable IrDA"), 1 ); 143 menu->insertItem( tr("Enable IrDA"), 1 );
144 144
145 if (irdaDiscoveryActive) 145 if (irdaDiscoveryActive)
146 menu->insertItem( tr("Disable Discovery"), 2 ); 146 menu->insertItem( tr("Disable Discovery"), 2 );
147 else 147 else
148 menu->insertItem( tr("Enable Discovery"), 3 ); 148 menu->insertItem( tr("Enable Discovery"), 3 );
149 149
150 if( receiveActive ){ 150 if( receiveActive ){
151 menu->insertItem( tr("Disable Receive"), 5 ); 151 menu->insertItem( tr("Disable Receive"), 5 );
152 } else { 152 } else {
153 menu->insertItem( tr("Enable Receive"), 4 ); 153 menu->insertItem( tr("Enable Receive"), 4 );
154 } 154 }
155 155
156 QPoint p = mapToGlobal( QPoint(1, menu->sizeHint().height()-1) ); 156 QPoint p = mapToGlobal( QPoint(1, menu->sizeHint().height()-1) );
157 ret = menu->exec(p, 2); 157 ret = menu->exec(p, 2);
158 158
159 qDebug("ret was %d\n", ret); 159 qDebug("ret was %d\n", ret);
160 160
161 switch(ret) { 161 switch(ret) {
162 case 0: 162 case 0:
163 setIrdaStatus(0); 163 setIrdaStatus(0);
164 timerEvent(NULL); 164 timerEvent(NULL);
165 break; 165 break;
166 case 1: 166 case 1:
167 setIrdaStatus(1); 167 setIrdaStatus(1);
168 timerEvent(NULL); 168 timerEvent(NULL);
169 break; 169 break;
170 case 2: 170 case 2:
171 setIrdaDiscoveryStatus(0); 171 setIrdaDiscoveryStatus(0);
172 timerEvent(NULL); 172 timerEvent(NULL);
173 break; 173 break;
174 case 3: 174 case 3:
175 setIrdaDiscoveryStatus(1); 175 setIrdaDiscoveryStatus(1);
176 timerEvent(NULL); // NULL is undefined in c++ use 0 or 0l 176 timerEvent(NULL); // NULL is undefined in c++ use 0 or 0l
177 break; 177 break;
178 case 4: { // enable receive 178 case 4: { // enable receive
179 qWarning("Enable receive" ); 179 qWarning("Enable receive" );
180 QCopEnvelope e("QPE/Obex", "receive(bool)" ); 180 QCopEnvelope e("QPE/Obex", "receive(int)" );
181 e << true; 181 e << 1;
182 receiveActive = true; 182 receiveActive = true;
183 receiveStateChanged = true; 183 receiveStateChanged = true;
184 timerEvent(NULL); 184 timerEvent(NULL);
185 break; 185 break;
186 } 186 }
187 case 5: { // disable receive 187 case 5: { // disable receive
188 qWarning("Disable receive" ); 188 qWarning("Disable receive" );
189 QCopEnvelope e("QPE/Obex", "receive(bool)" ); 189 QCopEnvelope e("QPE/Obex", "receive(int)" );
190 e << false; 190 e << 0;
191 receiveActive = false; 191 receiveActive = false;
192 receiveStateChanged = true; 192 receiveStateChanged = true;
193 timerEvent(NULL); 193 timerEvent(NULL);
194 break; 194 break;
195 } 195 }
196 case 6: 196 case 6:
197 qDebug("FIXME: Bring up pretty menu...\n"); 197 qDebug("FIXME: Bring up pretty menu...\n");
198 // With table of currently-detected devices. 198 // With table of currently-detected devices.
199 } 199 }
200 delete menu; // Can somebody explain why use a QPopupMenu* and not QPopupMenu nor QAction. with out delete we will leak cause QPopupMenu doesn't have a parent in this case 200 delete menu; // Can somebody explain why use a QPopupMenu* and not QPopupMenu nor QAction. with out delete we will leak cause QPopupMenu doesn't have a parent in this case
201} 201}
202 202
203void IrdaApplet::timerEvent( QTimerEvent * ) { 203void IrdaApplet::timerEvent( QTimerEvent * ) {
204 int oldactive = irdaactive; 204 int oldactive = irdaactive;
205 int olddiscovery = irdaDiscoveryActive; 205 int olddiscovery = irdaDiscoveryActive;
206 bool receiveUpdate = false; 206 bool receiveUpdate = false;
207 207
208 if (receiveStateChanged) { 208 if (receiveStateChanged) {
209 receiveUpdate = true; 209 receiveUpdate = true;
210 receiveStateChanged = false; 210 receiveStateChanged = false;
211 } 211 }
212 212
213 irdaactive = checkIrdaStatus(); 213 irdaactive = checkIrdaStatus();
214 irdaDiscoveryActive = checkIrdaDiscoveryStatus(); 214 irdaDiscoveryActive = checkIrdaDiscoveryStatus();
215 215
216 if ((irdaactive != oldactive) || (irdaDiscoveryActive != olddiscovery) || receiveUpdate ) { 216 if ((irdaactive != oldactive) || (irdaDiscoveryActive != olddiscovery) || receiveUpdate ) {
217 paintEvent(NULL); 217 paintEvent(NULL);
218 } 218 }
219 219
220} 220}
221 221
222void IrdaApplet::paintEvent( QPaintEvent* ) { 222void IrdaApplet::paintEvent( QPaintEvent* ) {
223 QPainter p(this); 223 QPainter p(this);
224 qDebug("paint irda pixmap"); 224 qDebug("paint irda pixmap");
225 225
226 p.eraseRect ( 0, 0, this->width(), this->height() ); 226 p.eraseRect ( 0, 0, this->width(), this->height() );
227 if (irdaactive > 0) { 227 if (irdaactive > 0) {
228 p.drawPixmap( 0, 1, irdaOnPixmap ); 228 p.drawPixmap( 0, 1, irdaOnPixmap );
229 } else { 229 } else {
230 p.drawPixmap( 0, 1, irdaOffPixmap ); 230 p.drawPixmap( 0, 1, irdaOffPixmap );
231 } 231 }
232 232
233 if (irdaDiscoveryActive > 0) { 233 if (irdaDiscoveryActive > 0) {
234 p.drawPixmap( 0, 1, irdaDiscoveryOnPixmap ); 234 p.drawPixmap( 0, 1, irdaDiscoveryOnPixmap );
235 } 235 }
236 if (receiveActive) { 236 if (receiveActive) {
237 p.drawPixmap( 0, 1, receiveActivePixmap); 237 p.drawPixmap( 0, 1, receiveActivePixmap);
238 } 238 }
diff --git a/core/applets/irdaapplet/irda.h b/core/applets/irdaapplet/irda.h
index 97ca3c3..002d295 100644
--- a/core/applets/irdaapplet/irda.h
+++ b/core/applets/irdaapplet/irda.h
@@ -6,58 +6,58 @@
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13**********************************************************************/ 13**********************************************************************/
14 14
15#ifndef SCREENSHOT_APPLET_H__ 15#ifndef SCREENSHOT_APPLET_H__
16#define SCREENSHOT_APPLET_H__ 16#define SCREENSHOT_APPLET_H__
17 17
18 18
19 19
20#include <qwidget.h> 20#include <qwidget.h>
21#include <qframe.h> 21#include <qframe.h>
22#include <qpixmap.h> 22#include <qpixmap.h>
23#include <qguardedptr.h> 23#include <qguardedptr.h>
24#include <qtimer.h> 24#include <qtimer.h>
25#include <qfile.h> 25#include <qfile.h>
26 26
27 27
28class IrdaApplet : public QWidget 28class IrdaApplet : public QWidget
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31public: 31public:
32 IrdaApplet( QWidget *parent = 0, const char *name=0 ); 32 IrdaApplet( QWidget *parent = 0, const char *name=0 );
33 ~IrdaApplet(); 33 ~IrdaApplet();
34 34
35protected: 35protected:
36 void timerEvent(QTimerEvent *te ); 36 void timerEvent(QTimerEvent *te );
37 37
38private: 38private:
39 void mousePressEvent( QMouseEvent * ); 39 void mousePressEvent( QMouseEvent * );
40 void paintEvent( QPaintEvent* ); 40 void paintEvent( QPaintEvent* );
41 int checkIrdaStatus(); 41 int checkIrdaStatus();
42 int setIrdaStatus(int); 42 int setIrdaStatus(int);
43 int checkIrdaDiscoveryStatus(); 43 int checkIrdaDiscoveryStatus();
44 int setIrdaDiscoveryStatus(int); 44 int setIrdaDiscoveryStatus(int);
45 int sockfd; 45 int sockfd;
46 46
47private: 47private:
48 QPixmap irdaOnPixmap; 48 QPixmap irdaOnPixmap;
49 QPixmap irdaOffPixmap; 49 QPixmap irdaOffPixmap;
50 QPixmap irdaDiscoveryOnPixmap; 50 QPixmap irdaDiscoveryOnPixmap;
51 QPixmap receiveActivePixmap; 51 QPixmap receiveActivePixmap;
52 int irdaactive; // bool and bitfields later bool irdaactive :1 ; 52 int irdaactive; // bool and bitfields later bool irdaactive :1 ;
53 int irdaDiscoveryActive; 53 int irdaDiscoveryActive;
54 bool receiveActive; 54 bool receiveActive : 1;
55 bool receiveStateChanged; 55 bool receiveStateChanged;
56private slots: 56private slots:
57 57
58 58
59}; 59};
60 60
61 61
62#endif // __SCREENSHOT_APPLET_H__ 62#endif // __SCREENSHOT_APPLET_H__
63 63