Diffstat (limited to 'noncore/applets/pcmcia/pcmcia.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
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 | |||
@@ -65,24 +65,25 @@ using namespace Opie::Ui; | |||
65 | 65 | ||
66 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) | 66 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) |
67 | { | 67 | { |
68 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 68 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
69 | connect( pcmciaChannel, | 69 | connect( pcmciaChannel, |
70 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | 70 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
71 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | 71 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
72 | 72 | ||
73 | setFocusPolicy( NoFocus ); | 73 | setFocusPolicy( NoFocus ); |
74 | setFixedWidth ( AppLnk::smallIconSize() ); | 74 | setFixedWidth ( AppLnk::smallIconSize() ); |
75 | setFixedHeight ( AppLnk::smallIconSize() ); | 75 | setFixedHeight ( AppLnk::smallIconSize() ); |
76 | pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); | 76 | pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); |
77 | configuring = false; | ||
77 | } | 78 | } |
78 | 79 | ||
79 | 80 | ||
80 | PcmciaManager::~PcmciaManager() | 81 | PcmciaManager::~PcmciaManager() |
81 | { | 82 | { |
82 | } | 83 | } |
83 | 84 | ||
84 | 85 | ||
85 | void PcmciaManager::popUp( QString message, QString icon ) | 86 | void PcmciaManager::popUp( QString message, QString icon ) |
86 | { | 87 | { |
87 | if ( !popupMenu ) { | 88 | if ( !popupMenu ) { |
88 | popupMenu = new QPopupMenu( this ); | 89 | popupMenu = new QPopupMenu( this ); |
@@ -101,51 +102,52 @@ void PcmciaManager::popUp( QString message, QString icon ) | |||
101 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 102 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), |
102 | p.y() - s.height() ), 0 ); | 103 | p.y() - s.height() ), 0 ); |
103 | 104 | ||
104 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); | 105 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); |
105 | } | 106 | } |
106 | 107 | ||
107 | 108 | ||
108 | void PcmciaManager::popupTimeout() | 109 | void PcmciaManager::popupTimeout() |
109 | { | 110 | { |
110 | popupMenu->hide(); | 111 | popupMenu->hide(); |
111 | } | 112 | } |
112 | 113 | ||
113 | enum { EJECT, INSERT, SUSPEND, RESUME, CONFIGURE }; | 114 | enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE }; |
114 | 115 | ||
115 | void PcmciaManager::mousePressEvent( QMouseEvent* ) | 116 | void PcmciaManager::mousePressEvent( QMouseEvent* ) |
116 | { | 117 | { |
117 | QPopupMenu* menu = new QPopupMenu( this ); | 118 | QPopupMenu* menu = new QPopupMenu( this ); |
118 | QStringList cmd; | 119 | QStringList cmd; |
119 | bool execute = true; | 120 | bool execute = true; |
120 | 121 | ||
121 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 122 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
122 | OPcmciaSystem::CardIterator it = sys->iterator(); | 123 | OPcmciaSystem::CardIterator it = sys->iterator(); |
123 | if ( !sys->count() ) return; | 124 | if ( !sys->count() ) return; |
124 | 125 | ||
125 | int i = 0; | 126 | int i = 0; |
126 | while ( it.current() ) | 127 | while ( it.current() ) |
127 | { | 128 | { |
128 | QPopupMenu* submenu = new QPopupMenu( menu ); | 129 | QPopupMenu* submenu = new QPopupMenu( menu ); |
129 | submenu->insertItem( "&Eject", EJECT+i*100 ); | 130 | submenu->insertItem( "&Eject", EJECT+i*100 ); |
130 | submenu->insertItem( "&Insert", INSERT+i*100 ); | 131 | submenu->insertItem( "&Insert", INSERT+i*100 ); |
131 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); | 132 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); |
132 | submenu->insertItem( "&Resume", RESUME+i*100 ); | 133 | submenu->insertItem( "&Resume", RESUME+i*100 ); |
134 | submenu->insertItem( "Rese&t", RESET+i*100 ); | ||
133 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); | 135 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); |
134 | 136 | ||
135 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); | 137 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); |
136 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); | 138 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); |
137 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); | 139 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); |
138 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); | 140 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); |
139 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() ); | 141 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); |
140 | 142 | ||
141 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); | 143 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); |
142 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); | 144 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); |
143 | ++it; | 145 | ++it; |
144 | } | 146 | } |
145 | 147 | ||
146 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 148 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
147 | QSize s = menu->sizeHint(); | 149 | QSize s = menu->sizeHint(); |
148 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); | 150 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); |
149 | qDebug( "pcmcia: menu result = %d", opt ); | 151 | qDebug( "pcmcia: menu result = %d", opt ); |
150 | delete menu; | 152 | delete menu; |
151 | } | 153 | } |
@@ -262,20 +264,22 @@ void PcmciaManager::userCardAction( int action ) | |||
262 | int socket = action / 100; | 264 | int socket = action / 100; |
263 | int what = action % 100; | 265 | int what = action % 100; |
264 | 266 | ||
265 | switch ( what ) | 267 | switch ( what ) |
266 | { | 268 | { |
267 | case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); break; | 269 | case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); break; |
268 | default: odebug << "not yet implemented"; | 270 | default: odebug << "not yet implemented"; |
269 | } | 271 | } |
270 | } | 272 | } |
271 | 273 | ||
272 | void PcmciaManager::configure( OPcmciaSocket* card ) | 274 | void PcmciaManager::configure( OPcmciaSocket* card ) |
273 | { | 275 | { |
274 | ConfigDialog dialog( card->identity(), qApp->desktop() ); | 276 | configuring = true; |
275 | int configresult = dialog.exec(); | 277 | ConfigDialog dialog( card, qApp->desktop() ); |
278 | int configresult = QPEApplication::execDialog( &dialog, false ); | ||
279 | configuring = false; | ||
276 | odebug << "pcmcia: configresult = " << configresult << oendl; | 280 | odebug << "pcmcia: configresult = " << configresult << oendl; |
277 | } | 281 | } |
278 | 282 | ||
279 | 283 | ||
280 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) | 284 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) |
281 | 285 | ||