-rw-r--r-- | noncore/applets/autorotateapplet/autorotate.cpp | 8 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/memorymeter.cpp | 26 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/memorystatus.cpp | 1 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/memorystatus.h | 4 | ||||
-rw-r--r-- | noncore/applets/networkapplet/networkapplet.cpp | 7 | ||||
-rw-r--r-- | noncore/applets/networkapplet/networkapplet.h | 18 | ||||
-rw-r--r-- | noncore/applets/notesapplet/notes.cpp | 8 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/wireless.cpp | 9 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/wireless.h | 9 | ||||
-rw-r--r-- | noncore/applets/zkbapplet/zkbwidget.cpp | 11 |
10 files changed, 51 insertions, 50 deletions
diff --git a/noncore/applets/autorotateapplet/autorotate.cpp b/noncore/applets/autorotateapplet/autorotate.cpp index 94be0ae..ae7fbd0 100644 --- a/noncore/applets/autorotateapplet/autorotate.cpp +++ b/noncore/applets/autorotateapplet/autorotate.cpp @@ -1,101 +1,97 @@ /* * copyright : (c) 2003 by Greg Gilbert * email : greg@treke.net * based on the cardmon applet by Max Reiss * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************/ #include "autorotate.h" /* OPIE */ #include <opie2/odevice.h> #include <opie2/otaskbarapplet.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/resource.h> /* QT */ #include <qpainter.h> -using namespace Opie; - +using namespace Opie::Ui; AutoRotate::AutoRotate(QWidget * parent):QWidget(parent) { setFixedWidth( AppLnk::smallIconSize() ); setFixedHeight( AppLnk::smallIconSize() ); enabledPm.convertFromImage( Resource::loadImage("autorotate/rotate").smoothScale( height(), width() ) ); disabledPm.convertFromImage( Resource::loadImage("autorotate/norotate").smoothScale( height(), width() ) ); repaint(true); popupMenu = 0; show(); } AutoRotate::~AutoRotate() { if (popupMenu) { delete popupMenu; } } int AutoRotate::position() { return 7; } void AutoRotate::mousePressEvent(QMouseEvent *) { QPopupMenu *menu = new QPopupMenu(this); menu->insertItem( isRotateEnabled()? "Disable Rotation" : "Enable Rotation" ,1 ); QPoint p = mapToGlobal(QPoint(0, 0)); QSize s = menu->sizeHint(); int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), p.y() - s.height()), 0); if (opt==1) { setRotateEnabled( !isRotateEnabled() ); repaint(true); } delete menu; } void AutoRotate::paintEvent(QPaintEvent *) { QPainter p(this); p.drawPixmap( 0, 0, isRotateEnabled()? enabledPm : disabledPm ); } void AutoRotate::setRotateEnabled(bool status) { Config cfg( "qpe" ); cfg.setGroup( "Appearance" ); cfg.writeEntry( "rotateEnabled", status ); } bool AutoRotate::isRotateEnabled() { Config cfg( "qpe" ); cfg.setGroup( "Appearance" ); bool res = cfg.readBoolEntry( "rotateEnabled" ); if (res ) qDebug("Enabled"); else qDebug("Disabled"); return res; } -Q_EXPORT_INTERFACE() -{ - Q_CREATE_INSTANCE( OTaskbarAppletWrapper<AutoRotate> ); -} +EXPORT_OPIE_APPLET_v1( AutoRotate ) diff --git a/noncore/applets/memoryapplet/memorymeter.cpp b/noncore/applets/memoryapplet/memorymeter.cpp index 9299f49..9cdeaf4 100644 --- a/noncore/applets/memoryapplet/memorymeter.cpp +++ b/noncore/applets/memoryapplet/memorymeter.cpp @@ -1,155 +1,156 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "memorymeter.h" #include "memorystatus.h" #include <opie2/otaskbarapplet.h> #include <qtopia/power.h> #include <qtopia/config.h> #include <qtopia/qcopenvelope_qws.h> #include <qpainter.h> #include <qtimer.h> #include <qapplication.h> #include <qtopia/applnk.h> +using namespace Opie::Ui; MemoryMeter::MemoryMeter( QWidget *parent ) : QWidget( parent ), memoryView(0) { bvsz = QSize(); - if ( qApp->desktop()->height() >= 300 ) + if ( qApp->desktop()->height() >= 300 ) { memoryView = new MemoryStatus( 0, WStyle_StaysOnTop | WType_Popup ); memoryView->setFrameStyle( QFrame::Panel | QFrame::Raised ); - } - else + } + else { memoryView = new MemoryStatus( 0 ); memoryView->showMaximized(); } Config config("MemoryPlugin"); config.setGroup("Warning levels"); low = config.readNumEntry("low", 40); critical = config.readNumEntry("critical", 20); startTimer( 10000 ); setFixedWidth(10); setFixedHeight(AppLnk::smallIconSize()); usageTimer = new QTimer( this ); connect( usageTimer, SIGNAL(timeout()), this, SLOT(usageTimeout()) ); timerEvent(0); } MemoryMeter::~MemoryMeter() { delete (QWidget *) memoryView; } int MemoryMeter::position() { return 7; } QSize MemoryMeter::sizeHint() const { return QSize(10, AppLnk::smallIconSize()); } bool MemoryMeter::updateMemoryViewGeometry() { if (memoryView != 0) { QSize sz = memoryView->sizeHint(); - if ( sz != bvsz ) + if ( sz != bvsz ) { bvsz = sz; QRect r(memoryView->pos(), memoryView->sizeHint()); - if ( qApp->desktop()->height() >= 300 ) + if ( qApp->desktop()->height() >= 300 ) { QPoint curPos = mapToGlobal( rect().topLeft() ); int lp = qApp->desktop()->width() - memoryView->sizeHint().width(); r.moveTopLeft( QPoint(lp, curPos.y() - memoryView->sizeHint().height()-1) ); } memoryView->setGeometry(r); return TRUE; } return FALSE; } return FALSE; } void MemoryMeter::mousePressEvent( QMouseEvent *) { - if ( memoryView->isVisible() ) + if ( memoryView->isVisible() ) { memoryView->hide(); - } - else + } + else { bvsz = QSize(); updateMemoryViewGeometry(); memoryView->raise(); memoryView->show(); } } void MemoryMeter::timerEvent( QTimerEvent * ) { if (memoryView != 0) { // read memory status percent = (memoryView->percent()); usageTimer->start( 1000 ); } } void MemoryMeter::usageTimeout() { if (memoryView != 0) { percent = (memoryView->percent()); if (updateMemoryViewGeometry() && memoryView->isVisible()) { memoryView->hide(); memoryView->show(); } repaint(FALSE); } } void MemoryMeter::paintEvent( QPaintEvent* ) { QPainter p(this); QColor c; QColor darkc; QColor lightc; if (percent > low) c = green; else if (percent > critical) c = yellow.dark(110); else c = red; @@ -161,87 +162,84 @@ void MemoryMeter::paintEvent( QPaintEvent* ) // to right, these are: medium, light, medium, dark. To avoid // hardcoding values for band "width", figure everything out on the run. // int batt_width; // width of each band int batt_height; // memory height (not including terminal) int used_height; // used amount of memory (scanlines) int batt_yoffset; // top of terminal int batt_xoffset; // left edge of core int band_width; // width of colour band int w = QMIN(height(), width()); band_width = (w-2) / 4; if ( band_width < 1 ) band_width = 1; batt_width = 4 * band_width + 2; // +2 for 1 pixel border on both sides batt_height = height()-2; batt_xoffset = (width() - batt_width) / 2; batt_yoffset = (height() - batt_height) / 2; // // Memory border. +1 to make space for the terminal at row 0. // p.setPen(QColor(80, 80, 80)); p.drawRect(batt_xoffset, batt_yoffset + 1, batt_width, batt_height); // // Draw terminal. +1 to take into account the left border. // //p.drawLine(batt_xoffset + band_width + 1, batt_yoffset, batt_xoffset + 3 * band_width, batt_yoffset); batt_height -= 2; // -2 because we don't want to include border batt_yoffset += 2; // +2 to account for border and terminal batt_xoffset++; // // 100 - percent, since percent is amount remaining, and we draw // reverse to this. // used_height = percent * batt_height / 100; if (used_height < 0) used_height = 0; // // Drained section. // - if (used_height != 0) + if (used_height != 0) { p.setPen(NoPen); p.setBrush(gray); p.drawRect(batt_xoffset, batt_yoffset, band_width, used_height); p.drawRect(batt_xoffset + 2 * band_width, batt_yoffset, band_width, used_height); p.setBrush(gray/*.light(130)*/); p.drawRect(batt_xoffset + band_width, batt_yoffset, band_width, used_height); p.setBrush(gray/*.dark(120)*/); p.drawRect(batt_xoffset + 3 * band_width, batt_yoffset, band_width, used_height); } // // Unused section. // - if ( batt_height - used_height > 0 ) + if ( batt_height - used_height > 0 ) { int unused_offset = used_height + batt_yoffset; int unused_height = batt_height - used_height; p.setPen(NoPen); p.setBrush(c); p.drawRect(batt_xoffset, unused_offset, band_width, unused_height); p.drawRect(batt_xoffset + 2 * band_width, unused_offset, band_width, unused_height); p.setBrush(lightc); p.drawRect(batt_xoffset + band_width, unused_offset, band_width, unused_height); p.setBrush(darkc); p.drawRect(batt_xoffset + 3 * band_width, unused_offset, band_width, unused_height); } } -Q_EXPORT_INTERFACE() -{ - Q_CREATE_INSTANCE( OTaskbarAppletWrapper<MemoryMeter> ); -} +EXPORT_OPIE_APPLET_v1( MemoryMeter ) diff --git a/noncore/applets/memoryapplet/memorystatus.cpp b/noncore/applets/memoryapplet/memorystatus.cpp index c01ba28..95ae06b 100644 --- a/noncore/applets/memoryapplet/memorystatus.cpp +++ b/noncore/applets/memoryapplet/memorystatus.cpp @@ -1,78 +1,79 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "memorystatus.h" #include "../../settings/sysinfo/memory.h" #include "swapfile.h" #include <qpainter.h> #include <qpushbutton.h> #include <qdrawutil.h> #include <qlabel.h> #include <qlayout.h> +using namespace Opie::Ui; MemoryStatus::MemoryStatus(QWidget *parent, WFlags f ) : QFrame(parent, 0, f), mi(0), sf(0) { setCaption( tr("Memory Status") ); //resize( 220, 180 ); QVBoxLayout *lay = new QVBoxLayout( this ); tab = new OTabWidget( this, "tabwidget", OTabWidget::Global ); lay->addWidget( tab ); tab->addTab( mi = new MemoryInfo( tab ), "memory/memorytabicon", tr("Memory") ); tab->addTab( sf = new Swapfile( tab ), "memory/storagetabicon", tr("Swapfile") ); QLabel* about = new QLabel(tr("<center><b>Memory Monitor Plugin</b><br>" "Copyright (C) 2003 Anton Maslovsky<br>" "<<a href=\"mailto:my-zaurus@narod.ru\">my-zaurus@narod.ru</a>><br>" "<a href=\"http://my-zaurus.narod.ru\">http://my-zaurus.narod.ru</a><br>" "Based on source code from:<br> qswap (udoseidel@gmx.de) <br> Battery Applet (trolltech.com) <br> SysInfo (OPIE)<br><br>" "This program is licensed under GNU GPL.</center>"), tab); tab->addTab( about, "memory/info", tr("About") ); tab->setCurrentTab( tr( "Memory" ) ); } int MemoryStatus::percent() { if (mi == 0) return 100; int total = mi->total; if (mi->swaptotal > 0) total += mi->swaptotal; int used = mi->realUsed; if (mi->swapused > 0) total += mi->swapused; return ((total - used) * 100)/total; } QSize MemoryStatus::sizeHint() const { QSize s = tab->size(); s.setWidth(200); s.setHeight((mi->swaptotal > 0) ? 220 : 200); return s; } diff --git a/noncore/applets/memoryapplet/memorystatus.h b/noncore/applets/memoryapplet/memorystatus.h index c3926db..d16787b 100644 --- a/noncore/applets/memoryapplet/memorystatus.h +++ b/noncore/applets/memoryapplet/memorystatus.h @@ -1,49 +1,49 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef MEMORY_STATUS_H #define MEMORY_STATUS_H #include <qframe.h> #include <opie2/otabwidget.h> class MemoryInfo; class Swapfile; -using Opie::OTabWidget; + class MemoryStatus : public QFrame { Q_OBJECT public: MemoryStatus(QWidget *parent = 0, WFlags f = 0); ~MemoryStatus(); QSize sizeHint() const; MemoryInfo* mi; Swapfile* sf; int percent(); private: - OTabWidget *tab; + Opie::Ui::OTabWidget *tab; }; #endif diff --git a/noncore/applets/networkapplet/networkapplet.cpp b/noncore/applets/networkapplet/networkapplet.cpp index 955ed2e..5eb5ad2 100644 --- a/noncore/applets/networkapplet/networkapplet.cpp +++ b/noncore/applets/networkapplet/networkapplet.cpp @@ -1,95 +1,97 @@ /* This file is part of the Opie Project =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= 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/resource.h> #include <qpainter.h> /* QT */ #include <qlabel.h> #include <qlayout.h> #include <qobjectlist.h> #include <assert.h> +using namespace Opie::Ui; +using namespace Opie::Net; 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() { _iface->setUp( isOn() ); setOn( _iface->isUp() ); // it might not have worked... repaint(); } IfaceIPAddress::IfaceIPAddress( QWidget* parent, const char* name ) :QLineEdit( parent, name ) { setFont( QFont( "fixed" ) ); _iface = ONetwork::instance()->interface( name ); setFixedWidth( 105 ); setText( _iface->ipV4Address() ); connect( this, SIGNAL( returnPressed() ), this, SLOT( returnPressed() ) ); } IfaceIPAddress::~IfaceIPAddress() { } void IfaceIPAddress::returnPressed() { QHostAddress a; a.setAddress( text() ); @@ -201,54 +203,51 @@ void NetworkAppletControl::hideEvent( QHideEvent* e ) 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 ) { 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, _pixmap ); } void NetworkApplet::mousePressEvent( QMouseEvent* ) { if ( !_control->isVisible() ) { popup( _control ); } else { _control->hide(); } } +EXPORT_OPIE_APPLET_v1( NetworkApplet ) -Q_EXPORT_INTERFACE() -{ - Q_CREATE_INSTANCE( OTaskbarAppletWrapper<NetworkApplet> ); -} diff --git a/noncore/applets/networkapplet/networkapplet.h b/noncore/applets/networkapplet/networkapplet.h index 8022537..1e2cac8 100644 --- a/noncore/applets/networkapplet/networkapplet.h +++ b/noncore/applets/networkapplet/networkapplet.h @@ -1,114 +1,120 @@ /* This file is part of the Opie Project =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= 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. */ #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; + +namespace Opie { +namespace Net { + class ONetwork; + 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; + Opie::Net::ONetworkInterface* _iface; }; class IfaceIPAddress : public QLineEdit { Q_OBJECT public: IfaceIPAddress( QWidget* parent, const char* name ); virtual ~IfaceIPAddress(); public slots: virtual void returnPressed(); private: - ONetworkInterface* _iface; + Opie::Net::ONetworkInterface* _iface; }; class NetworkAppletControl : public QFrame { public: - NetworkAppletControl( OTaskbarApplet* parent, const char* name = 0 ); + NetworkAppletControl( Opie::Ui::OTaskbarApplet* parent, const char* name = 0 ); ~NetworkAppletControl(); virtual QSize sizeHint() const; protected: virtual void showEvent( QShowEvent* ); virtual void hideEvent( QHideEvent* ); - QString guessDevice( ONetworkInterface* iface ); + QString guessDevice( Opie::Net::ONetworkInterface* iface ); void build(); private: QVBoxLayout* l; }; -class NetworkApplet : public OTaskbarApplet +class NetworkApplet : public Opie::Ui::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 diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp index 9b5e475..13f7cf3 100644 --- a/noncore/applets/notesapplet/notes.cpp +++ b/noncore/applets/notesapplet/notes.cpp @@ -1,96 +1,97 @@ /********************************************************************** ** Copyright (C) 2002 L.J. Potter <llornkcor@handhelds.org> ** All rights reserved. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include "notes.h" #include <qapplication.h> #include <stdlib.h> #include <qstringlist.h> #include <opie2/otaskbarapplet.h> #include <qpe/filemanager.h> #include <qpe/qpeapplication.h> #include <qpe/timestring.h> #include <qpe/applnk.h> #include <qpe/ir.h> #include <qpe/config.h> // #include <qsocket.h> // #include <qclipboard.h> #include <qmultilineedit.h> #include <qlistbox.h> #include <qpopupmenu.h> #include <qmessagebox.h> #include <qdir.h> #include <qfile.h> #include <qpoint.h> #include <qpushbutton.h> #include <qpainter.h> #include <qlayout.h> #include <qframe.h> #include <qpixmap.h> #include <qstring.h> #include <qtimer.h> /* XPM */ +using namespace Opie::Ui; static char * notes_xpm[] = { "16 16 11 1", " c None", ". c #000000", "+ c #7F7F7F", "@ c #BFBFBF", "# c #BFC1FF", "$ c #FF0000", "% c #FFFFFF", "& c #00037F", "* c #0006FF", "= c #0005BF", "- c #7F0000", " .. ", " .. ", " ... ", " .+ ", " .@. ", " . .+ ", " ..#.@. ", " ..###.+.. ", " ..###$...##.. ", "..###$$$%+$$##&.", ".*=####$-###&=&.", ".=**=###==&=&=..", " ..=**=#&=&=.. ", " ..=*=&=.. ", " ..=.. ", " . "}; NotesControl::NotesControl( QWidget *, const char * ) : QVBox( 0, "NotesControl",/* WDestructiveClose | */WStyle_StaysOnTop ) // : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) { QDir d( QDir::homeDirPath()+"/notes"); if( !d.exists()) { qDebug("make dir"); if(!d.mkdir( QDir::homeDirPath()+"/notes", true)) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed"); } Config cfg("Notes"); cfg.setGroup("Options"); showMax = cfg.readBoolEntry("ShowMax", false); setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); loaded=false; edited=false; @@ -463,52 +464,51 @@ NotesApplet::NotesApplet( QWidget *parent, const char *name ) vc = new NotesControl; } NotesApplet::~NotesApplet() { delete vc; } int NotesApplet::position() { return 6; } void NotesApplet::mousePressEvent( QMouseEvent *) { if( !vc->isHidden()) { vc->doPopulate=false; vc->save(); vc->close(); } else { // vc = new NotesControl; // QPoint curPos = mapToGlobal( rect().topLeft() ); if(vc->showMax) { qDebug("show max"); vc->showMaximized(); } else { qDebug("no show max"); QWidget *wid = QPEApplication::desktop(); QRect rect = QApplication::desktop()->geometry(); vc->setGeometry( ( wid->width() / 2) - ( vc->width() / 2 ) , 28 , wid->width() -10 , 180); vc->move ( (rect.center()/2) - (vc->rect().center()/2)); // vc->move( (( wid->width() / 2) - ( vc->width() / 2 ))-4, 28); } vc->show(); vc->doPopulate=true; vc->populateBox(); vc->doPopulate=false; vc->loaded=false; vc->load(); // this->setFocus(); vc->view->setFocus(); } } void NotesApplet::paintEvent( QPaintEvent* ) { QPainter p(this); p.drawPixmap( 0, 1, ( const char** ) notes_xpm ); } -Q_EXPORT_INTERFACE() -{ - Q_CREATE_INSTANCE( OTaskbarAppletWrapper<NotesApplet> ); -} + +EXPORT_OPIE_APPLET_v1( NotesApplet ) + diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp index 6ef2e44..f244426 100644 --- a/noncore/applets/wirelessapplet/wireless.cpp +++ b/noncore/applets/wirelessapplet/wireless.cpp @@ -1,98 +1,101 @@ /********************************************************************** ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer <mickey@vanille.de> ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include "wireless.h" #include "mgraph.h" #include "advancedconfig.h" #include "connect0.xpm" #include "connect1.xpm" #include "connect2.xpm" #include "connect3.xpm" #include "connect4.xpm" #include "connect5.xpm" #include "nowireless.xpm" /* OPIE */ #include <opie2/onetwork.h> #include <opie2/otaskbarapplet.h> #include <qpe/config.h> +#include <qpe/qpeapplication.h> /* QT */ #include <qradiobutton.h> #include <qpushbutton.h> #include <qpainter.h> #include <qlabel.h> #include <qslider.h> #include <qbuttongroup.h> #include <qlayout.h> #include <qfile.h> #include <qtextstream.h> /* STD */ #include <sys/types.h> #include <signal.h> #define STYLE_BARS 0 #define STYLE_ANTENNA 1 //#define MDEBUG #undef MDEBUG +using namespace Opie::Ui; +using namespace Opie::Net; WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) { readConfig(); writeConfigEntry( "UpdateFrequency", updateFrequency ); writeConfigEntry( "DisplayStyle", displayStyle ); setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); /* status label */ statusLabel = new QLabel( this, "statuslabel" ); QString text( "Wireless Status:<br>" "*** Unknown ***<br>" "Card not inserted ?<br>" "Or Sharp ROM ?<br>" "CELL: 00:00:00:00:00:00" ); /* QString text( "Station: Unknown<br>" "ESSID: Unknown<br>" "MODE: Unknown<br>" "FREQ: Unknown<br>" "CELL: AA:BB:CC:DD:EE:FF" ); */ statusLabel->setText( text ); statusLabel->setFixedSize( statusLabel->sizeHint() ); grid->addWidget( statusLabel, 0, 0 ); /* visualization group box */ QButtonGroup* group = new QButtonGroup( 1, Qt::Horizontal, "Visualization", this ); QRadioButton* r1 = new QRadioButton( "Color Bars", group ); QRadioButton* r2 = new QRadioButton( "Antenna", group ); r1->setFocusPolicy( QWidget::NoFocus ); r2->setFocusPolicy( QWidget::NoFocus ); group->setFocusPolicy( QWidget::NoFocus ); group->setButton( displayStyle ); grid->addWidget( group, 0, 1 ); /* quality graph */ mgraph = new MGraph( this ); mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); mgraph->setMin( 0 ); mgraph->setMax( 92 ); grid->addWidget( mgraph, 1, 0 ); mgraph->setFocusPolicy( QWidget::NoFocus ); @@ -505,54 +508,50 @@ void WirelessApplet::paintEvent( QPaintEvent* ) int Hue; int barSpace = 3; int leftoffset = 0; int bottomoffset = 2; // draw noise indicator pixelHeight = noiseH; Hue = 50; for ( int i = 0; i < pixelHeight; ++i ) { intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205; color.setHsv( Hue, 255, intensity ); p.setPen ( color ); p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i ); } // draw signal indicator pixelHeight = signalH; Hue = 100; leftoffset += pixelWidth + barSpace; for ( int i = 0; i < pixelHeight; ++i ) { intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205; color.setHsv( Hue, 255, intensity ); p.setPen ( color ); p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i ); } // draw quality indicator pixelHeight = qualityH; Hue = 250; leftoffset += pixelWidth + barSpace; for ( int i = 0; i < pixelHeight; ++i ) { intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205; color.setHsv( Hue, 255, intensity ); p.setPen ( color ); p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i ); } } } int WirelessApplet::position() { return 6; } - -Q_EXPORT_INTERFACE() -{ - Q_CREATE_INSTANCE( OTaskbarAppletWrapper<WirelessApplet> ); -} +EXPORT_OPIE_APPLET_v1( WirelessApplet ) diff --git a/noncore/applets/wirelessapplet/wireless.h b/noncore/applets/wirelessapplet/wireless.h index 27f8c90..b475a46 100644 --- a/noncore/applets/wirelessapplet/wireless.h +++ b/noncore/applets/wirelessapplet/wireless.h @@ -1,110 +1,113 @@ /********************************************************************** ** Copyright (C) 2002 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> ** All rights reserved. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #ifndef __WIRELESS_APPLET_H__ #define __WIRELESS_APPLET_H__ #include <qwidget.h> #include <qframe.h> #include <qpixmap.h> -class OWirelessNetworkInterface; +namespace Opie {namespace Net { + class OWirelessNetworkInterface; +} +} class Y; class QLabel; class WirelessApplet; class MGraph; class WirelessControl : public QFrame { Q_OBJECT public: WirelessControl( WirelessApplet* icon, QWidget *parent=0, const char *name=0 ); void show( bool ); void readConfig(); void writeConfigEntry( const char* entry, int val ); MGraph* mgraph; QLabel* statusLabel; QLabel* updateLabel; public slots: void updateDelayChange( int ); void displayStyleChange( int ); void advancedConfigClicked(); private: WirelessApplet* applet; int displayStyle; int updateFrequency; bool rocESSID; bool rocFREQ; bool rocAP; bool rocMODE; }; class WirelessApplet : public QWidget { Q_OBJECT public: WirelessApplet( QWidget *parent = 0, const char *name=0 ); ~WirelessApplet(); static int position(); WirelessControl* status; virtual void timerEvent( QTimerEvent* ); void updateDelayChange( int delay ); void displayStyleChange( int style ); void updateDHCPConfig( bool, bool, bool, bool ); private: void mousePressEvent( QMouseEvent * ); void paintEvent( QPaintEvent* ); void checkInterface(); void renewDHCP(); bool mustRepaint(); void updatePopupWindow(); const char** getQualityPixmap(); private: QPixmap snapshotPixmap; int visualStyle; int timer; - OWirelessNetworkInterface* interface; + Opie::Net::OWirelessNetworkInterface* interface; private: const char** oldpixmap; - OWirelessNetworkInterface* oldiface; + Opie::Net::OWirelessNetworkInterface* oldiface; int oldqualityH; int oldsignalH; int oldnoiseH; QString oldESSID; QString oldAP; QString oldMODE; double oldFREQ; bool rocESSID; bool rocFREQ; bool rocAP; bool rocMODE; }; #endif // __WIRELESS_APPLET_H__ diff --git a/noncore/applets/zkbapplet/zkbwidget.cpp b/noncore/applets/zkbapplet/zkbwidget.cpp index 0083e9b..3acff1e 100644 --- a/noncore/applets/zkbapplet/zkbwidget.cpp +++ b/noncore/applets/zkbapplet/zkbwidget.cpp @@ -1,162 +1,161 @@ #include <opie2/otaskbarapplet.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/applnk.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <stdio.h> #include <unistd.h> #include "zkbwidget.h" #include "zkbcfg.h" +using namespace Opie::Ui; ZkbWidget::ZkbWidget(QWidget* parent):QLabel(parent),keymap(0), disabled(Resource::loadPixmap("zkb-disabled")) { labels = new QPopupMenu(); - connect(labels, SIGNAL(activated(int)), this, + connect(labels, SIGNAL(activated(int)), this, SLOT(labelChanged(int))); loadKeymap(); channel = new QCopChannel("QPE/zkb", this); connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(signalReceived(const QCString&,const QByteArray&))); setFixedWidth ( AppLnk::smallIconSize() ); setFixedHeight ( AppLnk::smallIconSize() ); } ZkbWidget::~ZkbWidget() { } int ZkbWidget::position() { return 8; } bool ZkbWidget::loadKeymap() { ZkbConfig c(QPEApplication::qpeDir()+"/share/zkb"); QFontMetrics fm(font()); if (keymap != 0) { delete keymap; keymap = 0; } Keymap* km = new Keymap(); if (!c.load("zkb.xml", *km, "")) { delete km; setPixmap(disabled); return false; } connect(km, SIGNAL(stateChanged(const QString&)), this, SLOT(stateChanged(const QString&))); qwsServer->setKeyboardFilter(km); Keymap* oldkm = keymap; keymap = km; if (oldkm != 0) { delete oldkm; } setText(keymap->getCurrentLabel()); labels->clear(); QStringList l = keymap->listLabels(); labels->insertItem(disabled, 0, 0); int n = 1; w = 0; - for(QStringList::Iterator it = l.begin(); it != l.end(); + for(QStringList::Iterator it = l.begin(); it != l.end(); ++it, n++) { // printf("label: %s\n", (const char*) (*it).utf8()); labels->insertItem(*it, n, n); int lw = fm.width(*it); if (lw > w) { w = lw; } } if (w == 0) { hide(); } else { show(); } return true; } QSize ZkbWidget::sizeHint() const { return QSize(AppLnk::smallIconSize(),AppLnk::smallIconSize()); } void ZkbWidget::stateChanged(const QString& s) { // qDebug("stateChanged: %s\n", (const char*) s.utf8()); setText(s); } void ZkbWidget::labelChanged(int id) { if (id == 0) { keymap->disable(); setPixmap(disabled); return; } keymap->enable(); QStringList l = keymap->listLabels(); QString lbl = l[id-1]; // printf("labelChanged: %s\n", (const char*) lbl.utf8()); State* state = keymap->getStateByLabel(lbl); if (state != 0) { keymap->setCurrentState(state); setText(lbl); } } void ZkbWidget::mouseReleaseEvent(QMouseEvent*) { QSize sh = labels->sizeHint(); QPoint p = mapToGlobal(QPoint((width()-sh.width())/2,-sh.height())); labels->exec(p); } void ZkbWidget::signalReceived(const QCString& msg, const QByteArray& data) { QDataStream stream(data, IO_ReadOnly); if (msg == "enable()") { keymap->enable(); } else if (msg == "disable()") { keymap->disable(); } else if (msg == "reload()") { QCopEnvelope("QPE/System", "busy()"); QTimer::singleShot(0, this, SLOT(reload())); } else if (msg == "switch(QString)") { QString lbl; stream >> lbl; if (keymap != 0) { State* state = keymap->getStateByLabel(lbl); if (state != 0) { keymap->setCurrentState(state); setText(lbl); } } } else if (msg == "debug(QString)") { QString flag; stream >> flag; } } void ZkbWidget::reload() { loadKeymap(); QCopEnvelope("QPE/System", "notBusy()"); } -Q_EXPORT_INTERFACE() -{ - Q_CREATE_INSTANCE( OTaskbarAppletWrapper<ZkbWidget> ); -} +EXPORT_OPIE_APPLET_v1( ZkbWidget ) + |