summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-06-27 13:04:38 (UTC)
committer harlekin <harlekin>2002-06-27 13:04:38 (UTC)
commit540fd6a4a7cc86070c94f41833c4b9b9fa0e9824 (patch) (side-by-side diff)
tree821cc0443c0a24fd19329791121cef625910cb72
parent56d22ac17fdc194a20fd0deba673943f85e940ea (diff)
downloadopie-540fd6a4a7cc86070c94f41833c4b9b9fa0e9824.zip
opie-540fd6a4a7cc86070c94f41833c4b9b9fa0e9824.tar.gz
opie-540fd6a4a7cc86070c94f41833c4b9b9fa0e9824.tar.bz2
cleanups
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.cpp19
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.h3
2 files changed, 10 insertions, 12 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp
index 8bb7a93..c0ad246 100644
--- a/noncore/net/opietooth/applet/bluezapplet.cpp
+++ b/noncore/net/opietooth/applet/bluezapplet.cpp
@@ -35,170 +35,169 @@
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpoint.h>
#include <qpainter.h>
#include <qlayout.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qstring.h>
#include <qtimer.h>
#include <qpopupmenu.h>
#include <device.h>
namespace OpieTooth {
BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) {
setFixedHeight( 18 );
setFixedWidth( 14 );
bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" );
bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" );
// bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass" );
startTimer(5000);
btDevice = 0;
+ bluezactive = false;
+ bluezDiscoveryActive = false;
}
BluezApplet::~BluezApplet() {
}
bool BluezApplet::checkBluezStatus() {
if (btDevice) {
if (btDevice->isLoaded() ) {
return true;
} else {
return false;
}
} else {
return false;
}
}
int BluezApplet::setBluezStatus(int c) {
if (c == 1) {
btDevice = new Device("/dev/ttySB0", "csr" );
} else {
if (btDevice) {
delete btDevice;
btDevice = 0;
}
}
return 0;
}
int BluezApplet::checkBluezDiscoveryStatus() {
}
int BluezApplet::setBluezDiscoveryStatus(int d) {
}
void BluezApplet::mousePressEvent( QMouseEvent *) {
QPopupMenu *menu = new QPopupMenu();
QPopupMenu *signal = new QPopupMenu();
int ret=0;
/* Refresh active state */
- timerEvent(NULL);
+ timerEvent( 0 );
if (bluezactive) {
menu->insertItem( tr("Disable Bluetooth"), 0 );
} else {
menu->insertItem( tr("Enable Bluetooth"), 1 );
}
menu->insertItem( tr("Launch manager"), 2 );
menu->insertSeparator(6);
menu->insertItem( tr("Signal strength"), signal, 5);
menu->insertSeparator(8);
if (bluezDiscoveryActive) {
menu->insertItem( tr("Disable discovery"), 3 );
} else {
menu->insertItem( tr("Enable discovery"), 4 );
}
QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) );
ret = menu->exec(p, 0);
switch(ret) {
case 0:
setBluezStatus(0);
- timerEvent(NULL);
+ timerEvent( 0 );
break;
case 1:
setBluezStatus(1);
- timerEvent(NULL);
+ timerEvent( 0 );
break;
case 2:
// start bluetoothmanager
launchManager();
- timerEvent(NULL);
+ timerEvent( 0 );
break;
case 3:
setBluezDiscoveryStatus(0);
- timerEvent(NULL);
+ timerEvent( 0 );
break;
case 4:
setBluezDiscoveryStatus(1);
- timerEvent(NULL);
+ timerEvent(0 );
break;
//case 7:
// With table of currently-detected devices.
}
- timerEvent(NULL);
delete signal;
delete menu;
}
/**
* Launches the bluetooth manager
*/
void BluezApplet::launchManager() {
QCopEnvelope e("QPE/System", "execute(QString)");
e << QString("bluetooth-manager");
}
/**
* Refresh timer
* @param the timer event
*/
void BluezApplet::timerEvent( QTimerEvent * ) {
bool oldactive = bluezactive;
int olddiscovery = bluezDiscoveryActive;
bluezactive = checkBluezStatus();
bluezDiscoveryActive = checkBluezDiscoveryStatus();
if ((bluezactive != oldactive) || (bluezDiscoveryActive != olddiscovery)) {
- paintEvent(NULL);
+ update();
}
}
/**
* Implementation of the paint event
* @param the QPaintEvent
*/
void BluezApplet::paintEvent( QPaintEvent* ) {
QPainter p(this);
qDebug("paint bluetooth pixmap");
- p.eraseRect ( 0, 0, this->width(), this->height() );
-
if (bluezactive > 0) {
p.drawPixmap( 0, 1, bluezOnPixmap );
} else {
p.drawPixmap( 0, 1, bluezOffPixmap );
}
if (bluezDiscoveryActive > 0) {
p.drawPixmap( 0, 1, bluezDiscoveryOnPixmap );
}
}
};
diff --git a/noncore/net/opietooth/applet/bluezapplet.h b/noncore/net/opietooth/applet/bluezapplet.h
index 6a8a00e..a8d91a5 100644
--- a/noncore/net/opietooth/applet/bluezapplet.h
+++ b/noncore/net/opietooth/applet/bluezapplet.h
@@ -33,43 +33,42 @@
#include <qpixmap.h>
#include <qtimer.h>
namespace OpieTooth {
class Device;
class BluezApplet : public QWidget {
Q_OBJECT
public:
BluezApplet( QWidget *parent = 0, const char *name=0 );
~BluezApplet();
protected:
void timerEvent(QTimerEvent *te );
public slots:
private:
void mousePressEvent( QMouseEvent * );
void paintEvent( QPaintEvent* );
void launchManager();
bool checkBluezStatus();
int setBluezStatus(int);
int checkBluezDiscoveryStatus();
int setBluezDiscoveryStatus(int);
- int sockfd;
private:
Device* btDevice;
QPixmap bluezOnPixmap;
QPixmap bluezOffPixmap;
QPixmap bluezDiscoveryOnPixmap;
bool bluezactive;
- int bluezDiscoveryActive;
+ bool bluezDiscoveryActive;
private slots:
};
};
#endif