author | mickeyl <mickeyl> | 2005-05-21 20:23:42 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-05-21 20:23:42 (UTC) |
commit | 55753b4e3550f950497fe073488a206d924b75be (patch) (unidiff) | |
tree | bcb04412e5bc8ea0ac8ee3669ba4e8912954ec45 | |
parent | db6b46788db3653812f07c3018abc5bfaaa821c3 (diff) | |
download | opie-55753b4e3550f950497fe073488a206d924b75be.zip opie-55753b4e3550f950497fe073488a206d924b75be.tar.gz opie-55753b4e3550f950497fe073488a206d924b75be.tar.bz2 |
add first card configuration bits and config dialog skeleton
-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 73 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialog.h | 44 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialogbase.ui | 92 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 92 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.h | 4 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.pro | 12 |
6 files changed, 270 insertions, 47 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp new file mode 100644 index 0000000..c08926e --- a/dev/null +++ b/noncore/applets/pcmcia/configdialog.cpp | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | ||
4 | .=l. | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This program is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This program is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
18 | ..}^=.= = ; Library General Public License for more | ||
19 | ++= -. .` .: details. | ||
20 | : = ...= . :.=- | ||
21 | -. .:....=;==+<; You should have received a copy of the GNU | ||
22 | -_. . . )=. = Library General Public License along with | ||
23 | -- :-=` this library; see the file COPYING.LIB. | ||
24 | If not, write to the Free Software Foundation, | ||
25 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | ||
27 | |||
28 | */ | ||
29 | |||
30 | #include "configdialog.h" | ||
31 | |||
32 | /* OPIE */ | ||
33 | #include <opie2/oconfig.h> | ||
34 | #include <opie2/odebug.h> | ||
35 | using namespace Opie::Core; | ||
36 | |||
37 | /* QT */ | ||
38 | #include <qcombobox.h> | ||
39 | |||
40 | ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) | ||
41 | :ConfigDialogBase( parent, "pcmcia config dialog", true ) | ||
42 | { | ||
43 | setCaption( tr( "Configure %1" ).arg( cardname ) ); | ||
44 | |||
45 | OConfig cfg( "PCMCIA" ); | ||
46 | cfg.setGroup( "Global" ); | ||
47 | int nCards = cfg.readNumEntry( "nCards", 0 ); | ||
48 | QString insert; | ||
49 | |||
50 | for ( int i = 0; i < nCards; ++i ) | ||
51 | { | ||
52 | QString cardSection = QString( "Card_%1" ).arg( i ); | ||
53 | cfg.setGroup( cardSection ); | ||
54 | QString name = cfg.readEntry( "name" ); | ||
55 | odebug << "comparing card '" << cardname << "' with known card '" << name << "'" << oendl; | ||
56 | if ( cardname == name ) | ||
57 | { | ||
58 | insert = cfg.readEntry( "insert" ); | ||
59 | break; | ||
60 | } | ||
61 | } | ||
62 | odebug << "preferred action for card '" << cardname << "' seems to be '" << insert << "'" << oendl; | ||
63 | |||
64 | if ( !insert.isEmpty() ) | ||
65 | { | ||
66 | for ( int i; i < cbAction->count(); ++i ) | ||
67 | if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | ConfigDialog::~ConfigDialog() | ||
72 | { | ||
73 | } | ||
diff --git a/noncore/applets/pcmcia/configdialog.h b/noncore/applets/pcmcia/configdialog.h new file mode 100644 index 0000000..12500c4 --- a/dev/null +++ b/noncore/applets/pcmcia/configdialog.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | ||
4 | .=l. | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This program is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This program is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
18 | ..}^=.= = ; Library General Public License for more | ||
19 | ++= -. .` .: details. | ||
20 | : = ...= . :.=- | ||
21 | -. .:....=;==+<; You should have received a copy of the GNU | ||
22 | -_. . . )=. = Library General Public License along with | ||
23 | -- :-=` this library; see the file COPYING.LIB. | ||
24 | If not, write to the Free Software Foundation, | ||
25 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | ||
27 | |||
28 | */ | ||
29 | |||
30 | #ifndef CONFIGDIALOG_H | ||
31 | #define CONFIGDIALOG_H | ||
32 | |||
33 | #include "configdialogbase.h" | ||
34 | |||
35 | class ConfigDialog : public ConfigDialogBase | ||
36 | { | ||
37 | Q_OBJECT | ||
38 | public: | ||
39 | |||
40 | ConfigDialog( const QString& cardname, QWidget* parent ); | ||
41 | ~ConfigDialog(); | ||
42 | }; | ||
43 | |||
44 | #endif | ||
diff --git a/noncore/applets/pcmcia/configdialogbase.ui b/noncore/applets/pcmcia/configdialogbase.ui new file mode 100644 index 0000000..d8dd983 --- a/dev/null +++ b/noncore/applets/pcmcia/configdialogbase.ui | |||
@@ -0,0 +1,92 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>ConfigDialogBase</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>ConfigDialogBase</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>214</width> | ||
15 | <height>44</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Configure PCMCIA/CF Card</string> | ||
21 | </property> | ||
22 | <property> | ||
23 | <name>layoutMargin</name> | ||
24 | </property> | ||
25 | <property> | ||
26 | <name>layoutSpacing</name> | ||
27 | </property> | ||
28 | <grid> | ||
29 | <property stdset="1"> | ||
30 | <name>margin</name> | ||
31 | <number>11</number> | ||
32 | </property> | ||
33 | <property stdset="1"> | ||
34 | <name>spacing</name> | ||
35 | <number>6</number> | ||
36 | </property> | ||
37 | <widget row="0" column="2" > | ||
38 | <class>QLabel</class> | ||
39 | <property stdset="1"> | ||
40 | <name>name</name> | ||
41 | <cstring>TextLabel3</cstring> | ||
42 | </property> | ||
43 | <property stdset="1"> | ||
44 | <name>text</name> | ||
45 | <string>card</string> | ||
46 | </property> | ||
47 | </widget> | ||
48 | <widget row="0" column="1" > | ||
49 | <class>QComboBox</class> | ||
50 | <item> | ||
51 | <property> | ||
52 | <name>text</name> | ||
53 | <string>suspend</string> | ||
54 | </property> | ||
55 | </item> | ||
56 | <item> | ||
57 | <property> | ||
58 | <name>text</name> | ||
59 | <string>activate</string> | ||
60 | </property> | ||
61 | </item> | ||
62 | <item> | ||
63 | <property> | ||
64 | <name>text</name> | ||
65 | <string>eject</string> | ||
66 | </property> | ||
67 | </item> | ||
68 | <item> | ||
69 | <property> | ||
70 | <name>text</name> | ||
71 | <string>prompt for</string> | ||
72 | </property> | ||
73 | </item> | ||
74 | <property stdset="1"> | ||
75 | <name>name</name> | ||
76 | <cstring>cbAction</cstring> | ||
77 | </property> | ||
78 | </widget> | ||
79 | <widget row="0" column="0" > | ||
80 | <class>QLabel</class> | ||
81 | <property stdset="1"> | ||
82 | <name>name</name> | ||
83 | <cstring>TextLabel2</cstring> | ||
84 | </property> | ||
85 | <property stdset="1"> | ||
86 | <name>text</name> | ||
87 | <string>Upon insertion,</string> | ||
88 | </property> | ||
89 | </widget> | ||
90 | </grid> | ||
91 | </widget> | ||
92 | </UI> | ||
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp index a1deb6b..4fcc189 100644 --- a/noncore/applets/pcmcia/pcmcia.cpp +++ b/noncore/applets/pcmcia/pcmcia.cpp | |||
@@ -1,277 +1,281 @@ | |||
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 "pcmcia.h" | 30 | #include "pcmcia.h" |
31 | #include "configdialog.h" | ||
31 | 32 | ||
32 | /* OPIE */ | 33 | /* OPIE */ |
33 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
34 | #include <opie2/odevice.h> | 35 | #include <opie2/odevice.h> |
35 | #include <opie2/oconfig.h> | 36 | #include <opie2/oconfig.h> |
36 | #include <opie2/oprocess.h> | 37 | #include <opie2/oprocess.h> |
37 | #include <opie2/opcmciasystem.h> | 38 | #include <opie2/opcmciasystem.h> |
38 | #include <opie2/oresource.h> | 39 | #include <opie2/oresource.h> |
39 | #include <opie2/otaskbarapplet.h> | 40 | #include <opie2/otaskbarapplet.h> |
40 | #include <qpe/applnk.h> | 41 | #include <qpe/applnk.h> |
41 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
42 | using namespace Opie::Core; | 43 | using namespace Opie::Core; |
43 | using namespace Opie::Ui; | 44 | using namespace Opie::Ui; |
44 | 45 | ||
45 | /* QT */ | 46 | /* QT */ |
46 | #include <qcopchannel_qws.h> | 47 | #include <qcopchannel_qws.h> |
47 | #include <qpainter.h> | 48 | #include <qpainter.h> |
48 | #include <qfile.h> | 49 | #include <qfile.h> |
49 | #include <qtextstream.h> | 50 | #include <qtextstream.h> |
50 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
51 | #include <qsound.h> | 52 | #include <qsound.h> |
52 | #include <qtimer.h> | 53 | #include <qtimer.h> |
53 | 54 | ||
54 | /* STD */ | 55 | /* STD */ |
55 | #include <stdio.h> | 56 | #include <stdio.h> |
56 | #include <unistd.h> | 57 | #include <unistd.h> |
57 | #include <stdlib.h> | 58 | #include <stdlib.h> |
58 | #include <string.h> | 59 | #include <string.h> |
59 | #include <fcntl.h> | 60 | #include <fcntl.h> |
60 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 61 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
61 | #include <sys/vfs.h> | 62 | #include <sys/vfs.h> |
62 | #include <mntent.h> | 63 | #include <mntent.h> |
63 | #endif | 64 | #endif |
64 | 65 | ||
65 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) | 66 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) |
66 | { | 67 | { |
67 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 68 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
68 | connect( pcmciaChannel, | 69 | connect( pcmciaChannel, |
69 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | 70 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
70 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | 71 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
71 | 72 | ||
72 | setFocusPolicy( NoFocus ); | 73 | setFocusPolicy( NoFocus ); |
73 | setFixedWidth ( AppLnk::smallIconSize() ); | 74 | setFixedWidth ( AppLnk::smallIconSize() ); |
74 | setFixedHeight ( AppLnk::smallIconSize() ); | 75 | setFixedHeight ( AppLnk::smallIconSize() ); |
75 | pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); | 76 | pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); |
76 | } | 77 | } |
77 | 78 | ||
78 | 79 | ||
79 | PcmciaManager::~PcmciaManager() | 80 | PcmciaManager::~PcmciaManager() |
80 | { | 81 | { |
81 | } | 82 | } |
82 | 83 | ||
83 | 84 | ||
84 | void PcmciaManager::popUp( QString message, QString icon ) | 85 | void PcmciaManager::popUp( QString message, QString icon ) |
85 | { | 86 | { |
86 | if ( !popupMenu ) { | 87 | if ( !popupMenu ) { |
87 | popupMenu = new QPopupMenu( this ); | 88 | popupMenu = new QPopupMenu( this ); |
88 | } | 89 | } |
89 | 90 | ||
90 | popupMenu->clear(); | 91 | popupMenu->clear(); |
91 | if ( icon.isEmpty() ) { | 92 | if ( icon.isEmpty() ) { |
92 | popupMenu->insertItem( message, 0 ); | 93 | popupMenu->insertItem( message, 0 ); |
93 | } else { | 94 | } else { |
94 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), | 95 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), |
95 | message, 0 ); | 96 | message, 0 ); |
96 | } | 97 | } |
97 | 98 | ||
98 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 99 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
99 | QSize s = popupMenu->sizeHint(); | 100 | QSize s = popupMenu->sizeHint(); |
100 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 101 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), |
101 | p.y() - s.height() ), 0 ); | 102 | p.y() - s.height() ), 0 ); |
102 | 103 | ||
103 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); | 104 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); |
104 | } | 105 | } |
105 | 106 | ||
106 | 107 | ||
107 | void PcmciaManager::popupTimeout() | 108 | void PcmciaManager::popupTimeout() |
108 | { | 109 | { |
109 | popupMenu->hide(); | 110 | popupMenu->hide(); |
110 | } | 111 | } |
111 | 112 | ||
113 | enum { EJECT, INSERT, SUSPEND, RESUME, CONFIGURE }; | ||
112 | 114 | ||
113 | void PcmciaManager::mousePressEvent( QMouseEvent* ) | 115 | void PcmciaManager::mousePressEvent( QMouseEvent* ) |
114 | { | 116 | { |
115 | QPopupMenu* menu = new QPopupMenu( this ); | 117 | QPopupMenu* menu = new QPopupMenu( this ); |
116 | QStringList cmd; | 118 | QStringList cmd; |
117 | bool execute = true; | 119 | bool execute = true; |
118 | 120 | ||
119 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 121 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
120 | OPcmciaSystem::CardIterator it = sys->iterator(); | 122 | OPcmciaSystem::CardIterator it = sys->iterator(); |
121 | if ( !sys->count() ) return; | 123 | if ( !sys->count() ) return; |
122 | 124 | ||
123 | int i = 0; | 125 | int i = 0; |
124 | while ( it.current() ) | 126 | while ( it.current() ) |
125 | { | 127 | { |
126 | |||
127 | QPopupMenu* submenu = new QPopupMenu( menu ); | 128 | QPopupMenu* submenu = new QPopupMenu( menu ); |
128 | submenu->insertItem( "Eject" ); | 129 | submenu->insertItem( "&Eject", EJECT+i*100 ); |
129 | submenu->insertItem( "Insert" ); | 130 | submenu->insertItem( "&Insert", INSERT+i*100 ); |
130 | submenu->insertItem( "Suspend" ); | 131 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); |
131 | submenu->insertItem( "Resume" ); | 132 | submenu->insertItem( "&Resume", RESUME+i*100 ); |
132 | submenu->insertItem( "Configure" ); | 133 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); |
133 | 134 | ||
135 | submenu->setItemEnabled( EJECT+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() ); | ||
138 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); | ||
139 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() ); | ||
140 | |||
141 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); | ||
134 | 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 ); |
135 | ++it; | 143 | ++it; |
136 | } | 144 | } |
137 | 145 | ||
138 | |||
139 | |||
140 | /* insert items depending on number of cards etc. | ||
141 | |||
142 | if ( cardInSd ) { | ||
143 | menu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( "cardmon/ide", Opie::Core::OResource::SmallIcon ) ), | ||
144 | tr( "Eject SD/MMC card" ), 0 ); | ||
145 | } | ||
146 | |||
147 | |||
148 | |||
149 | if ( cardInPcmcia0 ) { | ||
150 | menu-> | ||
151 | insertItem( QIconSet | ||
152 | ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia0Type, Opie::Core::OResource::SmallIcon ) ), | ||
153 | tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 ); | ||
154 | } | ||
155 | |||
156 | if ( cardInPcmcia1 ) { | ||
157 | menu-> | ||
158 | insertItem( QIconSet | ||
159 | ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia1Type, Opie::Core::OResource::SmallIcon ) ), | ||
160 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); | ||
161 | } | ||
162 | */ | ||
163 | |||
164 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 146 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
165 | QSize s = menu->sizeHint(); | 147 | QSize s = menu->sizeHint(); |
166 | 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 ); |
167 | qDebug( "pcmcia: menu result = %d", opt ); | 149 | qDebug( "pcmcia: menu result = %d", opt ); |
168 | delete menu; | 150 | delete menu; |
169 | } | 151 | } |
170 | 152 | ||
171 | 153 | ||
172 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | 154 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) |
173 | { | 155 | { |
174 | odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; | 156 | odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; |
175 | if ( msg != "stabChanged()" ) return; | 157 | if ( msg != "stabChanged()" ) return; |
176 | 158 | ||
177 | /* check if a previously unknown card has been inserted */ | 159 | /* check if a previously unknown card has been inserted */ |
178 | OPcmciaSystem::instance()->synchronize(); | 160 | OPcmciaSystem::instance()->synchronize(); |
179 | 161 | ||
180 | if ( !OPcmciaSystem::instance()->cardCount() ) return; | 162 | if ( !OPcmciaSystem::instance()->cardCount() ) return; |
181 | 163 | ||
182 | OConfig cfg( "PCMCIA" ); | 164 | OConfig cfg( "PCMCIA" ); |
183 | cfg.setGroup( "Global" ); | 165 | cfg.setGroup( "Global" ); |
184 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 166 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
185 | 167 | ||
186 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 168 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
187 | OPcmciaSystem::CardIterator it = sys->iterator(); | 169 | OPcmciaSystem::CardIterator it = sys->iterator(); |
188 | 170 | ||
189 | bool newCard = true; | 171 | bool newCard = true; |
190 | QString cardName; | 172 | OPcmciaSocket* theCard = 0; |
191 | 173 | ||
192 | while ( it.current() && newCard ) | 174 | while ( it.current() && newCard ) |
193 | { | 175 | { |
194 | if ( it.current()->isEmpty() ) | 176 | if ( it.current()->isEmpty() ) |
195 | { | 177 | { |
196 | odebug << "skipping empty card in socket " << it.current()->number() << oendl; | 178 | odebug << "skipping empty card in socket " << it.current()->number() << oendl; |
197 | ++it; | 179 | ++it; |
198 | continue; | 180 | continue; |
199 | } | 181 | } |
200 | else | 182 | else |
201 | { | 183 | { |
202 | cardName = it.current()->identity(); | 184 | OPcmciaSocket* theCard = it.current(); |
185 | QString cardName = theCard->identity(); | ||
203 | for ( int i = 0; i < nCards; ++i ) | 186 | for ( int i = 0; i < nCards; ++i ) |
204 | { | 187 | { |
205 | QString cardSection = QString( "Card_%1" ).arg( i ); | 188 | QString cardSection = QString( "Card_%1" ).arg( i ); |
206 | cfg.setGroup( cardSection ); | 189 | cfg.setGroup( cardSection ); |
207 | QString name = cfg.readEntry( "name" ); | 190 | QString name = cfg.readEntry( "name" ); |
208 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; | 191 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
209 | if ( cardName == name ) | 192 | if ( cardName == name ) |
210 | { | 193 | { |
211 | newCard = false; | 194 | newCard = false; |
212 | break; | 195 | break; |
213 | } | 196 | } |
214 | } | 197 | } |
215 | if ( !newCard ) ++it; else break; | 198 | if ( !newCard ) ++it; else break; |
216 | } | 199 | } |
217 | } | 200 | } |
218 | if ( newCard ) | 201 | if ( newCard ) |
219 | { | 202 | { |
220 | odebug << "pcmcia: new card detected" << oendl; | 203 | odebug << "pcmcia: new card detected" << oendl; |
221 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); | 204 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); |
222 | cfg.writeEntry( "name", cardName ); | 205 | cfg.writeEntry( "name", theCard->identity() ); |
206 | cfg.writeEntry( "insert", "suspend" ); | ||
223 | cfg.setGroup( "Global" ); | 207 | cfg.setGroup( "Global" ); |
224 | cfg.writeEntry( "nCards", nCards+1 ); | 208 | cfg.writeEntry( "nCards", nCards+1 ); |
225 | cfg.write(); | 209 | cfg.write(); |
226 | 210 | ||
227 | int result = QMessageBox::information( qApp->desktop(), | 211 | int result = QMessageBox::information( qApp->desktop(), |
228 | tr( "PCMCIA/CF Subsystem" ), | 212 | tr( "PCMCIA/CF Subsystem" ), |
229 | tr( "You have inserted a new card:\n%1\nDo you want to configure?" ).arg( cardName ), | 213 | tr( "You have inserted a new card:\n%1\nDo you want to configure?" ).arg( theCard->identity() ), |
230 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); | 214 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); |
231 | odebug << "result = " << result << oendl; | 215 | odebug << "result = " << result << oendl; |
232 | if ( result == 0 ) | 216 | if ( result == 0 ) |
233 | { | 217 | { |
234 | QMessageBox::information( qApp->desktop(), | 218 | configure( theCard ); |
235 | tr( "PCMCIA/CF Subsystem" ), | ||
236 | tr( "Sorry, not yet implemented...\n~lart mickeyl :D" ), | ||
237 | tr( "No Problem" ), 0, 0, 0 ); | ||
238 | } | 219 | } |
239 | else | 220 | else |
240 | { | 221 | { |
241 | odebug << "pcmcia: user doesn't want to configure " << cardName << " now." << oendl; | 222 | odebug << "pcmcia: user doesn't want to configure " << theCard->identity() << " now." << oendl; |
242 | } | 223 | } |
243 | } | 224 | } |
244 | else | 225 | else |
245 | { | 226 | { |
246 | odebug << "pcmcia: card has been previously inserted" << oendl; | 227 | odebug << "pcmcia: card has been previously inserted" << oendl; |
247 | } | 228 | } |
248 | repaint( true ); | 229 | repaint( true ); |
249 | } | 230 | } |
250 | 231 | ||
251 | 232 | ||
252 | void PcmciaManager::paintEvent( QPaintEvent * ) | 233 | void PcmciaManager::paintEvent( QPaintEvent * ) |
253 | { | 234 | { |
254 | QPainter p( this ); | 235 | QPainter p( this ); |
255 | qDebug( "count = %d", (OPcmciaSystem::instance()->count() ) ); | 236 | odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl; |
256 | if ( OPcmciaSystem::instance()->count() ) | 237 | |
238 | if ( OPcmciaSystem::instance()->cardCount() ) | ||
257 | { | 239 | { |
258 | p.drawPixmap( 0, 0, pm ); | 240 | p.drawPixmap( 0, 0, pm ); |
259 | show(); | 241 | show(); |
260 | } | 242 | } |
261 | else | 243 | else |
262 | { | 244 | { |
263 | hide(); | 245 | hide(); |
264 | } | 246 | } |
265 | } | 247 | } |
266 | 248 | ||
267 | int PcmciaManager::position() | 249 | int PcmciaManager::position() |
268 | { | 250 | { |
269 | return 7; | 251 | return 7; |
270 | } | 252 | } |
271 | 253 | ||
272 | void PcmciaManager::execCommand( const QStringList &strList ) | 254 | void PcmciaManager::execCommand( const QStringList &strList ) |
273 | { | 255 | { |
274 | } | 256 | } |
275 | 257 | ||
258 | void PcmciaManager::userCardAction( int action ) | ||
259 | { | ||
260 | odebug << "user action requested. action = " << action << oendl; | ||
261 | |||
262 | int socket = action / 100; | ||
263 | int what = action % 100; | ||
264 | |||
265 | switch ( what ) | ||
266 | { | ||
267 | case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); break; | ||
268 | default: odebug << "not yet implemented"; | ||
269 | } | ||
270 | } | ||
271 | |||
272 | void PcmciaManager::configure( OPcmciaSocket* card ) | ||
273 | { | ||
274 | ConfigDialog dialog( card->identity(), qApp->desktop() ); | ||
275 | int configresult = dialog.exec(); | ||
276 | odebug << "pcmcia: configresult = " << configresult << oendl; | ||
277 | } | ||
278 | |||
279 | |||
276 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) | 280 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) |
277 | 281 | ||
diff --git a/noncore/applets/pcmcia/pcmcia.h b/noncore/applets/pcmcia/pcmcia.h index 5c20433..ed86579 100644 --- a/noncore/applets/pcmcia/pcmcia.h +++ b/noncore/applets/pcmcia/pcmcia.h | |||
@@ -1,65 +1,69 @@ | |||
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 | #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; } }; | ||
38 | |||
37 | class PcmciaManager : public QWidget | 39 | class PcmciaManager : public QWidget |
38 | { | 40 | { |
39 | Q_OBJECT | 41 | Q_OBJECT |
40 | public: | 42 | public: |
41 | PcmciaManager( QWidget *parent = 0 ); | 43 | PcmciaManager( QWidget *parent = 0 ); |
42 | ~PcmciaManager(); | 44 | ~PcmciaManager(); |
43 | static int position(); | 45 | static int position(); |
44 | 46 | ||
45 | private slots: | 47 | private slots: |
46 | void cardMessage( const QCString& msg, const QByteArray& ); | 48 | void cardMessage( const QCString& msg, const QByteArray& ); |
49 | void userCardAction( int action ); | ||
47 | void popupTimeout(); | 50 | void popupTimeout(); |
48 | 51 | ||
49 | protected: | 52 | protected: |
50 | void paintEvent( QPaintEvent* ); | 53 | void paintEvent( QPaintEvent* ); |
51 | void mousePressEvent( QMouseEvent * ); | 54 | void mousePressEvent( QMouseEvent * ); |
52 | 55 | ||
53 | private: | 56 | private: |
57 | void configure( Opie::Core::OPcmciaSocket* ); | ||
54 | void execCommand( const QStringList &command ); | 58 | void execCommand( const QStringList &command ); |
55 | void popUp(QString message, QString icon = QString::null ); | 59 | void popUp(QString message, QString icon = QString::null ); |
56 | 60 | ||
57 | private: | 61 | private: |
58 | int m_commandOrig; | 62 | int m_commandOrig; |
59 | QPixmap pm; | 63 | QPixmap pm; |
60 | QPopupMenu *popupMenu; | 64 | QPopupMenu *popupMenu; |
61 | 65 | ||
62 | }; | 66 | }; |
63 | 67 | ||
64 | #endif | 68 | #endif |
65 | 69 | ||
diff --git a/noncore/applets/pcmcia/pcmcia.pro b/noncore/applets/pcmcia/pcmcia.pro index c4f7b62..4a893b5 100644 --- a/noncore/applets/pcmcia/pcmcia.pro +++ b/noncore/applets/pcmcia/pcmcia.pro | |||
@@ -1,12 +1,18 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt plugin warn_on | 2 | CONFIG += qt plugin warn_on |
3 | HEADERS = pcmcia.h | 3 | |
4 | SOURCES = pcmcia.cpp | 4 | INTERFACES = configdialogbase.ui |
5 | HEADERS = pcmcia.h \ | ||
6 | configdialog.h | ||
7 | SOURCES = pcmcia.cpp \ | ||
8 | configdialog.cpp | ||
5 | TARGET = pcmciaapplet | 9 | TARGET = pcmciaapplet |
10 | |||
6 | DESTDIR = $(OPIEDIR)/plugins/applets | 11 | DESTDIR = $(OPIEDIR)/plugins/applets |
7 | INCLUDEPATH += $(OPIEDIR)/include | 12 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += $(OPIEDIR)/include | 13 | DEPENDPATH += $(OPIEDIR)/include |
14 | |||
9 | LIBS += -lqpe -lopiecore2 | 15 | LIBS += -lqpe -lopiecore2 |
10 | VERSION = 0.1.0 | 16 | VERSION = 0.2.0 |
11 | 17 | ||
12 | include( $(OPIEDIR)/include.pro ) | 18 | include( $(OPIEDIR)/include.pro ) |