From 7d8d317205a74bc2e23291ab4909472db6694091 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Tue, 14 Jun 2005 13:15:05 +0000 Subject: more work on configuring unsupported cards --- (limited to 'noncore/applets') diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp index e161d18..9fcf58c 100644 --- a/noncore/applets/pcmcia/configdialog.cpp +++ b/noncore/applets/pcmcia/configdialog.cpp @@ -32,20 +32,24 @@ /* OPIE */ #include #include +#include using namespace Opie::Core; /* QT */ #include #include #include +#include #include #include -ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) +ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) :ConfigDialogBase( parent, "pcmcia config dialog", true ) { - //setCaption( tr( "Configure %1" ).arg( cardname ) ); - txtCardName->setText( cardname ); + gbDetails->setTitle( QString( "Details for '%1'" ).arg( card->identity() ) ); + txtCardName->setText( card->productIdentity().join( " " ) ); + txtManfid->setText( card->manufacturerIdentity() ); + txtFunction->setText( card->function() ); OConfig cfg( "PCMCIA" ); cfg.setGroup( "Global" ); @@ -57,14 +61,14 @@ ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) QString cardSection = QString( "Card_%1" ).arg( i ); cfg.setGroup( cardSection ); QString name = cfg.readEntry( "name" ); - odebug << "comparing card '" << cardname << "' with known card '" << name << "'" << oendl; - if ( cardname == 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 '" << cardname << "' seems to be '" << insert << "'" << oendl; + odebug << "preferred action for card '" << card->name() << "' seems to be '" << insert << "'" << oendl; if ( !insert.isEmpty() ) { @@ -72,6 +76,20 @@ ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); } + if ( !card->isUnsupported() ) + { + odebug << "card is recognized - hiding bindings" << oendl; + textBindTo->hide(); + cbBindTo->hide(); + return; + } + else + { + odebug << "card is unsupported yet - showing possible bindings" << oendl; + textBindTo->show(); + cbBindTo->show(); + } + // parse possible bind entries out of /etc/pcmcia/*.conf typedef QMap StringMap; StringMap bindEntries; @@ -108,7 +126,7 @@ ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) { - odebug << "found device '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; + odebug << "found binding '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; cbBindTo->insertItem( it.key() ); } } diff --git a/noncore/applets/pcmcia/configdialog.h b/noncore/applets/pcmcia/configdialog.h index f79d7a6..3c7fe85 100644 --- a/noncore/applets/pcmcia/configdialog.h +++ b/noncore/applets/pcmcia/configdialog.h @@ -32,12 +32,14 @@ #include "configdialogbase.h" +namespace Opie { namespace Core { class OPcmciaSocket; }; }; + class ConfigDialog : public ConfigDialogBase { Q_OBJECT public: - ConfigDialog( const QString& cardname, QWidget* parent ); + ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent ); ~ConfigDialog(); }; diff --git a/noncore/applets/pcmcia/configdialogbase.ui b/noncore/applets/pcmcia/configdialogbase.ui index a0760d6..7ec3a75 100644 --- a/noncore/applets/pcmcia/configdialogbase.ui +++ b/noncore/applets/pcmcia/configdialogbase.ui @@ -11,8 +11,8 @@ 0 0 - 232 - 206 + 197 + 154 @@ -53,7 +53,7 @@ text - Upon insertion, + On insertion, @@ -94,9 +94,20 @@ cbBindTo + sizePolicy + + 5 + 0 + + + editable true + + autoResize + false + QLabel @@ -113,7 +124,7 @@ QGroupBox name - GroupBox1 + gbDetails title diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp index 6c18e86..fac7065 100644 --- a/noncore/applets/pcmcia/pcmcia.cpp +++ b/noncore/applets/pcmcia/pcmcia.cpp @@ -74,6 +74,7 @@ PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) setFixedWidth ( AppLnk::smallIconSize() ); setFixedHeight ( AppLnk::smallIconSize() ); pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); + configuring = false; } @@ -110,7 +111,7 @@ void PcmciaManager::popupTimeout() popupMenu->hide(); } -enum { EJECT, INSERT, SUSPEND, RESUME, CONFIGURE }; +enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE }; void PcmciaManager::mousePressEvent( QMouseEvent* ) { @@ -130,13 +131,14 @@ void PcmciaManager::mousePressEvent( QMouseEvent* ) submenu->insertItem( "&Insert", INSERT+i*100 ); submenu->insertItem( "&Suspend", SUSPEND+i*100 ); submenu->insertItem( "&Resume", RESUME+i*100 ); + submenu->insertItem( "Rese&t", RESET+i*100 ); submenu->insertItem( "&Configure", CONFIGURE+i*100 ); submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); - submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() ); + submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); @@ -271,8 +273,10 @@ void PcmciaManager::userCardAction( int action ) void PcmciaManager::configure( OPcmciaSocket* card ) { - ConfigDialog dialog( card->identity(), qApp->desktop() ); - int configresult = dialog.exec(); + configuring = true; + ConfigDialog dialog( card, qApp->desktop() ); + int configresult = QPEApplication::execDialog( &dialog, false ); + configuring = false; odebug << "pcmcia: configresult = " << configresult << oendl; } diff --git a/noncore/applets/pcmcia/pcmcia.h b/noncore/applets/pcmcia/pcmcia.h index ed86579..a453c1b 100644 --- a/noncore/applets/pcmcia/pcmcia.h +++ b/noncore/applets/pcmcia/pcmcia.h @@ -59,7 +59,8 @@ class PcmciaManager : public QWidget void popUp(QString message, QString icon = QString::null ); private: - int m_commandOrig; + bool configuring; + int commandOrig; QPixmap pm; QPopupMenu *popupMenu; -- cgit v0.9.0.2