summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/opietooth2_applet
authorwimpie <wimpie>2005-01-04 01:43:13 (UTC)
committer wimpie <wimpie>2005-01-04 01:43:13 (UTC)
commitb65cbb7c8b45d57f849722d22f8f165cc202ceb5 (patch) (unidiff)
tree12634fa9f91357b1da501634d8c6d8072bde0ba6 /noncore/settings/networksettings2/opietooth2_applet
parent2487b0a05f502e7410715460f390cc80e7e76fd9 (diff)
downloadopie-b65cbb7c8b45d57f849722d22f8f165cc202ceb5.zip
opie-b65cbb7c8b45d57f849722d22f8f165cc202ceb5.tar.gz
opie-b65cbb7c8b45d57f849722d22f8f165cc202ceb5.tar.bz2
New OPietooth bluetooth applet
Diffstat (limited to 'noncore/settings/networksettings2/opietooth2_applet') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/opietooth2_applet/config.in4
-rw-r--r--noncore/settings/networksettings2/opietooth2_applet/opie-bluetoothapplet.control10
-rw-r--r--noncore/settings/networksettings2/opietooth2_applet/opietooth2_applet.pro12
-rw-r--r--noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.cpp241
-rw-r--r--noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.h99
-rw-r--r--noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.cpp72
-rw-r--r--noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.h55
7 files changed, 493 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/opietooth2_applet/config.in b/noncore/settings/networksettings2/opietooth2_applet/config.in
new file mode 100644
index 0000000..b60b01c
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2_applet/config.in
@@ -0,0 +1,4 @@
1 config NS2OPIETOOTHAPPLET
2 boolean "opietooth2 bluetooth applet"
3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2OPIETOOTH
diff --git a/noncore/settings/networksettings2/opietooth2_applet/opie-bluetoothapplet.control b/noncore/settings/networksettings2/opietooth2_applet/opie-bluetoothapplet.control
new file mode 100644
index 0000000..ed13081
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2_applet/opie-bluetoothapplet.control
@@ -0,0 +1,10 @@
1Package: opie-opietooth2applet
2Files: plugins/applets/libopietooth2applet.so*
3Priority: optional
4Section: opie/applets
5Maintainer: Maximilian Reiss <max.reiss@gmx.de>
6Architecture: arm
7Depends: task-opie-minimal, libopietooth2
8Description: Bluetooth Applet
9 An bluetooth taskbar applet for the Opie environment using opietooth2
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/settings/networksettings2/opietooth2_applet/opietooth2_applet.pro b/noncore/settings/networksettings2/opietooth2_applet/opietooth2_applet.pro
new file mode 100644
index 0000000..90422c8
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2_applet/opietooth2_applet.pro
@@ -0,0 +1,12 @@
1TEMPLATE = lib
2CONFIG += qt plugin warn_on
3HEADERS = opietoothapplet.h opietoothappletimpl.h
4SOURCES = opietoothapplet.cpp opietoothappletimpl.cpp
5TARGET = opietooth2applet
6DESTDIR = $(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include ../opietooth2
8DEPENDPATH += $(OPIEDIR)/include ../opietooth2
9LIBS += -lqpe -lopietooth2
10VERSION = 0.0.3
11
12include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.cpp b/noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.cpp
new file mode 100644
index 0000000..e419942
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.cpp
@@ -0,0 +1,241 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can
6.> <,   >  .   <= redistribute it and/or modify it under
7:=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29
30#include <qapplication.h>
31
32#include <qpe/qcopenvelope_qws.h>
33#include <qpe/config.h>
34
35#include <qpoint.h>
36#include <qpainter.h>
37#include <qlayout.h>
38#include <qframe.h>
39#include <qpixmap.h>
40#include <qstring.h>
41#include <qpopupmenu.h>
42
43#include <OTGateway.h>
44#include <OTIcons.h>
45#include <opietoothapplet.h>
46
47namespace Opietooth2 {
48
49//
50//
51// Panel
52//
53//
54
55MessagePanel::MessagePanel( const QString & Msg,
56 QWidget* parent, const char* name ):
57 QLabel( parent, name, WType_Popup ){
58
59 QLabel * L = new QLabel( Msg, this );
60 L->setAlignment( Qt::WordBreak | Qt::AlignCenter );
61
62 QVBoxLayout * VL = new QVBoxLayout( this );
63 VL->addWidget( this );
64 VL->setMargin( 3 );
65
66 setFrameStyle( WinPanel|Raised );
67 setAlignment( AlignCenter );
68
69 resize(150,100);
70
71 moves = 0;
72}
73
74void MessagePanel::mouseReleaseEvent( QMouseEvent * e){
75
76 if (rect().contains( e->pos() ) || moves > 5)
77 close();
78}
79
80void MessagePanel::closeEvent( QCloseEvent *e ){
81
82 e->accept();
83
84 moves = 0;
85
86 if (!popupParent)
87 return;
88
89 /*
90 remember that we (as a popup) might recieve the mouse
91 release event instead of the popupParent. This is due to
92 the fact that the popupParent popped us up in its
93 mousePressEvent handler. To avoid the button remaining in
94 pressed state we simply send a faked mouse button release
95 event to it.
96 */
97
98 QMouseEvent me( QEvent::MouseButtonRelease,
99 QPoint(0,0),
100 QPoint(0,0),
101 QMouseEvent::LeftButton,
102 QMouseEvent::NoButton);
103 QApplication::sendEvent( popupParent, &me );
104}
105
106void MessagePanel::popup( QWidget* parent) {
107
108 popupParent = parent;
109
110 if (popupParent)
111 move( popupParent->mapToGlobal(
112 popupParent->rect().bottomLeft() )
113 );
114 show();
115}
116
117
118//
119//
120// Applet code
121//
122//
123
124Opietooth2Applet::Opietooth2Applet( QWidget *parent, const char *name ) : QWidget( parent, name ) {
125 OTIcons Ic;
126 setFixedHeight( 18 );
127 setFixedWidth( 14 );
128
129 OT = OTGateway::getOTGateway();
130
131 OnP = Ic.loadPixmap( "bluezon" );
132 OffP = Ic.loadPixmap( "bluezoff" );
133
134 // sent when bluetooth on device is enabled/disabled
135 connect( OT,
136 SIGNAL( deviceEnabled( bool ) ),
137 this,
138 SLOT( SLOT_StateChange( bool ) ) );
139
140 // sent when error
141 connect( OT,
142 SIGNAL( error( const QString & ) ),
143 this,
144 SLOT( SLOT_Error( const QString & ) ) );
145}
146
147Opietooth2Applet::~Opietooth2Applet() {
148 OTGateway::releaseOTGateway();
149}
150
151void Opietooth2Applet::mousePressEvent( QMouseEvent *) {
152
153 QPopupMenu *menu = new QPopupMenu();
154 // QPopupMenu *signal = new QPopupMenu();
155 int ret=0;
156
157 /* Refresh active state */
158 menu->insertItem( ( (OT->isEnabled()) ?
159 tr("Disable") :
160 tr("Enable")
161 ),
162 1 );
163 menu->insertItem( tr("Launch manager"), 2 );
164
165 //menu->insertItem( tr("Signal strength"), signal, 5);
166 //menu->insertSeparator(8);
167
168 /*
169 menu->insertItem( ( (DiscoveryActive) ?
170 tr("Disable discovery") :
171 tr("Enable discovery")
172 ),
173 3 );
174 */
175
176 QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) );
177
178 ret = menu->exec(p, 0);
179
180 switch(ret) {
181 case 1:
182 // toggle enabling of BT
183 OT->SLOT_SetEnabled( ! OT->isEnabled() );
184 break;
185 case 2:
186 // start bluetoothmanager
187 launchManager();
188 break;
189 //case 3:
190 // DiscoveryActive = 1 - DiscoveryActive;
191 // setDiscoveryStatus( DiscoveryActive );
192 // break;
193 // case 7:
194 // With table of currently-detected devices.
195 }
196 // delete signal;
197 delete menu;
198}
199
200
201void Opietooth2Applet::SLOT_Error( const QString & S ) {
202 MessagePanel * MP = new MessagePanel( S );
203
204 QPoint p = mapToGlobal(
205 QPoint(1, - MP->sizeHint().height()-1) );
206 MP->move( p );
207
208 MP->popup( 0 );
209 delete MP;
210}
211
212/**
213* Launches the bluetooth manager
214*/
215void Opietooth2Applet::launchManager() {
216 QCopEnvelope e("QPE/System", "execute(QString)");
217 e << QString("networksettings2-opietooth");
218}
219
220void Opietooth2Applet::SLOT_StateChange( bool ) {
221 // changed
222
223 // trigger painting
224 update();
225}
226
227/**
228* Implementation of the paint event
229* @param the QPaintEvent
230*/
231void Opietooth2Applet::paintEvent( QPaintEvent* ) {
232 QPainter p(this);
233
234 p.drawPixmap( 0, 1, (( OT->isEnabled() ) ? OnP : OffP) );
235}
236
237//
238// end of namespace
239//
240
241};
diff --git a/noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.h b/noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.h
new file mode 100644
index 0000000..92ae612
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.h
@@ -0,0 +1,99 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can
6.> <,   >  .   <= redistribute it and/or modify it under
7:=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef __OPIETOOTH2APPLET_H__
30#define __OPIETOOTH2APPLET_H__
31
32#include <qwidget.h>
33#include <qpixmap.h>
34#include <qlabel.h>
35#include <qtimer.h>
36
37namespace Opietooth2 {
38
39class OTGateway;
40
41class MessagePanel : public QLabel {
42
43 Q_OBJECT
44
45public:
46
47 MessagePanel( const QString & Msg,
48 QWidget* parent = 0,
49 const char* name=0);
50
51 void popup( QWidget* parent = 0);
52
53protected:
54
55 virtual void mouseReleaseEvent( QMouseEvent * );
56 virtual void closeEvent( QCloseEvent * );
57
58private:
59
60 QWidget* popupParent;
61 int moves;
62
63};
64
65class Opietooth2Applet : public QWidget {
66
67 Q_OBJECT
68
69public:
70
71 Opietooth2Applet( QWidget *parent = 0, const char *name=0 );
72 ~Opietooth2Applet();
73
74public slots:
75
76 // sent when device changes state
77 void SLOT_StateChange( bool );
78 void SLOT_Error( const QString & );
79
80private:
81
82 void mousePressEvent( QMouseEvent * );
83 void paintEvent( QPaintEvent* );
84
85 void launchManager();
86
87private:
88
89 OTGateway * OT;
90 QPixmap OnP;
91 QPixmap OffP;
92
93};
94
95};
96
97
98#endif
99
diff --git a/noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.cpp b/noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.cpp
new file mode 100644
index 0000000..f9cee4d
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.cpp
@@ -0,0 +1,72 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can
6.> <,   >  .   <= redistribute it and/or modify it under
7:=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include "opietoothapplet.h"
30#include "opietoothappletimpl.h"
31
32namespace Opietooth2 {
33
34 BluezAppletImpl::BluezAppletImpl() : bluetooth(0), ref(0) {
35 }
36
37 BluezAppletImpl::~BluezAppletImpl() {
38 delete bluetooth;
39 }
40
41 QWidget *BluezAppletImpl::applet( QWidget *parent ) {
42 if ( !bluetooth ) {
43 bluetooth = new Opietooth2Applet( parent );
44 }
45 return bluetooth;
46 }
47
48 int BluezAppletImpl::position() const {
49 return 6;
50 }
51
52 QRESULT BluezAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) {
53 *iface = 0;
54 if ( uuid == IID_QUnknown ) {
55 *iface = this;
56 } else if ( uuid == IID_TaskbarApplet ) {
57 *iface = this;
58 }
59
60 if ( *iface ) {
61 (*iface)->addRef();
62 }
63 return QS_OK;
64 }
65
66 Q_EXPORT_INTERFACE() {
67 Q_CREATE_INSTANCE( BluezAppletImpl )
68 }
69
70};
71
72
diff --git a/noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.h b/noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.h
new file mode 100644
index 0000000..8a4d9ab
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.h
@@ -0,0 +1,55 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can
6.> <,   >  .   <= redistribute it and/or modify it under
7:=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef OPIETOOTH2APPLETIMPL_H
30#define OPIETOOTH2APPLETIMPL_H
31
32#include <qpe/taskbarappletinterface.h>
33
34namespace Opietooth2 {
35
36 class Opietooth2Applet;
37
38 class BluezAppletImpl : public TaskbarAppletInterface {
39 public:
40 BluezAppletImpl();
41 virtual ~BluezAppletImpl();
42
43 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
44 Q_REFCOUNT
45
46 virtual QWidget *applet( QWidget *parent );
47 virtual int position() const;
48
49 private:
50 Opietooth2Applet *bluetooth;
51 ulong ref;
52 };
53};
54
55#endif