summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/networkapplet/networkapplet.cpp22
-rw-r--r--noncore/applets/networkapplet/networkapplet.h2
2 files changed, 17 insertions, 7 deletions
diff --git a/noncore/applets/networkapplet/networkapplet.cpp b/noncore/applets/networkapplet/networkapplet.cpp
index 4e658da..9a08568 100644
--- a/noncore/applets/networkapplet/networkapplet.cpp
+++ b/noncore/applets/networkapplet/networkapplet.cpp
@@ -8,62 +8,67 @@
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "networkapplet.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+#include <opie2/onetwork.h>
#include <opie2/otaskbarapplet.h>
+#include <qpe/applnk.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
#include <qpainter.h>
-#include <opie2/odebug.h>
-#include <opie2/onetwork.h>
-#include <qpushbutton.h>
+/* QT */
+#include <qhostaddress.h>
+#include <qimage.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
-#include <qtoolbutton.h>
-#include <qhostaddress.h>
#include <qobjectlist.h>
+#include <qpushbutton.h>
+#include <qtoolbutton.h>
#include <assert.h>
IfaceUpDownButton::IfaceUpDownButton( QWidget* parent, const char* name )
:QToolButton( parent, name )
{
_iface = ONetwork::instance()->interface( name );
assert( _iface );
setToggleButton( true );
//setAutoRaise( true );
setOnIconSet( QIconSet( Resource::loadPixmap( "up" ) ) );
setOffIconSet( QIconSet( Resource::loadPixmap( "down" ) ) );
setOn( _iface->isUp() );
//setFixedWidth( 16 );
connect( this, SIGNAL( clicked() ), this, SLOT( clicked() ) );
}
IfaceUpDownButton::~IfaceUpDownButton()
{
}
void IfaceUpDownButton::clicked()
@@ -189,64 +194,67 @@ void NetworkAppletControl::hideEvent( QHideEvent* e )
delete obj;
}
list = const_cast<QObjectList*>( children() );
if ( list )
qWarning( "D'oh! We still have %d children...", list->count() );
// renew layout
l = new QVBoxLayout( this, 4, 2 );
resize( 0, 0 );
}
QSize NetworkAppletControl::sizeHint() const
{
ONetwork::instance()->synchronize(); // rebuild interface database
qDebug( "sizeHint (#ifaces=%d)", ONetwork::instance()->count() );
return QSize( 14+35+105+14 + 8, ONetwork::instance()->count() * 26 );
}
NetworkApplet::NetworkApplet( QWidget *parent, const char *name )
:OTaskbarApplet( parent, name )
{
- _control = new NetworkAppletControl( this, "control" );
+ setFixedHeight( AppLnk::smallIconSize() );
+ setFixedWidth( AppLnk::smallIconSize() );
+ _pixmap.convertFromImage( Resource::loadImage( "networkapplet/network" ).smoothScale( height(), width() ) );
+ _control = new NetworkAppletControl( this, "control" );
}
NetworkApplet::~NetworkApplet()
{
}
int NetworkApplet::position()
{
return 4;
}
void NetworkApplet::paintEvent( QPaintEvent* )
{
QPainter p(this);
- p.drawPixmap(0, 2, Resource::loadPixmap( "networkapplet/network" ) );
+ p.drawPixmap(0, 2, _pixmap );
}
void NetworkApplet::mousePressEvent( QMouseEvent* )
{
if ( !_control->isVisible() )
{
popup( _control );
}
else
{
_control->hide();
}
}
Q_EXPORT_INTERFACE()
{
Q_CREATE_INSTANCE( OTaskbarAppletWrapper<NetworkApplet> );
}
diff --git a/noncore/applets/networkapplet/networkapplet.h b/noncore/applets/networkapplet/networkapplet.h
index 7b5fa97..8022537 100644
--- a/noncore/applets/networkapplet/networkapplet.h
+++ b/noncore/applets/networkapplet/networkapplet.h
@@ -15,48 +15,49 @@
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef NETWORKAPPLET_H
#define NETWORKAPPLET_H
#include <opie2/otaskbarapplet.h>
#include <qframe.h>
#include <qstring.h>
#include <qtoolbutton.h>
#include <qlineedit.h>
+#include <qpixmap.h>
class ONetworkInterface;
class QShowEvent;
class QHideEvent;
class QVBoxLayout;
class IfaceUpDownButton : public QToolButton
{
Q_OBJECT
public:
IfaceUpDownButton( QWidget* parent, const char* name );
virtual ~IfaceUpDownButton();
public slots:
virtual void clicked();
private:
ONetworkInterface* _iface;
};
class IfaceIPAddress : public QLineEdit
{
@@ -85,28 +86,29 @@ class NetworkAppletControl : public QFrame
virtual void showEvent( QShowEvent* );
virtual void hideEvent( QHideEvent* );
QString guessDevice( ONetworkInterface* iface );
void build();
private:
QVBoxLayout* l;
};
class NetworkApplet : public OTaskbarApplet
{
public:
NetworkApplet( QWidget* parent = 0, const char* name = 0 );
~NetworkApplet();
static int position();
protected:
virtual void paintEvent( QPaintEvent* );
virtual void mousePressEvent( QMouseEvent* );
private:
NetworkAppletControl* _control;
+ QPixmap _pixmap;
};
#endif