summaryrefslogtreecommitdiff
path: root/examples/main-tab
Unidiff
Diffstat (limited to 'examples/main-tab') (more/less context) (ignore whitespace changes)
-rw-r--r--examples/main-tab/config.in2
-rw-r--r--examples/main-tab/main-tab.pro2
-rw-r--r--examples/main-tab/opie-simple.control2
-rw-r--r--examples/main-tab/simple.cpp11
4 files changed, 8 insertions, 9 deletions
diff --git a/examples/main-tab/config.in b/examples/main-tab/config.in
index a40df56..640679e 100644
--- a/examples/main-tab/config.in
+++ b/examples/main-tab/config.in
@@ -1,4 +1,4 @@
1 config MAIN_TAB_EXAMPLE 1 config MAIN_TAB_EXAMPLE
2 boolean "Mainwindow with OTabWidget example" 2 boolean "Mainwindow with OTabWidget example"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIE2UI 4 depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIE2CORE && LIBOPIE2UI
diff --git a/examples/main-tab/main-tab.pro b/examples/main-tab/main-tab.pro
index a0df875..033a028 100644
--- a/examples/main-tab/main-tab.pro
+++ b/examples/main-tab/main-tab.pro
@@ -1,17 +1,17 @@
1CONFIG += qt warn_on quick-app 1CONFIG += qt warn_on quick-app
2 2
3 3
4TARGET = main-tab 4TARGET = main-tab
5 5
6HEADERS = simple.h 6HEADERS = simple.h
7SOURCES = simple.cpp 7SOURCES = simple.cpp
8 8
9 9
10INCLUDEPATH += $(OPIEDIR)/include 10INCLUDEPATH += $(OPIEDIR)/include
11DEPENDPATH += $(OPIEDIR)/include 11DEPENDPATH += $(OPIEDIR)/include
12 12
13 13
14# we now also include opie 14# we now also include opie
15LIBS += -lqpe -lopieui2 15LIBS += -lqpe -lopiecore2 -lopieui2
16 16
17include( $(OPIEDIR)/include.pro ) 17include( $(OPIEDIR)/include.pro )
diff --git a/examples/main-tab/opie-simple.control b/examples/main-tab/opie-simple.control
index 8525a94..2046281 100644
--- a/examples/main-tab/opie-simple.control
+++ b/examples/main-tab/opie-simple.control
@@ -1,9 +1,9 @@
1Package: opie-main-tab-example 1Package: opie-main-tab-example
2Files: bin/main-tab apps/Examples/main-tab.desktop 2Files: bin/main-tab apps/Examples/main-tab.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, libopieui2, opie-pics
8Description: A simple example 8Description: A simple example
9Version: $QPE_VERSION$EXTRAVERSION 9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/examples/main-tab/simple.cpp b/examples/main-tab/simple.cpp
index 7edb557..1e2d028 100644
--- a/examples/main-tab/simple.cpp
+++ b/examples/main-tab/simple.cpp
@@ -1,213 +1,212 @@
1#include <qaction.h> // action 1#include <qaction.h> // action
2#include <qmenubar.h> // menubar 2#include <qmenubar.h> // menubar
3#include <qtoolbar.h> // toolbar 3#include <qtoolbar.h> // toolbar
4#include <qlabel.h> // a label 4#include <qlabel.h> // a label
5#include <qpushbutton.h> // the header file for the QPushButton 5#include <qpushbutton.h> // the header file for the QPushButton
6#include <qlayout.h> 6#include <qlayout.h>
7 7
8#include <qpe/qpeapplication.h> // the QPEApplication 8#include <qpe/qpeapplication.h> // the QPEApplication
9#include <qpe/resource.h>
10#include <qpe/sound.h> 9#include <qpe/sound.h>
11 10
12#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching 11#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching
12#include <opie2/oresource.h>
13#include <opie2/otabwidget.h> 13#include <opie2/otabwidget.h>
14 14
15#include "simple.h" 15#include "simple.h"
16 16
17/* 17/*
18 * implementation of simple 18 * implementation of simple
19 */ 19 */
20 20
21/* 21/*
22 * The factory is used for quicklaunching 22 * The factory is used for quicklaunching
23 * 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 23 * 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
24 * 24 *
25 * Depending on the global quick launch setting this will create 25 * Depending on the global quick launch setting this will create
26 * either a main method or one for our component plugin system 26 * either a main method or one for our component plugin system
27 */ 27 */
28 28
29/* The OApplicationFactory is in the Opie::Core namespace */ 29/* The OApplicationFactory is in the Opie::Core namespace */
30using namespace Opie::Core; 30using namespace Opie::Core;
31OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 31OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
32 32
33MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) 33MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl )
34 : QMainWindow( parent, name, fl ) { 34 : QMainWindow( parent, name, fl ) {
35 setCaption(tr("My MainWindow") ); 35 setCaption(tr("My MainWindow") );
36 36
37 initUI(); 37 initUI();
38 38
39 39
40 /* 40 /*
41 * Tab widget as central 41 * Tab widget as central
42 */ 42 */
43 Opie::Ui::OTabWidget *tab = new Opie::Ui::OTabWidget(this); 43 Opie::Ui::OTabWidget *tab = new Opie::Ui::OTabWidget(this);
44 connect(tab, SIGNAL(currentChanged(QWidget*) ), 44 connect(tab, SIGNAL(currentChanged(QWidget*) ),
45 this, SLOT( slotCurrentChanged(QWidget*) ) ); 45 this, SLOT( slotCurrentChanged(QWidget*) ) );
46 setCentralWidget( tab ); 46 setCentralWidget( tab );
47 47
48 Simple1 *simple1 = new Simple1( this ); 48 Simple1 *simple1 = new Simple1( this );
49 tab->addTab( simple1, "new", tr("Simple1") ); 49 tab->addTab( simple1, "new", tr("Simple1") );
50 tab->setCurrentTab( tr("Simple1") ); 50 tab->setCurrentTab( tr("Simple1") );
51 51
52 Simple2 *simple2 = new Simple2( this ); 52 Simple2 *simple2 = new Simple2( this );
53 tab->addTab( simple2, "trash", tr("Simple2") ); 53 tab->addTab( simple2, "trash", tr("Simple2") );
54 54
55 m_oldCurrent = simple1; 55 m_oldCurrent = simple1;
56 56
57 connect(m_fire, SIGNAL(activated() ), 57 connect(m_fire, SIGNAL(activated() ),
58 simple1, SLOT(slotFire() ) ); 58 simple1, SLOT(slotFire() ) );
59} 59}
60 60
61MainWindow::~MainWindow() { 61MainWindow::~MainWindow() {
62 // again nothing to delete because Qt takes care 62 // again nothing to delete because Qt takes care
63} 63}
64 64
65 65
66void MainWindow::setDocument( const QString& /*str*/ ) { 66void MainWindow::setDocument( const QString& /*str*/ ) {
67} 67}
68void MainWindow::slotCurrentChanged( QWidget *wid) { 68void MainWindow::slotCurrentChanged( QWidget *wid) {
69 disconnect(m_fire, SIGNAL(activated() ), 69 disconnect(m_fire, SIGNAL(activated() ),
70 m_oldCurrent, SLOT(slotFire() ) ); 70 m_oldCurrent, SLOT(slotFire() ) );
71 connect(m_fire, SIGNAL(activated() ), 71 connect(m_fire, SIGNAL(activated() ),
72 wid, SLOT(slotFire() ) ); 72 wid, SLOT(slotFire() ) );
73 73
74 m_oldCurrent = wid; 74 m_oldCurrent = wid;
75} 75}
76 76
77void MainWindow::initUI() { 77void MainWindow::initUI() {
78 78
79 setToolBarsMovable( false ); 79 setToolBarsMovable( false );
80 80
81 QToolBar *menuBarHolder = new QToolBar( this ); 81 QToolBar *menuBarHolder = new QToolBar( this );
82 82
83 menuBarHolder->setHorizontalStretchable( true ); 83 menuBarHolder->setHorizontalStretchable( true );
84 QMenuBar *mb = new QMenuBar( menuBarHolder ); 84 QMenuBar *mb = new QMenuBar( menuBarHolder );
85 QToolBar *tb = new QToolBar( this ); 85 QToolBar *tb = new QToolBar( this );
86 86
87 QPopupMenu *fileMenu = new QPopupMenu( this ); 87 QPopupMenu *fileMenu = new QPopupMenu( this );
88 88
89 89
90 QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), 90 QAction *a = new QAction( tr("Quit"), Opie::Core::OResource::loadPixmap("quit_icon", Opie::Core::OResource::SmallIcon),
91 QString::null, 0, this, "quit_action" ); 91 QString::null, 0, this, "quit_action" );
92 /* 92 /*
93 * Connect quit to the QApplication quit slot 93 * Connect quit to the QApplication quit slot
94 */ 94 */
95 connect(a, SIGNAL(activated() ), 95 connect(a, SIGNAL(activated() ),
96 qApp, SLOT(quit() ) ); 96 qApp, SLOT(quit() ) );
97 a->addTo( fileMenu ); 97 a->addTo( fileMenu );
98 98
99 a = new QAction(tr("Fire"), 99 a = new QAction(tr("Fire"), Opie::Core::OResource::loadPixmap("new", Opie::Core::OResource::SmallIcon),
100 Resource::loadIconSet("new"),
101 QString::null, 0, this, "fire_button"); 100 QString::null, 0, this, "fire_button");
102 101
103 /* see the power? */ 102 /* see the power? */
104 a->addTo( fileMenu ); 103 a->addTo( fileMenu );
105 a->addTo( tb ); 104 a->addTo( tb );
106 m_fire = a; 105 m_fire = a;
107 106
108 107
109 mb->insertItem(tr("File"), fileMenu ); 108 mb->insertItem(tr("File"), fileMenu );
110 109
111} 110}
112 111
113Simple1::Simple1( QWidget* parent, const char* name, WFlags fl ) 112Simple1::Simple1( QWidget* parent, const char* name, WFlags fl )
114 : QWidget( parent, name, fl ) { 113 : QWidget( parent, name, fl ) {
115 114
116 QVBoxLayout *layout = new QVBoxLayout( this ); 115 QVBoxLayout *layout = new QVBoxLayout( this );
117 layout->setSpacing( 8 ); 116 layout->setSpacing( 8 );
118 layout->setMargin( 11 ); 117 layout->setMargin( 11 );
119 118
120 119
121 QLabel *lbl = new QLabel( this, "a name for the label" ); 120 QLabel *lbl = new QLabel( this, "a name for the label" );
122 lbl->setText( tr("Click on the button or follow the white rabbit") ); 121 lbl->setText( tr("Click on the button or follow the white rabbit") );
123 layout->addWidget( lbl ); 122 layout->addWidget( lbl );
124 123
125 124
126 m_button = new QPushButton(this); 125 m_button = new QPushButton(this);
127 126
128 127
129 m_button->setText( tr("Fire", "translatable quit string" ) ); 128 m_button->setText( tr("Fire", "translatable quit string" ) );
130 layout->addWidget( m_button ); 129 layout->addWidget( m_button );
131 130
132 131
133 connect( m_button, SIGNAL(clicked() ), 132 connect( m_button, SIGNAL(clicked() ),
134 this, SLOT( slotFire() ) ); 133 this, SLOT( slotFire() ) );
135} 134}
136 135
137Simple1::~Simple1() { 136Simple1::~Simple1() {
138 137
139} 138}
140 139
141void Simple1::slotFire() { 140void Simple1::slotFire() {
142 /* 141 /*
143 * NOTE: Simple is now a child window of MainWindow 142 * NOTE: Simple is now a child window of MainWindow
144 * close will hide() Simple and not delete it. But as 143 * close will hide() Simple and not delete it. But as
145 * the mainwindow is shown all children will be shown as well 144 * the mainwindow is shown all children will be shown as well
146 */ 145 */
147 close(); 146 close();
148} 147}
149 148
150 149
151Simple2::Simple2( QWidget* parent, const char* name, WFlags fl ) 150Simple2::Simple2( QWidget* parent, const char* name, WFlags fl )
152 : QWidget( parent, name, fl ) { 151 : QWidget( parent, name, fl ) {
153 152
154 /* 153 /*
155 * sets the caption of this toplevel widget 154 * sets the caption of this toplevel widget
156 * put all translatable string into tr() 155 * put all translatable string into tr()
157 */ 156 */
158 setCaption(tr("My Simple Application") ); 157 setCaption(tr("My Simple Application") );
159 158
160 /* 159 /*
161 * A simple vertical layout 160 * A simple vertical layout
162 * either call layout->setAutoAdd( true ) 161 * either call layout->setAutoAdd( true )
163 * or use layout->addWidget( wid ) to add widgets 162 * or use layout->addWidget( wid ) to add widgets
164 */ 163 */
165 QVBoxLayout *layout = new QVBoxLayout( this ); 164 QVBoxLayout *layout = new QVBoxLayout( this );
166 layout->setSpacing( 8 ); 165 layout->setSpacing( 8 );
167 layout->setMargin( 11 ); 166 layout->setMargin( 11 );
168 167
169 /* 168 /*
170 * creates a label 169 * creates a label
171 * The first parameter is this widget so the Label is a child 170 * The first parameter is this widget so the Label is a child
172 * of us and will be deleted when we're deleted. 171 * of us and will be deleted when we're deleted.
173 */ 172 */
174 QLabel *lbl = new QLabel( this, "a name for the label" ); 173 QLabel *lbl = new QLabel( this, "a name for the label" );
175 /* 174 /*
176 * Resource will search hard for a Pixmap in $OPIEDIR/pics 175 * OResource will search hard for a Pixmap in $OPIEDIR/pics
177 * to find 'logo/opielogo' You need to pass the subdir 176 * to find 'logo/opielogo' You need to pass the subdir
178 * but not the ending 177 * but not the ending
179 */ 178 */
180 lbl->setPixmap( Resource::loadPixmap("logo/opielogo") ); 179 lbl->setPixmap( Opie::Core::OResource::loadPixmap("logo/opielogo", Opie::Core::OResource::SmallIcon) );
181 layout->addWidget( lbl ); 180 layout->addWidget( lbl );
182 181
183 182
184 /* creates a button as child of this widget */ 183 /* creates a button as child of this widget */
185 m_button = new QPushButton(this); 184 m_button = new QPushButton(this);
186 /* 185 /*
187 * another way to call tr. The first parameter is the string 186 * another way to call tr. The first parameter is the string
188 * to translate and the second a hint to the translator 187 * to translate and the second a hint to the translator
189 */ 188 */
190 m_button->setText( tr("Fire", "translatable fire string" ) ); 189 m_button->setText( tr("Fire", "translatable fire string" ) );
191 layout->addWidget( m_button ); 190 layout->addWidget( m_button );
192 191
193 192
194 connect( m_button, SIGNAL(clicked() ), 193 connect( m_button, SIGNAL(clicked() ),
195 this, SLOT( slotQuit() ) ); 194 this, SLOT( slotQuit() ) );
196} 195}
197 196
198 197
199Simple2::~Simple2() { 198Simple2::~Simple2() {
200 199
201} 200}
202 201
203void Simple2::slotFire() { 202void Simple2::slotFire() {
204 /* 203 /*
205 * We will fire up a sound 204 * We will fire up a sound
206 * Note that Sound will use Resource as well 205 * Note that Sound will use Resource as well
207 * and we do not need to supply an ending 206 * and we do not need to supply an ending
208 * sounds are found in $OPIEDIR/sounds 207 * sounds are found in $OPIEDIR/sounds
209 */ 208 */
210 Sound snd("hit_target01"); 209 Sound snd("hit_target01");
211 snd.play(); 210 snd.play();
212 211
213} 212}