author | drw <drw> | 2005-06-15 22:39:20 (UTC) |
---|---|---|
committer | drw <drw> | 2005-06-15 22:39:20 (UTC) |
commit | e0205bac48b9d23af9feb48004c24fcf7a5e8200 (patch) (unidiff) | |
tree | 2faa077192fd0bfc4fc409f0513cc0e82113fa9e /examples/applet | |
parent | d2474c8e654d223b85b6200ce09fabd3a40af8e3 (diff) | |
download | opie-e0205bac48b9d23af9feb48004c24fcf7a5e8200.zip opie-e0205bac48b9d23af9feb48004c24fcf7a5e8200.tar.gz opie-e0205bac48b9d23af9feb48004c24fcf7a5e8200.tar.bz2 |
Resource -> OResource
-rw-r--r-- | examples/applet/applet.pro | 2 | ||||
-rw-r--r-- | examples/applet/config.in | 2 | ||||
-rw-r--r-- | examples/applet/simpleimpl.cpp | 25 |
3 files changed, 6 insertions, 23 deletions
diff --git a/examples/applet/applet.pro b/examples/applet/applet.pro index 6890141..1daf1b2 100644 --- a/examples/applet/applet.pro +++ b/examples/applet/applet.pro | |||
@@ -1,16 +1,16 @@ | |||
1 | CONFIG += warn_on qt | 1 | CONFIG += warn_on qt |
2 | 2 | ||
3 | TEMPLATE = lib | 3 | TEMPLATE = lib |
4 | DESTDIR = $(OPIEDIR)/plugins/applets | 4 | DESTDIR = $(OPIEDIR)/plugins/applets |
5 | TARGET = example | 5 | TARGET = example |
6 | 6 | ||
7 | SOURCES = simpleimpl.cpp | 7 | SOURCES = simpleimpl.cpp |
8 | HEADERS = simpleimpl.h | 8 | HEADERS = simpleimpl.h |
9 | 9 | ||
10 | INCLUDEPATH += $(OPIEDIR)/include | 10 | INCLUDEPATH += $(OPIEDIR)/include |
11 | DEPENDSPATH += $(OPIEDIR)/include | 11 | DEPENDSPATH += $(OPIEDIR)/include |
12 | 12 | ||
13 | LIBS += -lqpe -lopieui2 | 13 | LIBS += -lqpe -lopiecore2 -lopieui2 |
14 | 14 | ||
15 | 15 | ||
16 | include( $(OPIEDIR)/include.pro ) | 16 | include( $(OPIEDIR)/include.pro ) |
diff --git a/examples/applet/config.in b/examples/applet/config.in index f6a5d20..0d4d800 100644 --- a/examples/applet/config.in +++ b/examples/applet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config APPLET_EXAMPLE | 1 | config APPLET_EXAMPLE |
2 | boolean "Taskbar Applet Example" | 2 | boolean "Taskbar Applet Example" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI && EXAMPLES | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && EXAMPLES |
diff --git a/examples/applet/simpleimpl.cpp b/examples/applet/simpleimpl.cpp index ff651ca..d7e2db9 100644 --- a/examples/applet/simpleimpl.cpp +++ b/examples/applet/simpleimpl.cpp | |||
@@ -1,91 +1,74 @@ | |||
1 | 1 | ||
2 | #include "simpleimpl.h" | 2 | #include "simpleimpl.h" |
3 | 3 | ||
4 | #include <opie2/oresource.h> // for OResource loading | ||
4 | #include <opie2/otaskbarapplet.h> | 5 | #include <opie2/otaskbarapplet.h> |
5 | 6 | ||
6 | #include <qpe/applnk.h> // for AppLnk | 7 | #include <qpe/applnk.h> // for AppLnk |
7 | #include <qpe/resource.h> // for Resource loading | ||
8 | 8 | ||
9 | #include <qlabel.h> | 9 | #include <qlabel.h> |
10 | #include <qpainter.h> | 10 | #include <qpainter.h> |
11 | #include <qmessagebox.h> | 11 | #include <qmessagebox.h> |
12 | 12 | ||
13 | 13 | ||
14 | 14 | ||
15 | 15 | ||
16 | SimpleApplet::SimpleApplet(QWidget *parent) | 16 | SimpleApplet::SimpleApplet(QWidget *parent) |
17 | : QWidget( parent, "Simple Applet" ) { | 17 | : QWidget( parent, "Simple Applet" ) { |
18 | /* | 18 | /* |
19 | * we will load an Image, scale it for the right usage | 19 | * we will load an Pixmap, scaled for the right usage |
20 | * remember your applet might be used by different | 20 | * remember your applet might be used by different |
21 | * resolutions. | 21 | * resolutions. |
22 | * Then we will convert the image back to an Pixmap | ||
23 | * and draw this Pimxap. We need to use Image because its | ||
24 | * the only class that allows scaling. | ||
25 | */ | 22 | */ |
26 | 23 | ||
27 | QImage image = Resource::loadImage("Tux"); | 24 | m_pix = new QPixmap( Opie::Core::OResource::loadPixmap("Tux", Opie::Core::OResource::SmallIcon) ); |
28 | /* | ||
29 | * smooth scale to AppLnk smallIconSize for applest | ||
30 | * smallIconSize gets adjusted to the resolution | ||
31 | * so on some displays like SIMpad and a C-750 the smallIconSize | ||
32 | * is greater than on a iPAQ h3870 | ||
33 | */ | ||
34 | image = image.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | ||
35 | |||
36 | /* | ||
37 | * now we need to convert the Image to a Pixmap cause these | ||
38 | * can be drawn more easily | ||
39 | */ | ||
40 | m_pix = new QPixmap(); | ||
41 | m_pix->convertFromImage( image ); | ||
42 | 25 | ||
43 | /* | 26 | /* |
44 | * Now we will say that we don't want to be bigger than our | 27 | * Now we will say that we don't want to be bigger than our |
45 | * Pixmap | 28 | * Pixmap |
46 | */ | 29 | */ |
47 | setFixedHeight(AppLnk::smallIconSize() ); | 30 | setFixedHeight( AppLnk::smallIconSize() ); |
48 | setFixedWidth( AppLnk::smallIconSize() ); | 31 | setFixedWidth( AppLnk::smallIconSize() ); |
49 | 32 | ||
50 | } | 33 | } |
51 | 34 | ||
52 | SimpleApplet::~SimpleApplet() { | 35 | SimpleApplet::~SimpleApplet() { |
53 | delete m_pix; | 36 | delete m_pix; |
54 | } | 37 | } |
55 | 38 | ||
56 | 39 | ||
57 | /* | 40 | /* |
58 | * here you would normal show or do something | 41 | * here you would normal show or do something |
59 | * useful. If you want to show a widget at the top left | 42 | * useful. If you want to show a widget at the top left |
60 | * of your icon you need to map your rect().topLeft() to | 43 | * of your icon you need to map your rect().topLeft() to |
61 | * global with mapToGlobal(). Then you might also need to | 44 | * global with mapToGlobal(). Then you might also need to |
62 | * move the widgets so it is visible | 45 | * move the widgets so it is visible |
63 | */ | 46 | */ |
64 | void SimpleApplet::mousePressEvent(QMouseEvent* ) { | 47 | void SimpleApplet::mousePressEvent(QMouseEvent* ) { |
65 | QMessageBox::information(this, tr("No action taken"), | 48 | QMessageBox::information(this, tr("No action taken"), |
66 | tr("<qt>This Plugin does not yet support anything usefule aye.</qt>"), | 49 | tr("<qt>This Plugin does not yet support anything usefule aye.</qt>"), |
67 | QMessageBox::Ok ); | 50 | QMessageBox::Ok ); |
68 | 51 | ||
69 | } | 52 | } |
70 | 53 | ||
71 | void SimpleApplet::paintEvent( QPaintEvent* ) { | 54 | void SimpleApplet::paintEvent( QPaintEvent* ) { |
72 | QPainter p(this); | 55 | QPainter p(this); |
73 | 56 | ||
74 | /* simpy draw the pixmap from the start of this widget */ | 57 | /* simpy draw the pixmap from the start of this widget */ |
75 | p.drawPixmap(0, 0, *m_pix ); | 58 | p.drawPixmap(0, 0, *m_pix ); |
76 | } | 59 | } |
77 | 60 | ||
78 | /* | 61 | /* |
79 | * We need to add this symbol for the plugin exporter! | 62 | * We need to add this symbol for the plugin exporter! |
80 | */ | 63 | */ |
81 | int SimpleApplet::position(){ | 64 | int SimpleApplet::position(){ |
82 | return 1; | 65 | return 1; |
83 | } | 66 | } |
84 | 67 | ||
85 | 68 | ||
86 | 69 | ||
87 | /* | 70 | /* |
88 | * Here comes the implementation of the interface | 71 | * Here comes the implementation of the interface |
89 | */ | 72 | */ |
90 | EXPORT_OPIE_APPLET_v1( SimpleApplet ) | 73 | EXPORT_OPIE_APPLET_v1( SimpleApplet ) |
91 | 74 | ||