summaryrefslogtreecommitdiff
path: root/examples/simple-icon
authordrw <drw>2005-06-15 22:39:20 (UTC)
committer drw <drw>2005-06-15 22:39:20 (UTC)
commite0205bac48b9d23af9feb48004c24fcf7a5e8200 (patch) (unidiff)
tree2faa077192fd0bfc4fc409f0513cc0e82113fa9e /examples/simple-icon
parentd2474c8e654d223b85b6200ce09fabd3a40af8e3 (diff)
downloadopie-e0205bac48b9d23af9feb48004c24fcf7a5e8200.zip
opie-e0205bac48b9d23af9feb48004c24fcf7a5e8200.tar.gz
opie-e0205bac48b9d23af9feb48004c24fcf7a5e8200.tar.bz2
Resource -> OResource
Diffstat (limited to 'examples/simple-icon') (more/less context) (ignore whitespace changes)
-rw-r--r--examples/simple-icon/config.in2
-rw-r--r--examples/simple-icon/opie-simple.control2
-rw-r--r--examples/simple-icon/simple.cpp5
3 files changed, 4 insertions, 5 deletions
diff --git a/examples/simple-icon/config.in b/examples/simple-icon/config.in
index ec5e1ee..f0f9181 100644
--- a/examples/simple-icon/config.in
+++ b/examples/simple-icon/config.in
@@ -1,4 +1,4 @@
1 config SIMPLE_ICON 1 config SIMPLE_ICON
2 boolean "Simples Widget which loads Pixmaps and plays sound" 2 boolean "Simples Widget which loads Pixmaps and plays sound"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && EXAMPLES
diff --git a/examples/simple-icon/opie-simple.control b/examples/simple-icon/opie-simple.control
index 5adcf01..5e326ab 100644
--- a/examples/simple-icon/opie-simple.control
+++ b/examples/simple-icon/opie-simple.control
@@ -1,9 +1,9 @@
1Package: opie-simple-icon-example 1Package: opie-simple-icon-example
2Files: bin/simple-icon apps/Examples/simple-icon.desktop 2Files: bin/simple-icon apps/Examples/simple-icon.desktop
3Priority: optional 3Priority: optional
4Section: opie/examples 4Section: opie/examples
5Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org> 5Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal, opie-pics 7Depends: task-opie-minimal, libopiecore2, opie-pics
8Description: A simple icon example 8Description: A simple icon example
9Version: $QPE_VERSION$EXTRAVERSION 9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/examples/simple-icon/simple.cpp b/examples/simple-icon/simple.cpp
index fec1823..2c98ec0 100644
--- a/examples/simple-icon/simple.cpp
+++ b/examples/simple-icon/simple.cpp
@@ -1,80 +1,79 @@
1#include <qlabel.h> // a label 1#include <qlabel.h> // a label
2#include <qpushbutton.h> // the header file for the QPushButton 2#include <qpushbutton.h> // the header file for the QPushButton
3#include <qlayout.h> 3#include <qlayout.h>
4 4
5#include <qpe/qpeapplication.h> // the QPEApplication 5#include <qpe/qpeapplication.h> // the QPEApplication
6#include <qpe/resource.h> // for loading icon
7#include <qpe/sound.h> // for playing a sound 6#include <qpe/sound.h> // for playing a sound
8 7
9#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching 8#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching
10 9#include <opie2/oresource.h> // for loading icon
11#include "simple.h" 10#include "simple.h"
12 11
13/* 12/*
14 * implementation of simple 13 * implementation of simple
15 */ 14 */
16 15
17/* 16/*
18 * The factory is used for quicklaunching 17 * The factory is used for quicklaunching
19 * It needs a constructor ( c'tor ) with at least QWidget, const char* and WFlags as parameter and a static QString appName() matching the TARGET of the .pro 18 * It needs a constructor ( c'tor ) with at least QWidget, const char* and WFlags as parameter and a static QString appName() matching the TARGET of the .pro
20 * 19 *
21 * Depending on the global quick launch setting this will create 20 * Depending on the global quick launch setting this will create
22 * either a main method or one for our component plugin system 21 * either a main method or one for our component plugin system
23 */ 22 */
24using namespace Opie::Core; 23using namespace Opie::Core;
25OPIE_EXPORT_APP( OApplicationFactory<Simple> ) 24OPIE_EXPORT_APP( OApplicationFactory<Simple> )
26 25
27Simple::Simple( QWidget* parent, const char* name, WFlags fl ) 26Simple::Simple( QWidget* parent, const char* name, WFlags fl )
28 : QWidget( parent, name, fl ) { 27 : QWidget( parent, name, fl ) {
29 28
30 /* 29 /*
31 * sets the caption of this toplevel widget 30 * sets the caption of this toplevel widget
32 * put all translatable string into tr() 31 * put all translatable string into tr()
33 */ 32 */
34 setCaption(tr("My Simple Application") ); 33 setCaption(tr("My Simple Application") );
35 34
36 /* 35 /*
37 * A simple vertical layout 36 * A simple vertical layout
38 * either call layout->setAutoAdd( true ) 37 * either call layout->setAutoAdd( true )
39 * or use layout->addWidget( wid ) to add widgets 38 * or use layout->addWidget( wid ) to add widgets
40 */ 39 */
41 QVBoxLayout *layout = new QVBoxLayout( this ); 40 QVBoxLayout *layout = new QVBoxLayout( this );
42 layout->setSpacing( 8 ); 41 layout->setSpacing( 8 );
43 layout->setMargin( 11 ); 42 layout->setMargin( 11 );
44 43
45 /* 44 /*
46 * creates a label 45 * creates a label
47 * The first parameter is this widget so the Label is a child 46 * The first parameter is this widget so the Label is a child
48 * of us and will be deleted when we're deleted. 47 * of us and will be deleted when we're deleted.
49 */ 48 */
50 QLabel *lbl = new QLabel( this, "a name for the label" ); 49 QLabel *lbl = new QLabel( this, "a name for the label" );
51 /* 50 /*
52 * Resource will search hard for a Pixmap in $OPIEDIR/pics 51 * Resource will search hard for a Pixmap in $OPIEDIR/pics
53 * to find 'logo/opielogo' You need to pass the subdir 52 * to find 'logo/opielogo' You need to pass the subdir
54 * but not the ending 53 * but not the ending
55 */ 54 */
56 lbl->setPixmap( Resource::loadPixmap("logo/opielogo") ); 55 lbl->setPixmap( Opie::Core::OResource::loadPixmap("logo/opielogo", Opie::Core::OResource::SmallIcon) );
57 layout->addWidget( lbl ); 56 layout->addWidget( lbl );
58 57
59 58
60 /* creates a button as child of this widget */ 59 /* creates a button as child of this widget */
61 m_button = new QPushButton(this); 60 m_button = new QPushButton(this);
62 /* 61 /*
63 * another way to call tr. The first parameter is the string 62 * another way to call tr. The first parameter is the string
64 * to translate and the second a hint to the translator 63 * to translate and the second a hint to the translator
65 */ 64 */
66 m_button->setText( tr("Fire", "translatable fire string" ) ); 65 m_button->setText( tr("Fire", "translatable fire string" ) );
67 layout->addWidget( m_button ); 66 layout->addWidget( m_button );
68 67
69 /* 68 /*
70 * Now we bring the action into it. The power of qt is the dynamic 69 * Now we bring the action into it. The power of qt is the dynamic
71 * signal and slots model 70 * signal and slots model
72 * Usage is simple connect m_buttons clicked signal to our 71 * Usage is simple connect m_buttons clicked signal to our
73 * slotQuit slot. 72 * slotQuit slot.
74 * We could also have connected a SIGNAL to a SIGNAL or the clicked 73 * We could also have connected a SIGNAL to a SIGNAL or the clicked
75 * signal directly to qApp and SLOT(quit() ) 74 * signal directly to qApp and SLOT(quit() )
76 */ 75 */
77 connect( m_button, SIGNAL(clicked() ), 76 connect( m_button, SIGNAL(clicked() ),
78 this, SLOT( slotQuit() ) ); 77 this, SLOT( slotQuit() ) );
79} 78}
80 79