-rw-r--r-- | library/qpeapplication.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index b686e2e..f4a7f74 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,274 +1,275 @@ | |||
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 | #define QTOPIA_INTERNAL_LANGLIST | 20 | #define QTOPIA_INTERNAL_LANGLIST |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #ifndef Q_OS_MACX | 23 | #ifndef Q_OS_MACX |
24 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) | 24 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) |
25 | #endif | 25 | #endif |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qqueue.h> | 27 | #include <qqueue.h> |
28 | #ifdef Q_WS_QWS | 28 | #ifdef Q_WS_QWS |
29 | #ifndef QT_NO_COP | 29 | #ifndef QT_NO_COP |
30 | #if QT_VERSION <= 231 | 30 | #if QT_VERSION <= 231 |
31 | #define private public | 31 | #define private public |
32 | #define sendLocally processEvent | 32 | #define sendLocally processEvent |
33 | #include "qcopenvelope_qws.h" | 33 | #include "qcopenvelope_qws.h" |
34 | #undef private | 34 | #undef private |
35 | #else | 35 | #else |
36 | #include "qcopenvelope_qws.h" | 36 | #include "qcopenvelope_qws.h" |
37 | #endif | 37 | #endif |
38 | #endif | 38 | #endif |
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | #endif | 40 | #endif |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qpalette.h> | 42 | #include <qpalette.h> |
43 | #include <qbuffer.h> | 43 | #include <qbuffer.h> |
44 | #include <qptrdict.h> | 44 | #include <qptrdict.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qdir.h> | 46 | #include <qdir.h> |
47 | #include <qlabel.h> | 47 | #include <qlabel.h> |
48 | #include <qdialog.h> | 48 | #include <qdialog.h> |
49 | #include <qdragobject.h> | 49 | #include <qdragobject.h> |
50 | #include <qtextcodec.h> | 50 | #include <qtextcodec.h> |
51 | #include <qevent.h> | 51 | #include <qevent.h> |
52 | #include <qtooltip.h> | 52 | #include <qtooltip.h> |
53 | #include <qsignal.h> | 53 | #include <qsignal.h> |
54 | #include <qmainwindow.h> | 54 | #include <qmainwindow.h> |
55 | #include <qwidgetlist.h> | 55 | #include <qwidgetlist.h> |
56 | #include <qpixmapcache.h> | 56 | #include <qpixmapcache.h> |
57 | 57 | ||
58 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 58 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
59 | #define QTOPIA_INTERNAL_INITAPP | 59 | #define QTOPIA_INTERNAL_INITAPP |
60 | #include "qpeapplication.h" | 60 | #include "qpeapplication.h" |
61 | #include "qpestyle.h" | 61 | #include "qpestyle.h" |
62 | #include "styleinterface.h" | 62 | #include "styleinterface.h" |
63 | #if QT_VERSION >= 300 | 63 | #if QT_VERSION >= 300 |
64 | #include <qstylefactory.h> | 64 | #include <qstylefactory.h> |
65 | #else | 65 | #else |
66 | #include <qplatinumstyle.h> | 66 | #include <qplatinumstyle.h> |
67 | #include <qwindowsstyle.h> | 67 | #include <qwindowsstyle.h> |
68 | #include <qmotifstyle.h> | 68 | #include <qmotifstyle.h> |
69 | #include <qmotifplusstyle.h> | 69 | #include <qmotifplusstyle.h> |
70 | #include "lightstyle.h" | 70 | #include "lightstyle.h" |
71 | 71 | ||
72 | #include <qpe/qlibrary.h> | 72 | #include <qpe/qlibrary.h> |
73 | #endif | 73 | #endif |
74 | #include "global.h" | 74 | #include "global.h" |
75 | #include "resource.h" | 75 | #include "resource.h" |
76 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 76 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
77 | #include "qutfcodec.h" | 77 | #include "qutfcodec.h" |
78 | #endif | 78 | #endif |
79 | #include "config.h" | 79 | #include "config.h" |
80 | #include "network.h" | 80 | #include "network.h" |
81 | #ifdef QWS | 81 | #ifdef QWS |
82 | #include "fontmanager.h" | 82 | #include "fontmanager.h" |
83 | #include "fontdatabase.h" | ||
83 | #endif | 84 | #endif |
84 | 85 | ||
85 | #include "alarmserver.h" | 86 | #include "alarmserver.h" |
86 | #include "applnk.h" | 87 | #include "applnk.h" |
87 | #include "qpemenubar.h" | 88 | #include "qpemenubar.h" |
88 | #include "textcodecinterface.h" | 89 | #include "textcodecinterface.h" |
89 | #include "imagecodecinterface.h" | 90 | #include "imagecodecinterface.h" |
90 | 91 | ||
91 | #include <unistd.h> | 92 | #include <unistd.h> |
92 | #include <sys/file.h> | 93 | #include <sys/file.h> |
93 | #include <sys/ioctl.h> | 94 | #include <sys/ioctl.h> |
94 | #ifndef QT_NO_SOUND | 95 | #ifndef QT_NO_SOUND |
95 | #include <sys/soundcard.h> | 96 | #include <sys/soundcard.h> |
96 | #endif | 97 | #endif |
97 | #include "qt_override_p.h" | 98 | #include "qt_override_p.h" |
98 | 99 | ||
99 | static bool useBigPixmaps = 0; | 100 | static bool useBigPixmaps = 0; |
100 | 101 | ||
101 | class HackWidget : public QWidget | 102 | class HackWidget : public QWidget |
102 | { | 103 | { |
103 | public: | 104 | public: |
104 | bool needsOk() | 105 | bool needsOk() |
105 | { return (getWState() & WState_Reserved1 ); } | 106 | { return (getWState() & WState_Reserved1 ); } |
106 | 107 | ||
107 | QRect normalGeometry() | 108 | QRect normalGeometry() |
108 | { return topData()->normalGeometry; }; | 109 | { return topData()->normalGeometry; }; |
109 | }; | 110 | }; |
110 | 111 | ||
111 | class QPEApplicationData | 112 | class QPEApplicationData |
112 | { | 113 | { |
113 | public: | 114 | public: |
114 | QPEApplicationData ( ) | 115 | QPEApplicationData ( ) |
115 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 116 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
116 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 117 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
117 | keep_running( true ), qcopQok( false ), | 118 | keep_running( true ), qcopQok( false ), |
118 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), | 119 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), |
119 | bigIconSize( 32 ), qpe_main_widget( 0 ) | 120 | bigIconSize( 32 ), qpe_main_widget( 0 ) |
120 | { | 121 | { |
121 | Config cfg( "qpe" ); | 122 | Config cfg( "qpe" ); |
122 | cfg.setGroup( "Appearance" ); | 123 | cfg.setGroup( "Appearance" ); |
123 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); | 124 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); |
124 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); | 125 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); |
125 | fontSize = cfg.readNumEntry( "FontSize", 10 ); | 126 | fontSize = cfg.readNumEntry( "FontSize", 10 ); |
126 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); | 127 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); |
127 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); | 128 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); |
128 | } | 129 | } |
129 | 130 | ||
130 | int presstimer; | 131 | int presstimer; |
131 | QWidget* presswidget; | 132 | QWidget* presswidget; |
132 | QPoint presspos; | 133 | QPoint presspos; |
133 | 134 | ||
134 | bool rightpressed : 1; | 135 | bool rightpressed : 1; |
135 | bool kbgrabbed : 1; | 136 | bool kbgrabbed : 1; |
136 | bool notbusysent : 1; | 137 | bool notbusysent : 1; |
137 | bool preloaded : 1; | 138 | bool preloaded : 1; |
138 | bool forceshow : 1; | 139 | bool forceshow : 1; |
139 | bool nomaximize : 1; | 140 | bool nomaximize : 1; |
140 | bool keep_running : 1; | 141 | bool keep_running : 1; |
141 | bool qcopQok : 1; | 142 | bool qcopQok : 1; |
142 | 143 | ||
143 | QCString fontFamily; | 144 | QCString fontFamily; |
144 | int fontSize; | 145 | int fontSize; |
145 | int smallIconSize; | 146 | int smallIconSize; |
146 | int bigIconSize; | 147 | int bigIconSize; |
147 | 148 | ||
148 | QStringList langs; | 149 | QStringList langs; |
149 | QString appName; | 150 | QString appName; |
150 | struct QCopRec | 151 | struct QCopRec |
151 | { | 152 | { |
152 | QCopRec( const QCString &ch, const QCString &msg, | 153 | QCopRec( const QCString &ch, const QCString &msg, |
153 | const QByteArray &d ) : | 154 | const QByteArray &d ) : |
154 | channel( ch ), message( msg ), data( d ) | 155 | channel( ch ), message( msg ), data( d ) |
155 | { } | 156 | { } |
156 | 157 | ||
157 | QCString channel; | 158 | QCString channel; |
158 | QCString message; | 159 | QCString message; |
159 | QByteArray data; | 160 | QByteArray data; |
160 | }; | 161 | }; |
161 | QWidget* qpe_main_widget; | 162 | QWidget* qpe_main_widget; |
162 | QGuardedPtr<QWidget> lastraised; | 163 | QGuardedPtr<QWidget> lastraised; |
163 | QQueue<QCopRec> qcopq; | 164 | QQueue<QCopRec> qcopq; |
164 | QString styleName; | 165 | QString styleName; |
165 | QString decorationName; | 166 | QString decorationName; |
166 | 167 | ||
167 | void enqueueQCop( const QCString &ch, const QCString &msg, | 168 | void enqueueQCop( const QCString &ch, const QCString &msg, |
168 | const QByteArray &data ) | 169 | const QByteArray &data ) |
169 | { | 170 | { |
170 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 171 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
171 | } | 172 | } |
172 | void sendQCopQ() | 173 | void sendQCopQ() |
173 | { | 174 | { |
174 | if (!qcopQok ) | 175 | if (!qcopQok ) |
175 | return; | 176 | return; |
176 | 177 | ||
177 | QCopRec * r; | 178 | QCopRec * r; |
178 | 179 | ||
179 | while((r=qcopq.dequeue())) { | 180 | while((r=qcopq.dequeue())) { |
180 | // remove from queue before sending... | 181 | // remove from queue before sending... |
181 | // event loop can come around again before getting | 182 | // event loop can come around again before getting |
182 | // back from sendLocally | 183 | // back from sendLocally |
183 | #ifndef QT_NO_COP | 184 | #ifndef QT_NO_COP |
184 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 185 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
185 | #endif | 186 | #endif |
186 | 187 | ||
187 | delete r; | 188 | delete r; |
188 | } | 189 | } |
189 | } | 190 | } |
190 | 191 | ||
191 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) | 192 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) |
192 | { | 193 | { |
193 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) | 194 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) |
194 | { | 195 | { |
195 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); | 196 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); |
196 | } | 197 | } |
197 | QPoint p; | 198 | QPoint p; |
198 | QSize s; | 199 | QSize s; |
199 | bool max; | 200 | bool max; |
200 | if ( mw->isVisible() ) { | 201 | if ( mw->isVisible() ) { |
201 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 202 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
202 | mw->resize(s); | 203 | mw->resize(s); |
203 | mw->move(p); | 204 | mw->move(p); |
204 | } | 205 | } |
205 | mw->raise(); | 206 | mw->raise(); |
206 | } else { | 207 | } else { |
207 | 208 | ||
208 | if ( mw->layout() && mw->inherits("QDialog") ) { | 209 | if ( mw->layout() && mw->inherits("QDialog") ) { |
209 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 210 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
210 | mw->resize(s); | 211 | mw->resize(s); |
211 | mw->move(p); | 212 | mw->move(p); |
212 | 213 | ||
213 | if ( max && !nomaximize ) { | 214 | if ( max && !nomaximize ) { |
214 | mw->showMaximized(); | 215 | mw->showMaximized(); |
215 | } else { | 216 | } else { |
216 | mw->show(); | 217 | mw->show(); |
217 | } | 218 | } |
218 | } else { | 219 | } else { |
219 | qpe_show_dialog((QDialog*)mw,nomaximize); | 220 | qpe_show_dialog((QDialog*)mw,nomaximize); |
220 | } | 221 | } |
221 | } else { | 222 | } else { |
222 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 223 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
223 | mw->resize(s); | 224 | mw->resize(s); |
224 | mw->move(p); | 225 | mw->move(p); |
225 | } else { //no stored rectangle, make an estimation | 226 | } else { //no stored rectangle, make an estimation |
226 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | 227 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
227 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | 228 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
228 | mw->move( QMAX(x,0), QMAX(y,0) ); | 229 | mw->move( QMAX(x,0), QMAX(y,0) ); |
229 | #ifdef Q_WS_QWS | 230 | #ifdef Q_WS_QWS |
230 | if ( !nomaximize ) | 231 | if ( !nomaximize ) |
231 | mw->showMaximized(); | 232 | mw->showMaximized(); |
232 | #endif | 233 | #endif |
233 | } | 234 | } |
234 | if ( max && !nomaximize ) | 235 | if ( max && !nomaximize ) |
235 | mw->showMaximized(); | 236 | mw->showMaximized(); |
236 | else | 237 | else |
237 | mw->show(); | 238 | mw->show(); |
238 | } | 239 | } |
239 | } | 240 | } |
240 | } | 241 | } |
241 | 242 | ||
242 | static void qpe_show_dialog( QDialog* d, bool nomax ) | 243 | static void qpe_show_dialog( QDialog* d, bool nomax ) |
243 | { | 244 | { |
244 | QSize sh = d->sizeHint(); | 245 | QSize sh = d->sizeHint(); |
245 | int w = QMAX(sh.width(),d->width()); | 246 | int w = QMAX(sh.width(),d->width()); |
246 | int h = QMAX(sh.height(),d->height()); | 247 | int h = QMAX(sh.height(),d->height()); |
247 | 248 | ||
248 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) | 249 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) |
249 | nomax = TRUE; | 250 | nomax = TRUE; |
250 | 251 | ||
251 | #ifndef Q_WS_QWS | 252 | #ifndef Q_WS_QWS |
252 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); | 253 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); |
253 | #else | 254 | #else |
254 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); | 255 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); |
255 | #endif | 256 | #endif |
256 | 257 | ||
257 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); | 258 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); |
258 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); | 259 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); |
259 | 260 | ||
260 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { | 261 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { |
261 | d->showMaximized(); | 262 | d->showMaximized(); |
262 | } else { | 263 | } else { |
263 | // try centering the dialog around its parent | 264 | // try centering the dialog around its parent |
264 | QPoint p(0,0); | 265 | QPoint p(0,0); |
265 | if ( d->parentWidget() ) { | 266 | if ( d->parentWidget() ) { |
266 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); | 267 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); |
267 | p = QPoint( pp.x() + d->parentWidget()->width()/2, | 268 | p = QPoint( pp.x() + d->parentWidget()->width()/2, |
268 | pp.y() + d->parentWidget()->height()/ 2 ); | 269 | pp.y() + d->parentWidget()->height()/ 2 ); |
269 | } else { | 270 | } else { |
270 | p = QPoint( maxX/2, maxY/2 ); | 271 | p = QPoint( maxX/2, maxY/2 ); |
271 | } | 272 | } |
272 | 273 | ||
273 | p = QPoint( p.x() - w/2, p.y() - h/2 ); | 274 | p = QPoint( p.x() - w/2, p.y() - h/2 ); |
274 | // qDebug("p(x,y) is %d %d", p.x(), p.y() ); | 275 | // qDebug("p(x,y) is %d %d", p.x(), p.y() ); |
@@ -614,461 +615,462 @@ static void setBass( int t = 0, int percent = -1 ) | |||
614 | 615 | ||
615 | 616 | ||
616 | static void setTreble( int t = 0, int percent = -1 ) | 617 | static void setTreble( int t = 0, int percent = -1 ) |
617 | { | 618 | { |
618 | switch ( t ) { | 619 | switch ( t ) { |
619 | case 0: { | 620 | case 0: { |
620 | Config cfg( "qpe" ); | 621 | Config cfg( "qpe" ); |
621 | cfg.setGroup( "Volume" ); | 622 | cfg.setGroup( "Volume" ); |
622 | if ( percent < 0 ) | 623 | if ( percent < 0 ) |
623 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 624 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
624 | 625 | ||
625 | #ifndef QT_NO_SOUND | 626 | #ifndef QT_NO_SOUND |
626 | int fd = 0; | 627 | int fd = 0; |
627 | int treble = percent; | 628 | int treble = percent; |
628 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 629 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
629 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 630 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
630 | ::close( fd ); | 631 | ::close( fd ); |
631 | } | 632 | } |
632 | #endif | 633 | #endif |
633 | } | 634 | } |
634 | break; | 635 | break; |
635 | } | 636 | } |
636 | } | 637 | } |
637 | 638 | ||
638 | 639 | ||
639 | /** | 640 | /** |
640 | \class QPEApplication | 641 | \class QPEApplication |
641 | \brief The QPEApplication class implements various system services | 642 | \brief The QPEApplication class implements various system services |
642 | that are available to all Qtopia applications. | 643 | that are available to all Qtopia applications. |
643 | 644 | ||
644 | Simply by using QPEApplication instead of QApplication, a standard Qt | 645 | Simply by using QPEApplication instead of QApplication, a standard Qt |
645 | application becomes a Qtopia application. It automatically follows | 646 | application becomes a Qtopia application. It automatically follows |
646 | style changes, quits and raises, and in the | 647 | style changes, quits and raises, and in the |
647 | case of \link docwidget.html document-oriented\endlink applications, | 648 | case of \link docwidget.html document-oriented\endlink applications, |
648 | changes the currently displayed document in response to the environment. | 649 | changes the currently displayed document in response to the environment. |
649 | 650 | ||
650 | To create a \link docwidget.html document-oriented\endlink | 651 | To create a \link docwidget.html document-oriented\endlink |
651 | application use showMainDocumentWidget(); to create a | 652 | application use showMainDocumentWidget(); to create a |
652 | non-document-oriented application use showMainWidget(). The | 653 | non-document-oriented application use showMainWidget(). The |
653 | keepRunning() function indicates whether the application will | 654 | keepRunning() function indicates whether the application will |
654 | continue running after it's processed the last \link qcop.html | 655 | continue running after it's processed the last \link qcop.html |
655 | QCop\endlink message. This can be changed using setKeepRunning(). | 656 | QCop\endlink message. This can be changed using setKeepRunning(). |
656 | 657 | ||
657 | A variety of signals are emitted when certain events occur, for | 658 | A variety of signals are emitted when certain events occur, for |
658 | example, timeChanged(), clockChanged(), weekChanged(), | 659 | example, timeChanged(), clockChanged(), weekChanged(), |
659 | dateFormatChanged() and volumeChanged(). If the application receives | 660 | dateFormatChanged() and volumeChanged(). If the application receives |
660 | a \link qcop.html QCop\endlink message on the application's | 661 | a \link qcop.html QCop\endlink message on the application's |
661 | QPE/Application/\e{appname} channel, the appMessage() signal is | 662 | QPE/Application/\e{appname} channel, the appMessage() signal is |
662 | emitted. There are also flush() and reload() signals, which | 663 | emitted. There are also flush() and reload() signals, which |
663 | are emitted when synching begins and ends respectively - upon these | 664 | are emitted when synching begins and ends respectively - upon these |
664 | signals, the application should save and reload any data | 665 | signals, the application should save and reload any data |
665 | files that are involved in synching. Most of these signals will initially | 666 | files that are involved in synching. Most of these signals will initially |
666 | be received and unfiltered through the appMessage() signal. | 667 | be received and unfiltered through the appMessage() signal. |
667 | 668 | ||
668 | This class also provides a set of useful static functions. The | 669 | This class also provides a set of useful static functions. The |
669 | qpeDir() and documentDir() functions return the respective paths. | 670 | qpeDir() and documentDir() functions return the respective paths. |
670 | The grabKeyboard() and ungrabKeyboard() functions are used to | 671 | The grabKeyboard() and ungrabKeyboard() functions are used to |
671 | control whether the application takes control of the device's | 672 | control whether the application takes control of the device's |
672 | physical buttons (e.g. application launch keys). The stylus' mode of | 673 | physical buttons (e.g. application launch keys). The stylus' mode of |
673 | operation is set with setStylusOperation() and retrieved with | 674 | operation is set with setStylusOperation() and retrieved with |
674 | stylusOperation(). There are also setInputMethodHint() and | 675 | stylusOperation(). There are also setInputMethodHint() and |
675 | inputMethodHint() functions. | 676 | inputMethodHint() functions. |
676 | 677 | ||
677 | \ingroup qtopiaemb | 678 | \ingroup qtopiaemb |
678 | */ | 679 | */ |
679 | 680 | ||
680 | /*! | 681 | /*! |
681 | \fn void QPEApplication::clientMoused() | 682 | \fn void QPEApplication::clientMoused() |
682 | 683 | ||
683 | \internal | 684 | \internal |
684 | */ | 685 | */ |
685 | 686 | ||
686 | /*! | 687 | /*! |
687 | \fn void QPEApplication::timeChanged(); | 688 | \fn void QPEApplication::timeChanged(); |
688 | This signal is emitted when the time changes outside the normal | 689 | This signal is emitted when the time changes outside the normal |
689 | passage of time, i.e. if the time is set backwards or forwards. | 690 | passage of time, i.e. if the time is set backwards or forwards. |
690 | */ | 691 | */ |
691 | 692 | ||
692 | /*! | 693 | /*! |
693 | \fn void QPEApplication::clockChanged( bool ampm ); | 694 | \fn void QPEApplication::clockChanged( bool ampm ); |
694 | 695 | ||
695 | This signal is emitted when the user changes the clock's style. If | 696 | This signal is emitted when the user changes the clock's style. If |
696 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 697 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
697 | they want a 24-hour clock. | 698 | they want a 24-hour clock. |
698 | */ | 699 | */ |
699 | 700 | ||
700 | /*! | 701 | /*! |
701 | \fn void QPEApplication::volumeChanged( bool muted ) | 702 | \fn void QPEApplication::volumeChanged( bool muted ) |
702 | 703 | ||
703 | This signal is emitted whenever the mute state is changed. If \a | 704 | This signal is emitted whenever the mute state is changed. If \a |
704 | muted is TRUE, then sound output has been muted. | 705 | muted is TRUE, then sound output has been muted. |
705 | */ | 706 | */ |
706 | 707 | ||
707 | /*! | 708 | /*! |
708 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 709 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
709 | 710 | ||
710 | This signal is emitted if the week start day is changed. If \a | 711 | This signal is emitted if the week start day is changed. If \a |
711 | startOnMonday is TRUE then the first day of the week is Monday; if | 712 | startOnMonday is TRUE then the first day of the week is Monday; if |
712 | \a startOnMonday is FALSE then the first day of the week is | 713 | \a startOnMonday is FALSE then the first day of the week is |
713 | Sunday. | 714 | Sunday. |
714 | */ | 715 | */ |
715 | 716 | ||
716 | /*! | 717 | /*! |
717 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 718 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
718 | 719 | ||
719 | This signal is emitted whenever the date format is changed. | 720 | This signal is emitted whenever the date format is changed. |
720 | */ | 721 | */ |
721 | 722 | ||
722 | /*! | 723 | /*! |
723 | \fn void QPEApplication::flush() | 724 | \fn void QPEApplication::flush() |
724 | 725 | ||
725 | ### | 726 | ### |
726 | */ | 727 | */ |
727 | 728 | ||
728 | /*! | 729 | /*! |
729 | \fn void QPEApplication::reload() | 730 | \fn void QPEApplication::reload() |
730 | 731 | ||
731 | */ | 732 | */ |
732 | 733 | ||
733 | 734 | ||
734 | 735 | ||
735 | void QPEApplication::processQCopFile() | 736 | void QPEApplication::processQCopFile() |
736 | { | 737 | { |
737 | QString qcopfn("/tmp/qcop-msg-"); | 738 | QString qcopfn("/tmp/qcop-msg-"); |
738 | qcopfn += d->appName; // append command name | 739 | qcopfn += d->appName; // append command name |
739 | 740 | ||
740 | QFile f(qcopfn); | 741 | QFile f(qcopfn); |
741 | if ( f.open(IO_ReadWrite) ) { | 742 | if ( f.open(IO_ReadWrite) ) { |
742 | #ifndef Q_OS_WIN32 | 743 | #ifndef Q_OS_WIN32 |
743 | flock(f.handle(), LOCK_EX); | 744 | flock(f.handle(), LOCK_EX); |
744 | #endif | 745 | #endif |
745 | QDataStream ds(&f); | 746 | QDataStream ds(&f); |
746 | QCString channel, message; | 747 | QCString channel, message; |
747 | QByteArray data; | 748 | QByteArray data; |
748 | while(!ds.atEnd()) { | 749 | while(!ds.atEnd()) { |
749 | ds >> channel >> message >> data; | 750 | ds >> channel >> message >> data; |
750 | d->enqueueQCop(channel,message,data); | 751 | d->enqueueQCop(channel,message,data); |
751 | } | 752 | } |
752 | ::ftruncate(f.handle(), 0); | 753 | ::ftruncate(f.handle(), 0); |
753 | #ifndef Q_OS_WIN32 | 754 | #ifndef Q_OS_WIN32 |
754 | f.flush(); | 755 | f.flush(); |
755 | flock(f.handle(), LOCK_UN); | 756 | flock(f.handle(), LOCK_UN); |
756 | #endif | 757 | #endif |
757 | } | 758 | } |
758 | #endif | 759 | #endif |
759 | } | 760 | } |
760 | 761 | ||
761 | 762 | ||
762 | /*! | 763 | /*! |
763 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 764 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
764 | 765 | ||
765 | This signal is emitted when a message is received on this | 766 | This signal is emitted when a message is received on this |
766 | application's QPE/Application/<i>appname</i> \link qcop.html | 767 | application's QPE/Application/<i>appname</i> \link qcop.html |
767 | QCop\endlink channel. | 768 | QCop\endlink channel. |
768 | 769 | ||
769 | The slot to which you connect this signal uses \a msg and \a data | 770 | The slot to which you connect this signal uses \a msg and \a data |
770 | in the following way: | 771 | in the following way: |
771 | 772 | ||
772 | \code | 773 | \code |
773 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 774 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
774 | { | 775 | { |
775 | QDataStream stream( data, IO_ReadOnly ); | 776 | QDataStream stream( data, IO_ReadOnly ); |
776 | if ( msg == "someMessage(int,int,int)" ) { | 777 | if ( msg == "someMessage(int,int,int)" ) { |
777 | int a,b,c; | 778 | int a,b,c; |
778 | stream >> a >> b >> c; | 779 | stream >> a >> b >> c; |
779 | ... | 780 | ... |
780 | } else if ( msg == "otherMessage(QString)" ) { | 781 | } else if ( msg == "otherMessage(QString)" ) { |
781 | ... | 782 | ... |
782 | } | 783 | } |
783 | } | 784 | } |
784 | \endcode | 785 | \endcode |
785 | 786 | ||
786 | \sa qcop.html | 787 | \sa qcop.html |
787 | Note that messages received here may be processed by qpe application | 788 | Note that messages received here may be processed by qpe application |
788 | and emitted as signals, such as flush() and reload(). | 789 | and emitted as signals, such as flush() and reload(). |
789 | */ | 790 | */ |
790 | 791 | ||
791 | /*! | 792 | /*! |
792 | Constructs a QPEApplication just as you would construct | 793 | Constructs a QPEApplication just as you would construct |
793 | a QApplication, passing \a argc, \a argv, and \a t. | 794 | a QApplication, passing \a argc, \a argv, and \a t. |
794 | 795 | ||
795 | For applications, \a t should be the default, GuiClient. Only | 796 | For applications, \a t should be the default, GuiClient. Only |
796 | the Qtopia server passes GuiServer. | 797 | the Qtopia server passes GuiServer. |
797 | */ | 798 | */ |
798 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 799 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
799 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 800 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
800 | { | 801 | { |
801 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. | 802 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. |
802 | 803 | ||
803 | d = new QPEApplicationData; | 804 | d = new QPEApplicationData; |
804 | d->loadTextCodecs(); | 805 | d->loadTextCodecs(); |
805 | d->loadImageCodecs(); | 806 | d->loadImageCodecs(); |
806 | int dw = desktop() ->width(); | ||
807 | 807 | ||
808 | setFont( QFont( d->fontFamily, d->fontSize ) ); | 808 | setFont( QFont( d->fontFamily, d->fontSize ) ); |
809 | AppLnk::setSmallIconSize( d->smallIconSize ); | 809 | AppLnk::setSmallIconSize( d->smallIconSize ); |
810 | AppLnk::setBigIconSize( d->bigIconSize ); | 810 | AppLnk::setBigIconSize( d->bigIconSize ); |
811 | 811 | ||
812 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 812 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
813 | 813 | ||
814 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 814 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
815 | 815 | ||
816 | 816 | ||
817 | sysChannel = new QCopChannel( "QPE/System", this ); | 817 | sysChannel = new QCopChannel( "QPE/System", this ); |
818 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 818 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
819 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 819 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
820 | 820 | ||
821 | /* COde now in initapp */ | 821 | /* COde now in initapp */ |
822 | #if 0 | 822 | #if 0 |
823 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 823 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
824 | 824 | ||
825 | QString qcopfn( "/tmp/qcop-msg-" ); | 825 | QString qcopfn( "/tmp/qcop-msg-" ); |
826 | qcopfn += QString( argv[ 0 ] ); // append command name | 826 | qcopfn += QString( argv[ 0 ] ); // append command name |
827 | 827 | ||
828 | QFile f( qcopfn ); | 828 | QFile f( qcopfn ); |
829 | if ( f.open( IO_ReadOnly ) ) { | 829 | if ( f.open( IO_ReadOnly ) ) { |
830 | flock( f.handle(), LOCK_EX ); | 830 | flock( f.handle(), LOCK_EX ); |
831 | } | 831 | } |
832 | 832 | ||
833 | 833 | ||
834 | 834 | ||
835 | QCString channel = QCString( argv[ 0 ] ); | 835 | QCString channel = QCString( argv[ 0 ] ); |
836 | channel.replace( QRegExp( ".*/" ), "" ); | 836 | channel.replace( QRegExp( ".*/" ), "" ); |
837 | d->appName = channel; | 837 | d->appName = channel; |
838 | channel = "QPE/Application/" + channel; | 838 | channel = "QPE/Application/" + channel; |
839 | pidChannel = new QCopChannel( channel, this ); | 839 | pidChannel = new QCopChannel( channel, this ); |
840 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 840 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
841 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); | 841 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); |
842 | 842 | ||
843 | if ( f.isOpen() ) { | 843 | if ( f.isOpen() ) { |
844 | d->keep_running = FALSE; | 844 | d->keep_running = FALSE; |
845 | QDataStream ds( &f ); | 845 | QDataStream ds( &f ); |
846 | QCString channel, message; | 846 | QCString channel, message; |
847 | QByteArray data; | 847 | QByteArray data; |
848 | while ( !ds.atEnd() ) { | 848 | while ( !ds.atEnd() ) { |
849 | ds >> channel >> message >> data; | 849 | ds >> channel >> message >> data; |
850 | d->enqueueQCop( channel, message, data ); | 850 | d->enqueueQCop( channel, message, data ); |
851 | } | 851 | } |
852 | 852 | ||
853 | flock( f.handle(), LOCK_UN ); | 853 | flock( f.handle(), LOCK_UN ); |
854 | f.close(); | 854 | f.close(); |
855 | f.remove(); | 855 | f.remove(); |
856 | } | 856 | } |
857 | 857 | ||
858 | for ( int a = 0; a < argc; a++ ) { | 858 | for ( int a = 0; a < argc; a++ ) { |
859 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 859 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
860 | argv[ a ] = argv[ a + 1 ]; | 860 | argv[ a ] = argv[ a + 1 ]; |
861 | a++; | 861 | a++; |
862 | d->preloaded = TRUE; | 862 | d->preloaded = TRUE; |
863 | argc -= 1; | 863 | argc -= 1; |
864 | } | 864 | } |
865 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 865 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
866 | argv[ a ] = argv[ a + 1 ]; | 866 | argv[ a ] = argv[ a + 1 ]; |
867 | a++; | 867 | a++; |
868 | d->preloaded = TRUE; | 868 | d->preloaded = TRUE; |
869 | d->forceshow = TRUE; | 869 | d->forceshow = TRUE; |
870 | argc -= 1; | 870 | argc -= 1; |
871 | } | 871 | } |
872 | } | 872 | } |
873 | 873 | ||
874 | /* overide stored arguments */ | 874 | /* overide stored arguments */ |
875 | setArgs( argc, argv ); | 875 | setArgs( argc, argv ); |
876 | 876 | ||
877 | #endif | 877 | #endif |
878 | #else | 878 | #else |
879 | initApp( argc, argv ); | 879 | initApp( argc, argv ); |
880 | #endif | 880 | #endif |
881 | // qwsSetDecoration( new QPEDecoration() ); | 881 | #ifdef Q_WS_QWS |
882 | 882 | /* load the font renderer factories */ | |
883 | FontDatabase::loadRenderers(); | ||
884 | #endif | ||
883 | #ifndef QT_NO_TRANSLATION | 885 | #ifndef QT_NO_TRANSLATION |
884 | 886 | ||
885 | d->langs = Global::languageList(); | 887 | d->langs = Global::languageList(); |
886 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { | 888 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { |
887 | QString lang = *it; | 889 | QString lang = *it; |
888 | 890 | ||
889 | installTranslation( lang + "/libopie.qm"); | 891 | installTranslation( lang + "/libopie.qm"); |
890 | installTranslation( lang + "/libqpe.qm" ); | 892 | installTranslation( lang + "/libqpe.qm" ); |
891 | installTranslation( lang + "/" + d->appName + ".qm" ); | 893 | installTranslation( lang + "/" + d->appName + ".qm" ); |
892 | 894 | ||
893 | 895 | ||
894 | //###language/font hack; should look it up somewhere | 896 | //###language/font hack; should look it up somewhere |
895 | #ifdef QWS | 897 | #ifdef QWS |
896 | 898 | ||
897 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 899 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
898 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 900 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
899 | setFont( fn ); | 901 | setFont( fn ); |
900 | } | 902 | } |
901 | #endif | 903 | #endif |
902 | } | 904 | } |
903 | #endif | 905 | #endif |
904 | 906 | ||
905 | applyStyle(); | 907 | applyStyle(); |
906 | 908 | ||
907 | if ( type() == GuiServer ) { | 909 | if ( type() == GuiServer ) { |
908 | setVolume(); | 910 | setVolume(); |
909 | } | 911 | } |
910 | 912 | ||
911 | installEventFilter( this ); | 913 | installEventFilter( this ); |
912 | 914 | ||
913 | QPEMenuToolFocusManager::initialize(); | 915 | QPEMenuToolFocusManager::initialize(); |
914 | 916 | ||
915 | #ifdef QT_NO_QWS_CURSOR | 917 | #ifdef QT_NO_QWS_CURSOR |
916 | // if we have no cursor, probably don't want tooltips | 918 | // if we have no cursor, probably don't want tooltips |
917 | QToolTip::setEnabled( FALSE ); | 919 | QToolTip::setEnabled( FALSE ); |
918 | #endif | 920 | #endif |
919 | } | 921 | } |
920 | 922 | ||
921 | 923 | ||
922 | #ifdef QTOPIA_INTERNAL_INITAPP | 924 | #ifdef QTOPIA_INTERNAL_INITAPP |
923 | void QPEApplication::initApp( int argc, char **argv ) | 925 | void QPEApplication::initApp( int argc, char **argv ) |
924 | { | 926 | { |
925 | delete pidChannel; | 927 | delete pidChannel; |
926 | d->keep_running = TRUE; | 928 | d->keep_running = TRUE; |
927 | d->preloaded = FALSE; | 929 | d->preloaded = FALSE; |
928 | d->forceshow = FALSE; | 930 | d->forceshow = FALSE; |
929 | 931 | ||
930 | QCString channel = QCString(argv[0]); | 932 | QCString channel = QCString(argv[0]); |
931 | 933 | ||
932 | channel.replace(QRegExp(".*/"),""); | 934 | channel.replace(QRegExp(".*/"),""); |
933 | d->appName = channel; | 935 | d->appName = channel; |
934 | 936 | ||
935 | #if QT_VERSION > 235 | 937 | #if QT_VERSION > 235 |
936 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | 938 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 |
937 | #endif | 939 | #endif |
938 | 940 | ||
939 | channel = "QPE/Application/" + channel; | 941 | channel = "QPE/Application/" + channel; |
940 | pidChannel = new QCopChannel( channel, this); | 942 | pidChannel = new QCopChannel( channel, this); |
941 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 943 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
942 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); | 944 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); |
943 | 945 | ||
944 | 946 | ||
945 | 947 | ||
946 | processQCopFile(); | 948 | processQCopFile(); |
947 | d->keep_running = d->qcopq.isEmpty(); | 949 | d->keep_running = d->qcopq.isEmpty(); |
948 | 950 | ||
949 | for (int a=0; a<argc; a++) { | 951 | for (int a=0; a<argc; a++) { |
950 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 952 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
951 | argv[a] = argv[a+1]; | 953 | argv[a] = argv[a+1]; |
952 | a++; | 954 | a++; |
953 | d->preloaded = TRUE; | 955 | d->preloaded = TRUE; |
954 | argc-=1; | 956 | argc-=1; |
955 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 957 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
956 | argv[a] = argv[a+1]; | 958 | argv[a] = argv[a+1]; |
957 | a++; | 959 | a++; |
958 | d->preloaded = TRUE; | 960 | d->preloaded = TRUE; |
959 | d->forceshow = TRUE; | 961 | d->forceshow = TRUE; |
960 | argc-=1; | 962 | argc-=1; |
961 | } | 963 | } |
962 | } | 964 | } |
963 | 965 | ||
964 | /* overide stored arguments */ | 966 | /* overide stored arguments */ |
965 | setArgs(argc, argv); | 967 | setArgs(argc, argv); |
966 | 968 | ||
967 | /* install translation here */ | 969 | /* install translation here */ |
968 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) | 970 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) |
969 | installTranslation( (*it) + "/" + d->appName + ".qm" ); | 971 | installTranslation( (*it) + "/" + d->appName + ".qm" ); |
970 | } | 972 | } |
971 | #endif | 973 | #endif |
972 | 974 | ||
973 | 975 | ||
974 | static QPtrDict<void>* inputMethodDict = 0; | 976 | static QPtrDict<void>* inputMethodDict = 0; |
975 | static void createInputMethodDict() | 977 | static void createInputMethodDict() |
976 | { | 978 | { |
977 | if ( !inputMethodDict ) | 979 | if ( !inputMethodDict ) |
978 | inputMethodDict = new QPtrDict<void>; | 980 | inputMethodDict = new QPtrDict<void>; |
979 | } | 981 | } |
980 | 982 | ||
981 | /*! | 983 | /*! |
982 | Returns the currently set hint to the system as to whether | 984 | Returns the currently set hint to the system as to whether |
983 | widget \a w has any use for text input methods. | 985 | widget \a w has any use for text input methods. |
984 | 986 | ||
985 | 987 | ||
986 | \sa setInputMethodHint() InputMethodHint | 988 | \sa setInputMethodHint() InputMethodHint |
987 | */ | 989 | */ |
988 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 990 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
989 | { | 991 | { |
990 | if ( inputMethodDict && w ) | 992 | if ( inputMethodDict && w ) |
991 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 993 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
992 | return Normal; | 994 | return Normal; |
993 | } | 995 | } |
994 | 996 | ||
995 | /*! | 997 | /*! |
996 | \enum QPEApplication::InputMethodHint | 998 | \enum QPEApplication::InputMethodHint |
997 | 999 | ||
998 | \value Normal the application sometimes needs text input (the default). | 1000 | \value Normal the application sometimes needs text input (the default). |
999 | \value AlwaysOff the application never needs text input. | 1001 | \value AlwaysOff the application never needs text input. |
1000 | \value AlwaysOn the application always needs text input. | 1002 | \value AlwaysOn the application always needs text input. |
1001 | */ | 1003 | */ |
1002 | 1004 | ||
1003 | /*! | 1005 | /*! |
1004 | Hints to the system that widget \a w has use for text input methods | 1006 | Hints to the system that widget \a w has use for text input methods |
1005 | as specified by \a mode. | 1007 | as specified by \a mode. |
1006 | 1008 | ||
1007 | \sa inputMethodHint() InputMethodHint | 1009 | \sa inputMethodHint() InputMethodHint |
1008 | */ | 1010 | */ |
1009 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 1011 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
1010 | { | 1012 | { |
1011 | createInputMethodDict(); | 1013 | createInputMethodDict(); |
1012 | if ( mode == Normal ) { | 1014 | if ( mode == Normal ) { |
1013 | inputMethodDict->remove | 1015 | inputMethodDict->remove |
1014 | ( w ); | 1016 | ( w ); |
1015 | } | 1017 | } |
1016 | else { | 1018 | else { |
1017 | inputMethodDict->insert( w, ( void* ) mode ); | 1019 | inputMethodDict->insert( w, ( void* ) mode ); |
1018 | } | 1020 | } |
1019 | } | 1021 | } |
1020 | 1022 | ||
1021 | class HackDialog : public QDialog | 1023 | class HackDialog : public QDialog |
1022 | { | 1024 | { |
1023 | public: | 1025 | public: |
1024 | void acceptIt() | 1026 | void acceptIt() |
1025 | { | 1027 | { |
1026 | accept(); | 1028 | accept(); |
1027 | } | 1029 | } |
1028 | void rejectIt() | 1030 | void rejectIt() |
1029 | { | 1031 | { |
1030 | reject(); | 1032 | reject(); |
1031 | } | 1033 | } |
1032 | }; | 1034 | }; |
1033 | 1035 | ||
1034 | 1036 | ||
1035 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 1037 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
1036 | { | 1038 | { |
1037 | // specialised actions for certain widgets. May want to | 1039 | // specialised actions for certain widgets. May want to |
1038 | // add more stuff here. | 1040 | // add more stuff here. |
1039 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 1041 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
1040 | && activePopupWidget() ->parentWidget() | 1042 | && activePopupWidget() ->parentWidget() |
1041 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 1043 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
1042 | key = Qt::Key_Return; | 1044 | key = Qt::Key_Return; |
1043 | 1045 | ||
1044 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 1046 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
1045 | key = Qt::Key_Return; | 1047 | key = Qt::Key_Return; |
1046 | 1048 | ||
1047 | #ifdef QWS | 1049 | #ifdef QWS |
1048 | 1050 | ||
1049 | ke->simpleData.keycode = key; | 1051 | ke->simpleData.keycode = key; |
1050 | #endif | 1052 | #endif |
1051 | } | 1053 | } |
1052 | 1054 | ||
1053 | 1055 | ||
1054 | /*! | 1056 | /*! |
1055 | \internal | 1057 | \internal |
1056 | */ | 1058 | */ |
1057 | 1059 | ||
1058 | #ifdef QWS | 1060 | #ifdef QWS |
1059 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 1061 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
1060 | { | 1062 | { |
1061 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 1063 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
1062 | if ( qApp->type() != QApplication::GuiServer ) { | 1064 | if ( qApp->type() != QApplication::GuiServer ) { |
1063 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 1065 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
1064 | e << d->appName; | 1066 | e << d->appName; |
1065 | } | 1067 | } |
1066 | d->notbusysent = TRUE; | 1068 | d->notbusysent = TRUE; |
1067 | } | 1069 | } |
1068 | if ( type() == GuiServer ) { | 1070 | if ( type() == GuiServer ) { |
1069 | switch ( e->type ) { | 1071 | switch ( e->type ) { |
1070 | case QWSEvent::Mouse: | 1072 | case QWSEvent::Mouse: |
1071 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 1073 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
1072 | emit clientMoused(); | 1074 | emit clientMoused(); |
1073 | break; | 1075 | break; |
1074 | default: | 1076 | default: |