summaryrefslogtreecommitdiff
path: root/examples/main-tab
authorzecke <zecke>2004-03-14 20:08:59 (UTC)
committer zecke <zecke>2004-03-14 20:08:59 (UTC)
commit0d79c003839718ae70b3b997162044abd5c26bf6 (patch) (unidiff)
tree19708b041da3a09df8f3b571cd634a846f4ad6d7 /examples/main-tab
parent05c8d999941989a97a581fb5822437034ec10fd7 (diff)
downloadopie-0d79c003839718ae70b3b997162044abd5c26bf6.zip
opie-0d79c003839718ae70b3b997162044abd5c26bf6.tar.gz
opie-0d79c003839718ae70b3b997162044abd5c26bf6.tar.bz2
Update the Examples
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/example.pro2
-rw-r--r--examples/main-tab/simple.cpp8
3 files changed, 7 insertions, 5 deletions
diff --git a/examples/main-tab/config.in b/examples/main-tab/config.in
index e021d59..3a67bcb 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 && LIBOPIE 4 depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIEUI2
diff --git a/examples/main-tab/example.pro b/examples/main-tab/example.pro
index 3cafc20..87abf22 100644
--- a/examples/main-tab/example.pro
+++ b/examples/main-tab/example.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 -lopie 15LIBS += -lqpe -lopieui2
16 16
17include ( $(OPIEDIR)/include.pro ) 17include ( $(OPIEDIR)/include.pro )
diff --git a/examples/main-tab/simple.cpp b/examples/main-tab/simple.cpp
index c5a6d5a..7edb557 100644
--- a/examples/main-tab/simple.cpp
+++ b/examples/main-tab/simple.cpp
@@ -1,89 +1,91 @@
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> 9#include <qpe/resource.h>
10#include <qpe/sound.h> 10#include <qpe/sound.h>
11 11
12#include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching 12#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching
13#include <opie/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 */
30using namespace Opie::Core;
29OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 31OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
30 32
31MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) 33MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl )
32 : QMainWindow( parent, name, fl ) { 34 : QMainWindow( parent, name, fl ) {
33 setCaption(tr("My MainWindow") ); 35 setCaption(tr("My MainWindow") );
34 36
35 initUI(); 37 initUI();
36 38
37 39
38 /* 40 /*
39 * Tab widget as central 41 * Tab widget as central
40 */ 42 */
41 OTabWidget *tab = new OTabWidget(this); 43 Opie::Ui::OTabWidget *tab = new Opie::Ui::OTabWidget(this);
42 connect(tab, SIGNAL(currentChanged(QWidget*) ), 44 connect(tab, SIGNAL(currentChanged(QWidget*) ),
43 this, SLOT( slotCurrentChanged(QWidget*) ) ); 45 this, SLOT( slotCurrentChanged(QWidget*) ) );
44 setCentralWidget( tab ); 46 setCentralWidget( tab );
45 47
46 Simple1 *simple1 = new Simple1( this ); 48 Simple1 *simple1 = new Simple1( this );
47 tab->addTab( simple1, "new", tr("Simple1") ); 49 tab->addTab( simple1, "new", tr("Simple1") );
48 tab->setCurrentTab( tr("Simple1") ); 50 tab->setCurrentTab( tr("Simple1") );
49 51
50 Simple2 *simple2 = new Simple2( this ); 52 Simple2 *simple2 = new Simple2( this );
51 tab->addTab( simple2, "trash", tr("Simple2") ); 53 tab->addTab( simple2, "trash", tr("Simple2") );
52 54
53 m_oldCurrent = simple1; 55 m_oldCurrent = simple1;
54 56
55 connect(m_fire, SIGNAL(activated() ), 57 connect(m_fire, SIGNAL(activated() ),
56 simple1, SLOT(slotFire() ) ); 58 simple1, SLOT(slotFire() ) );
57} 59}
58 60
59MainWindow::~MainWindow() { 61MainWindow::~MainWindow() {
60 // again nothing to delete because Qt takes care 62 // again nothing to delete because Qt takes care
61} 63}
62 64
63 65
64void MainWindow::setDocument( const QString& /*str*/ ) { 66void MainWindow::setDocument( const QString& /*str*/ ) {
65} 67}
66void MainWindow::slotCurrentChanged( QWidget *wid) { 68void MainWindow::slotCurrentChanged( QWidget *wid) {
67 disconnect(m_fire, SIGNAL(activated() ), 69 disconnect(m_fire, SIGNAL(activated() ),
68 m_oldCurrent, SLOT(slotFire() ) ); 70 m_oldCurrent, SLOT(slotFire() ) );
69 connect(m_fire, SIGNAL(activated() ), 71 connect(m_fire, SIGNAL(activated() ),
70 wid, SLOT(slotFire() ) ); 72 wid, SLOT(slotFire() ) );
71 73
72 m_oldCurrent = wid; 74 m_oldCurrent = wid;
73} 75}
74 76
75void MainWindow::initUI() { 77void MainWindow::initUI() {
76 78
77 setToolBarsMovable( false ); 79 setToolBarsMovable( false );
78 80
79 QToolBar *menuBarHolder = new QToolBar( this ); 81 QToolBar *menuBarHolder = new QToolBar( this );
80 82
81 menuBarHolder->setHorizontalStretchable( true ); 83 menuBarHolder->setHorizontalStretchable( true );
82 QMenuBar *mb = new QMenuBar( menuBarHolder ); 84 QMenuBar *mb = new QMenuBar( menuBarHolder );
83 QToolBar *tb = new QToolBar( this ); 85 QToolBar *tb = new QToolBar( this );
84 86
85 QPopupMenu *fileMenu = new QPopupMenu( this ); 87 QPopupMenu *fileMenu = new QPopupMenu( this );
86 88
87 89
88 QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), 90 QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"),
89 QString::null, 0, this, "quit_action" ); 91 QString::null, 0, this, "quit_action" );