Diffstat (limited to 'noncore/applets/networkapplet/networkapplet.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/networkapplet/networkapplet.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/noncore/applets/networkapplet/networkapplet.cpp b/noncore/applets/networkapplet/networkapplet.cpp index 5eb5ad2..534a8d0 100644 --- a/noncore/applets/networkapplet/networkapplet.cpp +++ b/noncore/applets/networkapplet/networkapplet.cpp | |||
@@ -15,59 +15,61 @@ | |||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "networkapplet.h" | 31 | #include "networkapplet.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | #include <opie2/onetwork.h> | 35 | #include <opie2/onetwork.h> |
36 | #include <opie2/otaskbarapplet.h> | 36 | #include <opie2/otaskbarapplet.h> |
37 | #include <qpe/applnk.h> | 37 | #include <qpe/applnk.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | #include <qpainter.h> | 39 | using namespace Opie::Core; |
40 | using namespace Opie::Ui; | ||
41 | using namespace Opie::Net; | ||
40 | 42 | ||
41 | /* QT */ | 43 | /* QT */ |
44 | #include <qpainter.h> | ||
42 | #include <qlabel.h> | 45 | #include <qlabel.h> |
43 | #include <qlayout.h> | 46 | #include <qlayout.h> |
44 | #include <qobjectlist.h> | 47 | #include <qobjectlist.h> |
45 | 48 | ||
49 | /* STD */ | ||
46 | #include <assert.h> | 50 | #include <assert.h> |
47 | 51 | ||
48 | using namespace Opie::Ui; | ||
49 | using namespace Opie::Net; | ||
50 | IfaceUpDownButton::IfaceUpDownButton( QWidget* parent, const char* name ) | 52 | IfaceUpDownButton::IfaceUpDownButton( QWidget* parent, const char* name ) |
51 | :QToolButton( parent, name ) | 53 | :QToolButton( parent, name ) |
52 | { | 54 | { |
53 | _iface = ONetwork::instance()->interface( name ); | 55 | _iface = ONetwork::instance()->interface( name ); |
54 | assert( _iface ); | 56 | assert( _iface ); |
55 | setToggleButton( true ); | 57 | setToggleButton( true ); |
56 | //setAutoRaise( true ); | 58 | //setAutoRaise( true ); |
57 | setOnIconSet( QIconSet( Resource::loadPixmap( "up" ) ) ); | 59 | setOnIconSet( QIconSet( Resource::loadPixmap( "up" ) ) ); |
58 | setOffIconSet( QIconSet( Resource::loadPixmap( "down" ) ) ); | 60 | setOffIconSet( QIconSet( Resource::loadPixmap( "down" ) ) ); |
59 | setOn( _iface->isUp() ); | 61 | setOn( _iface->isUp() ); |
60 | //setFixedWidth( 16 ); | 62 | //setFixedWidth( 16 ); |
61 | connect( this, SIGNAL( clicked() ), this, SLOT( clicked() ) ); | 63 | connect( this, SIGNAL( clicked() ), this, SLOT( clicked() ) ); |
62 | } | 64 | } |
63 | 65 | ||
64 | 66 | ||
65 | IfaceUpDownButton::~IfaceUpDownButton() | 67 | IfaceUpDownButton::~IfaceUpDownButton() |
66 | { | 68 | { |
67 | } | 69 | } |
68 | 70 | ||
69 | 71 | ||
70 | void IfaceUpDownButton::clicked() | 72 | void IfaceUpDownButton::clicked() |
71 | { | 73 | { |
72 | _iface->setUp( isOn() ); | 74 | _iface->setUp( isOn() ); |
73 | setOn( _iface->isUp() ); // it might not have worked... | 75 | setOn( _iface->isUp() ); // it might not have worked... |
@@ -146,85 +148,85 @@ NetworkAppletControl::~NetworkAppletControl() | |||
146 | { | 148 | { |
147 | } | 149 | } |
148 | 150 | ||
149 | 151 | ||
150 | QString NetworkAppletControl::guessDevice( ONetworkInterface* iface ) | 152 | QString NetworkAppletControl::guessDevice( ONetworkInterface* iface ) |
151 | { | 153 | { |
152 | if ( iface->isWireless() ) | 154 | if ( iface->isWireless() ) |
153 | return "networksettings/wlan"; | 155 | return "networksettings/wlan"; |
154 | if ( iface->isLoopback() ) | 156 | if ( iface->isLoopback() ) |
155 | return "networksettings/lo"; | 157 | return "networksettings/lo"; |
156 | if ( QString( iface->name() ).contains( "usb" ) ) | 158 | if ( QString( iface->name() ).contains( "usb" ) ) |
157 | return "networksettings/usb"; | 159 | return "networksettings/usb"; |
158 | if ( QString( iface->name() ).contains( "ir" ) ) | 160 | if ( QString( iface->name() ).contains( "ir" ) ) |
159 | return "networksettings/irda"; | 161 | return "networksettings/irda"; |
160 | 162 | ||
161 | //TODO: Insert neat symbol and check for tunnel devices | 163 | //TODO: Insert neat symbol and check for tunnel devices |
162 | 164 | ||
163 | return "networksettings/lan"; | 165 | return "networksettings/lan"; |
164 | 166 | ||
165 | } | 167 | } |
166 | 168 | ||
167 | 169 | ||
168 | void NetworkAppletControl::showEvent( QShowEvent* e ) | 170 | void NetworkAppletControl::showEvent( QShowEvent* e ) |
169 | { | 171 | { |
170 | qDebug( "showEvent" ); | 172 | odebug << "showEvent" << oendl; |
171 | build(); | 173 | build(); |
172 | QWidget::showEvent( e ); | 174 | QWidget::showEvent( e ); |
173 | } | 175 | } |
174 | 176 | ||
175 | 177 | ||
176 | void NetworkAppletControl::hideEvent( QHideEvent* e ) | 178 | void NetworkAppletControl::hideEvent( QHideEvent* e ) |
177 | { | 179 | { |
178 | qDebug( "hideEvent" ); | 180 | odebug << "hideEvent" << oendl; |
179 | QWidget::hideEvent( e ); | 181 | QWidget::hideEvent( e ); |
180 | 182 | ||
181 | delete l; | 183 | delete l; |
182 | 184 | ||
183 | // delete all child widgets from this frame | 185 | // delete all child widgets from this frame |
184 | QObjectList* list = const_cast<QObjectList*>( children() ); | 186 | QObjectList* list = const_cast<QObjectList*>( children() ); |
185 | QObjectListIt it(*list); | 187 | QObjectListIt it(*list); |
186 | QObject* obj; | 188 | QObject* obj; |
187 | while ( (obj=it.current()) ) | 189 | while ( (obj=it.current()) ) |
188 | { | 190 | { |
189 | ++it; | 191 | ++it; |
190 | delete obj; | 192 | delete obj; |
191 | } | 193 | } |
192 | 194 | ||
193 | list = const_cast<QObjectList*>( children() ); | 195 | list = const_cast<QObjectList*>( children() ); |
194 | if ( list ) | 196 | if ( list ) |
195 | qWarning( "D'oh! We still have %d children...", list->count() ); | 197 | owarn << "D'oh! We still have " << list->count() << " children..." << oendl; |
196 | 198 | ||
197 | // renew layout | 199 | // renew layout |
198 | l = new QVBoxLayout( this, 4, 2 ); | 200 | l = new QVBoxLayout( this, 4, 2 ); |
199 | resize( 0, 0 ); | 201 | resize( 0, 0 ); |
200 | } | 202 | } |
201 | 203 | ||
202 | 204 | ||
203 | QSize NetworkAppletControl::sizeHint() const | 205 | QSize NetworkAppletControl::sizeHint() const |
204 | { | 206 | { |
205 | ONetwork::instance()->synchronize(); // rebuild interface database | 207 | ONetwork::instance()->synchronize(); // rebuild interface database |
206 | qDebug( "sizeHint (#ifaces=%d)", ONetwork::instance()->count() ); | 208 | odebug << "sizeHint (#ifaces=" << ONetwork::instance()->count() << ")" << oendl; |
207 | return QSize( 14+35+105+14 + 8, ONetwork::instance()->count() * 26 ); | 209 | return QSize( 14+35+105+14 + 8, ONetwork::instance()->count() * 26 ); |
208 | } | 210 | } |
209 | 211 | ||
210 | 212 | ||
211 | NetworkApplet::NetworkApplet( QWidget *parent, const char *name ) | 213 | NetworkApplet::NetworkApplet( QWidget *parent, const char *name ) |
212 | :OTaskbarApplet( parent, name ) | 214 | :OTaskbarApplet( parent, name ) |
213 | { | 215 | { |
214 | setFixedHeight( AppLnk::smallIconSize() ); | 216 | setFixedHeight( AppLnk::smallIconSize() ); |
215 | setFixedWidth( AppLnk::smallIconSize() ); | 217 | setFixedWidth( AppLnk::smallIconSize() ); |
216 | _pixmap.convertFromImage( Resource::loadImage( "networkapplet/network" ).smoothScale( height(), width() ) ); | 218 | _pixmap.convertFromImage( Resource::loadImage( "networkapplet/network" ).smoothScale( height(), width() ) ); |
217 | _control = new NetworkAppletControl( this, "control" ); | 219 | _control = new NetworkAppletControl( this, "control" ); |
218 | } | 220 | } |
219 | 221 | ||
220 | 222 | ||
221 | NetworkApplet::~NetworkApplet() | 223 | NetworkApplet::~NetworkApplet() |
222 | { | 224 | { |
223 | } | 225 | } |
224 | 226 | ||
225 | 227 | ||
226 | int NetworkApplet::position() | 228 | int NetworkApplet::position() |
227 | { | 229 | { |
228 | return 4; | 230 | return 4; |
229 | } | 231 | } |
230 | 232 | ||