summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pyquicklaunch/pyquicklaunch.cpp64
-rw-r--r--noncore/applets/pyquicklaunch/pyquicklaunch.h15
2 files changed, 68 insertions, 11 deletions
diff --git a/noncore/applets/pyquicklaunch/pyquicklaunch.cpp b/noncore/applets/pyquicklaunch/pyquicklaunch.cpp
index 2ee8e17..bcd2f0d 100644
--- a/noncore/applets/pyquicklaunch/pyquicklaunch.cpp
+++ b/noncore/applets/pyquicklaunch/pyquicklaunch.cpp
@@ -19,4 +19,5 @@
#include <opie2/otaskbarapplet.h>
-#include <qpe/qpeapplication.h>
#include <qpe/config.h>
+#include <qpe/qpeapplication.h>
+#include <qpe/resource.h>
using namespace Opie::Core;
@@ -24,4 +25,12 @@ using namespace Opie::Core;
/* QT */
+#include <qcopchannel_qws.h>
#include <qpainter.h>
#include <qframe.h>
+#include <qfile.h>
+#include <qtimer.h>
+
+/* STD */
+#include <pwd.h>
+#include <sys/types.h>
+#include <unistd.h>
@@ -69,3 +78,3 @@ void PyQuicklaunchControl::writeConfigEntry( const char *entry, int val )
PyQuicklaunchApplet::PyQuicklaunchApplet( QWidget *parent, const char *name )
- : QWidget( parent, name )
+ : QWidget( parent, name ), online( false )
{
@@ -74,2 +83,14 @@ PyQuicklaunchApplet::PyQuicklaunchApplet( QWidget *parent, const char *name )
status = new PyQuicklaunchControl( this, this, "Python Quicklaunch Status" );
+
+ _online = Resource::loadPixmap( "pyquicklaunch/online" );
+ _offline = Resource::loadPixmap( "pyquicklaunch/offline" );
+
+ _fifoName = QString().sprintf( "/tmp/mickeys-quicklauncher-%s", ::getpwuid( ::getuid() )->pw_name );
+ odebug << "PyQuicklaunchApplet fifo name = '" << _fifoName << "'" << oendl;
+ _fifo.setName( _fifoName );
+
+ _control = new QCopChannel( "QPE/PyLauncher", parent, "PyLauncher QCop Control Channel" );
+ connect( _control, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(receivedMessage(const QCString&,const QByteArray&) ) );
+
}
@@ -78,3 +99,25 @@ PyQuicklaunchApplet::PyQuicklaunchApplet( QWidget *parent, const char *name )
PyQuicklaunchApplet::~PyQuicklaunchApplet()
-{}
+{
+}
+
+
+void PyQuicklaunchApplet::receivedMessage( const QCString& msg, const QByteArray& data )
+{
+ odebug << "receivedMessage = '" << msg << "' " << oendl;
+
+ if ( msg == "setOnline()" )
+ {
+ online = true;
+ repaint( true );
+ }
+ else if ( msg == "setOffline()" )
+ {
+ online = false;
+ repaint( true );
+ }
+ else
+ {
+ odebug << "unknown command." << oendl;
+ }
+}
@@ -83,5 +126,11 @@ void PyQuicklaunchApplet::timerEvent( QTimerEvent* )
{
- // FIXME
+ bool nowOnline = _fifo.exists();
+ if ( nowOnline != online )
+ {
+ online = nowOnline;
+ repaint( true );
+ }
}
+
void PyQuicklaunchApplet::mousePressEvent( QMouseEvent * )
@@ -91,2 +140,3 @@ void PyQuicklaunchApplet::mousePressEvent( QMouseEvent * )
+
void PyQuicklaunchApplet::paintEvent( QPaintEvent* )
@@ -94,7 +144,3 @@ void PyQuicklaunchApplet::paintEvent( QPaintEvent* )
QPainter p( this );
- int h = height();
- int w = width();
-
- // FIXME
-
+ p.drawPixmap( 0, 2, online ? _online : _offline );
}
diff --git a/noncore/applets/pyquicklaunch/pyquicklaunch.h b/noncore/applets/pyquicklaunch/pyquicklaunch.h
index e99f780..f108b43 100644
--- a/noncore/applets/pyquicklaunch/pyquicklaunch.h
+++ b/noncore/applets/pyquicklaunch/pyquicklaunch.h
@@ -18,2 +18,3 @@
#include <qwidget.h>
+#include <qfile.h>
#include <qframe.h>
@@ -22,2 +23,3 @@
class PyQuicklaunchApplet;
+class QCopChannel;
@@ -33,4 +35,2 @@ class PyQuicklaunchControl : public QFrame
- public slots:
-
private:
@@ -49,2 +49,6 @@ class PyQuicklaunchApplet : public QWidget
virtual void timerEvent( QTimerEvent* );
+ bool online;
+
+ public slots:
+ void receivedMessage( const QCString & msg, const QByteArray & data );
@@ -53,2 +57,9 @@ class PyQuicklaunchApplet : public QWidget
virtual void paintEvent( QPaintEvent* );
+
+ private:
+ QCopChannel* _control;
+ QFile _fifo;
+ QString _fifoName;
+ QPixmap _online;
+ QPixmap _offline;
};