summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/cardmon/cardmon.cpp80
-rw-r--r--core/applets/cardmon/cardmon.h11
-rw-r--r--core/applets/cardmon/opie-cardmon.control2
3 files changed, 51 insertions, 42 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp
index 93bc97a..de02fe6 100644
--- a/core/applets/cardmon/cardmon.cpp
+++ b/core/applets/cardmon/cardmon.cpp
@@ -52,2 +52,5 @@ CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ),
52 52
53 cardInPcmcia0 = FALSE;
54 cardInPcmcia1 = FALSE;
55
53 setFixedSize( pm.size() ); 56 setFixedSize( pm.size() );
@@ -56,4 +59,3 @@ CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ),
56 repaint(FALSE); 59 repaint(FALSE);
57 popUpMenu = 0; 60 popupMenu = 0;
58 popUpMenuTimer = 0;
59} 61}
@@ -61,14 +63,20 @@ CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ),
61CardMonitor::~CardMonitor() { 63CardMonitor::~CardMonitor() {
64 if( popupMenu ) { delete popupMenu; }
62} 65}
63 66
64void CardMonitor::popUp(QString message) { 67void CardMonitor::popup(QString message, QString icon="") {
65 if ( ! popUpMenu ) { 68 if ( ! popupMenu ) {
66 popUpMenu = new QPopupMenu(); 69 popupMenu = new QPopupMenu();
70 }
71 popupMenu->clear();
72 if( icon == "" ) {
73 popupMenu->insertItem( message, 0 );
74 } else {
75 popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon )),
76 message, 0 );
67 } 77 }
68 popUpMenu->clear();
69 popUpMenu->insertItem( message, 0 );
70 78
71 QPoint p = mapToGlobal ( QPoint ( 0, 0 )); 79 QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
72 QSize s = popUpMenu->sizeHint ( ); 80 QSize s = popupMenu->sizeHint ( );
73 popUpMenu->popup( QPoint ( 81 popupMenu->popup( QPoint (
74 p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), 82 p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ),
@@ -76,13 +84,3 @@ void CardMonitor::popUp(QString message) {
76 84
77 if ( ! popUpMenuTimer ) { 85 QTimer::singleShot( 2000, this, SLOT(popupMenuTimeout()) );
78 popUpMenuTimer = new QTimer( this );
79 connect( popUpMenuTimer, SIGNAL(timeout()), this, SLOT(popUpTimeout()) );
80 }
81 timerEvent(0);
82 popUpMenuTimer->start( 2000 );
83}
84
85void CardMonitor::popUpTimeout() {
86 popUpMenu->hide();
87 popUpMenuTimer->stop();
88} 86}
@@ -99,3 +97,4 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
99 if ( cardInPcmcia0 ) { 97 if ( cardInPcmcia0 ) {
100 menu->insertItem( tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1 ); 98 menu->insertItem( QIconSet ( Resource::loadPixmap ( getIconName(cardInPcmcia0Type) )),
99 tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1 );
101 } 100 }
@@ -103,3 +102,4 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
103 if ( cardInPcmcia1 ) { 102 if ( cardInPcmcia1 ) {
104 menu->insertItem( tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2 ); 103 menu->insertItem( QIconSet ( Resource::loadPixmap ( getIconName(cardInPcmcia1Type) )),
104 tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2 );
105 } 105 }
@@ -118,3 +118,3 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
118 qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", err); 118 qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", err);
119 popUp( tr("CF/PCMCIA card eject failed!")); 119 popup( tr("CF/PCMCIA card eject failed!"));
120 } 120 }
@@ -125,3 +125,3 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
125 qDebug("Could not execute `/etc/sdcontrol comeject'! err=%d", err); 125 qDebug("Could not execute `/etc/sdcontrol comeject'! err=%d", err);
126 popUp( tr("SD/MMC card eject failed!")); 126 popup( tr("SD/MMC card eject failed!"));
127 } 127 }
@@ -132,3 +132,3 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
132 qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err); 132 qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err);
133 popUp( tr("CF/PCMCIA card eject failed!")); 133 popup( tr("CF/PCMCIA card eject failed!"));
134 } 134 }
@@ -187,5 +187,8 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
187 show(); 187 show();
188 line++;
189 int pos=(*line).find('\t')+1;
190 cardInPcmcia0Type = (*line).mid( pos, (*line).find("\t", pos) - pos);
188 } 191 }
189 } 192 }
190 if( (*line).startsWith("Socket 1:") ){ 193 else if( (*line).startsWith("Socket 1:") ){
191 if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){ 194 if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){
@@ -197,2 +200,5 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
197 show(); 200 show();
201 line++;
202 int pos=(*line).find('\t')+1;
203 cardInPcmcia1Type = (*line).mid( pos, (*line).find("\t", pos) - pos);
198 } 204 }
@@ -200,2 +206,3 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
200 } 206 }
207 f.close();
201 } else { 208 } else {
@@ -209,6 +216,2 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
209 216
210 if(!cardInPcmcia0 && !cardInPcmcia1) {
211 qDebug("Pcmcia: no cards");
212 }
213
214 if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { 217 if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) {
@@ -219,5 +222,3 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
219 text += cardInPcmcia0Name; 222 text += cardInPcmcia0Name;
220 } 223 popup( text, getIconName( cardInPcmcia0Type ) );
221 if(cardWas0 != cardInPcmcia0 && cardWas1 != cardInPcmcia1) {
222 text += "\n";
223 } 224 }
@@ -227,7 +228,6 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
227 text += cardInPcmcia1Name; 228 text += cardInPcmcia1Name;
229 popup( text, getIconName( cardInPcmcia1Type ) );
228 } 230 }
229 popUp( text );
230 } 231 }
231 232
232 f.close();
233 233
@@ -259,3 +259,3 @@ bool CardMonitor::getStatusSd( int showPopUp ) {
259 else { text += "SD Removed"; } 259 else { text += "SD Removed"; }
260 popUp( text ); 260 popup( text); // XX add SD pic
261 } 261 }
@@ -280,2 +280,10 @@ void CardMonitor::paintEvent( QPaintEvent * ) {
280 280
281QString CardMonitor::getIconName( QString type ) {
282 if( type != "network" &&
283 type != "ide" ) {
284 type="cardmon";
285 }
286 return "cardmon/"+type;
287}
288
281 289
diff --git a/core/applets/cardmon/cardmon.h b/core/applets/cardmon/cardmon.h
index 34b8d95..e424192 100644
--- a/core/applets/cardmon/cardmon.h
+++ b/core/applets/cardmon/cardmon.h
@@ -24,3 +24,2 @@
24#include <qpopupmenu.h> 24#include <qpopupmenu.h>
25#include <qtimer.h>
26 25
@@ -36,3 +35,3 @@ private slots:
36 void cardMessage( const QCString &msg, const QByteArray & ); 35 void cardMessage( const QCString &msg, const QByteArray & );
37 void popUpTimeout(); 36 void popupTimeout();
38 37
@@ -43,4 +42,2 @@ private:
43 QPixmap pm; 42 QPixmap pm;
44 QPopupMenu *popUpMenu;
45 QTimer *popUpMenuTimer;
46 // pcmcia socket 0 43 // pcmcia socket 0
@@ -48,2 +45,3 @@ private:
48 QString cardInPcmcia0Name; 45 QString cardInPcmcia0Name;
46 QString cardInPcmcia0Type;
49 // pcmcia socket 1 47 // pcmcia socket 1
@@ -51,5 +49,8 @@ private:
51 QString cardInPcmcia1Name; 49 QString cardInPcmcia1Name;
50 QString cardInPcmcia1Type;
52 bool cardInSd; 51 bool cardInSd;
53 void iconShow(); 52 void iconShow();
54 void popUp(QString message); 53 QPopupMenu *popupMenu;
54 void popup(QString message, QString icon="");
55 QString getIconName(QString type);
55}; 56};
diff --git a/core/applets/cardmon/opie-cardmon.control b/core/applets/cardmon/opie-cardmon.control
index 9f941f8..bcd0326 100644
--- a/core/applets/cardmon/opie-cardmon.control
+++ b/core/applets/cardmon/opie-cardmon.control
@@ -1,2 +1,2 @@
1Files: plugins/applets/libcardmonapplet.so* pics/cardmon/pcmcia.png 1Files: plugins/applets/libcardmonapplet.so* pics/cardmon/*.png
2Priority: optional 2Priority: optional