summaryrefslogtreecommitdiff
path: root/examples/simple-main
Unidiff
Diffstat (limited to 'examples/simple-main') (more/less context) (ignore whitespace changes)
-rw-r--r--examples/simple-main/simple.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/examples/simple-main/simple.cpp b/examples/simple-main/simple.cpp
index 8de911f..cf00cc6 100644
--- a/examples/simple-main/simple.cpp
+++ b/examples/simple-main/simple.cpp
@@ -1,122 +1,123 @@
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 10
11#include <opie/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 12
13#include "simple.h" 13#include "simple.h"
14 14
15/* 15/*
16 * implementation of simple 16 * implementation of simple
17 */ 17 */
18 18
19/* 19/*
20 * The factory is used for quicklaunching 20 * The factory is used for quicklaunching
21 * 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 21 * 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
22 * 22 *
23 * Depending on the global quick launch setting this will create 23 * Depending on the global quick launch setting this will create
24 * either a main method or one for our component plugin system 24 * either a main method or one for our component plugin system
25 */ 25 */
26 26
27using namespace Opie::Core;
27OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 28OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
28 29
29MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) 30MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl )
30 : QMainWindow( parent, name, fl ) { 31 : QMainWindow( parent, name, fl ) {
31 setCaption(tr("My MainWindow") ); 32 setCaption(tr("My MainWindow") );
32 setIcon( Resource::loadPixmap("new") ); 33 setIcon( Resource::loadPixmap("new") );
33 /* 34 /*
34 * out mainwindow should have a menubar 35 * out mainwindow should have a menubar
35 * a toolbar, a mainwidget and use Resource 36 * a toolbar, a mainwidget and use Resource
36 * to get the IconSets 37 * to get the IconSets
37 */ 38 */
38 /* 39 /*
39 * we initialize the GUI in a different methid 40 * we initialize the GUI in a different methid
40 */ 41 */
41 initUI(); 42 initUI();
42 43
43 Simple *simple = new Simple( this ); 44 Simple *simple = new Simple( this );
44 setCentralWidget( simple ); 45 setCentralWidget( simple );
45 46
46 /* 47 /*
47 * If you use signal and slots do not include the parameter 48 * If you use signal and slots do not include the parameter
48 * names inside 49 * names inside
49 * so SIGNAL(fooBar(int) ) and NOT SIGNAL(fooBar(int foo) ) 50 * so SIGNAL(fooBar(int) ) and NOT SIGNAL(fooBar(int foo) )
50 */ 51 */
51 /* 52 /*
52 * We connect the activation of our QAction 53 * We connect the activation of our QAction
53 * to the slot connected to the firebutton 54 * to the slot connected to the firebutton
54 * We could also connect the signal to the clicked 55 * We could also connect the signal to the clicked
55 * signal of the button 56 * signal of the button
56 */ 57 */
57 connect(m_fire, SIGNAL(activated() ), 58 connect(m_fire, SIGNAL(activated() ),
58 simple, SLOT(slotFire() ) ); 59 simple, SLOT(slotFire() ) );
59} 60}
60 61
61MainWindow::~MainWindow() { 62MainWindow::~MainWindow() {
62 // again nothing to delete because Qt takes care 63 // again nothing to delete because Qt takes care
63} 64}
64 65
65/* 66/*
66 * set Document is a special function used by Document 67 * set Document is a special function used by Document
67 * centric applications. 68 * centric applications.
68 * In example if Opie receives a Todo via IrDa it uses 69 * In example if Opie receives a Todo via IrDa it uses
69 * setDocument via QCOP the IPC system to load the card 70 * setDocument via QCOP the IPC system to load the card
70 * Or If you decide to open a file in filemanager with textedit 71 * Or If you decide to open a file in filemanager with textedit
71 * setDocument is called via IPC in textedit. 72 * setDocument is called via IPC in textedit.
72 * Also any call to QPE/Application/xyz and xyz is currently not running 73 * Also any call to QPE/Application/xyz and xyz is currently not running
73 * leads to the start of xyz and delivering of the QCOP call 74 * leads to the start of xyz and delivering of the QCOP call
74 * But more on QCOP in the next application 75 * But more on QCOP in the next application
75 */ 76 */
76void MainWindow::setDocument( const QString& /*str*/ ) { 77void MainWindow::setDocument( const QString& /*str*/ ) {
77 // in our case empty but you should see if it is a direct 78 // in our case empty but you should see if it is a direct
78 // file request or if it is a DocLnk. 79 // file request or if it is a DocLnk.
79 // A DocLnk is Link to an Document so you would end up 80 // A DocLnk is Link to an Document so you would end up
80 // opening the document behind the file you got 81 // opening the document behind the file you got
81} 82}
82 83
83/* 84/*
84 * Two new concepts with this Method 85 * Two new concepts with this Method
85 * 1. QAction. An action can be grouped and emits 86 * 1. QAction. An action can be grouped and emits
86 * an activated signal. Action a universal useable 87 * an activated signal. Action a universal useable
87 * you can just plug/addTo in most Qt widgets. For example 88 * you can just plug/addTo in most Qt widgets. For example
88 * the same action can be plugged into a ToolBar, MenuBar, 89 * the same action can be plugged into a ToolBar, MenuBar,
89 * QPopupMenu and other widgets but you do not need to worry 90 * QPopupMenu and other widgets but you do not need to worry
90 * about it 91 * about it
91 * 92 *
92 * 2. an IconSet contains pixmaps and provides them scaled down, scaled up 93 * 2. an IconSet contains pixmaps and provides them scaled down, scaled up
93 * enabled and disabled. SO if you use QIConSet and the toolbar 94 * enabled and disabled. SO if you use QIConSet and the toolbar
94 * size changes to use big pixmaps you will not use upscaled icons 95 * size changes to use big pixmaps you will not use upscaled icons
95 * but the right ones thanks to QIconSet and Resource 96 * but the right ones thanks to QIconSet and Resource
96 */ 97 */
97 98
98void MainWindow::initUI() { 99void MainWindow::initUI() {
99/* 100/*
100 * We want to provde a File Menu with Quit as option 101 * We want to provde a File Menu with Quit as option
101 * and a Fire Toolbutton ( QAction ) 102 * and a Fire Toolbutton ( QAction )
102 * So we need two actions 103 * So we need two actions
103 * A toolbar and a popupMenu 104 * A toolbar and a popupMenu
104 */ 105 */
105 setToolBarsMovable( false ); 106 setToolBarsMovable( false );
106 /* 107 /*
107 *We don't want the static toolbar but share it with the 108 *We don't want the static toolbar but share it with the
108 * toolbar on small screens 109 * toolbar on small screens
109 */ 110 */
110 QToolBar *menuBarHolder = new QToolBar( this ); 111 QToolBar *menuBarHolder = new QToolBar( this );
111 /* we allow the menubarholder to become bigger than 112 /* we allow the menubarholder to become bigger than
112 * the screen width and to offer a > for the additional items 113 * the screen width and to offer a > for the additional items
113 */ 114 */
114 menuBarHolder->setHorizontalStretchable( true ); 115 menuBarHolder->setHorizontalStretchable( true );
115 QMenuBar *mb = new QMenuBar( menuBarHolder ); 116 QMenuBar *mb = new QMenuBar( menuBarHolder );
116 QToolBar *tb = new QToolBar( this ); 117 QToolBar *tb = new QToolBar( this );
117 118
118 QPopupMenu *fileMenu = new QPopupMenu( this ); 119 QPopupMenu *fileMenu = new QPopupMenu( this );
119 120
120 /* 121 /*
121 * we create our first action with the Text Quit 122 * we create our first action with the Text Quit
122 * a IconSet, no menu name, no acceleration ( keyboard shortcut ), 123 * a IconSet, no menu name, no acceleration ( keyboard shortcut ),