summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/configdialog.cpp42
-rw-r--r--noncore/applets/pcmcia/configdialogbase.ui159
2 files changed, 166 insertions, 35 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp
index e7c97c1..e161d18 100644
--- a/noncore/applets/pcmcia/configdialog.cpp
+++ b/noncore/applets/pcmcia/configdialog.cpp
@@ -1,86 +1,118 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include "configdialog.h" 30#include "configdialog.h"
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>
35using namespace Opie::Core; 35using namespace Opie::Core;
36 36
37/* QT */ 37/* QT */
38#include <qcombobox.h> 38#include <qcombobox.h>
39#include <qdir.h> 39#include <qdir.h>
40#include <qfile.h>
40#include <qlabel.h> 41#include <qlabel.h>
42#include <qtextstream.h>
41 43
42ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) 44ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent )
43 :ConfigDialogBase( parent, "pcmcia config dialog", true ) 45 :ConfigDialogBase( parent, "pcmcia config dialog", true )
44{ 46{
45 //setCaption( tr( "Configure %1" ).arg( cardname ) ); 47 //setCaption( tr( "Configure %1" ).arg( cardname ) );
46 textCardName->setText( cardname ); 48 txtCardName->setText( cardname );
47 49
48 OConfig cfg( "PCMCIA" ); 50 OConfig cfg( "PCMCIA" );
49 cfg.setGroup( "Global" ); 51 cfg.setGroup( "Global" );
50 int nCards = cfg.readNumEntry( "nCards", 0 ); 52 int nCards = cfg.readNumEntry( "nCards", 0 );
51 QString insert; 53 QString insert;
52 54
53 for ( int i = 0; i < nCards; ++i ) 55 for ( int i = 0; i < nCards; ++i )
54 { 56 {
55 QString cardSection = QString( "Card_%1" ).arg( i ); 57 QString cardSection = QString( "Card_%1" ).arg( i );
56 cfg.setGroup( cardSection ); 58 cfg.setGroup( cardSection );
57 QString name = cfg.readEntry( "name" ); 59 QString name = cfg.readEntry( "name" );
58 odebug << "comparing card '" << cardname << "' with known card '" << name << "'" << oendl; 60 odebug << "comparing card '" << cardname << "' with known card '" << name << "'" << oendl;
59 if ( cardname == name ) 61 if ( cardname == name )
60 { 62 {
61 insert = cfg.readEntry( "insert" ); 63 insert = cfg.readEntry( "insert" );
62 break; 64 break;
63 } 65 }
64 } 66 }
65 odebug << "preferred action for card '" << cardname << "' seems to be '" << insert << "'" << oendl; 67 odebug << "preferred action for card '" << cardname << "' seems to be '" << insert << "'" << oendl;
66 68
67 if ( !insert.isEmpty() ) 69 if ( !insert.isEmpty() )
68 { 70 {
69 for ( int i; i < cbAction->count(); ++i ) 71 for ( int i; i < cbAction->count(); ++i )
70 if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); 72 if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i );
71 } 73 }
72 74
73 // parse possible device and class names out of /etc/pcmcia/*.conf 75 // parse possible bind entries out of /etc/pcmcia/*.conf
74 QStringList deviceNames; 76 typedef QMap<QString,QString> StringMap;
75 QStringList classNames; 77 StringMap bindEntries;
76 78
77 QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); 79 QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" );
78 80
79 for ( int i = 0; i < pcmciaconfdir.count(); ++i ) 81 for ( int i = 0; i < pcmciaconfdir.count(); ++i )
80 odebug << "found conf file '" << pcmciaconfdir[i] << "'" << oendl; 82 {
83 odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl;
84 QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] );
85 QFile conffile( conffilename );
86 if ( conffile.open( IO_ReadOnly ) )
87 {
88 QTextStream ts( &conffile );
89 while ( !ts.atEnd() )
90 {
91 QString word;
92 ts >> word;
93 if ( word == "bind" )
94 {
95 word = ts.readLine();
96 bindEntries[ word.stripWhiteSpace() ] = conffilename;
97 continue;
98 }
99 ts.readLine();
100 }
101 }
102 else
103 {
104 owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl;
105 continue;
106 }
107 }
81 108
109 for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it )
110 {
111 odebug << "found device '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl;
112 cbBindTo->insertItem( it.key() );
113 }
82} 114}
83 115
84ConfigDialog::~ConfigDialog() 116ConfigDialog::~ConfigDialog()
85{ 117{
86} 118}
diff --git a/noncore/applets/pcmcia/configdialogbase.ui b/noncore/applets/pcmcia/configdialogbase.ui
index a9682c5..a0760d6 100644
--- a/noncore/applets/pcmcia/configdialogbase.ui
+++ b/noncore/applets/pcmcia/configdialogbase.ui
@@ -1,150 +1,249 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>ConfigDialogBase</class> 2<class>ConfigDialogBase</class>
3<widget> 3<widget>
4 <class>QDialog</class> 4 <class>QDialog</class>
5 <property stdset="1"> 5 <property stdset="1">
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>234</width> 14 <width>232</width>
15 <height>130</height> 15 <height>206</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>7</number> 31 <number>5</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>4</number> 35 <number>2</number>
36 </property> 36 </property>
37 <widget row="2" 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="2" column="0" > 48 <widget row="2" column="0" >
49 <class>QLabel</class> 49 <class>QLabel</class>
50 <property stdset="1"> 50 <property stdset="1">
51 <name>name</name> 51 <name>name</name>
52 <cstring>TextLabel2</cstring> 52 <cstring>TextLabel2</cstring>
53 </property> 53 </property>
54 <property stdset="1"> 54 <property stdset="1">
55 <name>text</name> 55 <name>text</name>
56 <string>Upon insertion,</string> 56 <string>Upon insertion,</string>
57 </property> 57 </property>
58 </widget> 58 </widget>
59 <widget row="2" column="1" > 59 <widget row="2" column="1" >
60 <class>QComboBox</class> 60 <class>QComboBox</class>
61 <item> 61 <item>
62 <property> 62 <property>
63 <name>text</name> 63 <name>text</name>
64 <string>suspend</string> 64 <string>suspend</string>
65 </property> 65 </property>
66 </item> 66 </item>
67 <item> 67 <item>
68 <property> 68 <property>
69 <name>text</name> 69 <name>text</name>
70 <string>activate</string> 70 <string>activate</string>
71 </property> 71 </property>
72 </item> 72 </item>
73 <item> 73 <item>
74 <property> 74 <property>
75 <name>text</name> 75 <name>text</name>
76 <string>eject</string> 76 <string>eject</string>
77 </property> 77 </property>
78 </item> 78 </item>
79 <item> 79 <item>
80 <property> 80 <property>
81 <name>text</name> 81 <name>text</name>
82 <string>prompt for</string> 82 <string>prompt for</string>
83 </property> 83 </property>
84 </item> 84 </item>
85 <property stdset="1"> 85 <property stdset="1">
86 <name>name</name> 86 <name>name</name>
87 <cstring>cbAction</cstring> 87 <cstring>cbAction</cstring>
88 </property> 88 </property>
89 </widget> 89 </widget>
90 <widget row="3" column="1" rowspan="1" colspan="2" > 90 <widget row="3" column="1" rowspan="1" colspan="2" >
91 <class>QComboBox</class> 91 <class>QComboBox</class>
92 <property stdset="1"> 92 <property stdset="1">
93 <name>name</name> 93 <name>name</name>
94 <cstring>cbBindTo</cstring> 94 <cstring>cbBindTo</cstring>
95 </property> 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"> 96 <property stdset="1">
104 <name>orientation</name> 97 <name>editable</name>
105 <enum>Horizontal</enum> 98 <bool>true</bool>
106 </property> 99 </property>
107 </widget> 100 </widget>
108 <widget row="3" column="0" > 101 <widget row="3" column="0" >
109 <class>QLabel</class> 102 <class>QLabel</class>
110 <property stdset="1"> 103 <property stdset="1">
111 <name>name</name> 104 <name>name</name>
112 <cstring>textBindTo</cstring> 105 <cstring>textBindTo</cstring>
113 </property> 106 </property>
114 <property stdset="1"> 107 <property stdset="1">
115 <name>text</name> 108 <name>text</name>
116 <string>Bind to:</string> 109 <string>Bind to:</string>
117 </property> 110 </property>
118 </widget> 111 </widget>
119 <widget row="4" column="0" > 112 <widget row="0" column="0" rowspan="1" colspan="3" >
120 <class>QLabel</class> 113 <class>QGroupBox</class>
121 <property stdset="1"> 114 <property stdset="1">
122 <name>name</name> 115 <name>name</name>
123 <cstring>textClassName</cstring> 116 <cstring>GroupBox1</cstring>
124 </property> 117 </property>
125 <property stdset="1"> 118 <property stdset="1">
126 <name>text</name> 119 <name>title</name>
127 <string>Classname:</string> 120 <string>Details</string>
121 </property>
122 <property>
123 <name>layoutMargin</name>
128 </property> 124 </property>
125 <property>
126 <name>layoutSpacing</name>
127 </property>
128 <grid>
129 <property stdset="1">
130 <name>margin</name>
131 <number>6</number>
132 </property>
133 <property stdset="1">
134 <name>spacing</name>
135 <number>4</number>
136 </property>
137 <widget row="0" column="0" >
138 <class>QLabel</class>
139 <property stdset="1">
140 <name>name</name>
141 <cstring>labelCardName</cstring>
142 </property>
143 <property stdset="1">
144 <name>text</name>
145 <string>CardName:</string>
146 </property>
147 </widget>
148 <widget row="2" column="0" >
149 <class>QLabel</class>
150 <property stdset="1">
151 <name>name</name>
152 <cstring>labelFunction</cstring>
153 </property>
154 <property stdset="1">
155 <name>text</name>
156 <string>Function:</string>
157 </property>
158 </widget>
159 <widget row="1" column="0" >
160 <class>QLabel</class>
161 <property stdset="1">
162 <name>name</name>
163 <cstring>labelManufacturer</cstring>
164 </property>
165 <property stdset="1">
166 <name>text</name>
167 <string>Manufacturer:</string>
168 </property>
169 </widget>
170 <widget row="1" column="1" >
171 <class>QLabel</class>
172 <property stdset="1">
173 <name>name</name>
174 <cstring>txtManfid</cstring>
175 </property>
176 <property stdset="1">
177 <name>sizePolicy</name>
178 <sizepolicy>
179 <hsizetype>7</hsizetype>
180 <vsizetype>1</vsizetype>
181 </sizepolicy>
182 </property>
183 <property stdset="1">
184 <name>text</name>
185 <string>TextLabel6</string>
186 </property>
187 </widget>
188 <widget row="2" column="1" >
189 <class>QLabel</class>
190 <property stdset="1">
191 <name>name</name>
192 <cstring>txtFunction</cstring>
193 </property>
194 <property stdset="1">
195 <name>sizePolicy</name>
196 <sizepolicy>
197 <hsizetype>7</hsizetype>
198 <vsizetype>1</vsizetype>
199 </sizepolicy>
200 </property>
201 <property stdset="1">
202 <name>text</name>
203 <string>TextLabel7</string>
204 </property>
205 </widget>
206 <widget row="0" column="1" >
207 <class>QLabel</class>
208 <property stdset="1">
209 <name>name</name>
210 <cstring>txtCardName</cstring>
211 </property>
212 <property stdset="1">
213 <name>sizePolicy</name>
214 <sizepolicy>
215 <hsizetype>7</hsizetype>
216 <vsizetype>1</vsizetype>
217 </sizepolicy>
218 </property>
219 <property stdset="1">
220 <name>text</name>
221 <string>TextLabel3</string>
222 </property>
223 </widget>
224 </grid>
129 </widget> 225 </widget>
130 <widget row="4" column="1" rowspan="1" colspan="2" > 226 <spacer row="1" column="1" >
131 <class>QComboBox</class> 227 <property>
132 <property stdset="1">
133 <name>name</name> 228 <name>name</name>
134 <cstring>cbClassName</cstring> 229 <cstring>Spacer1</cstring>
135 </property> 230 </property>
136 </widget>
137 <widget row="0" column="0" rowspan="1" colspan="3" >
138 <class>QLabel</class>
139 <property stdset="1"> 231 <property stdset="1">
140 <name>name</name> 232 <name>orientation</name>
141 <cstring>textCardName</cstring> 233 <enum>Vertical</enum>
142 </property> 234 </property>
143 <property stdset="1"> 235 <property stdset="1">
144 <name>text</name> 236 <name>sizeType</name>
145 <string>CardName</string> 237 <enum>Expanding</enum>
146 </property> 238 </property>
147 </widget> 239 <property>
240 <name>sizeHint</name>
241 <size>
242 <width>20</width>
243 <height>20</height>
244 </size>
245 </property>
246 </spacer>
148 </grid> 247 </grid>
149</widget> 248</widget>
150</UI> 249</UI>