-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 21 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialog.h | 2 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialogbase.ui | 76 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 12 |
4 files changed, 91 insertions, 20 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp index c08926e..e7c97c1 100644 --- a/noncore/applets/pcmcia/configdialog.cpp +++ b/noncore/applets/pcmcia/configdialog.cpp | |||
@@ -31,43 +31,56 @@ | |||
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/oconfig.h> | 33 | #include <opie2/oconfig.h> |
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | using namespace Opie::Core; | 35 | using namespace Opie::Core; |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
39 | #include <qdir.h> | ||
40 | #include <qlabel.h> | ||
39 | 41 | ||
40 | ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) | 42 | ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) |
41 | :ConfigDialogBase( parent, "pcmcia config dialog", true ) | 43 | :ConfigDialogBase( parent, "pcmcia config dialog", true ) |
42 | { | 44 | { |
43 | setCaption( tr( "Configure %1" ).arg( cardname ) ); | 45 | //setCaption( tr( "Configure %1" ).arg( cardname ) ); |
44 | 46 | textCardName->setText( cardname ); | |
47 | |||
45 | OConfig cfg( "PCMCIA" ); | 48 | OConfig cfg( "PCMCIA" ); |
46 | cfg.setGroup( "Global" ); | 49 | cfg.setGroup( "Global" ); |
47 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 50 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
48 | QString insert; | 51 | QString insert; |
49 | 52 | ||
50 | for ( int i = 0; i < nCards; ++i ) | 53 | for ( int i = 0; i < nCards; ++i ) |
51 | { | 54 | { |
52 | QString cardSection = QString( "Card_%1" ).arg( i ); | 55 | QString cardSection = QString( "Card_%1" ).arg( i ); |
53 | cfg.setGroup( cardSection ); | 56 | cfg.setGroup( cardSection ); |
54 | QString name = cfg.readEntry( "name" ); | 57 | QString name = cfg.readEntry( "name" ); |
55 | odebug << "comparing card '" << cardname << "' with known card '" << name << "'" << oendl; | 58 | odebug << "comparing card '" << cardname << "' with known card '" << name << "'" << oendl; |
56 | if ( cardname == name ) | 59 | if ( cardname == name ) |
57 | { | 60 | { |
58 | insert = cfg.readEntry( "insert" ); | 61 | insert = cfg.readEntry( "insert" ); |
59 | break; | 62 | break; |
60 | } | 63 | } |
61 | } | 64 | } |
62 | odebug << "preferred action for card '" << cardname << "' seems to be '" << insert << "'" << oendl; | 65 | odebug << "preferred action for card '" << cardname << "' seems to be '" << insert << "'" << oendl; |
63 | 66 | ||
64 | if ( !insert.isEmpty() ) | 67 | if ( !insert.isEmpty() ) |
65 | { | 68 | { |
66 | for ( int i; i < cbAction->count(); ++i ) | 69 | for ( int i; i < cbAction->count(); ++i ) |
67 | if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); | 70 | if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); |
68 | } | 71 | } |
72 | |||
73 | // parse possible device and class names out of /etc/pcmcia/*.conf | ||
74 | QStringList deviceNames; | ||
75 | QStringList classNames; | ||
76 | |||
77 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); | ||
78 | |||
79 | for ( int i = 0; i < pcmciaconfdir.count(); ++i ) | ||
80 | odebug << "found conf file '" << pcmciaconfdir[i] << "'" << oendl; | ||
81 | |||
69 | } | 82 | } |
70 | 83 | ||
71 | ConfigDialog::~ConfigDialog() | 84 | ConfigDialog::~ConfigDialog() |
72 | { | 85 | { |
73 | } | 86 | } |
diff --git a/noncore/applets/pcmcia/configdialog.h b/noncore/applets/pcmcia/configdialog.h index 12500c4..f79d7a6 100644 --- a/noncore/applets/pcmcia/configdialog.h +++ b/noncore/applets/pcmcia/configdialog.h | |||
@@ -31,14 +31,14 @@ | |||
31 | #define CONFIGDIALOG_H | 31 | #define CONFIGDIALOG_H |
32 | 32 | ||
33 | #include "configdialogbase.h" | 33 | #include "configdialogbase.h" |
34 | 34 | ||
35 | class ConfigDialog : public ConfigDialogBase | 35 | class ConfigDialog : public ConfigDialogBase |
36 | { | 36 | { |
37 | Q_OBJECT | 37 | Q_OBJECT |
38 | public: | 38 | public: |
39 | 39 | ||
40 | ConfigDialog( const QString& cardname, QWidget* parent ); | 40 | ConfigDialog( const QString& cardname, QWidget* parent ); |
41 | ~ConfigDialog(); | 41 | ~ConfigDialog(); |
42 | }; | 42 | }; |
43 | 43 | ||
44 | #endif | 44 | #endif |
diff --git a/noncore/applets/pcmcia/configdialogbase.ui b/noncore/applets/pcmcia/configdialogbase.ui index d8dd983..a9682c5 100644 --- a/noncore/applets/pcmcia/configdialogbase.ui +++ b/noncore/applets/pcmcia/configdialogbase.ui | |||
@@ -6,51 +6,62 @@ | |||
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>ConfigDialogBase</cstring> | 7 | <cstring>ConfigDialogBase</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>214</width> | 14 | <width>234</width> |
15 | <height>44</height> | 15 | <height>130</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>Configure PCMCIA/CF Card</string> | 20 | <string>Configure PCMCIA/CF Card</string> |
21 | </property> | 21 | </property> |
22 | <property> | 22 | <property> |
23 | <name>layoutMargin</name> | 23 | <name>layoutMargin</name> |
24 | </property> | 24 | </property> |
25 | <property> | 25 | <property> |
26 | <name>layoutSpacing</name> | 26 | <name>layoutSpacing</name> |
27 | </property> | 27 | </property> |
28 | <grid> | 28 | <grid> |
29 | <property stdset="1"> | 29 | <property stdset="1"> |
30 | <name>margin</name> | 30 | <name>margin</name> |
31 | <number>11</number> | 31 | <number>7</number> |
32 | </property> | 32 | </property> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>spacing</name> | 34 | <name>spacing</name> |
35 | <number>6</number> | 35 | <number>4</number> |
36 | </property> | 36 | </property> |
37 | <widget row="0" column="2" > | 37 | <widget row="2" column="2" > |
38 | <class>QLabel</class> | 38 | <class>QLabel</class> |
39 | <property stdset="1"> | 39 | <property stdset="1"> |
40 | <name>name</name> | 40 | <name>name</name> |
41 | <cstring>TextLabel3</cstring> | 41 | <cstring>TextLabel3</cstring> |
42 | </property> | 42 | </property> |
43 | <property stdset="1"> | 43 | <property stdset="1"> |
44 | <name>text</name> | 44 | <name>text</name> |
45 | <string>card</string> | 45 | <string>card</string> |
46 | </property> | 46 | </property> |
47 | </widget> | 47 | </widget> |
48 | <widget row="0" column="1" > | 48 | <widget row="2" column="0" > |
49 | <class>QLabel</class> | ||
50 | <property stdset="1"> | ||
51 | <name>name</name> | ||
52 | <cstring>TextLabel2</cstring> | ||
53 | </property> | ||
54 | <property stdset="1"> | ||
55 | <name>text</name> | ||
56 | <string>Upon insertion,</string> | ||
57 | </property> | ||
58 | </widget> | ||
59 | <widget row="2" column="1" > | ||
49 | <class>QComboBox</class> | 60 | <class>QComboBox</class> |
50 | <item> | 61 | <item> |
51 | <property> | 62 | <property> |
52 | <name>text</name> | 63 | <name>text</name> |
53 | <string>suspend</string> | 64 | <string>suspend</string> |
54 | </property> | 65 | </property> |
55 | </item> | 66 | </item> |
56 | <item> | 67 | <item> |
@@ -71,22 +82,69 @@ | |||
71 | <string>prompt for</string> | 82 | <string>prompt for</string> |
72 | </property> | 83 | </property> |
73 | </item> | 84 | </item> |
74 | <property stdset="1"> | 85 | <property stdset="1"> |
75 | <name>name</name> | 86 | <name>name</name> |
76 | <cstring>cbAction</cstring> | 87 | <cstring>cbAction</cstring> |
77 | </property> | 88 | </property> |
78 | </widget> | 89 | </widget> |
79 | <widget row="0" column="0" > | 90 | <widget row="3" column="1" rowspan="1" colspan="2" > |
91 | <class>QComboBox</class> | ||
92 | <property stdset="1"> | ||
93 | <name>name</name> | ||
94 | <cstring>cbBindTo</cstring> | ||
95 | </property> | ||
96 | </widget> | ||
97 | <widget row="1" column="0" rowspan="1" colspan="3" > | ||
98 | <class>Line</class> | ||
99 | <property stdset="1"> | ||
100 | <name>name</name> | ||
101 | <cstring>Line1</cstring> | ||
102 | </property> | ||
103 | <property stdset="1"> | ||
104 | <name>orientation</name> | ||
105 | <enum>Horizontal</enum> | ||
106 | </property> | ||
107 | </widget> | ||
108 | <widget row="3" column="0" > | ||
80 | <class>QLabel</class> | 109 | <class>QLabel</class> |
81 | <property stdset="1"> | 110 | <property stdset="1"> |
82 | <name>name</name> | 111 | <name>name</name> |
83 | <cstring>TextLabel2</cstring> | 112 | <cstring>textBindTo</cstring> |
84 | </property> | 113 | </property> |
85 | <property stdset="1"> | 114 | <property stdset="1"> |
86 | <name>text</name> | 115 | <name>text</name> |
87 | <string>Upon insertion,</string> | 116 | <string>Bind to:</string> |
117 | </property> | ||
118 | </widget> | ||
119 | <widget row="4" column="0" > | ||
120 | <class>QLabel</class> | ||
121 | <property stdset="1"> | ||
122 | <name>name</name> | ||
123 | <cstring>textClassName</cstring> | ||
124 | </property> | ||
125 | <property stdset="1"> | ||
126 | <name>text</name> | ||
127 | <string>Classname:</string> | ||
128 | </property> | ||
129 | </widget> | ||
130 | <widget row="4" column="1" rowspan="1" colspan="2" > | ||
131 | <class>QComboBox</class> | ||
132 | <property stdset="1"> | ||
133 | <name>name</name> | ||
134 | <cstring>cbClassName</cstring> | ||
135 | </property> | ||
136 | </widget> | ||
137 | <widget row="0" column="0" rowspan="1" colspan="3" > | ||
138 | <class>QLabel</class> | ||
139 | <property stdset="1"> | ||
140 | <name>name</name> | ||
141 | <cstring>textCardName</cstring> | ||
142 | </property> | ||
143 | <property stdset="1"> | ||
144 | <name>text</name> | ||
145 | <string>CardName</string> | ||
88 | </property> | 146 | </property> |
89 | </widget> | 147 | </widget> |
90 | </grid> | 148 | </grid> |
91 | </widget> | 149 | </widget> |
92 | </UI> | 150 | </UI> |
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp index 4fcc189..6c18e86 100644 --- a/noncore/applets/pcmcia/pcmcia.cpp +++ b/noncore/applets/pcmcia/pcmcia.cpp | |||
@@ -126,23 +126,23 @@ void PcmciaManager::mousePressEvent( QMouseEvent* ) | |||
126 | while ( it.current() ) | 126 | while ( it.current() ) |
127 | { | 127 | { |
128 | QPopupMenu* submenu = new QPopupMenu( menu ); | 128 | QPopupMenu* submenu = new QPopupMenu( menu ); |
129 | submenu->insertItem( "&Eject", EJECT+i*100 ); | 129 | submenu->insertItem( "&Eject", EJECT+i*100 ); |
130 | submenu->insertItem( "&Insert", INSERT+i*100 ); | 130 | submenu->insertItem( "&Insert", INSERT+i*100 ); |
131 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); | 131 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); |
132 | submenu->insertItem( "&Resume", RESUME+i*100 ); | 132 | submenu->insertItem( "&Resume", RESUME+i*100 ); |
133 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); | 133 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); |
134 | 134 | ||
135 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); | 135 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); |
136 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); | 136 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); |
137 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); | 137 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); |
138 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); | 138 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); |
139 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() ); | 139 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() ); |
140 | 140 | ||
141 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); | 141 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); |
142 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); | 142 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); |
143 | ++it; | 143 | ++it; |
144 | } | 144 | } |
145 | 145 | ||
146 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 146 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
147 | QSize s = menu->sizeHint(); | 147 | QSize s = menu->sizeHint(); |
148 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); | 148 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); |
@@ -165,17 +165,17 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | |||
165 | cfg.setGroup( "Global" ); | 165 | cfg.setGroup( "Global" ); |
166 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 166 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
167 | 167 | ||
168 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 168 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
169 | OPcmciaSystem::CardIterator it = sys->iterator(); | 169 | OPcmciaSystem::CardIterator it = sys->iterator(); |
170 | 170 | ||
171 | bool newCard = true; | 171 | bool newCard = true; |
172 | OPcmciaSocket* theCard = 0; | 172 | OPcmciaSocket* theCard = 0; |
173 | 173 | ||
174 | while ( it.current() && newCard ) | 174 | while ( it.current() && newCard ) |
175 | { | 175 | { |
176 | if ( it.current()->isEmpty() ) | 176 | if ( it.current()->isEmpty() ) |
177 | { | 177 | { |
178 | odebug << "skipping empty card in socket " << it.current()->number() << oendl; | 178 | odebug << "skipping empty card in socket " << it.current()->number() << oendl; |
179 | ++it; | 179 | ++it; |
180 | continue; | 180 | continue; |
181 | } | 181 | } |
@@ -229,17 +229,17 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | |||
229 | repaint( true ); | 229 | repaint( true ); |
230 | } | 230 | } |
231 | 231 | ||
232 | 232 | ||
233 | void PcmciaManager::paintEvent( QPaintEvent * ) | 233 | void PcmciaManager::paintEvent( QPaintEvent * ) |
234 | { | 234 | { |
235 | QPainter p( this ); | 235 | QPainter p( this ); |
236 | odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl; | 236 | odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl; |
237 | 237 | ||
238 | if ( OPcmciaSystem::instance()->cardCount() ) | 238 | if ( OPcmciaSystem::instance()->cardCount() ) |
239 | { | 239 | { |
240 | p.drawPixmap( 0, 0, pm ); | 240 | p.drawPixmap( 0, 0, pm ); |
241 | show(); | 241 | show(); |
242 | } | 242 | } |
243 | else | 243 | else |
244 | { | 244 | { |
245 | hide(); | 245 | hide(); |
@@ -253,20 +253,20 @@ int PcmciaManager::position() | |||
253 | 253 | ||
254 | void PcmciaManager::execCommand( const QStringList &strList ) | 254 | void PcmciaManager::execCommand( const QStringList &strList ) |
255 | { | 255 | { |
256 | } | 256 | } |
257 | 257 | ||
258 | void PcmciaManager::userCardAction( int action ) | 258 | void PcmciaManager::userCardAction( int action ) |
259 | { | 259 | { |
260 | odebug << "user action requested. action = " << action << oendl; | 260 | odebug << "user action requested. action = " << action << oendl; |
261 | 261 | ||
262 | int socket = action / 100; | 262 | int socket = action / 100; |
263 | int what = action % 100; | 263 | int what = action % 100; |
264 | 264 | ||
265 | switch ( what ) | 265 | switch ( what ) |
266 | { | 266 | { |
267 | case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); break; | 267 | case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); break; |
268 | default: odebug << "not yet implemented"; | 268 | default: odebug << "not yet implemented"; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | void PcmciaManager::configure( OPcmciaSocket* card ) | 272 | void PcmciaManager::configure( OPcmciaSocket* card ) |