-rw-r--r-- | core/applets/cardmon/cardmon.cpp | 412 |
1 files changed, 219 insertions, 193 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index 9293c6f..25bb137 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp | |||
@@ -26,12 +26,13 @@ | |||
26 | #include <qcopchannel_qws.h> | 26 | #include <qcopchannel_qws.h> |
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtimer.h> | 31 | #include <qtimer.h> |
32 | #include <qapplication.h> | ||
32 | 33 | ||
33 | #include <stdio.h> | 34 | #include <stdio.h> |
34 | #include <unistd.h> | 35 | #include <unistd.h> |
35 | #include <stdlib.h> | 36 | #include <stdlib.h> |
36 | #include <string.h> | 37 | #include <string.h> |
37 | #include <fcntl.h> | 38 | #include <fcntl.h> |
@@ -41,275 +42,300 @@ | |||
41 | #include <sys/vfs.h> | 42 | #include <sys/vfs.h> |
42 | #include <mntent.h> | 43 | #include <mntent.h> |
43 | #endif | 44 | #endif |
44 | 45 | ||
45 | using namespace Opie; | 46 | using namespace Opie; |
46 | 47 | ||
47 | CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ), | 48 | CardMonitor::CardMonitor(QWidget * parent):QWidget(parent), |
48 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) { | 49 | pm(Resource:: |
50 | loadPixmap("cardmon/pcmcia")) | ||
51 | { | ||
49 | 52 | ||
50 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 53 | QCopChannel *pcmciaChannel = new QCopChannel("QPE/Card", this); |
51 | connect( pcmciaChannel, SIGNAL( received( const QCString &, const QByteArray &) ), | 54 | connect(pcmciaChannel, |
52 | this, SLOT( cardMessage( const QCString &, const QByteArray &) ) ); | 55 | SIGNAL(received(const QCString &, const QByteArray &)), this, |
56 | SLOT(cardMessage(const QCString &, const QByteArray &))); | ||
53 | 57 | ||
54 | QCopChannel* sdChannel = new QCopChannel( "QPE/Card", this ); | 58 | QCopChannel *sdChannel = new QCopChannel("QPE/Card", this); |
55 | connect( sdChannel, SIGNAL( received( const QCString &, const QByteArray &) ), | 59 | connect(sdChannel, |
56 | this, SLOT( cardMessage( const QCString &, const QByteArray &) ) ); | 60 | SIGNAL(received(const QCString &, const QByteArray &)), this, |
61 | SLOT(cardMessage(const QCString &, const QByteArray &))); | ||
57 | 62 | ||
58 | cardInPcmcia0 = FALSE; | 63 | cardInPcmcia0 = FALSE; |
59 | cardInPcmcia1 = FALSE; | 64 | cardInPcmcia1 = FALSE; |
60 | cardInSd = FALSE; | 65 | cardInSd = FALSE; |
61 | 66 | ||
62 | setFixedSize( pm.size() ); | 67 | setFixedSize(pm.size()); |
63 | getStatusPcmcia( TRUE ); | 68 | getStatusPcmcia(TRUE); |
64 | getStatusSd( TRUE ); | 69 | getStatusSd(TRUE); |
65 | repaint( FALSE ); | 70 | repaint(FALSE); |
66 | popupMenu = 0; | 71 | popupMenu = 0; |
67 | } | 72 | } |
68 | 73 | ||
69 | CardMonitor::~CardMonitor() { | 74 | CardMonitor::~CardMonitor() |
70 | if( popupMenu ) { | 75 | { |
71 | delete popupMenu; | 76 | if (popupMenu) { |
77 | delete popupMenu; | ||
72 | } | 78 | } |
73 | } | 79 | } |
74 | 80 | ||
75 | void CardMonitor::popUp( QString message, QString icon ) { | 81 | void CardMonitor::popUp(QString message, QString icon) |
76 | if ( ! popupMenu ) { | 82 | { |
77 | popupMenu = new QPopupMenu(this); | 83 | if (!popupMenu) { |
84 | popupMenu = new QPopupMenu(this); | ||
78 | } | 85 | } |
79 | 86 | ||
80 | popupMenu->clear(); | 87 | popupMenu->clear(); |
81 | if( icon.isEmpty() ) { | 88 | if (icon.isEmpty()) { |
82 | popupMenu->insertItem( message, 0 ); | 89 | popupMenu->insertItem(message, 0); |
83 | } else { | 90 | } else { |
84 | popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon ) ), message, 0 ); | 91 | popupMenu->insertItem(QIconSet(Resource::loadPixmap(icon)), |
92 | message, 0); | ||
85 | } | 93 | } |
86 | 94 | ||
87 | QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); | 95 | QPoint p = mapToGlobal(QPoint(0, 0)); |
88 | QSize s = popupMenu->sizeHint (); | 96 | QSize s = popupMenu->sizeHint(); |
89 | popupMenu->popup( QPoint ( | 97 | popupMenu->popup(QPoint(p.x() + (width() / 2) - (s.width() / 2), |
90 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 98 | p.y() - s.height()), 0); |
91 | p. y ( ) - s. height ( ) ), 0); | ||
92 | 99 | ||
93 | QTimer::singleShot( 2000, this, SLOT(popupTimeout() ) ); | 100 | QTimer::singleShot(2000, this, SLOT(popupTimeout())); |
94 | } | 101 | } |
95 | 102 | ||
96 | void CardMonitor::popupTimeout() { | 103 | void CardMonitor::popupTimeout() |
104 | { | ||
97 | popupMenu->hide(); | 105 | popupMenu->hide(); |
98 | } | 106 | } |
99 | 107 | ||
100 | void CardMonitor::mousePressEvent( QMouseEvent * ) { | 108 | void CardMonitor::mousePressEvent(QMouseEvent *) |
109 | { | ||
101 | QPopupMenu *menu = new QPopupMenu(this); | 110 | QPopupMenu *menu = new QPopupMenu(this); |
102 | QString cmd; | 111 | QString cmd; |
103 | int err=0; | 112 | int err = 0; |
104 | 113 | ||
105 | if ( cardInSd ) { | 114 | if (cardInSd) { |
106 | menu->insertItem( tr("Eject SD/MMC card"), 0 ); | 115 | menu->insertItem(QIconSet(Resource::loadPixmap("cardmon/ide")), |
116 | tr("Eject SD/MMC card"), 0); | ||
107 | } | 117 | } |
108 | 118 | ||
109 | if ( cardInPcmcia0 ) { | 119 | if (cardInPcmcia0) { |
110 | menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia0Type ) ), | 120 | menu-> |
111 | tr( "Eject card 0: %1" ).arg(cardInPcmcia0Name ), 1 ); | 121 | insertItem(QIconSet |
122 | (Resource::loadPixmap("cardmon/" + cardInPcmcia0Type)), | ||
123 | tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1); | ||
112 | } | 124 | } |
113 | 125 | ||
114 | if ( cardInPcmcia1 ) { | 126 | if (cardInPcmcia1) { |
115 | menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia1Type ) ), | 127 | menu-> |
116 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); | 128 | insertItem(QIconSet |
129 | (Resource::loadPixmap("cardmon/" + cardInPcmcia1Type)), | ||
130 | tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2); | ||
117 | } | 131 | } |
118 | 132 | ||
119 | QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); | 133 | QPoint p = mapToGlobal(QPoint(0, 0)); |
120 | QSize s = menu->sizeHint (); | 134 | QSize s = menu->sizeHint(); |
121 | int opt = menu->exec( QPoint ( | 135 | int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), |
122 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 136 | p.y() - s.height()), 0); |
123 | p. y ( ) - s. height ( ) ), 0); | 137 | |
124 | 138 | if (opt == 1) { | |
125 | if ( opt == 1 ) { | 139 | cmd = "/sbin/cardctl eject 0"; |
126 | cmd = "/sbin/cardctl eject 0"; | 140 | err = system((const char *) cmd); |
127 | err = system( ( const char * ) cmd ); | 141 | if (err != 0) { |
128 | if ( ( err == 127 ) || ( err < 0 ) ) { | 142 | qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", |
129 | qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d", err ); | 143 | err); |
130 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); | 144 | popUp(tr("CF/PCMCIA card eject failed!")); |
131 | } | 145 | } |
132 | } else if ( opt == 0 ) { | 146 | } else if (opt == 0) { |
133 | if ( ODevice::inst()->system() == System_Familiar ) { | 147 | if (ODevice::inst()->system() == System_Familiar) { |
134 | cmd = "umount /dev/mmc/part1"; | 148 | cmd = "umount /dev/mmc/part1"; |
135 | err = system( ( const char *) cmd ); | 149 | } else { |
136 | if ( ( err != 0 ) ) { | 150 | cmd = "umount /dev/mmcda1"; |
137 | popUp( tr("SD/MMC card eject failed!") ); | 151 | } |
138 | } | 152 | err = system((const char *) cmd); |
139 | } else { | 153 | if (err != 0) { |
140 | cmd = "/etc/sdcontrol compeject"; | 154 | popUp(tr("SD/MMC card eject failed!")); |
141 | err = system( ( const char *) cmd ); | 155 | } |
142 | if ( ( err != 0 ) ) { | 156 | } else if (opt == 2) { |
143 | qDebug( "Could not execute `/etc/sdcontrol comeject'! err=%d", err ); | 157 | cmd = "/sbin/cardctl eject 1"; |
144 | popUp( tr("SD/MMC card eject failed!") ); | 158 | err = system((const char *) cmd); |
145 | } | 159 | if (err != 0) { |
146 | } | 160 | qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", |
147 | } else if ( opt == 2 ) { | 161 | err); |
148 | cmd = "/sbin/cardctl eject 1"; | 162 | popUp(tr("CF/PCMCIA card eject failed!")); |
149 | err = system( ( const char *) cmd ); | 163 | } |
150 | if ( ( err == 127 ) || ( err < 0 ) ) { | ||
151 | qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d", err ); | ||
152 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); | ||
153 | } | ||
154 | } | 164 | } |
155 | delete menu; | 165 | delete menu; |
156 | } | 166 | } |
157 | 167 | ||
158 | 168 | ||
159 | void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) { | 169 | void CardMonitor::cardMessage(const QCString & msg, const QByteArray &) |
160 | if ( msg == "stabChanged()" ) { | 170 | { |
161 | // qDebug("Pcmcia: stabchanged"); | 171 | if (msg == "stabChanged()") { |
162 | getStatusPcmcia(); | 172 | // qDebug("Pcmcia: stabchanged"); |
163 | } else if ( msg == "mtabChanged()" ) { | 173 | getStatusPcmcia(); |
164 | qDebug("CARDMONAPPLET: mtabchanged"); | 174 | } else if (msg == "mtabChanged()") { |
165 | getStatusSd(); | 175 | // qDebug("CARDMONAPPLET: mtabchanged"); |
166 | } | 176 | getStatusSd(); |
177 | } | ||
167 | } | 178 | } |
168 | 179 | ||
169 | bool CardMonitor::getStatusPcmcia( int showPopUp ) { | 180 | bool CardMonitor::getStatusPcmcia(int showPopUp) |
181 | { | ||
170 | 182 | ||
171 | bool cardWas0 = cardInPcmcia0; // remember last state | 183 | bool cardWas0 = cardInPcmcia0;// remember last state |
172 | bool cardWas1 = cardInPcmcia1; | 184 | bool cardWas1 = cardInPcmcia1; |
173 | 185 | ||
174 | QString fileName; | 186 | QString fileName; |
175 | 187 | ||
176 | // one of these 3 files should exist | 188 | // one of these 3 files should exist |
177 | if ( QFile::exists( "/var/run/stab" ) ) { | 189 | if (QFile::exists("/var/run/stab")) { |
178 | fileName = "/var/run/stab"; | 190 | fileName = "/var/run/stab"; |
179 | } else if (QFile::exists( "/var/state/pcmcia/stab" ) ) { | 191 | } else if (QFile::exists("/var/state/pcmcia/stab")) { |
180 | fileName = "/var/state/pcmcia/stab"; | 192 | fileName = "/var/state/pcmcia/stab"; |
181 | } else { | 193 | } else { |
182 | fileName = "/var/lib/pcmcia/stab"; | 194 | fileName = "/var/lib/pcmcia/stab"; |
183 | } | 195 | } |
184 | 196 | ||
185 | QFile f( fileName ); | 197 | QFile f(fileName); |
186 | 198 | ||
187 | if ( f.open( IO_ReadOnly ) ) { | 199 | if (f.open(IO_ReadOnly)) { |
188 | QStringList list; | 200 | QStringList list; |
189 | QTextStream stream ( &f ); | 201 | QTextStream stream(&f); |
190 | QString streamIn; | 202 | QString streamIn; |
191 | streamIn = stream.read(); | 203 | streamIn = stream.read(); |
192 | list = QStringList::split( "\n", streamIn ); | 204 | list = QStringList::split("\n", streamIn); |
193 | for( QStringList::Iterator line=list.begin(); line!=list.end(); line++ ) { | 205 | for (QStringList::Iterator line = list.begin(); line != list.end(); |
194 | if( (*line).startsWith( "Socket 0:" ) ){ | 206 | line++) { |
195 | if( (*line).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ){ | 207 | if ((*line).startsWith("Socket 0:")) { |
196 | cardInPcmcia0 = FALSE; | 208 | if ((*line).startsWith("Socket 0: empty") && cardInPcmcia0) { |
197 | } else if ( !(*line).startsWith( "Socket 0: empty" ) && !cardInPcmcia0 ){ | 209 | cardInPcmcia0 = FALSE; |
198 | cardInPcmcia0Name = (*line).mid( ( (*line).find( ':' ) + 1 ), (*line).length() - 9 ); | 210 | } else if (!(*line).startsWith("Socket 0: empty") |
199 | cardInPcmcia0Name.stripWhiteSpace(); | 211 | && !cardInPcmcia0) { |
200 | cardInPcmcia0 = TRUE; | 212 | cardInPcmcia0Name = |
201 | show(); | 213 | (*line).mid(((*line).find(':') + 1), |
202 | line++; | 214 | (*line).length() - 9); |
203 | int pos=(*line).find('\t' ) + 1; | 215 | cardInPcmcia0Name.stripWhiteSpace(); |
204 | cardInPcmcia0Type = (*line).mid( pos, (*line).find( "\t" , pos) - pos ); | 216 | cardInPcmcia0 = TRUE; |
205 | } | 217 | show(); |
206 | } else if( (*line).startsWith( "Socket 1:" ) ){ | 218 | line++; |
207 | if( (*line).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) { | 219 | int pos = (*line).find('\t') + 1; |
208 | cardInPcmcia1 = FALSE; | 220 | cardInPcmcia0Type = |
209 | } else if ( !(*line).startsWith( "Socket 1: empty" ) && !cardInPcmcia1 ) { | 221 | (*line).mid(pos, (*line).find("\t", pos) - pos); |
210 | cardInPcmcia1Name = (*line).mid(((*line).find(':') + 1), (*line).length() - 9 ); | 222 | } |
211 | cardInPcmcia1Name.stripWhiteSpace(); | 223 | } else if ((*line).startsWith("Socket 1:")) { |
212 | cardInPcmcia1 = TRUE; | 224 | if ((*line).startsWith("Socket 1: empty") && cardInPcmcia1) { |
213 | show(); | 225 | cardInPcmcia1 = FALSE; |
214 | line++; | 226 | } else if (!(*line).startsWith("Socket 1: empty") |
215 | int pos=(*line).find('\t') + 1; | 227 | && !cardInPcmcia1) { |
216 | cardInPcmcia1Type = (*line).mid( pos, (*line).find("\t", pos) - pos ); | 228 | cardInPcmcia1Name = |
217 | } | 229 | (*line).mid(((*line).find(':') + 1), |
218 | } | 230 | (*line).length() - 9); |
219 | } | 231 | cardInPcmcia1Name.stripWhiteSpace(); |
220 | f.close(); | 232 | cardInPcmcia1 = TRUE; |
221 | 233 | show(); | |
222 | if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1) ) { | 234 | line++; |
223 | QString text = QString::null; | 235 | int pos = (*line).find('\t') + 1; |
224 | QString what = QString::null; | 236 | cardInPcmcia1Type = |
225 | if(cardWas0 != cardInPcmcia0) { | 237 | (*line).mid(pos, (*line).find("\t", pos) - pos); |
226 | if(cardInPcmcia0) { | 238 | } |
227 | text += tr( "New card: " ); | 239 | } |
228 | what="on"; | 240 | } |
229 | } else { | 241 | f.close(); |
230 | text += tr( "Ejected: " ); | 242 | |
231 | what="off"; | 243 | if (!showPopUp |
232 | } | 244 | && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { |
233 | text += cardInPcmcia0Name; | 245 | QString text = QString::null; |
234 | popUp( text, "cardmon/" + cardInPcmcia0Type ); | 246 | QString what = QString::null; |
235 | } | 247 | if (cardWas0 != cardInPcmcia0) { |
236 | 248 | if (cardInPcmcia0) { | |
237 | if( cardWas1 != cardInPcmcia1) { | 249 | text += tr("New card: "); |
238 | if( cardInPcmcia1) { | 250 | what = "on"; |
239 | text += tr( "New card: " ); | 251 | } else { |
240 | what = "on"; | 252 | text += tr("Ejected: "); |
241 | } else { | 253 | what = "off"; |
242 | text += tr( "Ejected: " ); | 254 | } |
243 | what = "off"; | 255 | text += cardInPcmcia0Name; |
244 | } | 256 | popUp(text, "cardmon/" + cardInPcmcia0Type); |
245 | text += cardInPcmcia1Name; | 257 | } |
246 | popUp( text, "cardmon/" + cardInPcmcia1Type ); | 258 | |
247 | } | 259 | if (cardWas1 != cardInPcmcia1) { |
248 | QSound::play( Resource::findSound( "cardmon/card" + what) ); | 260 | if (cardInPcmcia1) { |
249 | } | 261 | text += tr("New card: "); |
262 | what = "on"; | ||
263 | } else { | ||
264 | text += tr("Ejected: "); | ||
265 | what = "off"; | ||
266 | } | ||
267 | text += cardInPcmcia1Name; | ||
268 | popUp(text, "cardmon/" + cardInPcmcia1Type); | ||
269 | } | ||
270 | QSound::play(Resource::findSound("cardmon/card" + what)); | ||
271 | } | ||
250 | } else { | 272 | } else { |
251 | // no file found | 273 | // no file found |
252 | qDebug( "no file found" ); | 274 | qDebug("no file found"); |
253 | cardInPcmcia0 = FALSE; | 275 | cardInPcmcia0 = FALSE; |
254 | cardInPcmcia1 = FALSE; | 276 | cardInPcmcia1 = FALSE; |
255 | } | 277 | } |
256 | return ( (cardWas0 == cardInPcmcia0 && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE ); | 278 | return ((cardWas0 == cardInPcmcia0 |
279 | && cardWas1 == cardInPcmcia1) ? FALSE : TRUE); | ||
257 | } | 280 | } |
258 | 281 | ||
259 | 282 | ||
260 | bool CardMonitor::getStatusSd( int showPopUp ) { | 283 | bool CardMonitor::getStatusSd(int showPopUp) |
284 | { | ||
261 | 285 | ||
262 | bool cardWas = cardInSd; // remember last state | 286 | bool cardWas = cardInSd;// remember last state |
263 | cardInSd = FALSE; | 287 | cardInSd = FALSE; |
264 | 288 | ||
265 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 289 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
266 | struct mntent *me; | 290 | struct mntent *me; |
267 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 291 | FILE *mntfp = setmntent("/etc/mtab", "r"); |
268 | 292 | ||
269 | if ( mntfp ) { | 293 | if (mntfp) { |
270 | while ( ( me = getmntent( mntfp ) ) != 0 ) { | 294 | while ((me = getmntent(mntfp)) != 0) { |
271 | QString fs = me->mnt_fsname; | 295 | QString fs = me->mnt_fsname; |
272 | //qDebug( fs ); | 296 | //qDebug( fs ); |
273 | if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" || fs.left( 9 ) == "/dev/mmcd" ) { | 297 | if (fs.left(14) == "/dev/mmc/part1" || fs.left(7) == "/dev/sd" |
274 | cardInSd = TRUE; | 298 | || fs.left(9) == "/dev/mmcd") { |
275 | show(); | 299 | cardInSd = TRUE; |
276 | } | 300 | show(); |
301 | } | ||
277 | // else { | 302 | // else { |
278 | // cardInSd = FALSE; | 303 | // cardInSd = FALSE; |
279 | // } | 304 | // } |
280 | } | 305 | } |
281 | endmntent( mntfp ); | 306 | endmntent(mntfp); |
282 | } | 307 | } |
283 | 308 | ||
284 | if( !showPopUp && cardWas != cardInSd ) { | 309 | if (!showPopUp && cardWas != cardInSd) { |
285 | QString text = QString::null; | 310 | QString text = QString::null; |
286 | QString what = QString::null; | 311 | QString what = QString::null; |
287 | if( cardInSd ) { | 312 | if (cardInSd) { |
288 | text += "SD Inserted"; | 313 | text += "New card: SD/MMC"; |
289 | what = "on"; | 314 | what = "on"; |
290 | } else { | 315 | } else { |
291 | text += "SD Removed"; | 316 | text += "Ejected: SD/MMC"; |
292 | what = "off"; | 317 | what = "off"; |
293 | } | 318 | } |
294 | //qDebug("TEXT: " + text ); | 319 | //qDebug("TEXT: " + text ); |
295 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); | 320 | QSound::play(Resource::findSound("cardmon/card" + what)); |
296 | popUp( text, "cardmon/ide" ); // XX add SD pic | 321 | popUp(text, "cardmon/ide");// XX add SD pic |
297 | } | 322 | } |
298 | #else | 323 | #else |
299 | #error "Not on Linux" | 324 | #error "Not on Linux" |
300 | #endif | 325 | #endif |
301 | return ( ( cardWas == cardInSd) ? FALSE : TRUE ); | 326 | return ((cardWas == cardInSd) ? FALSE : TRUE); |
302 | } | 327 | } |
303 | 328 | ||
304 | void CardMonitor::paintEvent( QPaintEvent * ) { | 329 | void CardMonitor::paintEvent(QPaintEvent *) |
330 | { | ||
305 | 331 | ||
306 | QPainter p( this ); | 332 | QPainter p(this); |
307 | 333 | ||
308 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { | 334 | if (cardInPcmcia0 || cardInPcmcia1 || cardInSd) { |
309 | p.drawPixmap( 0, 0, pm ); | 335 | p.drawPixmap(0, 0, pm); |
310 | show(); | 336 | show(); |
311 | } else { | 337 | } else { |
312 | p.eraseRect( rect() ); | 338 | p.eraseRect(rect()); |
313 | hide(); | 339 | hide(); |
314 | } | 340 | } |
315 | } | 341 | } |