author | harlekin <harlekin> | 2002-06-23 23:32:29 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-06-23 23:32:29 (UTC) |
commit | 340e6e7830df8dcc9cf73fb1bf8a29130e34211d (patch) (unidiff) | |
tree | 38f5c6a7c82d4c0758b8640be96c8e318008939c | |
parent | 5713a36f24973c01a46fdff6203acf4590927f49 (diff) | |
download | opie-340e6e7830df8dcc9cf73fb1bf8a29130e34211d.zip opie-340e6e7830df8dcc9cf73fb1bf8a29130e34211d.tar.gz opie-340e6e7830df8dcc9cf73fb1bf8a29130e34211d.tar.bz2 |
now cardmon should even start
-rw-r--r-- | core/applets/cardmon/cardmon.cpp | 20 | ||||
-rw-r--r-- | core/applets/cardmon/cardmon.h | 2 |
2 files changed, 13 insertions, 9 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index de02fe6..0addb89 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp | |||
@@ -1,289 +1,293 @@ | |||
1 | /* | 1 | /* |
2 | * cardmon.cpp | 2 | * cardmon.cpp |
3 | * | 3 | * |
4 | * --------------------- | 4 | * --------------------- |
5 | * | 5 | * |
6 | * copyright : (c) 2002 by Maximilian Reiss | 6 | * copyright : (c) 2002 by Maximilian Reiss |
7 | * email : max.reiss@gmx.de | 7 | * email : max.reiss@gmx.de |
8 | * based on two apps by Devin Butterfield | 8 | * based on two apps by Devin Butterfield |
9 | */ | 9 | */ |
10 | /*************************************************************************** | 10 | /*************************************************************************** |
11 | * * | 11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * | 12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * | 13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 15 | * (at your option) any later version. * |
16 | * * | 16 | * * |
17 | ***************************************************************************/ | 17 | ***************************************************************************/ |
18 | 18 | ||
19 | 19 | ||
20 | #include "cardmon.h" | 20 | #include "cardmon.h" |
21 | 21 | ||
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | 23 | ||
24 | #include <qcopchannel_qws.h> | 24 | #include <qcopchannel_qws.h> |
25 | #include <qpainter.h> | 25 | #include <qpainter.h> |
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | #include <qtimer.h> | 29 | #include <qtimer.h> |
30 | 30 | ||
31 | #include <stdio.h> | 31 | #include <stdio.h> |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
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 | 36 | ||
37 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 37 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
38 | #include <sys/vfs.h> | 38 | #include <sys/vfs.h> |
39 | #include <mntent.h> | 39 | #include <mntent.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ), | 42 | CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ), |
43 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) { | 43 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) { |
44 | 44 | ||
45 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 45 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
46 | connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 46 | connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
47 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); | 47 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); |
48 | 48 | ||
49 | QCopChannel* sdChannel = new QCopChannel( "QPE/Card", this ); | 49 | QCopChannel* sdChannel = new QCopChannel( "QPE/Card", this ); |
50 | connect( sdChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 50 | connect( sdChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
51 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); | 51 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); |
52 | 52 | ||
53 | cardInPcmcia0 = FALSE; | 53 | cardInPcmcia0 = FALSE; |
54 | cardInPcmcia1 = FALSE; | 54 | cardInPcmcia1 = FALSE; |
55 | 55 | ||
56 | setFixedSize( pm.size() ); | 56 | setFixedSize( pm.size() ); |
57 | getStatusPcmcia(TRUE); | 57 | getStatusPcmcia(TRUE); |
58 | getStatusSd(TRUE); | 58 | getStatusSd(TRUE); |
59 | repaint(FALSE); | 59 | repaint(FALSE); |
60 | popupMenu = 0; | 60 | popupMenu = 0; |
61 | } | 61 | } |
62 | 62 | ||
63 | CardMonitor::~CardMonitor() { | 63 | CardMonitor::~CardMonitor() { |
64 | if( popupMenu ) { delete popupMenu; } | 64 | if( popupMenu ) { delete popupMenu; } |
65 | } | 65 | } |
66 | 66 | ||
67 | void CardMonitor::popup(QString message, QString icon="") { | 67 | void CardMonitor::popUp(QString message, QString icon="") { |
68 | if ( ! popupMenu ) { | 68 | if ( ! popupMenu ) { |
69 | popupMenu = new QPopupMenu(); | 69 | popupMenu = new QPopupMenu(); |
70 | } | 70 | } |
71 | popupMenu->clear(); | 71 | popupMenu->clear(); |
72 | if( icon == "" ) { | 72 | if( icon == "" ) { |
73 | popupMenu->insertItem( message, 0 ); | 73 | popupMenu->insertItem( message, 0 ); |
74 | } else { | 74 | } else { |
75 | popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon )), | 75 | popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon )), |
76 | message, 0 ); | 76 | message, 0 ); |
77 | } | 77 | } |
78 | 78 | ||
79 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | 79 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); |
80 | QSize s = popupMenu->sizeHint ( ); | 80 | QSize s = popupMenu->sizeHint ( ); |
81 | popupMenu->popup( QPoint ( | 81 | popupMenu->popup( QPoint ( |
82 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 82 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), |
83 | p. y ( ) - s. height ( ) ), 0); | 83 | p. y ( ) - s. height ( ) ), 0); |
84 | 84 | ||
85 | QTimer::singleShot( 2000, this, SLOT(popupMenuTimeout()) ); | 85 | QTimer::singleShot( 2000, this, SLOT(popupTimeout()) ); |
86 | } | ||
87 | |||
88 | void CardMonitor::popupTimeout() { | ||
89 | popupMenu->hide(); | ||
86 | } | 90 | } |
87 | 91 | ||
88 | void CardMonitor::mousePressEvent( QMouseEvent * ) { | 92 | void CardMonitor::mousePressEvent( QMouseEvent * ) { |
89 | QPopupMenu *menu = new QPopupMenu(); | 93 | QPopupMenu *menu = new QPopupMenu(); |
90 | QString cmd; | 94 | QString cmd; |
91 | int err=0; | 95 | int err=0; |
92 | 96 | ||
93 | if ( cardInSd ) { | 97 | if ( cardInSd ) { |
94 | menu->insertItem( tr("Eject SD/MMC card"), 0 ); | 98 | menu->insertItem( tr("Eject SD/MMC card"), 0 ); |
95 | } | 99 | } |
96 | 100 | ||
97 | if ( cardInPcmcia0 ) { | 101 | if ( cardInPcmcia0 ) { |
98 | menu->insertItem( QIconSet ( Resource::loadPixmap ( getIconName(cardInPcmcia0Type) )), | 102 | menu->insertItem( QIconSet ( Resource::loadPixmap ( getIconName(cardInPcmcia0Type) )), |
99 | tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1 ); | 103 | tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1 ); |
100 | } | 104 | } |
101 | 105 | ||
102 | if ( cardInPcmcia1 ) { | 106 | if ( cardInPcmcia1 ) { |
103 | menu->insertItem( QIconSet ( Resource::loadPixmap ( getIconName(cardInPcmcia1Type) )), | 107 | menu->insertItem( QIconSet ( Resource::loadPixmap ( getIconName(cardInPcmcia1Type) )), |
104 | tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2 ); | 108 | tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2 ); |
105 | } | 109 | } |
106 | 110 | ||
107 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | 111 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); |
108 | QSize s = menu->sizeHint ( ); | 112 | QSize s = menu->sizeHint ( ); |
109 | int opt = menu->exec( QPoint ( | 113 | int opt = menu->exec( QPoint ( |
110 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 114 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), |
111 | p. y ( ) - s. height ( ) ), 0); | 115 | p. y ( ) - s. height ( ) ), 0); |
112 | 116 | ||
113 | if ( opt == 1 ) { | 117 | if ( opt == 1 ) { |
114 | 118 | ||
115 | cmd = "/sbin/cardctl eject 0"; | 119 | cmd = "/sbin/cardctl eject 0"; |
116 | err = system( (const char *) cmd ); | 120 | err = system( (const char *) cmd ); |
117 | if ( ( err == 127 ) || ( err < 0 ) ) { | 121 | if ( ( err == 127 ) || ( err < 0 ) ) { |
118 | qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", err); | 122 | qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", err); |
119 | popup( tr("CF/PCMCIA card eject failed!")); | 123 | popUp( tr("CF/PCMCIA card eject failed!")); |
120 | } | 124 | } |
121 | } else if ( opt == 0 ) { | 125 | } else if ( opt == 0 ) { |
122 | cmd = "/etc/sdcontrol compeject"; | 126 | cmd = "/etc/sdcontrol compeject"; |
123 | err = system( (const char *) cmd ); | 127 | err = system( (const char *) cmd ); |
124 | if ( ( err != 0 ) ) { | 128 | if ( ( err != 0 ) ) { |
125 | qDebug("Could not execute `/etc/sdcontrol comeject'! err=%d", err); | 129 | qDebug("Could not execute `/etc/sdcontrol comeject'! err=%d", err); |
126 | popup( tr("SD/MMC card eject failed!")); | 130 | popUp( tr("SD/MMC card eject failed!")); |
127 | } | 131 | } |
128 | } else if ( opt == 2 ) { | 132 | } else if ( opt == 2 ) { |
129 | cmd = "/sbin/cardctl eject 1"; | 133 | cmd = "/sbin/cardctl eject 1"; |
130 | err = system( (const char *) cmd ); | 134 | err = system( (const char *) cmd ); |
131 | if ( ( err == 127 ) || ( err < 0 ) ) { | 135 | if ( ( err == 127 ) || ( err < 0 ) ) { |
132 | qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err); | 136 | qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err); |
133 | popup( tr("CF/PCMCIA card eject failed!")); | 137 | popUp( tr("CF/PCMCIA card eject failed!")); |
134 | } | 138 | } |
135 | } | 139 | } |
136 | 140 | ||
137 | delete menu; | 141 | delete menu; |
138 | } | 142 | } |
139 | 143 | ||
140 | 144 | ||
141 | void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) { | 145 | void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) { |
142 | if ( msg == "stabChanged()" ) { | 146 | if ( msg == "stabChanged()" ) { |
143 | // qDebug("Pcmcia: stabchanged"); | 147 | // qDebug("Pcmcia: stabchanged"); |
144 | if ( getStatusPcmcia() ) { | 148 | if ( getStatusPcmcia() ) { |
145 | repaint(FALSE); | 149 | repaint(FALSE); |
146 | } | 150 | } |
147 | } else if ( msg == "mtabChanged()" ) { | 151 | } else if ( msg == "mtabChanged()" ) { |
148 | // qDebug("Pcmcia: mtabchanged"); | 152 | // qDebug("Pcmcia: mtabchanged"); |
149 | if ( getStatusSd() ) { | 153 | if ( getStatusSd() ) { |
150 | repaint(FALSE); | 154 | repaint(FALSE); |
151 | } | 155 | } |
152 | } | 156 | } |
153 | } | 157 | } |
154 | 158 | ||
155 | bool CardMonitor::getStatusPcmcia( int showPopUp ) { | 159 | bool CardMonitor::getStatusPcmcia( int showPopUp ) { |
156 | 160 | ||
157 | bool cardWas0 = cardInPcmcia0; // remember last state | 161 | bool cardWas0 = cardInPcmcia0; // remember last state |
158 | bool cardWas1 = cardInPcmcia1; | 162 | bool cardWas1 = cardInPcmcia1; |
159 | 163 | ||
160 | QString fileName; | 164 | QString fileName; |
161 | 165 | ||
162 | // one of these 3 files should exist | 166 | // one of these 3 files should exist |
163 | if (QFile::exists("/var/run/stab")) { | 167 | if (QFile::exists("/var/run/stab")) { |
164 | fileName = "/var/run/stab"; | 168 | fileName = "/var/run/stab"; |
165 | } else if (QFile::exists("/var/state/pcmcia/stab")) { | 169 | } else if (QFile::exists("/var/state/pcmcia/stab")) { |
166 | fileName="/var/state/pcmcia/stab"; | 170 | fileName="/var/state/pcmcia/stab"; |
167 | } else { | 171 | } else { |
168 | fileName="/var/lib/pcmcia/stab"; | 172 | fileName="/var/lib/pcmcia/stab"; |
169 | } | 173 | } |
170 | 174 | ||
171 | QFile f(fileName); | 175 | QFile f(fileName); |
172 | 176 | ||
173 | if ( f.open(IO_ReadOnly) ) { | 177 | if ( f.open(IO_ReadOnly) ) { |
174 | QStringList list; | 178 | QStringList list; |
175 | QTextStream stream ( &f); | 179 | QTextStream stream ( &f); |
176 | QString streamIn; | 180 | QString streamIn; |
177 | streamIn = stream.read(); | 181 | streamIn = stream.read(); |
178 | list = QStringList::split("\n", streamIn); | 182 | list = QStringList::split("\n", streamIn); |
179 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { | 183 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { |
180 | if( (*line).startsWith("Socket 0:") ){ | 184 | if( (*line).startsWith("Socket 0:") ){ |
181 | if( (*line).startsWith("Socket 0: empty") && cardInPcmcia0 ){ | 185 | if( (*line).startsWith("Socket 0: empty") && cardInPcmcia0 ){ |
182 | cardInPcmcia0 = FALSE; | 186 | cardInPcmcia0 = FALSE; |
183 | } else if ( !(*line).startsWith("Socket 0: empty") && !cardInPcmcia0 ){ | 187 | } else if ( !(*line).startsWith("Socket 0: empty") && !cardInPcmcia0 ){ |
184 | cardInPcmcia0Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); | 188 | cardInPcmcia0Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); |
185 | cardInPcmcia0Name.stripWhiteSpace(); | 189 | cardInPcmcia0Name.stripWhiteSpace(); |
186 | cardInPcmcia0 = TRUE; | 190 | cardInPcmcia0 = TRUE; |
187 | show(); | 191 | show(); |
188 | line++; | 192 | line++; |
189 | int pos=(*line).find('\t')+1; | 193 | int pos=(*line).find('\t')+1; |
190 | cardInPcmcia0Type = (*line).mid( pos, (*line).find("\t", pos) - pos); | 194 | cardInPcmcia0Type = (*line).mid( pos, (*line).find("\t", pos) - pos); |
191 | } | 195 | } |
192 | } | 196 | } |
193 | else if( (*line).startsWith("Socket 1:") ){ | 197 | else if( (*line).startsWith("Socket 1:") ){ |
194 | if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){ | 198 | if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){ |
195 | cardInPcmcia1 = FALSE; | 199 | cardInPcmcia1 = FALSE; |
196 | } else if ( !(*line).startsWith("Socket 1: empty") && !cardInPcmcia1 ){ | 200 | } else if ( !(*line).startsWith("Socket 1: empty") && !cardInPcmcia1 ){ |
197 | cardInPcmcia1Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); | 201 | cardInPcmcia1Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); |
198 | cardInPcmcia1Name.stripWhiteSpace(); | 202 | cardInPcmcia1Name.stripWhiteSpace(); |
199 | cardInPcmcia1 = TRUE; | 203 | cardInPcmcia1 = TRUE; |
200 | show(); | 204 | show(); |
201 | line++; | 205 | line++; |
202 | int pos=(*line).find('\t')+1; | 206 | int pos=(*line).find('\t')+1; |
203 | cardInPcmcia1Type = (*line).mid( pos, (*line).find("\t", pos) - pos); | 207 | cardInPcmcia1Type = (*line).mid( pos, (*line).find("\t", pos) - pos); |
204 | } | 208 | } |
205 | } | 209 | } |
206 | } | 210 | } |
207 | f.close(); | 211 | f.close(); |
208 | } else { | 212 | } else { |
209 | // no file found | 213 | // no file found |
210 | qDebug("no file found"); | 214 | qDebug("no file found"); |
211 | cardInPcmcia0 = FALSE; | 215 | cardInPcmcia0 = FALSE; |
212 | cardInPcmcia1 = FALSE; | 216 | cardInPcmcia1 = FALSE; |
213 | return FALSE; | 217 | return FALSE; |
214 | 218 | ||
215 | } | 219 | } |
216 | 220 | ||
217 | if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { | 221 | if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { |
218 | QString text = ""; | 222 | QString text = ""; |
219 | if(cardWas0 != cardInPcmcia0) { | 223 | if(cardWas0 != cardInPcmcia0) { |
220 | if(cardInPcmcia0) { text += tr("New card: "); } | 224 | if(cardInPcmcia0) { text += tr("New card: "); } |
221 | else { text += tr("Ejected: "); } | 225 | else { text += tr("Ejected: "); } |
222 | text += cardInPcmcia0Name; | 226 | text += cardInPcmcia0Name; |
223 | popup( text, getIconName( cardInPcmcia0Type ) ); | 227 | popUp( text, getIconName( cardInPcmcia0Type ) ); |
224 | } | 228 | } |
225 | if(cardWas1 != cardInPcmcia1) { | 229 | if(cardWas1 != cardInPcmcia1) { |
226 | if(cardInPcmcia1) { text += tr("New card: "); } | 230 | if(cardInPcmcia1) { text += tr("New card: "); } |
227 | else { text += tr("Ejected: "); } | 231 | else { text += tr("Ejected: "); } |
228 | text += cardInPcmcia1Name; | 232 | text += cardInPcmcia1Name; |
229 | popup( text, getIconName( cardInPcmcia1Type ) ); | 233 | popUp( text, getIconName( cardInPcmcia1Type ) ); |
230 | } | 234 | } |
231 | } | 235 | } |
232 | 236 | ||
233 | 237 | ||
234 | return ((cardWas0 == cardInPcmcia0 || cardWas1 == cardInPcmcia1) ? FALSE : TRUE); | 238 | return ((cardWas0 == cardInPcmcia0 || cardWas1 == cardInPcmcia1) ? FALSE : TRUE); |
235 | } | 239 | } |
236 | 240 | ||
237 | 241 | ||
238 | bool CardMonitor::getStatusSd( int showPopUp ) { | 242 | bool CardMonitor::getStatusSd( int showPopUp ) { |
239 | 243 | ||
240 | bool cardWas=cardInSd; // remember last state | 244 | bool cardWas=cardInSd; // remember last state |
241 | cardInSd=false; | 245 | cardInSd=false; |
242 | 246 | ||
243 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 247 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
244 | struct mntent *me; | 248 | struct mntent *me; |
245 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 249 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
246 | 250 | ||
247 | if ( mntfp ) { | 251 | if ( mntfp ) { |
248 | while ( (me = getmntent( mntfp )) != 0 ) { | 252 | while ( (me = getmntent( mntfp )) != 0 ) { |
249 | QString fs = me->mnt_fsname; | 253 | QString fs = me->mnt_fsname; |
250 | if ( fs.left(7)=="/dev/sd" || fs.left(9) == "/dev/mmcd" ) { | 254 | if ( fs.left(7)=="/dev/sd" || fs.left(9) == "/dev/mmcd" ) { |
251 | cardInSd=true; | 255 | cardInSd=true; |
252 | } | 256 | } |
253 | } | 257 | } |
254 | endmntent( mntfp ); | 258 | endmntent( mntfp ); |
255 | } | 259 | } |
256 | if(!showPopUp && cardWas != cardInSd) { | 260 | if(!showPopUp && cardWas != cardInSd) { |
257 | QString text = ""; | 261 | QString text = ""; |
258 | if(cardInSd) { text += "SD Inserted"; } | 262 | if(cardInSd) { text += "SD Inserted"; } |
259 | else { text += "SD Removed"; } | 263 | else { text += "SD Removed"; } |
260 | popup( text); // XX add SD pic | 264 | popUp( text); // XX add SD pic |
261 | } | 265 | } |
262 | 266 | ||
263 | #else | 267 | #else |
264 | #error "Not on Linux" | 268 | #error "Not on Linux" |
265 | #endif | 269 | #endif |
266 | return ((cardWas == cardInSd) ? FALSE : TRUE); | 270 | return ((cardWas == cardInSd) ? FALSE : TRUE); |
267 | } | 271 | } |
268 | 272 | ||
269 | void CardMonitor::paintEvent( QPaintEvent * ) { | 273 | void CardMonitor::paintEvent( QPaintEvent * ) { |
270 | QPainter p( this ); | 274 | QPainter p( this ); |
271 | 275 | ||
272 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { | 276 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { |
273 | p.drawPixmap( 0, 0, pm ); | 277 | p.drawPixmap( 0, 0, pm ); |
274 | show(); | 278 | show(); |
275 | } else { | 279 | } else { |
276 | p.eraseRect( rect() ); | 280 | p.eraseRect( rect() ); |
277 | hide(); | 281 | hide(); |
278 | } | 282 | } |
279 | } | 283 | } |
280 | 284 | ||
281 | QString CardMonitor::getIconName( QString type ) { | 285 | QString CardMonitor::getIconName( QString type ) { |
282 | if( type != "network" && | 286 | if( type != "network" && |
283 | type != "ide" ) { | 287 | type != "ide" ) { |
284 | type="cardmon"; | 288 | type="cardmon"; |
285 | } | 289 | } |
286 | return "cardmon/"+type; | 290 | return "cardmon/"+type; |
287 | } | 291 | } |
288 | 292 | ||
289 | 293 | ||
diff --git a/core/applets/cardmon/cardmon.h b/core/applets/cardmon/cardmon.h index e424192..3dcf235 100644 --- a/core/applets/cardmon/cardmon.h +++ b/core/applets/cardmon/cardmon.h | |||
@@ -1,59 +1,59 @@ | |||
1 | /* | 1 | /* |
2 | * cardmon.h | 2 | * cardmon.h |
3 | * | 3 | * |
4 | * --------------------- | 4 | * --------------------- |
5 | * | 5 | * |
6 | * copyright : (c) 2002 by Maximilian Reiss | 6 | * copyright : (c) 2002 by Maximilian Reiss |
7 | * email : max.reiss@gmx.de | 7 | * email : max.reiss@gmx.de |
8 | * based on two apps by Devin Butterfield | 8 | * based on two apps by Devin Butterfield |
9 | */ | 9 | */ |
10 | /*************************************************************************** | 10 | /*************************************************************************** |
11 | * * | 11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * | 12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * | 13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 15 | * (at your option) any later version. * |
16 | * * | 16 | * * |
17 | ***************************************************************************/ | 17 | ***************************************************************************/ |
18 | 18 | ||
19 | #ifndef CARDMON_H | 19 | #ifndef CARDMON_H |
20 | #define CARDMON_H | 20 | #define CARDMON_H |
21 | 21 | ||
22 | #include <qwidget.h> | 22 | #include <qwidget.h> |
23 | #include <qpixmap.h> | 23 | #include <qpixmap.h> |
24 | #include <qpopupmenu.h> | 24 | #include <qpopupmenu.h> |
25 | 25 | ||
26 | class CardMonitor : public QWidget { | 26 | class CardMonitor : public QWidget { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | public: | 28 | public: |
29 | CardMonitor( QWidget *parent = 0 ); | 29 | CardMonitor( QWidget *parent = 0 ); |
30 | ~CardMonitor(); | 30 | ~CardMonitor(); |
31 | bool getStatusPcmcia( int showPopUp = FALSE ); | 31 | bool getStatusPcmcia( int showPopUp = FALSE ); |
32 | bool getStatusSd( int showPopUp = FALSE ); | 32 | bool getStatusSd( int showPopUp = FALSE ); |
33 | 33 | ||
34 | private slots: | 34 | private slots: |
35 | void cardMessage( const QCString &msg, const QByteArray & ); | 35 | void cardMessage( const QCString &msg, const QByteArray & ); |
36 | void popupTimeout(); | 36 | void popupTimeout(); |
37 | 37 | ||
38 | protected: | 38 | protected: |
39 | void paintEvent( QPaintEvent* ); | 39 | void paintEvent( QPaintEvent* ); |
40 | void mousePressEvent( QMouseEvent * ); | 40 | void mousePressEvent( QMouseEvent * ); |
41 | private: | 41 | private: |
42 | QPixmap pm; | 42 | QPixmap pm; |
43 | // pcmcia socket 0 | 43 | // pcmcia socket 0 |
44 | bool cardInPcmcia0; | 44 | bool cardInPcmcia0; |
45 | QString cardInPcmcia0Name; | 45 | QString cardInPcmcia0Name; |
46 | QString cardInPcmcia0Type; | 46 | QString cardInPcmcia0Type; |
47 | // pcmcia socket 1 | 47 | // pcmcia socket 1 |
48 | bool cardInPcmcia1; | 48 | bool cardInPcmcia1; |
49 | QString cardInPcmcia1Name; | 49 | QString cardInPcmcia1Name; |
50 | QString cardInPcmcia1Type; | 50 | QString cardInPcmcia1Type; |
51 | bool cardInSd; | 51 | bool cardInSd; |
52 | void iconShow(); | 52 | void iconShow(); |
53 | QPopupMenu *popupMenu; | 53 | QPopupMenu *popupMenu; |
54 | void popup(QString message, QString icon=""); | 54 | void popUp(QString message, QString icon=""); |
55 | QString getIconName(QString type); | 55 | QString getIconName(QString type); |
56 | }; | 56 | }; |
57 | 57 | ||
58 | #endif | 58 | #endif |
59 | 59 | ||