summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/applets/pcmcia/configdialog.cpp52
-rw-r--r--noncore/applets/pcmcia/configdialog.h2
-rw-r--r--noncore/applets/pcmcia/configdialogbase.ui217
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp38
-rw-r--r--noncore/applets/pcmcia/pcmcia.h2
5 files changed, 185 insertions, 126 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
@@ -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 @@
<rect>
<x>0</x>
<y>0</y>
- <width>197</width>
- <height>154</height>
+ <width>215</width>
+ <height>329</height>
</rect>
</property>
<property stdset="1">
@@ -34,92 +34,6 @@
<name>spacing</name>
<number>2</number>
</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" >
<class>QGroupBox</class>
<property stdset="1">
@@ -234,10 +148,133 @@
</widget>
</grid>
</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>&lt;None&gt;</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>&lt;qt&gt;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:&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ <spacer row="2" column="1" >
<property>
<name>name</name>
- <cstring>Spacer1</cstring>
+ <cstring>Spacer2</cstring>
</property>
<property stdset="1">
<name>orientation</name>
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( "<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 );
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 << "pcmcia: user doesn't want to configure " << theCard->productIdentity().join( " " ) << " now." << oendl;
+ odebug << "card has not been configured this time. leaving as unknown card" << oendl;
}
}
else
{
- odebug << "pcmcia: card has been previously inserted" << oendl;
+ odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl;
+ }
+ }
+ else // it's an already configured card
+ {
+ 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 );