author | mickeyl <mickeyl> | 2005-06-19 22:02:38 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-06-19 22:02:38 (UTC) |
commit | 34ecdb361924656b758da2073ef6ac0c1bffd210 (patch) (side-by-side diff) | |
tree | dbc91b753acae2f9f6a62e922e6707cfef55e171 | |
parent | 83fec70860e56af97d66e9505b913602505423d7 (diff) | |
download | opie-34ecdb361924656b758da2073ef6ac0c1bffd210.zip opie-34ecdb361924656b758da2073ef6ac0c1bffd210.tar.gz opie-34ecdb361924656b758da2073ef6ac0c1bffd210.tar.bz2 |
- s/new card/unconfigured card/
- add note about unrecognized cards in configuration dialog
- add ConfigDialog::preferredAction()
-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 52 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialog.h | 2 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialogbase.ui | 217 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 40 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.h | 2 |
5 files changed, 186 insertions, 127 deletions
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 @@ -48,3 +48,3 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) { - 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( " " ) ); @@ -53,25 +53,10 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) - 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 ); } @@ -81,2 +66,3 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) odebug << "card is recognized - hiding bindings" << oendl; + textInfo->hide(); textBindTo->hide(); @@ -88,2 +74,3 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) odebug << "card is unsupported yet - showing possible bindings" << oendl; + textInfo->show(); textBindTo->show(); @@ -98,3 +85,3 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) - for ( int i = 0; i < pcmciaconfdir.count(); ++i ) + for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i ) { @@ -136 +123,24 @@ 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 @@ -40,5 +40,5 @@ class ConfigDialog : public ConfigDialogBase public: - ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent ); ~ConfigDialog(); + static QString preferredAction( const Opie::Core::OPcmciaSocket* card ); }; 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 @@ -13,4 +13,4 @@ <y>0</y> - <width>197</width> - <height>154</height> + <width>215</width> + <height>329</height> </rect> @@ -36,88 +36,2 @@ </property> - <widget row="2" column="2" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel3</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>card</string> - </property> - </widget> - <widget row="2" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel2</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>On insertion,</string> - </property> - </widget> - <widget row="2" column="1" > - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>suspend</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>activate</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>eject</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>prompt for</string> - </property> - </item> - <property stdset="1"> - <name>name</name> - <cstring>cbAction</cstring> - </property> - </widget> - <widget row="3" column="1" rowspan="1" colspan="2" > - <class>QComboBox</class> - <property stdset="1"> - <name>name</name> - <cstring>cbBindTo</cstring> - </property> - <property stdset="1"> - <name>sizePolicy</name> - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>0</vsizetype> - </sizepolicy> - </property> - <property stdset="1"> - <name>editable</name> - <bool>true</bool> - </property> - <property stdset="1"> - <name>autoResize</name> - <bool>false</bool> - </property> - </widget> - <widget row="3" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>textBindTo</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Bind to:</string> - </property> - </widget> <widget row="0" column="0" rowspan="1" colspan="3" > @@ -236,6 +150,129 @@ </widget> - <spacer row="1" column="1" > + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>On insertion,</string> + </property> + </widget> + <widget row="1" column="1" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>suspend</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>activate</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>eject</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>prompt for</string> + </property> + </item> + <property stdset="1"> + <name>name</name> + <cstring>cbAction</cstring> + </property> + </widget> + <widget row="1" column="2" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel3</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>card</string> + </property> + </widget> + <widget row="4" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>textBindTo</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Bind to:</string> + </property> + </widget> + <widget row="4" column="1" rowspan="1" colspan="2" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string><None></string> + </property> + </item> + <property stdset="1"> + <name>name</name> + <cstring>cbBindTo</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>editable</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>currentItem</name> + <number>0</number> + </property> + <property stdset="1"> + <name>autoResize</name> + <bool>false</bool> + </property> + </widget> + <widget row="3" column="0" rowspan="1" colspan="3" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>textInfo</cstring> + </property> + <property stdset="1"> + <name>frameShape</name> + <enum>Box</enum> + </property> + <property stdset="1"> + <name>frameShadow</name> + <enum>Raised</enum> + </property> + <property stdset="1"> + <name>lineWidth</name> + <number>2</number> + </property> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>text</name> + <string><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></string> + </property> + </widget> + <spacer row="2" column="1" > <property> <name>name</name> - <cstring>Spacer1</cstring> + <cstring>Spacer2</cstring> </property> 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 @@ -205,13 +205,7 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) { - 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( "<qt>You have inserted the card '%1'. This card is not yet configured. Do you want to configure it now?</qt>" ).arg( newCardName ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ); @@ -220,3 +214,18 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) { - 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; + } } @@ -224,8 +233,10 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) { - 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; } @@ -286,3 +297,3 @@ void PcmciaManager::userCardAction( int action ) -void PcmciaManager::configure( OPcmciaSocket* card ) +bool PcmciaManager::configure( OPcmciaSocket* card ) { @@ -293,2 +304,3 @@ void PcmciaManager::configure( OPcmciaSocket* card ) 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 @@ -56,3 +56,3 @@ class PcmciaManager : public QWidget private: - void configure( Opie::Core::OPcmciaSocket* ); + bool configure( Opie::Core::OPcmciaSocket* ); void execCommand( const QStringList &command ); |