summaryrefslogtreecommitdiff
path: root/core
authordavipt <davipt>2002-06-20 19:10:03 (UTC)
committer davipt <davipt>2002-06-20 19:10:03 (UTC)
commit8c55fec6394ca27aebf49692c643d71db32b7ebf (patch) (side-by-side diff)
tree652f92eb31431ddae39fa6e7cb58e8f1e8b9d5af /core
parente3b199e4b3ad71cb8d046e33e792402250a8faec (diff)
downloadopie-8c55fec6394ca27aebf49692c643d71db32b7ebf.zip
opie-8c55fec6394ca27aebf49692c643d71db32b7ebf.tar.gz
opie-8c55fec6394ca27aebf49692c643d71db32b7ebf.tar.bz2
Fix cardmon applet visibility (now visible is some card is plugged) and added
popup on succesfull ejection or insertion of a card.
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/cardmon/cardmon.cpp84
-rw-r--r--core/applets/cardmon/cardmon.h5
-rw-r--r--core/applets/cardmon/cardmon.pro28
3 files changed, 73 insertions, 44 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp
index 9522b88..ac2aea2 100644
--- a/core/applets/cardmon/cardmon.cpp
+++ b/core/applets/cardmon/cardmon.cpp
@@ -50,10 +50,10 @@ CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ),
connect( sdChannel, SIGNAL(received(const QCString &, const QByteArray &)),
this, SLOT(cardMessage( const QCString &, const QByteArray &)) );
-
setFixedSize( pm.size() );
- hide();
- getStatusPcmcia();
+ getStatusPcmcia(TRUE);
+ getStatusSd(TRUE);
+ repaint(FALSE);
}
CardMonitor::~CardMonitor() {
@@ -65,20 +65,24 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
int err=0;
if ( cardInSd ) {
- menu->insertItem( tr("Eject SD/ MMC card"), 0 );
+ menu->insertItem( tr("Eject SD/MMC card"), 0 );
}
if ( cardInPcmcia0 ) {
- menu->insertItem( tr("Eject card (0) %1").arg(cardInPcmcia0Name), 1 );
+ menu->insertItem( tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1 );
}
if ( cardInPcmcia1 ) {
- menu->insertItem( tr("Eject card (1) %1").arg(cardInPcmcia1Name), 2 );
+ menu->insertItem( tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2 );
}
- QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) );
+ QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
+ QSize s = menu->sizeHint ( );
+ int opt = menu->exec( QPoint (
+ p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ),
+ p. y ( ) - s. height ( ) ), 0);
- if ( menu->exec( p, 1 ) == 1 ) {
+ if ( opt == 1 ) {
cmd = "/sbin/cardctl eject 0";
err = system( (const char *) cmd );
@@ -86,23 +90,23 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", err);
QMessageBox::warning( this, tr("CardMonitor"), tr("CF/PCMCIA card eject failed!"),
tr("&OK") );
- }
- } else if ( menu->exec( p, 1 ) == 0 ) {
+ }
+ } else if ( opt == 0 ) {
cmd = "/etc/sdcontrol compeject";
err = system( (const char *) cmd );
if ( ( err != 0 ) ) {
qDebug("Could not execute `/etc/sdcontrol comeject'! err=%d", err);
QMessageBox::warning( this, tr("CardMonitor"), tr("SD/MMC card eject failed!"),
tr("&OK") );
- }
- } else if ( menu->exec( p, 1 ) == 2 ) {
+ }
+ } else if ( opt == 2 ) {
cmd = "/sbin/cardctl eject 1";
err = system( (const char *) cmd );
if ( ( err == 127 ) || ( err < 0 ) ) {
qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err);
QMessageBox::warning( this, tr("CardMonitor"), tr("CF/PCMCIA card eject failed!"),
tr("&OK") );
- }
+ }
}
delete menu;
@@ -111,17 +115,19 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) {
if ( msg == "stabChanged()" ) {
+ // qDebug("Pcmcia: stabchanged");
if ( getStatusPcmcia() ) {
repaint(FALSE);
}
} else if ( msg == "mtabChanged()" ) {
+ // qDebug("Pcmcia: mtabchanged");
if ( getStatusSd() ) {
repaint(FALSE);
}
}
}
-bool CardMonitor::getStatusPcmcia( void ) {
+bool CardMonitor::getStatusPcmcia( int showPopUp = FALSE ) {
bool cardWas0 = cardInPcmcia0; // remember last state
bool cardWas1 = cardInPcmcia1;
@@ -147,12 +153,11 @@ bool CardMonitor::getStatusPcmcia( void ) {
list = QStringList::split("\n", streamIn);
for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) {
if( (*line).startsWith("Socket 0:") ){
- // extendable, maybe read out card name
if( (*line).startsWith("Socket 0: empty") && cardInPcmcia0 ){
cardInPcmcia0 = FALSE;
- hide();
} else if ( !(*line).startsWith("Socket 0: empty") && !cardInPcmcia0 ){
cardInPcmcia0Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 );
+ cardInPcmcia0Name.stripWhiteSpace();
cardInPcmcia0 = TRUE;
show();
}
@@ -160,9 +165,9 @@ bool CardMonitor::getStatusPcmcia( void ) {
if( (*line).startsWith("Socket 1:") ){
if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){
cardInPcmcia1 = FALSE;
- hide();
} else if ( !(*line).startsWith("Socket 1: empty") && !cardInPcmcia1 ){
cardInPcmcia1Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 );
+ cardInPcmcia1Name.stripWhiteSpace();
cardInPcmcia1 = TRUE;
show();
}
@@ -173,18 +178,40 @@ bool CardMonitor::getStatusPcmcia( void ) {
qDebug("no file found");
cardInPcmcia0 = FALSE;
cardInPcmcia1 = FALSE;
- hide();
return FALSE;
}
+ if(!cardInPcmcia0 && !cardInPcmcia1) {
+ qDebug("Pcmcia: no cards");
+ }
+
+ if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) {
+ QString text = "";
+ if(cardWas0 != cardInPcmcia0) {
+ if(cardInPcmcia0) { text += tr("New card: "); }
+ else { text += tr("Ejected: "); }
+ text += cardInPcmcia0Name;
+ }
+ if(cardWas0 != cardInPcmcia0 && cardWas1 != cardInPcmcia1) {
+ text += "\n";
+ }
+ if(cardWas1 != cardInPcmcia1) {
+ if(cardInPcmcia1) { text += tr("New card: "); }
+ else { text += tr("Ejected: "); }
+ text += cardInPcmcia1Name;
+ }
+ QMessageBox::warning( this, tr("CardMonitor"), text,
+ tr("&OK") );
+ }
+
f.close();
return ((cardWas0 == cardInPcmcia0 || cardWas1 == cardInPcmcia1) ? FALSE : TRUE);
}
-bool CardMonitor::getStatusSd( void ) {
+bool CardMonitor::getStatusSd( int showPopUp = FALSE ) {
bool cardWas=cardInSd; // remember last state
cardInSd=false;
@@ -201,16 +228,15 @@ bool CardMonitor::getStatusSd( void ) {
}
}
endmntent( mntfp );
- if (cardInSd!=cardWas) {
- if (cardInSd) {
- show();
- } else {
- hide();
- }
- }
- } else {
- hide();
}
+ if(!showPopUp && cardWas != cardInSd) {
+ QString text = "";
+ if(cardInSd) { text += "SD Inserted"; }
+ else { text += "SD Removed"; }
+ QMessageBox::warning( this, tr("CardMonitor"), text,
+ tr("&OK") );
+ }
+
#else
#error "Not on Linux"
#endif
@@ -222,8 +248,10 @@ void CardMonitor::paintEvent( QPaintEvent * ) {
if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) {
p.drawPixmap( 0, 0, pm );
+ show();
} else {
p.eraseRect( rect() );
+ hide();
}
}
diff --git a/core/applets/cardmon/cardmon.h b/core/applets/cardmon/cardmon.h
index 2a90c90..f9e3819 100644
--- a/core/applets/cardmon/cardmon.h
+++ b/core/applets/cardmon/cardmon.h
@@ -27,8 +27,8 @@ class CardMonitor : public QWidget {
public:
CardMonitor( QWidget *parent = 0 );
~CardMonitor();
- bool getStatusPcmcia( void );
- bool getStatusSd( void );
+ bool getStatusPcmcia( int showPopUp = FALSE );
+ bool getStatusSd( int showPopUp = FALSE );
private slots:
void cardMessage( const QCString &msg, const QByteArray & );
@@ -45,6 +45,7 @@ private:
bool cardInPcmcia1;
QString cardInPcmcia1Name;
bool cardInSd;
+ void iconShow();
};
diff --git a/core/applets/cardmon/cardmon.pro b/core/applets/cardmon/cardmon.pro
index ff3463c..e79e91a 100644
--- a/core/applets/cardmon/cardmon.pro
+++ b/core/applets/cardmon/cardmon.pro
@@ -9,17 +9,17 @@ DEPENDPATH += $(OPIEDIR)/include ../launcher
LIBS += -lqpe
VERSION = 1.0.0
-TRANSLATIONS = ../i18n/de/libcardmonapplet.ts
-TRANSLATIONS += ../i18n/es/libcardmonapplet.ts
-TRANSLATIONS += ../i18n/pt/libcardmonapplet.ts
-TRANSLATIONS += ../i18n/pt_BR/libcardmonapplet.ts
-TRANSLATIONS += ../i18n/en/libcardmonapplet.ts
-TRANSLATIONS += ../i18n/hu/libcardmonapplet.ts
-TRANSLATIONS += ../i18n/sl/libcardmonapplet.ts
-TRANSLATIONS += ../i18n/pl/libcardmonapplet.ts
-TRANSLATIONS += ../i18n/ja/libcardmonapplet.ts
-TRANSLATIONS += ../i18n/fr/libcardmonapplet.ts
-TRANSLATIONS += ../i18n/ko/libcardmonapplet.ts
-TRANSLATIONS += ../i18n/no/libcardmonapplet.ts
-TRANSLATIONS += ../i18n/zh_CN/libcardmonapplet.ts
-TRANSLATIONS += ../i18n/zh_TW/libcardmonapplet.ts
+TRANSLATIONS = ../../i18n/de/libcardmonapplet.ts
+TRANSLATIONS += ../../i18n/es/libcardmonapplet.ts
+TRANSLATIONS += ../../i18n/pt/libcardmonapplet.ts
+TRANSLATIONS += ../../i18n/pt_BR/libcardmonapplet.ts
+TRANSLATIONS += ../../i18n/en/libcardmonapplet.ts
+TRANSLATIONS += ../../i18n/hu/libcardmonapplet.ts
+TRANSLATIONS += ../../i18n/sl/libcardmonapplet.ts
+TRANSLATIONS += ../../i18n/pl/libcardmonapplet.ts
+TRANSLATIONS += ../../i18n/ja/libcardmonapplet.ts
+TRANSLATIONS += ../../i18n/fr/libcardmonapplet.ts
+TRANSLATIONS += ../../i18n/ko/libcardmonapplet.ts
+TRANSLATIONS += ../../i18n/no/libcardmonapplet.ts
+TRANSLATIONS += ../../i18n/zh_CN/libcardmonapplet.ts
+TRANSLATIONS += ../../i18n/zh_TW/libcardmonapplet.ts