author | zecke <zecke> | 2004-02-05 15:51:34 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-02-05 15:51:34 (UTC) |
commit | 58bd1952241a733e90dfaabc7515af03c969b214 (patch) (unidiff) | |
tree | c4ac00dfa71cc3d4eada7b23cd857f25ccbe9134 /examples | |
parent | cc0045d01be5368365059567764efc8f94c4bc0c (diff) | |
download | opie-58bd1952241a733e90dfaabc7515af03c969b214.zip opie-58bd1952241a733e90dfaabc7515af03c969b214.tar.gz opie-58bd1952241a733e90dfaabc7515af03c969b214.tar.bz2 |
Initial revision
-rw-r--r-- | examples/menuapplet/config.in | 4 | ||||
-rw-r--r-- | examples/menuapplet/example.cpp | 78 | ||||
-rw-r--r-- | examples/menuapplet/example.h | 33 | ||||
-rw-r--r-- | examples/menuapplet/menuapplet.pro | 12 |
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 | |||
12 | MenuAppletExample::MenuAppletExample() | ||
13 | :QObject( 0, "MenuAppletExample" ) | ||
14 | { | ||
15 | } | ||
16 | |||
17 | MenuAppletExample::~MenuAppletExample ( ) | ||
18 | {} | ||
19 | |||
20 | int MenuAppletExample::position() const | ||
21 | { | ||
22 | return 3; | ||
23 | } | ||
24 | |||
25 | QString MenuAppletExample::name() const | ||
26 | { | ||
27 | return tr( "MenuApplet Example Name" ); | ||
28 | } | ||
29 | |||
30 | QString MenuAppletExample::text() const | ||
31 | { | ||
32 | return tr( "Click the white rabbit" ); | ||
33 | } | ||
34 | |||
35 | |||
36 | QIconSet 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 | |||
45 | QPopupMenu* MenuAppletExample::popup(QWidget*) const | ||
46 | { | ||
47 | /* no subdir */ | ||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | void 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 | |||
60 | QRESULT 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 | |||
75 | Q_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 | |||
9 | class MenuAppletExample : public QObject, public MenuAppletInterface | ||
10 | { | ||
11 | |||
12 | Q_OBJECT | ||
13 | |||
14 | public: | ||
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 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += qt plugn warn_on release | ||
3 | HEADERS = example.h | ||
4 | SOURCES = example.cpp | ||
5 | TARGET = example_applet | ||
6 | DESTDIR = $(OPIEDIR)/plugins/applets | ||
7 | INCLUDEPATH += $(OPIEDIR)/include | ||
8 | DEPENDPATH += $(OPIEDIR)/include | ||
9 | LIBS += -lqpe | ||
10 | VERSION = 1.0.0 | ||
11 | |||
12 | include ( $(OPIEDIR)/include.pro ) | ||