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/menuapplet/example.cpp | |
parent | cc0045d01be5368365059567764efc8f94c4bc0c (diff) | |
download | opie-58bd1952241a733e90dfaabc7515af03c969b214.zip opie-58bd1952241a733e90dfaabc7515af03c969b214.tar.gz opie-58bd1952241a733e90dfaabc7515af03c969b214.tar.bz2 |
Initial revision
Diffstat (limited to 'examples/menuapplet/example.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | examples/menuapplet/example.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
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 | } | ||