-rw-r--r-- | library/qpeapplication.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/library/qpeapplication.h b/library/qpeapplication.h index 6486cad..7c99a9a 100644 --- a/library/qpeapplication.h +++ b/library/qpeapplication.h | |||
@@ -1,242 +1,244 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef __QPE_APPLICATION_H__ | 20 | #ifndef __QPE_APPLICATION_H__ |
21 | #define __QPE_APPLICATION_H__ | 21 | #define __QPE_APPLICATION_H__ |
22 | 22 | ||
23 | #include <stdlib.h> // for setenv() | 23 | #include <stdlib.h> // for setenv() |
24 | 24 | ||
25 | #include <qglobal.h> | 25 | #include <qglobal.h> |
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #include <qdialog.h> | 27 | #include <qdialog.h> |
28 | #include <qwsdisplay_qws.h> | 28 | #include <qwsdisplay_qws.h> |
29 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) | 29 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) |
30 | #define Q_WS_QWS | 30 | #define Q_WS_QWS |
31 | #endif | 31 | #endif |
32 | #include "qpedecoration_qws.h" | 32 | #include "qpedecoration_qws.h" |
33 | #include "timestring.h" | 33 | #include "timestring.h" |
34 | #include "qpeglobal.h" | 34 | #include "qpeglobal.h" |
35 | 35 | ||
36 | class QCopChannel; | 36 | class QCopChannel; |
37 | class QPEApplicationData; | 37 | class QPEApplicationData; |
38 | class QWSEvent; | 38 | class QWSEvent; |
39 | class QWSKeyEvent; | 39 | class QWSKeyEvent; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | \brief The QPEApplication class implements various system services | 42 | \brief The QPEApplication class implements various system services |
43 | that are available to all Qtopia applications. | 43 | that are available to all Qtopia applications. |
44 | 44 | ||
45 | Simply by using QPEApplication instead of QApplication, a standard Qt | 45 | Simply by using QPEApplication instead of QApplication, a standard Qt |
46 | application becomes a Qtopia application. It automatically follows | 46 | application becomes a Qtopia application. It automatically follows |
47 | style changes, quits and raises, and in the | 47 | style changes, quits and raises, and in the |
48 | case of \link docwidget.html document-oriented\endlink applications, | 48 | case of \link docwidget.html document-oriented\endlink applications, |
49 | changes the currently displayed document in response to the environment. | 49 | changes the currently displayed document in response to the environment. |
50 | 50 | ||
51 | To create a \link docwidget.html document-oriented\endlink | 51 | To create a \link docwidget.html document-oriented\endlink |
52 | application use showMainDocumentWidget(); to create a | 52 | application use showMainDocumentWidget(); to create a |
53 | non-document-oriented application use showMainWidget(). The | 53 | non-document-oriented application use showMainWidget(). The |
54 | keepRunning() function indicates whether the application will | 54 | keepRunning() function indicates whether the application will |
55 | continue running after it's processed the last \link qcop.html | 55 | continue running after it's processed the last \link qcop.html |
56 | QCop\endlink message. This can be changed using setKeepRunning(). | 56 | QCop\endlink message. This can be changed using setKeepRunning(). |
57 | 57 | ||
58 | A variety of signals are emitted when certain events occur, for | 58 | A variety of signals are emitted when certain events occur, for |
59 | example, timeChanged(), clockChanged(), weekChanged(), | 59 | example, timeChanged(), clockChanged(), weekChanged(), |
60 | dateFormatChanged() and volumeChanged(). If the application receives | 60 | dateFormatChanged() and volumeChanged(). If the application receives |
61 | a \link qcop.html QCop\endlink message on the application's | 61 | a \link qcop.html QCop\endlink message on the application's |
62 | QPE/Application/\e{appname} channel, the appMessage() signal is | 62 | QPE/Application/\e{appname} channel, the appMessage() signal is |
63 | emitted. There are also flush() and reload() signals, which | 63 | emitted. There are also flush() and reload() signals, which |
64 | are emitted when synching begins and ends respectively - upon these | 64 | are emitted when synching begins and ends respectively - upon these |
65 | signals, the application should save and reload any data | 65 | signals, the application should save and reload any data |
66 | files that are involved in synching. Most of these signals will initially | 66 | files that are involved in synching. Most of these signals will initially |
67 | be received and unfiltered through the appMessage() signal. | 67 | be received and unfiltered through the appMessage() signal. |
68 | 68 | ||
69 | This class also provides a set of useful static functions. The | 69 | This class also provides a set of useful static functions. The |
70 | qpeDir() and documentDir() functions return the respective paths. | 70 | qpeDir() and documentDir() functions return the respective paths. |
71 | The grabKeyboard() and ungrabKeyboard() functions are used to | 71 | The grabKeyboard() and ungrabKeyboard() functions are used to |
72 | control whether the application takes control of the device's | 72 | control whether the application takes control of the device's |
73 | physical buttons (e.g. application launch keys). The stylus' mode of | 73 | physical buttons (e.g. application launch keys). The stylus' mode of |
74 | operation is set with setStylusOperation() and retrieved with | 74 | operation is set with setStylusOperation() and retrieved with |
75 | stylusOperation(). There are also setInputMethodHint() and | 75 | stylusOperation(). There are also setInputMethodHint() and |
76 | inputMethodHint() functions. | 76 | inputMethodHint() functions. |
77 | 77 | ||
78 | \ingroup qtopiaemb | 78 | \ingroup qtopiaemb |
79 | */ | 79 | */ |
80 | class QPEApplication : public QApplication | 80 | class QPEApplication : public QApplication |
81 | { | 81 | { |
82 | Q_OBJECT | 82 | Q_OBJECT |
83 | public: | 83 | public: |
84 | QPEApplication( int& argc, char **argv, Type=GuiClient ); | 84 | QPEApplication( int& argc, char **argv, Type=GuiClient ); |
85 | ~QPEApplication(); | 85 | ~QPEApplication(); |
86 | 86 | ||
87 | static QString qpeDir(); | 87 | static QString qpeDir(); |
88 | static QString documentDir(); | 88 | static QString documentDir(); |
89 | void applyStyle(); | 89 | void applyStyle(); |
90 | void reset(); | 90 | void reset(); |
91 | static int defaultRotation(); | 91 | static int defaultRotation(); |
92 | static void setDefaultRotation(int r); | 92 | static void setDefaultRotation(int r); |
93 | static void setCurrentRotation(int r); | 93 | static void setCurrentRotation(int r); |
94 | static void setCurrentMode(int x, int y, int depth ); | 94 | static void setCurrentMode(int x, int y, int depth ); |
95 | static void grabKeyboard(); | 95 | static void grabKeyboard(); |
96 | static void ungrabKeyboard(); | 96 | static void ungrabKeyboard(); |
97 | 97 | ||
98 | enum StylusMode { | 98 | enum StylusMode { |
99 | LeftOnly, | 99 | LeftOnly, |
100 | RightOnHold | 100 | RightOnHold |
101 | // RightOnHoldLeftDelayed, etc. | 101 | // RightOnHoldLeftDelayed, etc. |
102 | }; | 102 | }; |
103 | static void setStylusOperation( QWidget*, StylusMode ); | 103 | static void setStylusOperation( QWidget*, StylusMode ); |
104 | static StylusMode stylusOperation( QWidget* ); | 104 | static StylusMode stylusOperation( QWidget* ); |
105 | 105 | ||
106 | enum InputMethodHint { | 106 | enum InputMethodHint { |
107 | Normal, | 107 | Normal, |
108 | AlwaysOff, | 108 | AlwaysOff, |
109 | AlwaysOn | 109 | AlwaysOn |
110 | }; | 110 | }; |
111 | 111 | ||
112 | enum screenSaverHint { | 112 | enum screenSaverHint { |
113 | Disable = 0, | 113 | Disable = 0, |
114 | DisableLightOff = 1, | 114 | DisableLightOff = 1, |
115 | DisableSuspend = 2, | 115 | DisableSuspend = 2, |
116 | Enable = 100 | 116 | Enable = 100 |
117 | }; | 117 | }; |
118 | 118 | ||
119 | static void setInputMethodHint( QWidget *, InputMethodHint ); | 119 | static void setInputMethodHint( QWidget *, InputMethodHint ); |
120 | static InputMethodHint inputMethodHint( QWidget * ); | 120 | static InputMethodHint inputMethodHint( QWidget * ); |
121 | 121 | ||
122 | void showMainWidget( QWidget*, bool nomax=FALSE ); | 122 | void showMainWidget( QWidget*, bool nomax=FALSE ); |
123 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); | 123 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); |
124 | 124 | ||
125 | static void showDialog( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; | 125 | static void showDialog( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; |
126 | static int execDialog ( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; | 126 | static int execDialog ( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; |
127 | static void showWidget( QWidget*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; | 127 | static void showWidget( QWidget*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; |
128 | /* Merge setTempScreenSaverMode */ | 128 | /* Merge setTempScreenSaverMode */ |
129 | #ifdef QTOPIA_INTERNAL_INITAPP | 129 | #ifdef QTOPIA_INTERNAL_INITAPP |
130 | void initApp( int argv, char **argv ); | 130 | void initApp( int argv, char **argv ); |
131 | #endif | 131 | #endif |
132 | 132 | ||
133 | static void setKeepRunning(); | 133 | static void setKeepRunning(); |
134 | bool keepRunning() const; | 134 | bool keepRunning() const; |
135 | 135 | ||
136 | bool keyboardGrabbed() const; | 136 | bool keyboardGrabbed() const; |
137 | 137 | ||
138 | int exec(); | 138 | int exec(); |
139 | 139 | ||
140 | static bool isSaveWindowsPos(); | ||
141 | |||
140 | signals: | 142 | signals: |
141 | void clientMoused(); | 143 | void clientMoused(); |
142 | void timeChanged(); | 144 | void timeChanged(); |
143 | void clockChanged( bool pm ); | 145 | void clockChanged( bool pm ); |
144 | void micChanged( bool muted ); | 146 | void micChanged( bool muted ); |
145 | void volumeChanged( bool muted ); | 147 | void volumeChanged( bool muted ); |
146 | void appMessage( const QCString& msg, const QByteArray& data); | 148 | void appMessage( const QCString& msg, const QByteArray& data); |
147 | void weekChanged( bool startOnMonday ); | 149 | void weekChanged( bool startOnMonday ); |
148 | void dateFormatChanged( DateFormat ); | 150 | void dateFormatChanged( DateFormat ); |
149 | void flush(); | 151 | void flush(); |
150 | void reload(); | 152 | void reload(); |
151 | /* linkChanged signal */ | 153 | /* linkChanged signal */ |
152 | 154 | ||
153 | private slots: | 155 | private slots: |
154 | void systemMessage( const QCString &msg, const QByteArray &data ); | 156 | void systemMessage( const QCString &msg, const QByteArray &data ); |
155 | void pidMessage( const QCString &msg, const QByteArray &data ); | 157 | void pidMessage( const QCString &msg, const QByteArray &data ); |
156 | void removeSenderFromStylusDict(); | 158 | void removeSenderFromStylusDict(); |
157 | void hideOrQuit(); | 159 | void hideOrQuit(); |
158 | 160 | ||
159 | protected: | 161 | protected: |
160 | bool qwsEventFilter( QWSEvent * ); | 162 | bool qwsEventFilter( QWSEvent * ); |
161 | void internalSetStyle( const QString &style ); | 163 | void internalSetStyle( const QString &style ); |
162 | void prepareForTermination(bool willrestart); | 164 | void prepareForTermination(bool willrestart); |
163 | virtual void restart(); | 165 | virtual void restart(); |
164 | virtual void shutdown(); | 166 | virtual void shutdown(); |
165 | bool eventFilter( QObject *, QEvent * ); | 167 | bool eventFilter( QObject *, QEvent * ); |
166 | void timerEvent( QTimerEvent * ); | 168 | void timerEvent( QTimerEvent * ); |
167 | bool raiseAppropriateWindow(); | 169 | bool raiseAppropriateWindow(); |
168 | virtual void tryQuit(); | 170 | virtual void tryQuit(); |
169 | private: | 171 | private: |
170 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); | 172 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); |
171 | void processQCopFile(); | 173 | void processQCopFile(); |
172 | 174 | ||
173 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 175 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
174 | QCopChannel *sysChannel; | 176 | QCopChannel *sysChannel; |
175 | QCopChannel *pidChannel; | 177 | QCopChannel *pidChannel; |
176 | #endif | 178 | #endif |
177 | QPEApplicationData *d; | 179 | QPEApplicationData *d; |
178 | 180 | ||
179 | bool reserved_sh; | 181 | bool reserved_sh; |
180 | 182 | ||
181 | }; | 183 | }; |
182 | 184 | ||
183 | 185 | ||
184 | 186 | ||
185 | enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ | 187 | enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ |
186 | 188 | ||
187 | inline int TransToDeg ( Transformation t ) | 189 | inline int TransToDeg ( Transformation t ) |
188 | { | 190 | { |
189 | int d = static_cast<int>( t ); | 191 | int d = static_cast<int>( t ); |
190 | return d * 90; | 192 | return d * 90; |
191 | } | 193 | } |
192 | 194 | ||
193 | inline Transformation DegToTrans ( int d ) | 195 | inline Transformation DegToTrans ( int d ) |
194 | { | 196 | { |
195 | Transformation t = static_cast<Transformation>( d / 90 ); | 197 | Transformation t = static_cast<Transformation>( d / 90 ); |
196 | return t; | 198 | return t; |
197 | } | 199 | } |
198 | 200 | ||
199 | /* | 201 | /* |
200 | * Set current rotation of Opie, and rotation for newly started apps. | 202 | * Set current rotation of Opie, and rotation for newly started apps. |
201 | * Differs from setDefaultRotation in that 1) it rotates currently running apps, | 203 | * Differs from setDefaultRotation in that 1) it rotates currently running apps, |
202 | * and 2) does not set deforient or save orientation to qpe.conf. | 204 | * and 2) does not set deforient or save orientation to qpe.conf. |
203 | */ | 205 | */ |
204 | 206 | ||
205 | inline void QPEApplication::setCurrentRotation( int r ) | 207 | inline void QPEApplication::setCurrentRotation( int r ) |
206 | { | 208 | { |
207 | // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots | 209 | // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots |
208 | // for compatibility with the SharpROM use fallback to setDefaultTransformation() | 210 | // for compatibility with the SharpROM use fallback to setDefaultTransformation() |
209 | #if QT_VERSION > 233 | 211 | #if QT_VERSION > 233 |
210 | Transformation e = DegToTrans( r ); | 212 | Transformation e = DegToTrans( r ); |
211 | QCString old = getenv("QWS_DISPLAY") ? getenv( "QWS_DISPLAY" ) : "Transformed"; | 213 | QCString old = getenv("QWS_DISPLAY") ? getenv( "QWS_DISPLAY" ) : "Transformed"; |
212 | int j = 0; | 214 | int j = 0; |
213 | QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() ); | 215 | QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() ); |
214 | ::setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg( driver ).arg( r ).latin1(), 1 ); | 216 | ::setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg( driver ).arg( r ).latin1(), 1 ); |
215 | qApp->desktop()->qwsDisplay()->setTransformation( e ); | 217 | qApp->desktop()->qwsDisplay()->setTransformation( e ); |
216 | #else | 218 | #else |
217 | setDefaultRotation( r ); | 219 | setDefaultRotation( r ); |
218 | #endif | 220 | #endif |
219 | } | 221 | } |
220 | 222 | ||
221 | /* | 223 | /* |
222 | * Qtopia 1.7 SDK compatibility macros | 224 | * Qtopia 1.7 SDK compatibility macros |
223 | * FIXME: Support Opie Quicklaunch Interface | 225 | * FIXME: Support Opie Quicklaunch Interface |
224 | */ | 226 | */ |
225 | #define QTOPIA_ADD_APPLICATION(NAME,IMPLEMENTATION) \ | 227 | #define QTOPIA_ADD_APPLICATION(NAME,IMPLEMENTATION) \ |
226 | int main( int argc, char** argv ) \ | 228 | int main( int argc, char** argv ) \ |
227 | { \ | 229 | { \ |
228 | QPEApplication app( argc, argv );\ | 230 | QPEApplication app( argc, argv );\ |
229 | IMPLEMENTATION* mw = new IMPLEMENTATION(); \ | 231 | IMPLEMENTATION* mw = new IMPLEMENTATION(); \ |
230 | app.showMainWidget( mw ); \ | 232 | app.showMainWidget( mw ); \ |
231 | app.exec(); \ | 233 | app.exec(); \ |
232 | } | 234 | } |
233 | #define QTOPIA_MAIN // Bee-Bop-Alula | 235 | #define QTOPIA_MAIN // Bee-Bop-Alula |
234 | 236 | ||
235 | /* | 237 | /* |
236 | * -remove me | 238 | * -remove me |
237 | */ | 239 | */ |
238 | #ifdef Q_WS_QWS | 240 | #ifdef Q_WS_QWS |
239 | extern Q_EXPORT QRect qt_maxWindowRect; | 241 | extern Q_EXPORT QRect qt_maxWindowRect; |
240 | #endif | 242 | #endif |
241 | 243 | ||
242 | #endif | 244 | #endif |