summaryrefslogtreecommitdiff
path: root/examples/menuapplet
Unidiff
Diffstat (limited to 'examples/menuapplet') (more/less context) (ignore whitespace changes)
-rw-r--r--examples/menuapplet/config.in4
-rw-r--r--examples/menuapplet/example.cpp78
-rw-r--r--examples/menuapplet/example.h33
-rw-r--r--examples/menuapplet/menuapplet.pro12
4 files changed, 127 insertions, 0 deletions
diff --git a/examples/menuapplet/config.in b/examples/menuapplet/config.in
new file mode 100644
index 0000000..f5b4c24
--- a/dev/null
+++ b/examples/menuapplet/config.in
@@ -0,0 +1,4 @@
1 config EXAMPLE_MENU
2 boolean "Menu Applet"
3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE
diff --git a/examples/menuapplet/example.cpp b/examples/menuapplet/example.cpp
new file mode 100644
index 0000000..8ae77da
--- a/dev/null
+++ b/examples/menuapplet/example.cpp
@@ -0,0 +1,78 @@
1#include "example.h"
2
3#include <qpe/applnk.h>
4#include <qpe/resource.h>
5
6/* QT */
7#include <qiconset.h>
8#include <qpopupmenu.h>
9#include <qmessagebox.h>
10
11
12MenuAppletExample::MenuAppletExample()
13 :QObject( 0, "MenuAppletExample" )
14{
15}
16
17MenuAppletExample::~MenuAppletExample ( )
18{}
19
20int MenuAppletExample::position() const
21{
22 return 3;
23}
24
25QString MenuAppletExample::name() const
26{
27 return tr( "MenuApplet Example Name" );
28}
29
30QString MenuAppletExample::text() const
31{
32 return tr( "Click the white rabbit" );
33}
34
35
36QIconSet MenuAppletExample::icon() const
37{
38 QPixmap pix;
39 QImage img = Resource::loadImage( "Tux" );
40 if ( !img.isNull() )
41 pix.convertFromImage( img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
42 return pix;
43}
44
45QPopupMenu* MenuAppletExample::popup(QWidget*) const
46{
47 /* no subdir */
48 return 0;
49}
50
51void MenuAppletExample::activated()
52{
53 QMessageBox::information(0,tr("No white rabbit found"),
54 tr("<qt>No white rabbit was seen near Opie."
55 "Only the beautiful OpieZilla is available"
56 "for your pleassure</qt>"));
57}
58
59
60QRESULT MenuAppletExample::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
61{
62 *iface = 0;
63 if ( uuid == IID_QUnknown )
64 *iface = this;
65 else if ( uuid == IID_MenuApplet )
66 *iface = this;
67 else
68 return QS_FALSE;
69
70 if ( *iface )
71 (*iface)->addRef();
72 return QS_OK;
73}
74
75Q_EXPORT_INTERFACE()
76{
77 Q_CREATE_INSTANCE( MenuAppletExample )
78}
diff --git a/examples/menuapplet/example.h b/examples/menuapplet/example.h
new file mode 100644
index 0000000..ec507dd
--- a/dev/null
+++ b/examples/menuapplet/example.h
@@ -0,0 +1,33 @@
1#ifndef OPIE_EXAMPLE_MENU_APPLET_H
2#define OPIE_EXAMPLE_MENU_APPLET_H
3
4#include <qpe/menuappletinterface.h>
5#include <qobject.h>
6
7#include <qobject.h>
8
9class MenuAppletExample : public QObject, public MenuAppletInterface
10{
11
12 Q_OBJECT
13
14public:
15 MenuAppletExample ( );
16 virtual ~MenuAppletExample ( );
17
18 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
19 Q_REFCOUNT
20
21 virtual int position() const;
22
23 virtual QString name ( ) const;
24 virtual QIconSet icon ( ) const;
25 virtual QString text ( ) const;
26 /* virtual QString tr( const char* ) const;
27 virtual QString tr( const char*, const char* ) const;
28 */
29 virtual QPopupMenu *popup ( QWidget *parent ) const;
30 virtual void activated ( );
31};
32
33#endif
diff --git a/examples/menuapplet/menuapplet.pro b/examples/menuapplet/menuapplet.pro
new file mode 100644
index 0000000..3567a2e
--- a/dev/null
+++ b/examples/menuapplet/menuapplet.pro
@@ -0,0 +1,12 @@
1TEMPLATE = lib
2CONFIG += qt plugn warn_on release
3HEADERS = example.h
4SOURCES = example.cpp
5TARGET = example_applet
6DESTDIR = $(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe
10VERSION = 1.0.0
11
12include ( $(OPIEDIR)/include.pro )