-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 15 | ||||
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.h | 4 |
2 files changed, 12 insertions, 7 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp index 94e29c7..8bb7a93 100644 --- a/noncore/net/opietooth/applet/bluezapplet.cpp +++ b/noncore/net/opietooth/applet/bluezapplet.cpp @@ -49,41 +49,41 @@ 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; } BluezApplet::~BluezApplet() { } - int BluezApplet::checkBluezStatus() { + bool BluezApplet::checkBluezStatus() { if (btDevice) { if (btDevice->isLoaded() ) { - return 1; + return true; } else { - return 0; + return false; } } else { - return 0; + 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; } @@ -115,70 +115,75 @@ namespace OpieTooth { 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); break; case 1: setBluezStatus(1); + timerEvent(NULL); break; case 2: // start bluetoothmanager launchManager(); + timerEvent(NULL); break; case 3: setBluezDiscoveryStatus(0); + timerEvent(NULL); break; case 4: setBluezDiscoveryStatus(1); + timerEvent(NULL); 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 * ) { - int oldactive = bluezactive; + bool oldactive = bluezactive; int olddiscovery = bluezDiscoveryActive; bluezactive = checkBluezStatus(); bluezDiscoveryActive = checkBluezDiscoveryStatus(); if ((bluezactive != oldactive) || (bluezDiscoveryActive != olddiscovery)) { paintEvent(NULL); } } /** * Implementation of the paint event * @param the QPaintEvent */ void BluezApplet::paintEvent( QPaintEvent* ) { QPainter p(this); diff --git a/noncore/net/opietooth/applet/bluezapplet.h b/noncore/net/opietooth/applet/bluezapplet.h index da05a18..6a8a00e 100644 --- a/noncore/net/opietooth/applet/bluezapplet.h +++ b/noncore/net/opietooth/applet/bluezapplet.h @@ -37,39 +37,39 @@ 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(); - int checkBluezStatus(); + bool checkBluezStatus(); int setBluezStatus(int); int checkBluezDiscoveryStatus(); int setBluezDiscoveryStatus(int); int sockfd; private: Device* btDevice; QPixmap bluezOnPixmap; QPixmap bluezOffPixmap; QPixmap bluezDiscoveryOnPixmap; - int bluezactive; + bool bluezactive; int bluezDiscoveryActive; private slots: }; }; #endif |