summaryrefslogtreecommitdiff
path: root/libopie2/examples/opieui/owidgetstack_example
Unidiff
Diffstat (limited to 'libopie2/examples/opieui/owidgetstack_example') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/examples/opieui/owidgetstack_example/.cvsignore6
-rw-r--r--libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.cpp132
-rw-r--r--libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.h28
-rw-r--r--libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.pro13
4 files changed, 179 insertions, 0 deletions
diff --git a/libopie2/examples/opieui/owidgetstack_example/.cvsignore b/libopie2/examples/opieui/owidgetstack_example/.cvsignore
new file mode 100644
index 0000000..8f7300c
--- a/dev/null
+++ b/libopie2/examples/opieui/owidgetstack_example/.cvsignore
@@ -0,0 +1,6 @@
1Makefile*
2moc*
3*moc
4*.o
5~*
6
diff --git a/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.cpp b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.cpp
new file mode 100644
index 0000000..b1c5e70
--- a/dev/null
+++ b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.cpp
@@ -0,0 +1,132 @@
1/*
2 * You may use, modify and distribute this example without any limitation
3 */
4
5#include "owidgetstack_example.h"
6
7/* OPIE */
8#include <opie2/oapplicationfactory.h>
9#include <opie2/owidgetstack.h>
10#include <qpe/resource.h>
11
12/* QT */
13#include <qaction.h>
14#include <qtoolbar.h>
15#include <qpopupmenu.h>
16#include <qmenubar.h>
17#include <qlayout.h>
18#include <qlabel.h>
19#include <qpushbutton.h>
20#include <qsignalmapper.h>
21
22using namespace Opie;
23
24OPIE_EXPORT_APP( OApplicationFactory<StackExample> )
25
26StackExample::StackExample( QWidget* parent, const char* name, WFlags fl )
27 : QMainWindow( parent, name, fl )
28{
29 m_stack = new OWidgetStack( this );
30 setCentralWidget( m_stack );
31
32 /* nice Signal Mapper ;) */
33 QSignalMapper *sm = new QSignalMapper(this);
34 connect(sm, SIGNAL(mapped(int) ), m_stack, SLOT(raiseWidget(int)) );
35
36 /* toolbar first but this should be known from the other examples */
37 setToolBarsMovable( false );
38
39 /* only a menubar here */
40 QToolBar* holder = new QToolBar( this );
41 holder->setHorizontalStretchable( true );
42
43 QMenuBar *bar = new QMenuBar( holder );
44 QPopupMenu *menu = new QPopupMenu( this );
45
46 QAction* a = new QAction( tr("Show MainWidget"), Resource::loadPixmap("zoom"),
47 QString::null, 0, this, 0 );
48 sm->setMapping(a, 1 );
49 connect(a, SIGNAL(activated() ),
50 sm, SLOT(map() ) );
51 a->addTo( menu );
52
53 a = new QAction( tr("Show Details Small"), Resource::loadPixmap("zoom"),
54 QString::null, 0, this, 0 );
55 sm->setMapping(a, 2 );
56 connect(a, SIGNAL(activated() ),
57 sm, SLOT(map() ) );
58 a->addTo( menu );
59
60 a = new QAction( tr("Show Details More"), Resource::loadPixmap("zoom"),
61 QString::null, 0, this, 0 );
62 sm->setMapping(a, 3 );
63 connect(a, SIGNAL(activated() ),
64 sm, SLOT(map() ) );
65 a->addTo( menu );
66
67 a = new QAction( tr("Show Details All"), Resource::loadPixmap("zoom"),
68 QString::null, 0, this, 0 );
69 sm->setMapping(a, 4 );
70 connect(a, SIGNAL(activated() ),
71 sm, SLOT(map() ) );
72
73 bar->insertItem( tr("Actions"), menu );
74
75 /* now the gui */
76
77 /* first widget, main widget */
78 QWidget * wid = new QWidget( m_stack );
79 QGridLayout *grid = new QGridLayout(wid, 2, 2 );
80
81 QPushButton *btn = new QPushButton( tr("Show Details Small"), wid, "details1" );
82 sm->setMapping(btn, 2 );
83 connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) );
84 grid->addWidget( btn, 0, 0 );
85
86 btn = new QPushButton( tr("Show Details Medium"), wid, "details2");
87 sm->setMapping(btn, 3 );
88 connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) );
89 grid->addWidget( btn, 0, 1 );
90
91 btn = new QPushButton( tr("Show Details All"), wid, "details3");
92 sm->setMapping(btn, 4 );
93 connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) );
94 grid->addWidget( btn, 1, 1 );
95
96 m_stack->addWidget( wid, 1 );
97 m_main = wid;
98
99 QLabel *lbl = new QLabel(m_stack );
100 lbl->setText(tr("Only small Details are shown here. Määh") );
101 m_stack->addWidget( lbl, 2 );
102
103 lbl = new QLabel( m_stack );
104 lbl->setText( tr("Some more details....Wo ist das Schaf?") );
105 m_stack->addWidget( lbl, 3 );
106
107 lbl = new QLabel( m_stack );
108 lbl->setText( tr("<qt>Ne nicht in Bayerisch Gmain sondern in Berlin<br>Vermiss und meine Augen werden nicht eckig, da mein Bildschirm abgerundet ist<br>Es lebe Hamburg Süd,weiss du, verstehst du? ;)<br>Susi ist dOOf, es lebe die Ofenecke...", "hard to translate that") );
109 m_stack->addWidget( lbl, 4 );
110
111
112 /* THE signal mapper does all the magic */
113 m_stack->raiseWidget( m_main );
114}
115
116
117StackExample::~StackExample() {
118
119}
120
121
122
123void StackExample::closeEvent( QCloseEvent* ev) {
124 /* if the close even came when we displayed a details */
125 if (m_stack->visibleWidget() != m_main ) {
126 m_stack->raiseWidget( m_main );
127 ev->ignore();
128 return;
129 }
130
131 ev->accept();
132}
diff --git a/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.h b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.h
new file mode 100644
index 0000000..aea85cb
--- a/dev/null
+++ b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.h
@@ -0,0 +1,28 @@
1/*
2 * You may use, modify and distribute this example without any limitation
3 */
4
5#ifndef O_STACK_EXAMPLE_SIMPLE_H
6#define O_STACK_EXAMPLE_SIMPLE_H
7
8#include <qmainwindow.h>
9#include <opie2/owidgetstack.h>
10
11using namespace Opie;
12
13class StackExample : public QMainWindow {
14 Q_OBJECT
15public:
16 StackExample( QWidget* paren, const char* name, WFlags fl );
17 ~StackExample();
18 static QString appName() { return QString::fromLatin1("owidgetstack-example"); }
19
20protected:
21 void closeEvent( QCloseEvent* e );
22private:
23 OWidgetStack* m_stack;
24 QWidget* m_main;
25
26};
27
28#endif
diff --git a/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.pro b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.pro
new file mode 100644
index 0000000..395a4fb
--- a/dev/null
+++ b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.pro
@@ -0,0 +1,13 @@
1CONFIG += qt warn_on
2TEMPLATE = app
3TARGET = owidgetstack-example
4
5SOURCES = owidgetstack_example.cpp
6HEADERS = owidgetstack_example.h
7
8INCLUDEPATH += $(OPIEDIR)/include
9DEPENDSPATH += $(OPIEDIR)/include
10
11LIBS += -lqpe -lopieui2
12
13include ( $(OPIEDIR)/include.pro )