-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 32 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialog.h | 4 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialogbase.ui | 19 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 12 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.h | 3 |
5 files changed, 53 insertions, 17 deletions
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 | |||
@@ -3,116 +3,134 @@ | |||
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> |
35 | #include <opie2/opcmciasystem.h> | ||
35 | using namespace Opie::Core; | 36 | using namespace Opie::Core; |
36 | 37 | ||
37 | /* QT */ | 38 | /* QT */ |
38 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
39 | #include <qdir.h> | 40 | #include <qdir.h> |
40 | #include <qfile.h> | 41 | #include <qfile.h> |
42 | #include <qgroupbox.h> | ||
41 | #include <qlabel.h> | 43 | #include <qlabel.h> |
42 | #include <qtextstream.h> | 44 | #include <qtextstream.h> |
43 | 45 | ||
44 | ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) | 46 | ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) |
45 | :ConfigDialogBase( parent, "pcmcia config dialog", true ) | 47 | :ConfigDialogBase( parent, "pcmcia config dialog", true ) |
46 | { | 48 | { |
47 | //setCaption( tr( "Configure %1" ).arg( cardname ) ); | 49 | gbDetails->setTitle( QString( "Details for '%1'" ).arg( card->identity() ) ); |
48 | txtCardName->setText( cardname ); | 50 | txtCardName->setText( card->productIdentity().join( " " ) ); |
51 | txtManfid->setText( card->manufacturerIdentity() ); | ||
52 | txtFunction->setText( card->function() ); | ||
49 | 53 | ||
50 | OConfig cfg( "PCMCIA" ); | 54 | OConfig cfg( "PCMCIA" ); |
51 | cfg.setGroup( "Global" ); | 55 | cfg.setGroup( "Global" ); |
52 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 56 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
53 | QString insert; | 57 | QString insert; |
54 | 58 | ||
55 | for ( int i = 0; i < nCards; ++i ) | 59 | for ( int i = 0; i < nCards; ++i ) |
56 | { | 60 | { |
57 | QString cardSection = QString( "Card_%1" ).arg( i ); | 61 | QString cardSection = QString( "Card_%1" ).arg( i ); |
58 | cfg.setGroup( cardSection ); | 62 | cfg.setGroup( cardSection ); |
59 | QString name = cfg.readEntry( "name" ); | 63 | QString name = cfg.readEntry( "name" ); |
60 | odebug << "comparing card '" << cardname << "' with known card '" << name << "'" << oendl; | 64 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; |
61 | if ( cardname == name ) | 65 | if ( card->name() == name ) |
62 | { | 66 | { |
63 | insert = cfg.readEntry( "insert" ); | 67 | insert = cfg.readEntry( "insert" ); |
64 | break; | 68 | break; |
65 | } | 69 | } |
66 | } | 70 | } |
67 | odebug << "preferred action for card '" << cardname << "' seems to be '" << insert << "'" << oendl; | 71 | odebug << "preferred action for card '" << card->name() << "' seems to be '" << insert << "'" << oendl; |
68 | 72 | ||
69 | if ( !insert.isEmpty() ) | 73 | if ( !insert.isEmpty() ) |
70 | { | 74 | { |
71 | for ( int i; i < cbAction->count(); ++i ) | 75 | for ( int i; i < cbAction->count(); ++i ) |
72 | if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); | 76 | if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); |
73 | } | 77 | } |
74 | 78 | ||
79 | if ( !card->isUnsupported() ) | ||
80 | { | ||
81 | odebug << "card is recognized - hiding bindings" << oendl; | ||
82 | textBindTo->hide(); | ||
83 | cbBindTo->hide(); | ||
84 | return; | ||
85 | } | ||
86 | else | ||
87 | { | ||
88 | odebug << "card is unsupported yet - showing possible bindings" << oendl; | ||
89 | textBindTo->show(); | ||
90 | cbBindTo->show(); | ||
91 | } | ||
92 | |||
75 | // parse possible bind entries out of /etc/pcmcia/*.conf | 93 | // parse possible bind entries out of /etc/pcmcia/*.conf |
76 | typedef QMap<QString,QString> StringMap; | 94 | typedef QMap<QString,QString> StringMap; |
77 | StringMap bindEntries; | 95 | StringMap bindEntries; |
78 | 96 | ||
79 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); | 97 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); |
80 | 98 | ||
81 | for ( int i = 0; i < pcmciaconfdir.count(); ++i ) | 99 | for ( int i = 0; i < pcmciaconfdir.count(); ++i ) |
82 | { | 100 | { |
83 | odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; | 101 | odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; |
84 | QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); | 102 | QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); |
85 | QFile conffile( conffilename ); | 103 | QFile conffile( conffilename ); |
86 | if ( conffile.open( IO_ReadOnly ) ) | 104 | if ( conffile.open( IO_ReadOnly ) ) |
87 | { | 105 | { |
88 | QTextStream ts( &conffile ); | 106 | QTextStream ts( &conffile ); |
89 | while ( !ts.atEnd() ) | 107 | while ( !ts.atEnd() ) |
90 | { | 108 | { |
91 | QString word; | 109 | QString word; |
92 | ts >> word; | 110 | ts >> word; |
93 | if ( word == "bind" ) | 111 | if ( word == "bind" ) |
94 | { | 112 | { |
95 | word = ts.readLine(); | 113 | word = ts.readLine(); |
96 | bindEntries[ word.stripWhiteSpace() ] = conffilename; | 114 | bindEntries[ word.stripWhiteSpace() ] = conffilename; |
97 | continue; | 115 | continue; |
98 | } | 116 | } |
99 | ts.readLine(); | 117 | ts.readLine(); |
100 | } | 118 | } |
101 | } | 119 | } |
102 | else | 120 | else |
103 | { | 121 | { |
104 | owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl; | 122 | owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl; |
105 | continue; | 123 | continue; |
106 | } | 124 | } |
107 | } | 125 | } |
108 | 126 | ||
109 | for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) | 127 | for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) |
110 | { | 128 | { |
111 | odebug << "found device '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; | 129 | odebug << "found binding '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; |
112 | cbBindTo->insertItem( it.key() ); | 130 | cbBindTo->insertItem( it.key() ); |
113 | } | 131 | } |
114 | } | 132 | } |
115 | 133 | ||
116 | ConfigDialog::~ConfigDialog() | 134 | ConfigDialog::~ConfigDialog() |
117 | { | 135 | { |
118 | } | 136 | } |
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 | |||
@@ -3,42 +3,44 @@ | |||
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 | #ifndef CONFIGDIALOG_H | 30 | #ifndef CONFIGDIALOG_H |
31 | #define CONFIGDIALOG_H | 31 | #define CONFIGDIALOG_H |
32 | 32 | ||
33 | #include "configdialogbase.h" | 33 | #include "configdialogbase.h" |
34 | 34 | ||
35 | namespace Opie { namespace Core { class OPcmciaSocket; }; }; | ||
36 | |||
35 | class ConfigDialog : public ConfigDialogBase | 37 | class ConfigDialog : public ConfigDialogBase |
36 | { | 38 | { |
37 | Q_OBJECT | 39 | Q_OBJECT |
38 | public: | 40 | public: |
39 | 41 | ||
40 | ConfigDialog( const QString& cardname, QWidget* parent ); | 42 | ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent ); |
41 | ~ConfigDialog(); | 43 | ~ConfigDialog(); |
42 | }; | 44 | }; |
43 | 45 | ||
44 | #endif | 46 | #endif |
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 | |||
@@ -1,148 +1,159 @@ | |||
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>232</width> | 14 | <width>197</width> |
15 | <height>206</height> | 15 | <height>154</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>5</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>2</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>On 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 | <property stdset="1"> | 96 | <property stdset="1"> |
97 | <name>sizePolicy</name> | ||
98 | <sizepolicy> | ||
99 | <hsizetype>5</hsizetype> | ||
100 | <vsizetype>0</vsizetype> | ||
101 | </sizepolicy> | ||
102 | </property> | ||
103 | <property stdset="1"> | ||
97 | <name>editable</name> | 104 | <name>editable</name> |
98 | <bool>true</bool> | 105 | <bool>true</bool> |
99 | </property> | 106 | </property> |
107 | <property stdset="1"> | ||
108 | <name>autoResize</name> | ||
109 | <bool>false</bool> | ||
110 | </property> | ||
100 | </widget> | 111 | </widget> |
101 | <widget row="3" column="0" > | 112 | <widget row="3" column="0" > |
102 | <class>QLabel</class> | 113 | <class>QLabel</class> |
103 | <property stdset="1"> | 114 | <property stdset="1"> |
104 | <name>name</name> | 115 | <name>name</name> |
105 | <cstring>textBindTo</cstring> | 116 | <cstring>textBindTo</cstring> |
106 | </property> | 117 | </property> |
107 | <property stdset="1"> | 118 | <property stdset="1"> |
108 | <name>text</name> | 119 | <name>text</name> |
109 | <string>Bind to:</string> | 120 | <string>Bind to:</string> |
110 | </property> | 121 | </property> |
111 | </widget> | 122 | </widget> |
112 | <widget row="0" column="0" rowspan="1" colspan="3" > | 123 | <widget row="0" column="0" rowspan="1" colspan="3" > |
113 | <class>QGroupBox</class> | 124 | <class>QGroupBox</class> |
114 | <property stdset="1"> | 125 | <property stdset="1"> |
115 | <name>name</name> | 126 | <name>name</name> |
116 | <cstring>GroupBox1</cstring> | 127 | <cstring>gbDetails</cstring> |
117 | </property> | 128 | </property> |
118 | <property stdset="1"> | 129 | <property stdset="1"> |
119 | <name>title</name> | 130 | <name>title</name> |
120 | <string>Details</string> | 131 | <string>Details</string> |
121 | </property> | 132 | </property> |
122 | <property> | 133 | <property> |
123 | <name>layoutMargin</name> | 134 | <name>layoutMargin</name> |
124 | </property> | 135 | </property> |
125 | <property> | 136 | <property> |
126 | <name>layoutSpacing</name> | 137 | <name>layoutSpacing</name> |
127 | </property> | 138 | </property> |
128 | <grid> | 139 | <grid> |
129 | <property stdset="1"> | 140 | <property stdset="1"> |
130 | <name>margin</name> | 141 | <name>margin</name> |
131 | <number>6</number> | 142 | <number>6</number> |
132 | </property> | 143 | </property> |
133 | <property stdset="1"> | 144 | <property stdset="1"> |
134 | <name>spacing</name> | 145 | <name>spacing</name> |
135 | <number>4</number> | 146 | <number>4</number> |
136 | </property> | 147 | </property> |
137 | <widget row="0" column="0" > | 148 | <widget row="0" column="0" > |
138 | <class>QLabel</class> | 149 | <class>QLabel</class> |
139 | <property stdset="1"> | 150 | <property stdset="1"> |
140 | <name>name</name> | 151 | <name>name</name> |
141 | <cstring>labelCardName</cstring> | 152 | <cstring>labelCardName</cstring> |
142 | </property> | 153 | </property> |
143 | <property stdset="1"> | 154 | <property stdset="1"> |
144 | <name>text</name> | 155 | <name>text</name> |
145 | <string>CardName:</string> | 156 | <string>CardName:</string> |
146 | </property> | 157 | </property> |
147 | </widget> | 158 | </widget> |
148 | <widget row="2" column="0" > | 159 | <widget row="2" column="0" > |
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 | |||
@@ -45,127 +45,129 @@ using namespace Opie::Ui; | |||
45 | 45 | ||
46 | /* QT */ | 46 | /* QT */ |
47 | #include <qcopchannel_qws.h> | 47 | #include <qcopchannel_qws.h> |
48 | #include <qpainter.h> | 48 | #include <qpainter.h> |
49 | #include <qfile.h> | 49 | #include <qfile.h> |
50 | #include <qtextstream.h> | 50 | #include <qtextstream.h> |
51 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
52 | #include <qsound.h> | 52 | #include <qsound.h> |
53 | #include <qtimer.h> | 53 | #include <qtimer.h> |
54 | 54 | ||
55 | /* STD */ | 55 | /* STD */ |
56 | #include <stdio.h> | 56 | #include <stdio.h> |
57 | #include <unistd.h> | 57 | #include <unistd.h> |
58 | #include <stdlib.h> | 58 | #include <stdlib.h> |
59 | #include <string.h> | 59 | #include <string.h> |
60 | #include <fcntl.h> | 60 | #include <fcntl.h> |
61 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 61 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
62 | #include <sys/vfs.h> | 62 | #include <sys/vfs.h> |
63 | #include <mntent.h> | 63 | #include <mntent.h> |
64 | #endif | 64 | #endif |
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 ); |
89 | } | 90 | } |
90 | 91 | ||
91 | popupMenu->clear(); | 92 | popupMenu->clear(); |
92 | if ( icon.isEmpty() ) { | 93 | if ( icon.isEmpty() ) { |
93 | popupMenu->insertItem( message, 0 ); | 94 | popupMenu->insertItem( message, 0 ); |
94 | } else { | 95 | } else { |
95 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), | 96 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), |
96 | message, 0 ); | 97 | message, 0 ); |
97 | } | 98 | } |
98 | 99 | ||
99 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 100 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
100 | QSize s = popupMenu->sizeHint(); | 101 | QSize s = popupMenu->sizeHint(); |
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 | } |
152 | 154 | ||
153 | 155 | ||
154 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | 156 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) |
155 | { | 157 | { |
156 | odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; | 158 | odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; |
157 | if ( msg != "stabChanged()" ) return; | 159 | if ( msg != "stabChanged()" ) return; |
158 | 160 | ||
159 | /* check if a previously unknown card has been inserted */ | 161 | /* check if a previously unknown card has been inserted */ |
160 | OPcmciaSystem::instance()->synchronize(); | 162 | OPcmciaSystem::instance()->synchronize(); |
161 | 163 | ||
162 | if ( !OPcmciaSystem::instance()->cardCount() ) return; | 164 | if ( !OPcmciaSystem::instance()->cardCount() ) return; |
163 | 165 | ||
164 | OConfig cfg( "PCMCIA" ); | 166 | OConfig cfg( "PCMCIA" ); |
165 | cfg.setGroup( "Global" ); | 167 | cfg.setGroup( "Global" ); |
166 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 168 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
167 | 169 | ||
168 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 170 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
169 | OPcmciaSystem::CardIterator it = sys->iterator(); | 171 | OPcmciaSystem::CardIterator it = sys->iterator(); |
170 | 172 | ||
171 | bool newCard = true; | 173 | bool newCard = true; |
@@ -242,40 +244,42 @@ void PcmciaManager::paintEvent( QPaintEvent * ) | |||
242 | } | 244 | } |
243 | else | 245 | else |
244 | { | 246 | { |
245 | hide(); | 247 | hide(); |
246 | } | 248 | } |
247 | } | 249 | } |
248 | 250 | ||
249 | int PcmciaManager::position() | 251 | int PcmciaManager::position() |
250 | { | 252 | { |
251 | return 7; | 253 | return 7; |
252 | } | 254 | } |
253 | 255 | ||
254 | void PcmciaManager::execCommand( const QStringList &strList ) | 256 | void PcmciaManager::execCommand( const QStringList &strList ) |
255 | { | 257 | { |
256 | } | 258 | } |
257 | 259 | ||
258 | void PcmciaManager::userCardAction( int action ) | 260 | void PcmciaManager::userCardAction( int action ) |
259 | { | 261 | { |
260 | odebug << "user action requested. action = " << action << oendl; | 262 | odebug << "user action requested. action = " << action << oendl; |
261 | 263 | ||
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 | ||
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 | |||
@@ -30,40 +30,41 @@ | |||
30 | #ifndef PCMCIA_H | 30 | #ifndef PCMCIA_H |
31 | #define PCMCIA_H | 31 | #define PCMCIA_H |
32 | 32 | ||
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | 36 | ||
37 | namespace Opie { namespace Core { class OPcmciaSocket; } }; | 37 | namespace Opie { namespace Core { class OPcmciaSocket; } }; |
38 | 38 | ||
39 | class PcmciaManager : public QWidget | 39 | class PcmciaManager : public QWidget |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | PcmciaManager( QWidget *parent = 0 ); | 43 | PcmciaManager( QWidget *parent = 0 ); |
44 | ~PcmciaManager(); | 44 | ~PcmciaManager(); |
45 | static int position(); | 45 | static int position(); |
46 | 46 | ||
47 | private slots: | 47 | private slots: |
48 | void cardMessage( const QCString& msg, const QByteArray& ); | 48 | void cardMessage( const QCString& msg, const QByteArray& ); |
49 | void userCardAction( int action ); | 49 | void userCardAction( int action ); |
50 | void popupTimeout(); | 50 | void popupTimeout(); |
51 | 51 | ||
52 | protected: | 52 | protected: |
53 | void paintEvent( QPaintEvent* ); | 53 | void paintEvent( QPaintEvent* ); |
54 | void mousePressEvent( QMouseEvent * ); | 54 | void mousePressEvent( QMouseEvent * ); |
55 | 55 | ||
56 | private: | 56 | private: |
57 | void configure( Opie::Core::OPcmciaSocket* ); | 57 | void configure( Opie::Core::OPcmciaSocket* ); |
58 | void execCommand( const QStringList &command ); | 58 | void execCommand( const QStringList &command ); |
59 | void popUp(QString message, QString icon = QString::null ); | 59 | void popUp(QString message, QString icon = QString::null ); |
60 | 60 | ||
61 | private: | 61 | private: |
62 | int m_commandOrig; | 62 | bool configuring; |
63 | int commandOrig; | ||
63 | QPixmap pm; | 64 | QPixmap pm; |
64 | QPopupMenu *popupMenu; | 65 | QPopupMenu *popupMenu; |
65 | 66 | ||
66 | }; | 67 | }; |
67 | 68 | ||
68 | #endif | 69 | #endif |
69 | 70 | ||