From 34ecdb361924656b758da2073ef6ac0c1bffd210 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sun, 19 Jun 2005 22:02:38 +0000 Subject: - s/new card/unconfigured card/ - add note about unrecognized cards in configuration dialog - add ConfigDialog::preferredAction() --- (limited to 'noncore/applets') diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp index 9fcf58c..f961069 100644 --- a/noncore/applets/pcmcia/configdialog.cpp +++ b/noncore/applets/pcmcia/configdialog.cpp @@ -46,39 +46,25 @@ using namespace Opie::Core; ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) :ConfigDialogBase( parent, "pcmcia config dialog", true ) { - gbDetails->setTitle( QString( "Details for '%1'" ).arg( card->identity() ) ); + gbDetails->setTitle( QString( "Details for card in socket #%1" ).arg( card->number() ) ); txtCardName->setText( card->productIdentity().join( " " ) ); txtManfid->setText( card->manufacturerIdentity() ); txtFunction->setText( card->function() ); - OConfig cfg( "PCMCIA" ); - cfg.setGroup( "Global" ); - int nCards = cfg.readNumEntry( "nCards", 0 ); - QString insert; + QString action = preferredAction( card ); - for ( int i = 0; i < nCards; ++i ) - { - QString cardSection = QString( "Card_%1" ).arg( i ); - cfg.setGroup( cardSection ); - QString name = cfg.readEntry( "name" ); - odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; - if ( card->name() == name ) - { - insert = cfg.readEntry( "insert" ); - break; - } - } - odebug << "preferred action for card '" << card->name() << "' seems to be '" << insert << "'" << oendl; + odebug << "preferred action for card '" << card->name() << "' seems to be '" << action << "'" << oendl; - if ( !insert.isEmpty() ) + if ( !action.isEmpty() ) { for ( int i; i < cbAction->count(); ++i ) - if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); + if ( cbAction->text( i ) == action ) cbAction->setCurrentItem( i ); } if ( !card->isUnsupported() ) { odebug << "card is recognized - hiding bindings" << oendl; + textInfo->hide(); textBindTo->hide(); cbBindTo->hide(); return; @@ -86,6 +72,7 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) else { odebug << "card is unsupported yet - showing possible bindings" << oendl; + textInfo->show(); textBindTo->show(); cbBindTo->show(); } @@ -96,7 +83,7 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); - for ( int i = 0; i < pcmciaconfdir.count(); ++i ) + for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i ) { odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); @@ -134,3 +121,26 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) ConfigDialog::~ConfigDialog() { } + +QString ConfigDialog::preferredAction( const OPcmciaSocket* card ) +{ + OConfig cfg( "PCMCIA" ); + cfg.setGroup( "Global" ); + int nCards = cfg.readNumEntry( "nCards", 0 ); + QString action; + + for ( int i = 0; i < nCards; ++i ) + { + QString cardSection = QString( "Card_%1" ).arg( i ); + cfg.setGroup( cardSection ); + QString name = cfg.readEntry( "name" ); + odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; + if ( card->name() == name ) + { + action = cfg.readEntry( "action" ); + break; + } + } + + return action; +} diff --git a/noncore/applets/pcmcia/configdialog.h b/noncore/applets/pcmcia/configdialog.h index 3c7fe85..321180d 100644 --- a/noncore/applets/pcmcia/configdialog.h +++ b/noncore/applets/pcmcia/configdialog.h @@ -38,9 +38,9 @@ class ConfigDialog : public ConfigDialogBase { Q_OBJECT public: - ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent ); ~ConfigDialog(); + static QString preferredAction( const Opie::Core::OPcmciaSocket* card ); }; #endif diff --git a/noncore/applets/pcmcia/configdialogbase.ui b/noncore/applets/pcmcia/configdialogbase.ui index 7ec3a75..829b71a 100644 --- a/noncore/applets/pcmcia/configdialogbase.ui +++ b/noncore/applets/pcmcia/configdialogbase.ui @@ -11,8 +11,8 @@ 0 0 - 197 - 154 + 215 + 329 @@ -34,92 +34,6 @@ spacing 2 - - QLabel - - name - TextLabel3 - - - text - card - - - - QLabel - - name - TextLabel2 - - - text - On insertion, - - - - QComboBox - - - text - suspend - - - - - text - activate - - - - - text - eject - - - - - text - prompt for - - - - name - cbAction - - - - QComboBox - - name - cbBindTo - - - sizePolicy - - 5 - 0 - - - - editable - true - - - autoResize - false - - - - QLabel - - name - textBindTo - - - text - Bind to: - - QGroupBox @@ -234,10 +148,133 @@ - + + QLabel + + name + TextLabel2 + + + text + On insertion, + + + + QComboBox + + + text + suspend + + + + + text + activate + + + + + text + eject + + + + + text + prompt for + + + + name + cbAction + + + + QLabel + + name + TextLabel3 + + + text + card + + + + QLabel + + name + textBindTo + + + text + Bind to: + + + + QComboBox + + + text + <None> + + + + name + cbBindTo + + + sizePolicy + + 5 + 0 + + + + editable + true + + + currentItem + 0 + + + autoResize + false + + + + QLabel + + name + textInfo + + + frameShape + Box + + + frameShadow + Raised + + + lineWidth + 2 + + + margin + 0 + + + text + <qt>CAUTION: This card is not yet recognized by your system. Without a valid binding, your card may not function correctly. Please choose a driver to bind the card to below:</qt> + + + name - Spacer1 + Spacer2 orientation diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp index 99c1bc9..1a2b619 100644 --- a/noncore/applets/pcmcia/pcmcia.cpp +++ b/noncore/applets/pcmcia/pcmcia.cpp @@ -203,31 +203,42 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) } if ( newCard ) { - odebug << "pcmcia: new card detected" << oendl; - cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); - cfg.writeEntry( "name", theCard->productIdentity().join( " " ) ); - cfg.writeEntry( "insert", "suspend" ); - cfg.setGroup( "Global" ); - cfg.writeEntry( "nCards", nCards+1 ); - cfg.write(); - + odebug << "pcmcia: unconfigured card detected" << oendl; + QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); int result = QMessageBox::information( qApp->desktop(), tr( "PCMCIA/CF Subsystem" ), - tr( "You have inserted a new card:\n%1\nDo you want to configure?" ).arg( theCard->productIdentity().join( " " ) ), + tr( "You have inserted the card '%1'. This card is not yet configured. Do you want to configure it now?" ).arg( newCardName ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ); odebug << "result = " << result << oendl; if ( result == 0 ) { - configure( theCard ); + bool configured = configure( theCard ); + + if ( configured ) + { + odebug << "card has been configured. writing out to dabase" << oendl; + cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); + cfg.writeEntry( "name", newCardName ); + cfg.writeEntry( "insert", "suspend" ); + cfg.setGroup( "Global" ); + cfg.writeEntry( "nCards", nCards+1 ); + cfg.write(); + } + else + { + odebug << "card has not been configured this time. leaving as unknown card" << oendl; + } } else { - odebug << "pcmcia: user doesn't want to configure " << theCard->productIdentity().join( " " ) << " now." << oendl; + odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; } } - else + else // it's an already configured card { - odebug << "pcmcia: card has been previously inserted" << oendl; + QString action = ConfigDialog::preferredAction( theCard ); + odebug << "pcmcia: card has been previously configured" << oendl; + odebug << "pcmcia: need to perform action'" << action << "' now... sorry, not yet implemented..." << oendl; } repaint( true ); } @@ -284,13 +295,14 @@ void PcmciaManager::userCardAction( int action ) } -void PcmciaManager::configure( OPcmciaSocket* card ) +bool PcmciaManager::configure( OPcmciaSocket* card ) { configuring = true; ConfigDialog dialog( card, qApp->desktop() ); int configresult = QPEApplication::execDialog( &dialog, false ); configuring = false; odebug << "pcmcia: configresult = " << configresult << oendl; + return configresult; } diff --git a/noncore/applets/pcmcia/pcmcia.h b/noncore/applets/pcmcia/pcmcia.h index a453c1b..eb9c513 100644 --- a/noncore/applets/pcmcia/pcmcia.h +++ b/noncore/applets/pcmcia/pcmcia.h @@ -54,7 +54,7 @@ class PcmciaManager : public QWidget void mousePressEvent( QMouseEvent * ); private: - void configure( Opie::Core::OPcmciaSocket* ); + bool configure( Opie::Core::OPcmciaSocket* ); void execCommand( const QStringList &command ); void popUp(QString message, QString icon = QString::null ); -- cgit v0.9.0.2