summaryrefslogtreecommitdiff
path: root/core/applets/cardmon/cardmon.cpp
Unidiff
Diffstat (limited to 'core/applets/cardmon/cardmon.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/cardmon/cardmon.cpp54
1 files changed, 22 insertions, 32 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp
index 0addb89..0bd1ed3 100644
--- a/core/applets/cardmon/cardmon.cpp
+++ b/core/applets/cardmon/cardmon.cpp
@@ -33,6 +33,7 @@
33#include <stdlib.h> 33#include <stdlib.h>
34#include <string.h> 34#include <string.h>
35#include <fcntl.h> 35#include <fcntl.h>
36#include <qsound.h>
36 37
37#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 38#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
38#include <sys/vfs.h> 39#include <sys/vfs.h>
@@ -99,12 +100,12 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
99 } 100 }
100 101
101 if ( cardInPcmcia0 ) { 102 if ( cardInPcmcia0 ) {
102 menu->insertItem( QIconSet ( Resource::loadPixmap ( getIconName(cardInPcmcia0Type) )), 103 menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia0Type )),
103 tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1 ); 104 tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1 );
104 } 105 }
105 106
106 if ( cardInPcmcia1 ) { 107 if ( cardInPcmcia1 ) {
107 menu->insertItem( QIconSet ( Resource::loadPixmap ( getIconName(cardInPcmcia1Type) )), 108 menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia1Type )),
108 tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2 ); 109 tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2 );
109 } 110 }
110 111
@@ -209,33 +210,32 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
209 } 210 }
210 } 211 }
211 f.close(); 212 f.close();
213 if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) {
214 QString text = "";
215 QString what = "";
216 if(cardWas0 != cardInPcmcia0) {
217 if(cardInPcmcia0) { text += tr("New card: "); what="on";}
218 else { text += tr("Ejected: "); what="off";}
219 text += cardInPcmcia0Name;
220 popUp( text, "cardmon/" + cardInPcmcia0Type );
221 }
222 if(cardWas1 != cardInPcmcia1) {
223 if(cardInPcmcia1) { text += tr("New card: "); what="on";}
224 else { text += tr("Ejected: "); what="off";}
225 text += cardInPcmcia1Name;
226 popUp( text, "cardmon/" + cardInPcmcia1Type );
227 }
228 QSound::play(Resource::findSound("cardmon/card" + what));
229 }
230
212 } else { 231 } else {
213 // no file found 232 // no file found
214 qDebug("no file found"); 233 qDebug("no file found");
215 cardInPcmcia0 = FALSE; 234 cardInPcmcia0 = FALSE;
216 cardInPcmcia1 = FALSE; 235 cardInPcmcia1 = FALSE;
217 return FALSE;
218
219 } 236 }
220 237
221 if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { 238 return ((cardWas0 == cardInPcmcia0 && cardWas1 == cardInPcmcia1) ? FALSE : TRUE);
222 QString text = "";
223 if(cardWas0 != cardInPcmcia0) {
224 if(cardInPcmcia0) { text += tr("New card: "); }
225 else { text += tr("Ejected: "); }
226 text += cardInPcmcia0Name;
227 popUp( text, getIconName( cardInPcmcia0Type ) );
228 }
229 if(cardWas1 != cardInPcmcia1) {
230 if(cardInPcmcia1) { text += tr("New card: "); }
231 else { text += tr("Ejected: "); }
232 text += cardInPcmcia1Name;
233 popUp( text, getIconName( cardInPcmcia1Type ) );
234 }
235 }
236
237
238 return ((cardWas0 == cardInPcmcia0 || cardWas1 == cardInPcmcia1) ? FALSE : TRUE);
239} 239}
240 240
241 241
@@ -281,13 +281,3 @@ void CardMonitor::paintEvent( QPaintEvent * ) {
281 hide(); 281 hide();
282 } 282 }
283} 283}
284
285QString CardMonitor::getIconName( QString type ) {
286 if( type != "network" &&
287 type != "ide" ) {
288 type="cardmon";
289 }
290 return "cardmon/"+type;
291}
292
293