summaryrefslogtreecommitdiff
path: root/core/applets
Unidiff
Diffstat (limited to 'core/applets') (more/less context) (show whitespace changes)
-rw-r--r--core/applets/irdaapplet/irda.cpp69
-rw-r--r--core/applets/irdaapplet/irda.h4
2 files changed, 48 insertions, 25 deletions
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp
index 67e7f22..03912aa 100644
--- a/core/applets/irdaapplet/irda.cpp
+++ b/core/applets/irdaapplet/irda.cpp
@@ -56,4 +56,3 @@
56IrdaApplet::IrdaApplet( QWidget *parent, const char *name ) 56IrdaApplet::IrdaApplet( QWidget *parent, const char *name )
57 : QWidget( parent, name ) 57 : QWidget( parent, name ) {
58{
59 setFixedHeight( 18 ); 58 setFixedHeight( 18 );
@@ -64,2 +63,4 @@ IrdaApplet::IrdaApplet( QWidget *parent, const char *name )
64 irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" ); 63 irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" );
64 receiveActivePixmap = Resource::loadPixmap("irdaapplet/receive");
65 receiveActive = false;
65 startTimer(5000); 66 startTimer(5000);
@@ -68,4 +69,3 @@ IrdaApplet::IrdaApplet( QWidget *parent, const char *name )
68 69
69IrdaApplet::~IrdaApplet() 70IrdaApplet::~IrdaApplet() {
70{
71 close(sockfd); 71 close(sockfd);
@@ -73,4 +73,3 @@ IrdaApplet::~IrdaApplet()
73 73
74int IrdaApplet::checkIrdaStatus() 74int IrdaApplet::checkIrdaStatus() {
75{
76 struct ifreq ifr; 75 struct ifreq ifr;
@@ -85,4 +84,3 @@ int IrdaApplet::checkIrdaStatus()
85 84
86int IrdaApplet::setIrdaStatus(int c) 85int IrdaApplet::setIrdaStatus(int c) {
87{
88 struct ifreq ifr; 86 struct ifreq ifr;
@@ -105,4 +103,3 @@ int IrdaApplet::setIrdaStatus(int c)
105 103
106int IrdaApplet::checkIrdaDiscoveryStatus() 104int IrdaApplet::checkIrdaDiscoveryStatus() {
107{
108 QFile discovery("/proc/sys/net/irda/discovery"); 105 QFile discovery("/proc/sys/net/irda/discovery");
@@ -117,4 +114,3 @@ int IrdaApplet::checkIrdaDiscoveryStatus()
117 114
118int IrdaApplet::setIrdaDiscoveryStatus(int d) 115int IrdaApplet::setIrdaDiscoveryStatus(int d) {
119{
120 QFile discovery("/proc/sys/net/irda/discovery"); 116 QFile discovery("/proc/sys/net/irda/discovery");
@@ -133,4 +129,4 @@ int IrdaApplet::setIrdaDiscoveryStatus(int d)
133 129
134void IrdaApplet::mousePressEvent( QMouseEvent *) 130
135{ 131void IrdaApplet::mousePressEvent( QMouseEvent *) {
136 QPopupMenu *menu = new QPopupMenu(); 132 QPopupMenu *menu = new QPopupMenu();
@@ -153,5 +149,8 @@ void IrdaApplet::mousePressEvent( QMouseEvent *)
153 149
154 if( Ir::supported() ){ 150 if( receiveActive ){
151 menu->insertItem( tr("Disable Receive"), 5 );
152 } else {
155 menu->insertItem( tr("Enable Receive"), 4 ); 153 menu->insertItem( tr("Enable Receive"), 4 );
156 } 154 }
155
157 QPoint p = mapToGlobal( QPoint(1, menu->sizeHint().height()-1) ); 156 QPoint p = mapToGlobal( QPoint(1, menu->sizeHint().height()-1) );
@@ -178,3 +177,3 @@ void IrdaApplet::mousePressEvent( QMouseEvent *)
178 break; 177 break;
179 case 4: { // enable receive{ 178 case 4: { // enable receive
180 qWarning("Enable receive" ); 179 qWarning("Enable receive" );
@@ -182,2 +181,14 @@ void IrdaApplet::mousePressEvent( QMouseEvent *)
182 e << true; 181 e << true;
182 receiveActive = true;
183 receiveStateChanged = true;
184 timerEvent(NULL);
185 break;
186 }
187 case 5: { // disable receive
188 qWarning("Disable receive" );
189 QCopEnvelope e("QPE/Obex", "receive(bool)" );
190 e << false;
191 receiveActive = false;
192 receiveStateChanged = true;
193 timerEvent(NULL);
183 break; 194 break;
@@ -191,6 +202,11 @@ void IrdaApplet::mousePressEvent( QMouseEvent *)
191 202
192void IrdaApplet::timerEvent( QTimerEvent * ) 203void IrdaApplet::timerEvent( QTimerEvent * ) {
193{
194 int oldactive = irdaactive; 204 int oldactive = irdaactive;
195 int olddiscovery = irdaDiscoveryActive; 205 int olddiscovery = irdaDiscoveryActive;
206 bool receiveUpdate = false;
207
208 if (receiveStateChanged) {
209 receiveUpdate = true;
210 receiveStateChanged = false;
211 }
196 212
@@ -199,4 +215,5 @@ void IrdaApplet::timerEvent( QTimerEvent * )
199 215
200 if ((irdaactive != oldactive) || (irdaDiscoveryActive != olddiscovery)) 216 if ((irdaactive != oldactive) || (irdaDiscoveryActive != olddiscovery) || receiveUpdate ) {
201 paintEvent(NULL); 217 paintEvent(NULL);
218 }
202 219
@@ -204,4 +221,3 @@ void IrdaApplet::timerEvent( QTimerEvent * )
204 221
205void IrdaApplet::paintEvent( QPaintEvent* ) 222void IrdaApplet::paintEvent( QPaintEvent* ) {
206{
207 QPainter p(this); 223 QPainter p(this);
@@ -210,9 +226,14 @@ void IrdaApplet::paintEvent( QPaintEvent* )
210 p.eraseRect ( 0, 0, this->width(), this->height() ); 226 p.eraseRect ( 0, 0, this->width(), this->height() );
211 if (irdaactive > 0) 227 if (irdaactive > 0) {
212 p.drawPixmap( 0, 1, irdaOnPixmap ); 228 p.drawPixmap( 0, 1, irdaOnPixmap );
213 else 229 } else {
214 p.drawPixmap( 0, 1, irdaOffPixmap ); 230 p.drawPixmap( 0, 1, irdaOffPixmap );
231 }
215 232
216 if (irdaDiscoveryActive > 0) 233 if (irdaDiscoveryActive > 0) {
217 p.drawPixmap( 0, 1, irdaDiscoveryOnPixmap ); 234 p.drawPixmap( 0, 1, irdaDiscoveryOnPixmap );
218} 235}
236 if (receiveActive) {
237 p.drawPixmap( 0, 1, receiveActivePixmap);
238 }
239}
diff --git a/core/applets/irdaapplet/irda.h b/core/applets/irdaapplet/irda.h
index bb174e8..97ca3c3 100644
--- a/core/applets/irdaapplet/irda.h
+++ b/core/applets/irdaapplet/irda.h
@@ -50,5 +50,7 @@ private:
50 QPixmap irdaDiscoveryOnPixmap; 50 QPixmap irdaDiscoveryOnPixmap;
51 QPixmap receiveActivePixmap;
51 int irdaactive; // bool and bitfields later bool irdaactive :1 ; 52 int irdaactive; // bool and bitfields later bool irdaactive :1 ;
52 int irdaDiscoveryActive; 53 int irdaDiscoveryActive;
53 54 bool receiveActive;
55 bool receiveStateChanged;
54private slots: 56private slots: