author | zecke <zecke> | 2004-09-19 18:48:56 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-19 18:48:56 (UTC) |
commit | 4564befecf3df38911d48f216ab216faf93b9c1d (patch) (unidiff) | |
tree | 9d4ec4264de74230e9fba4f9963535be604db90a | |
parent | 84166797fd3caa436d38e312957d5542046f10b0 (diff) | |
download | opie-4564befecf3df38911d48f216ab216faf93b9c1d.zip opie-4564befecf3df38911d48f216ab216faf93b9c1d.tar.gz opie-4564befecf3df38911d48f216ab216faf93b9c1d.tar.bz2 |
Have only one showDialog function.
If the dialog sizeHint is smaller than the width of the desktop
qpe_show_dialog didn't 'maximize' the widget and just showed it.
QPEApplication::showDialog does better in that respect but does not
have custom 'centering' of the dialog. But that doesn't matter
as we save/restore size and position for BigScreen.
-rw-r--r-- | library/qpeapplication.cpp | 60 |
1 files changed, 1 insertions, 59 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index e1edd4c..df313ce 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,1077 +1,1019 @@ | |||
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 | #include "fontdatabase.h" |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | #include "alarmserver.h" | 86 | #include "alarmserver.h" |
87 | #include "applnk.h" | 87 | #include "applnk.h" |
88 | #include "qpemenubar.h" | 88 | #include "qpemenubar.h" |
89 | #include "textcodecinterface.h" | 89 | #include "textcodecinterface.h" |
90 | #include "imagecodecinterface.h" | 90 | #include "imagecodecinterface.h" |
91 | 91 | ||
92 | #include <unistd.h> | 92 | #include <unistd.h> |
93 | #include <sys/file.h> | 93 | #include <sys/file.h> |
94 | #include <sys/ioctl.h> | 94 | #include <sys/ioctl.h> |
95 | #ifndef QT_NO_SOUND | 95 | #ifndef QT_NO_SOUND |
96 | #include <sys/soundcard.h> | 96 | #include <sys/soundcard.h> |
97 | #endif | 97 | #endif |
98 | #include "qt_override_p.h" | 98 | #include "qt_override_p.h" |
99 | 99 | ||
100 | #include <backend/rohfeedback.h> | 100 | #include <backend/rohfeedback.h> |
101 | 101 | ||
102 | 102 | ||
103 | static bool useBigPixmaps = 0; | 103 | static bool useBigPixmaps = 0; |
104 | 104 | ||
105 | class HackWidget : public QWidget | 105 | class HackWidget : public QWidget |
106 | { | 106 | { |
107 | public: | 107 | public: |
108 | bool needsOk() | 108 | bool needsOk() |
109 | { return (getWState() & WState_Reserved1 ); } | 109 | { return (getWState() & WState_Reserved1 ); } |
110 | 110 | ||
111 | QRect normalGeometry() | 111 | QRect normalGeometry() |
112 | { return topData()->normalGeometry; }; | 112 | { return topData()->normalGeometry; }; |
113 | }; | 113 | }; |
114 | 114 | ||
115 | class QPEApplicationData | 115 | class QPEApplicationData |
116 | { | 116 | { |
117 | public: | 117 | public: |
118 | QPEApplicationData ( ) : | 118 | QPEApplicationData ( ) : |
119 | presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 119 | presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
120 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 120 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
121 | keep_running( true ), qcopQok( false ), | 121 | keep_running( true ), qcopQok( false ), |
122 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), | 122 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), |
123 | bigIconSize( 32 ), qpe_main_widget( 0 ) | 123 | bigIconSize( 32 ), qpe_main_widget( 0 ) |
124 | { | 124 | { |
125 | Config cfg( "qpe" ); | 125 | Config cfg( "qpe" ); |
126 | cfg.setGroup( "Appearance" ); | 126 | cfg.setGroup( "Appearance" ); |
127 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); | 127 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); |
128 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); | 128 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); |
129 | fontSize = cfg.readNumEntry( "FontSize", 10 ); | 129 | fontSize = cfg.readNumEntry( "FontSize", 10 ); |
130 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); | 130 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); |
131 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); | 131 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); |
132 | #ifdef OPIE_WITHROHFEEDBACK | 132 | #ifdef OPIE_WITHROHFEEDBACK |
133 | RoH = 0; | 133 | RoH = 0; |
134 | #endif | 134 | #endif |
135 | } | 135 | } |
136 | 136 | ||
137 | int presstimer; | 137 | int presstimer; |
138 | QWidget* presswidget; | 138 | QWidget* presswidget; |
139 | QPoint presspos; | 139 | QPoint presspos; |
140 | #ifdef OPIE_WITHROHFEEDBACK | 140 | #ifdef OPIE_WITHROHFEEDBACK |
141 | Opie::Internal::RoHFeedback *RoH; | 141 | Opie::Internal::RoHFeedback *RoH; |
142 | #endif | 142 | #endif |
143 | 143 | ||
144 | bool rightpressed : 1; | 144 | bool rightpressed : 1; |
145 | bool kbgrabbed : 1; | 145 | bool kbgrabbed : 1; |
146 | bool notbusysent : 1; | 146 | bool notbusysent : 1; |
147 | bool preloaded : 1; | 147 | bool preloaded : 1; |
148 | bool forceshow : 1; | 148 | bool forceshow : 1; |
149 | bool nomaximize : 1; | 149 | bool nomaximize : 1; |
150 | bool keep_running : 1; | 150 | bool keep_running : 1; |
151 | bool qcopQok : 1; | 151 | bool qcopQok : 1; |
152 | 152 | ||
153 | QCString fontFamily; | 153 | QCString fontFamily; |
154 | int fontSize; | 154 | int fontSize; |
155 | int smallIconSize; | 155 | int smallIconSize; |
156 | int bigIconSize; | 156 | int bigIconSize; |
157 | 157 | ||
158 | QStringList langs; | 158 | QStringList langs; |
159 | QString appName; | 159 | QString appName; |
160 | struct QCopRec | 160 | struct QCopRec |
161 | { | 161 | { |
162 | QCopRec( const QCString &ch, const QCString &msg, | 162 | QCopRec( const QCString &ch, const QCString &msg, |
163 | const QByteArray &d ) : | 163 | const QByteArray &d ) : |
164 | channel( ch ), message( msg ), data( d ) | 164 | channel( ch ), message( msg ), data( d ) |
165 | { } | 165 | { } |
166 | 166 | ||
167 | QCString channel; | 167 | QCString channel; |
168 | QCString message; | 168 | QCString message; |
169 | QByteArray data; | 169 | QByteArray data; |
170 | }; | 170 | }; |
171 | QWidget* qpe_main_widget; | 171 | QWidget* qpe_main_widget; |
172 | QGuardedPtr<QWidget> lastraised; | 172 | QGuardedPtr<QWidget> lastraised; |
173 | QQueue<QCopRec> qcopq; | 173 | QQueue<QCopRec> qcopq; |
174 | QString styleName; | 174 | QString styleName; |
175 | QString decorationName; | 175 | QString decorationName; |
176 | 176 | ||
177 | void enqueueQCop( const QCString &ch, const QCString &msg, | 177 | void enqueueQCop( const QCString &ch, const QCString &msg, |
178 | const QByteArray &data ) | 178 | const QByteArray &data ) |
179 | { | 179 | { |
180 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 180 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
181 | } | 181 | } |
182 | void sendQCopQ() | 182 | void sendQCopQ() |
183 | { | 183 | { |
184 | if (!qcopQok ) | 184 | if (!qcopQok ) |
185 | return; | 185 | return; |
186 | 186 | ||
187 | QCopRec * r; | 187 | QCopRec * r; |
188 | 188 | ||
189 | while((r=qcopq.dequeue())) { | 189 | while((r=qcopq.dequeue())) { |
190 | // remove from queue before sending... | 190 | // remove from queue before sending... |
191 | // event loop can come around again before getting | 191 | // event loop can come around again before getting |
192 | // back from sendLocally | 192 | // back from sendLocally |
193 | #ifndef QT_NO_COP | 193 | #ifndef QT_NO_COP |
194 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 194 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
195 | #endif | 195 | #endif |
196 | 196 | ||
197 | delete r; | 197 | delete r; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) | 201 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) |
202 | { | 202 | { |
203 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) | 203 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) |
204 | { | 204 | { |
205 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); | 205 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); |
206 | } | 206 | } |
207 | QPoint p; | 207 | QPoint p; |
208 | QSize s; | 208 | QSize s; |
209 | bool max; | 209 | bool max; |
210 | if ( mw->isVisible() ) { | 210 | if ( mw->isVisible() ) { |
211 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 211 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
212 | mw->resize(s); | 212 | mw->resize(s); |
213 | mw->move(p); | 213 | mw->move(p); |
214 | } | 214 | } |
215 | mw->raise(); | 215 | mw->raise(); |
216 | } else { | 216 | } else { |
217 | 217 | ||
218 | if ( mw->layout() && mw->inherits("QDialog") ) { | 218 | if ( mw->layout() && mw->inherits("QDialog") ) { |
219 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 219 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
220 | mw->resize(s); | 220 | mw->resize(s); |
221 | mw->move(p); | 221 | mw->move(p); |
222 | 222 | ||
223 | if ( max && !nomaximize ) { | 223 | if ( max && !nomaximize ) { |
224 | mw->showMaximized(); | 224 | mw->showMaximized(); |
225 | } else { | 225 | } else { |
226 | mw->show(); | 226 | mw->show(); |
227 | } | 227 | } |
228 | } else { | 228 | } else { |
229 | qpe_show_dialog((QDialog*)mw,nomaximize); | 229 | QPEApplication::showDialog((QDialog*)mw,nomaximize); |
230 | } | 230 | } |
231 | } else { | 231 | } else { |
232 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 232 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
233 | mw->resize(s); | 233 | mw->resize(s); |
234 | mw->move(p); | 234 | mw->move(p); |
235 | } else { //no stored rectangle, make an estimation | 235 | } else { //no stored rectangle, make an estimation |
236 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | 236 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
237 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | 237 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
238 | mw->move( QMAX(x,0), QMAX(y,0) ); | 238 | mw->move( QMAX(x,0), QMAX(y,0) ); |
239 | #ifdef Q_WS_QWS | 239 | #ifdef Q_WS_QWS |
240 | if ( !nomaximize ) | 240 | if ( !nomaximize ) |
241 | mw->showMaximized(); | 241 | mw->showMaximized(); |
242 | #endif | 242 | #endif |
243 | } | 243 | } |
244 | if ( max && !nomaximize ) | 244 | if ( max && !nomaximize ) |
245 | mw->showMaximized(); | 245 | mw->showMaximized(); |
246 | else | 246 | else |
247 | mw->show(); | 247 | mw->show(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | static void qpe_show_dialog( QDialog* d, bool nomax ) | ||
253 | { | ||
254 | QSize sh = d->sizeHint(); | ||
255 | int w = QMAX(sh.width(),d->width()); | ||
256 | int h = QMAX(sh.height(),d->height()); | ||
257 | |||
258 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) | ||
259 | nomax = TRUE; | ||
260 | |||
261 | #ifndef Q_WS_QWS | ||
262 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); | ||
263 | #else | ||
264 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); | ||
265 | #endif | ||
266 | |||
267 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); | ||
268 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); | ||
269 | |||
270 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { | ||
271 | d->showMaximized(); | ||
272 | } else { | ||
273 | // try centering the dialog around its parent | ||
274 | QPoint p(0,0); | ||
275 | if ( d->parentWidget() ) { | ||
276 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); | ||
277 | p = QPoint( pp.x() + d->parentWidget()->width()/2, | ||
278 | pp.y() + d->parentWidget()->height()/ 2 ); | ||
279 | } else { | ||
280 | p = QPoint( maxX/2, maxY/2 ); | ||
281 | } | ||
282 | |||
283 | p = QPoint( p.x() - w/2, p.y() - h/2 ); | ||
284 | // qDebug("p(x,y) is %d %d", p.x(), p.y() ); | ||
285 | |||
286 | if ( w >= maxX ) { | ||
287 | if ( p.y() < 0 ) | ||
288 | p.setY(0); | ||
289 | if ( p.y() + h > maxY ) | ||
290 | p.setY( maxY - h); | ||
291 | |||
292 | d->resize(maxX, h); | ||
293 | d->move(0, p.y() ); | ||
294 | } else if ( h >= maxY ) { | ||
295 | if ( p.x() < 0 ) | ||
296 | p.setX(0); | ||
297 | if ( p.x() + w > maxX ) | ||
298 | p.setX( maxX - w); | ||
299 | |||
300 | d->resize(w, maxY); | ||
301 | d->move(p.x(),0); | ||
302 | } else { | ||
303 | d->resize(w, h); | ||
304 | } | ||
305 | |||
306 | d->show(); | ||
307 | } | ||
308 | } | ||
309 | |||
310 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) | 252 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) |
311 | { | 253 | { |
312 | maximized = TRUE; | 254 | maximized = TRUE; |
313 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 255 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
314 | if ( qApp->desktop()->width() <= 350 ) | 256 | if ( qApp->desktop()->width() <= 350 ) |
315 | return FALSE; | 257 | return FALSE; |
316 | 258 | ||
317 | Config cfg( "qpe" ); | 259 | Config cfg( "qpe" ); |
318 | cfg.setGroup("ApplicationPositions"); | 260 | cfg.setGroup("ApplicationPositions"); |
319 | QString str = cfg.readEntry( app, QString::null ); | 261 | QString str = cfg.readEntry( app, QString::null ); |
320 | QStringList l = QStringList::split(",", str); | 262 | QStringList l = QStringList::split(",", str); |
321 | 263 | ||
322 | if ( l.count() == 5) { | 264 | if ( l.count() == 5) { |
323 | p.setX( l[0].toInt() ); | 265 | p.setX( l[0].toInt() ); |
324 | p.setY( l[1].toInt() ); | 266 | p.setY( l[1].toInt() ); |
325 | 267 | ||
326 | s.setWidth( l[2].toInt() ); | 268 | s.setWidth( l[2].toInt() ); |
327 | s.setHeight( l[3].toInt() ); | 269 | s.setHeight( l[3].toInt() ); |
328 | 270 | ||
329 | maximized = l[4].toInt(); | 271 | maximized = l[4].toInt(); |
330 | 272 | ||
331 | return TRUE; | 273 | return TRUE; |
332 | } | 274 | } |
333 | 275 | ||
334 | return FALSE; | 276 | return FALSE; |
335 | } | 277 | } |
336 | 278 | ||
337 | 279 | ||
338 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) | 280 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) |
339 | { | 281 | { |
340 | #ifndef Q_WS_QWS | 282 | #ifndef Q_WS_QWS |
341 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); | 283 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); |
342 | #endif | 284 | #endif |
343 | int maxX = qt_maxWindowRect.width(); | 285 | int maxX = qt_maxWindowRect.width(); |
344 | int maxY = qt_maxWindowRect.height(); | 286 | int maxY = qt_maxWindowRect.height(); |
345 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); | 287 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); |
346 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); | 288 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); |
347 | 289 | ||
348 | // total window size is not allowed to be larger than desktop window size | 290 | // total window size is not allowed to be larger than desktop window size |
349 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) | 291 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) |
350 | return FALSE; | 292 | return FALSE; |
351 | 293 | ||
352 | if ( wWidth > maxX ) { | 294 | if ( wWidth > maxX ) { |
353 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); | 295 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); |
354 | wWidth = maxX; | 296 | wWidth = maxX; |
355 | } | 297 | } |
356 | 298 | ||
357 | if ( wHeight > maxY ) { | 299 | if ( wHeight > maxY ) { |
358 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); | 300 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); |
359 | wHeight = maxY; | 301 | wHeight = maxY; |
360 | } | 302 | } |
361 | 303 | ||
362 | // any smaller than this and the maximize/close/help buttons will be overlapping | 304 | // any smaller than this and the maximize/close/help buttons will be overlapping |
363 | if ( wWidth < 80 || wHeight < 60 ) | 305 | if ( wWidth < 80 || wHeight < 60 ) |
364 | return FALSE; | 306 | return FALSE; |
365 | 307 | ||
366 | if ( p.x() < 0 ) | 308 | if ( p.x() < 0 ) |
367 | p.setX(0); | 309 | p.setX(0); |
368 | if ( p.y() < 0 ) | 310 | if ( p.y() < 0 ) |
369 | p.setY(0); | 311 | p.setY(0); |
370 | 312 | ||
371 | if ( p.x() + wWidth > maxX ) | 313 | if ( p.x() + wWidth > maxX ) |
372 | p.setX( maxX - wWidth ); | 314 | p.setX( maxX - wWidth ); |
373 | if ( p.y() + wHeight > maxY ) | 315 | if ( p.y() + wHeight > maxY ) |
374 | p.setY( maxY - wHeight ); | 316 | p.setY( maxY - wHeight ); |
375 | 317 | ||
376 | return TRUE; | 318 | return TRUE; |
377 | } | 319 | } |
378 | 320 | ||
379 | static void store_widget_rect(QWidget *w, QString &app) | 321 | static void store_widget_rect(QWidget *w, QString &app) |
380 | { | 322 | { |
381 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 323 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
382 | if ( qApp->desktop()->width() <= 350 ) | 324 | if ( qApp->desktop()->width() <= 350 ) |
383 | return; | 325 | return; |
384 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to | 326 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to |
385 | // get the non-maximized version, so we have to do it the hard way ) | 327 | // get the non-maximized version, so we have to do it the hard way ) |
386 | int offsetX = w->x() - w->geometry().left(); | 328 | int offsetX = w->x() - w->geometry().left(); |
387 | int offsetY = w->y() - w->geometry().top(); | 329 | int offsetY = w->y() - w->geometry().top(); |
388 | 330 | ||
389 | QRect r; | 331 | QRect r; |
390 | if ( w->isMaximized() ) | 332 | if ( w->isMaximized() ) |
391 | r = ( (HackWidget *) w)->normalGeometry(); | 333 | r = ( (HackWidget *) w)->normalGeometry(); |
392 | else | 334 | else |
393 | r = w->geometry(); | 335 | r = w->geometry(); |
394 | 336 | ||
395 | // Stores the window placement as pos(), size() (due to the offset mapping) | 337 | // Stores the window placement as pos(), size() (due to the offset mapping) |
396 | Config cfg( "qpe" ); | 338 | Config cfg( "qpe" ); |
397 | cfg.setGroup("ApplicationPositions"); | 339 | cfg.setGroup("ApplicationPositions"); |
398 | QString s; | 340 | QString s; |
399 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | 341 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); |
400 | cfg.writeEntry( app, s ); | 342 | cfg.writeEntry( app, s ); |
401 | } | 343 | } |
402 | 344 | ||
403 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 345 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
404 | { | 346 | { |
405 | /* | 347 | /* |
406 | // This works but disable it for now until it is safe to apply | 348 | // This works but disable it for now until it is safe to apply |
407 | // What is does is scan the .desktop files of all the apps for | 349 | // What is does is scan the .desktop files of all the apps for |
408 | // the applnk that has the corresponding argv[0] as this program | 350 | // the applnk that has the corresponding argv[0] as this program |
409 | // then it uses the name stored in the .desktop file as the caption | 351 | // then it uses the name stored in the .desktop file as the caption |
410 | // for the main widget. This saves duplicating translations for | 352 | // for the main widget. This saves duplicating translations for |
411 | // the app name in the program and in the .desktop files. | 353 | // the app name in the program and in the .desktop files. |
412 | 354 | ||
413 | AppLnkSet apps( appsPath ); | 355 | AppLnkSet apps( appsPath ); |
414 | 356 | ||
415 | QList<AppLnk> appsList = apps.children(); | 357 | QList<AppLnk> appsList = apps.children(); |
416 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 358 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
417 | if ( (*it)->exec() == appName ) { | 359 | if ( (*it)->exec() == appName ) { |
418 | mw->setCaption( (*it)->name() ); | 360 | mw->setCaption( (*it)->name() ); |
419 | return TRUE; | 361 | return TRUE; |
420 | } | 362 | } |
421 | } | 363 | } |
422 | */ | 364 | */ |
423 | return FALSE; | 365 | return FALSE; |
424 | } | 366 | } |
425 | 367 | ||
426 | 368 | ||
427 | void show(QWidget* mw, bool nomax) | 369 | void show(QWidget* mw, bool nomax) |
428 | { | 370 | { |
429 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 371 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
430 | nomaximize = nomax; | 372 | nomaximize = nomax; |
431 | qpe_main_widget = mw; | 373 | qpe_main_widget = mw; |
432 | qcopQok = TRUE; | 374 | qcopQok = TRUE; |
433 | #ifndef QT_NO_COP | 375 | #ifndef QT_NO_COP |
434 | 376 | ||
435 | sendQCopQ(); | 377 | sendQCopQ(); |
436 | #endif | 378 | #endif |
437 | 379 | ||
438 | if ( preloaded ) { | 380 | if ( preloaded ) { |
439 | if (forceshow) | 381 | if (forceshow) |
440 | show_mx(mw, nomax, appName); | 382 | show_mx(mw, nomax, appName); |
441 | } | 383 | } |
442 | else if ( keep_running ) { | 384 | else if ( keep_running ) { |
443 | show_mx(mw, nomax, appName); | 385 | show_mx(mw, nomax, appName); |
444 | } | 386 | } |
445 | } | 387 | } |
446 | 388 | ||
447 | void loadTextCodecs() | 389 | void loadTextCodecs() |
448 | { | 390 | { |
449 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 391 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
450 | #ifdef Q_OS_MACX | 392 | #ifdef Q_OS_MACX |
451 | QDir dir( path, "lib*.dylib" ); | 393 | QDir dir( path, "lib*.dylib" ); |
452 | #else | 394 | #else |
453 | QDir dir( path, "lib*.so" ); | 395 | QDir dir( path, "lib*.so" ); |
454 | #endif | 396 | #endif |
455 | QStringList list; | 397 | QStringList list; |
456 | if ( dir. exists ( )) | 398 | if ( dir. exists ( )) |
457 | list = dir.entryList(); | 399 | list = dir.entryList(); |
458 | QStringList::Iterator it; | 400 | QStringList::Iterator it; |
459 | for ( it = list.begin(); it != list.end(); ++it ) { | 401 | for ( it = list.begin(); it != list.end(); ++it ) { |
460 | TextCodecInterface *iface = 0; | 402 | TextCodecInterface *iface = 0; |
461 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 403 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
462 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 404 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
463 | QValueList<int> mibs = iface->mibEnums(); | 405 | QValueList<int> mibs = iface->mibEnums(); |
464 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 406 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
465 | (void)iface->createForMib(*i); | 407 | (void)iface->createForMib(*i); |
466 | // ### it exists now; need to remember if we can delete it | 408 | // ### it exists now; need to remember if we can delete it |
467 | } | 409 | } |
468 | } | 410 | } |
469 | else { | 411 | else { |
470 | lib->unload(); | 412 | lib->unload(); |
471 | delete lib; | 413 | delete lib; |
472 | } | 414 | } |
473 | } | 415 | } |
474 | } | 416 | } |
475 | 417 | ||
476 | void loadImageCodecs() | 418 | void loadImageCodecs() |
477 | { | 419 | { |
478 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 420 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
479 | #ifdef Q_OS_MACX | 421 | #ifdef Q_OS_MACX |
480 | QDir dir( path, "lib*.dylib" ); | 422 | QDir dir( path, "lib*.dylib" ); |
481 | #else | 423 | #else |
482 | QDir dir( path, "lib*.so" ); | 424 | QDir dir( path, "lib*.so" ); |
483 | #endif | 425 | #endif |
484 | QStringList list; | 426 | QStringList list; |
485 | if ( dir. exists ( )) | 427 | if ( dir. exists ( )) |
486 | list = dir.entryList(); | 428 | list = dir.entryList(); |
487 | QStringList::Iterator it; | 429 | QStringList::Iterator it; |
488 | for ( it = list.begin(); it != list.end(); ++it ) { | 430 | for ( it = list.begin(); it != list.end(); ++it ) { |
489 | ImageCodecInterface *iface = 0; | 431 | ImageCodecInterface *iface = 0; |
490 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 432 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
491 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 433 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
492 | QStringList formats = iface->keys(); | 434 | QStringList formats = iface->keys(); |
493 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 435 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
494 | (void)iface->installIOHandler(*i); | 436 | (void)iface->installIOHandler(*i); |
495 | // ### it exists now; need to remember if we can delete it | 437 | // ### it exists now; need to remember if we can delete it |
496 | } | 438 | } |
497 | } | 439 | } |
498 | else { | 440 | else { |
499 | lib->unload(); | 441 | lib->unload(); |
500 | delete lib; | 442 | delete lib; |
501 | } | 443 | } |
502 | } | 444 | } |
503 | } | 445 | } |
504 | 446 | ||
505 | }; | 447 | }; |
506 | 448 | ||
507 | class ResourceMimeFactory : public QMimeSourceFactory | 449 | class ResourceMimeFactory : public QMimeSourceFactory |
508 | { | 450 | { |
509 | public: | 451 | public: |
510 | ResourceMimeFactory() : resImage( 0 ) | 452 | ResourceMimeFactory() : resImage( 0 ) |
511 | { | 453 | { |
512 | setFilePath( Global::helpPath() ); | 454 | setFilePath( Global::helpPath() ); |
513 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 455 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
514 | } | 456 | } |
515 | ~ResourceMimeFactory() { | 457 | ~ResourceMimeFactory() { |
516 | delete resImage; | 458 | delete resImage; |
517 | } | 459 | } |
518 | 460 | ||
519 | const QMimeSource* data( const QString& abs_name ) const | 461 | const QMimeSource* data( const QString& abs_name ) const |
520 | { | 462 | { |
521 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 463 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
522 | if ( !r ) { | 464 | if ( !r ) { |
523 | int sl = abs_name.length(); | 465 | int sl = abs_name.length(); |
524 | do { | 466 | do { |
525 | sl = abs_name.findRev( '/', sl - 1 ); | 467 | sl = abs_name.findRev( '/', sl - 1 ); |
526 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 468 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
527 | int dot = name.findRev( '.' ); | 469 | int dot = name.findRev( '.' ); |
528 | if ( dot >= 0 ) | 470 | if ( dot >= 0 ) |
529 | name = name.left( dot ); | 471 | name = name.left( dot ); |
530 | QImage img = Resource::loadImage( name ); | 472 | QImage img = Resource::loadImage( name ); |
531 | if ( !img.isNull() ) { | 473 | if ( !img.isNull() ) { |
532 | delete resImage; | 474 | delete resImage; |
533 | resImage = new QImageDrag( img ); | 475 | resImage = new QImageDrag( img ); |
534 | r = resImage; | 476 | r = resImage; |
535 | } | 477 | } |
536 | } | 478 | } |
537 | while ( !r && sl > 0 ); | 479 | while ( !r && sl > 0 ); |
538 | } | 480 | } |
539 | return r; | 481 | return r; |
540 | } | 482 | } |
541 | private: | 483 | private: |
542 | mutable QImageDrag *resImage; | 484 | mutable QImageDrag *resImage; |
543 | }; | 485 | }; |
544 | 486 | ||
545 | static int& hack(int& i) | 487 | static int& hack(int& i) |
546 | { | 488 | { |
547 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 489 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
548 | // These should be created, but aren't in Qt 2.3.0 | 490 | // These should be created, but aren't in Qt 2.3.0 |
549 | (void)new QUtf8Codec; | 491 | (void)new QUtf8Codec; |
550 | (void)new QUtf16Codec; | 492 | (void)new QUtf16Codec; |
551 | #endif | 493 | #endif |
552 | return i; | 494 | return i; |
553 | } | 495 | } |
554 | 496 | ||
555 | static int muted = 0; | 497 | static int muted = 0; |
556 | static int micMuted = 0; | 498 | static int micMuted = 0; |
557 | 499 | ||
558 | static void setVolume( int t = 0, int percent = -1 ) | 500 | static void setVolume( int t = 0, int percent = -1 ) |
559 | { | 501 | { |
560 | switch ( t ) { | 502 | switch ( t ) { |
561 | case 0: { | 503 | case 0: { |
562 | Config cfg( "qpe" ); | 504 | Config cfg( "qpe" ); |
563 | cfg.setGroup( "Volume" ); | 505 | cfg.setGroup( "Volume" ); |
564 | if ( percent < 0 ) | 506 | if ( percent < 0 ) |
565 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 507 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
566 | #ifndef QT_NO_SOUND | 508 | #ifndef QT_NO_SOUND |
567 | int fd = 0; | 509 | int fd = 0; |
568 | #ifdef QT_QWS_DEVFS | 510 | #ifdef QT_QWS_DEVFS |
569 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 511 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
570 | #else | 512 | #else |
571 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 513 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
572 | #endif | 514 | #endif |
573 | int vol = muted ? 0 : percent; | 515 | int vol = muted ? 0 : percent; |
574 | // set both channels to same volume | 516 | // set both channels to same volume |
575 | vol |= vol << 8; | 517 | vol |= vol << 8; |
576 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); | 518 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); |
577 | ::close( fd ); | 519 | ::close( fd ); |
578 | } | 520 | } |
579 | #endif | 521 | #endif |
580 | } | 522 | } |
581 | break; | 523 | break; |
582 | } | 524 | } |
583 | } | 525 | } |
584 | 526 | ||
585 | static void setMic( int t = 0, int percent = -1 ) | 527 | static void setMic( int t = 0, int percent = -1 ) |
586 | { | 528 | { |
587 | switch ( t ) { | 529 | switch ( t ) { |
588 | case 0: { | 530 | case 0: { |
589 | Config cfg( "qpe" ); | 531 | Config cfg( "qpe" ); |
590 | cfg.setGroup( "Volume" ); | 532 | cfg.setGroup( "Volume" ); |
591 | if ( percent < 0 ) | 533 | if ( percent < 0 ) |
592 | percent = cfg.readNumEntry( "Mic", 50 ); | 534 | percent = cfg.readNumEntry( "Mic", 50 ); |
593 | 535 | ||
594 | #ifndef QT_NO_SOUND | 536 | #ifndef QT_NO_SOUND |
595 | int fd = 0; | 537 | int fd = 0; |
596 | int mic = micMuted ? 0 : percent; | 538 | int mic = micMuted ? 0 : percent; |
597 | #ifdef QT_QWS_DEVFS | 539 | #ifdef QT_QWS_DEVFS |
598 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 540 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
599 | #else | 541 | #else |
600 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 542 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
601 | #endif | 543 | #endif |
602 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 544 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
603 | ::close( fd ); | 545 | ::close( fd ); |
604 | } | 546 | } |
605 | #endif | 547 | #endif |
606 | } | 548 | } |
607 | break; | 549 | break; |
608 | } | 550 | } |
609 | } | 551 | } |
610 | 552 | ||
611 | 553 | ||
612 | static void setBass( int t = 0, int percent = -1 ) | 554 | static void setBass( int t = 0, int percent = -1 ) |
613 | { | 555 | { |
614 | switch ( t ) { | 556 | switch ( t ) { |
615 | case 0: { | 557 | case 0: { |
616 | Config cfg( "qpe" ); | 558 | Config cfg( "qpe" ); |
617 | cfg.setGroup( "Volume" ); | 559 | cfg.setGroup( "Volume" ); |
618 | if ( percent < 0 ) | 560 | if ( percent < 0 ) |
619 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 561 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
620 | 562 | ||
621 | #ifndef QT_NO_SOUND | 563 | #ifndef QT_NO_SOUND |
622 | int fd = 0; | 564 | int fd = 0; |
623 | int bass = percent; | 565 | int bass = percent; |
624 | #ifdef QT_QWS_DEVFS | 566 | #ifdef QT_QWS_DEVFS |
625 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 567 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
626 | #else | 568 | #else |
627 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 569 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
628 | #endif | 570 | #endif |
629 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 571 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
630 | ::close( fd ); | 572 | ::close( fd ); |
631 | } | 573 | } |
632 | #endif | 574 | #endif |
633 | } | 575 | } |
634 | break; | 576 | break; |
635 | } | 577 | } |
636 | } | 578 | } |
637 | 579 | ||
638 | 580 | ||
639 | static void setTreble( int t = 0, int percent = -1 ) | 581 | static void setTreble( int t = 0, int percent = -1 ) |
640 | { | 582 | { |
641 | switch ( t ) { | 583 | switch ( t ) { |
642 | case 0: { | 584 | case 0: { |
643 | Config cfg( "qpe" ); | 585 | Config cfg( "qpe" ); |
644 | cfg.setGroup( "Volume" ); | 586 | cfg.setGroup( "Volume" ); |
645 | if ( percent < 0 ) | 587 | if ( percent < 0 ) |
646 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 588 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
647 | 589 | ||
648 | #ifndef QT_NO_SOUND | 590 | #ifndef QT_NO_SOUND |
649 | int fd = 0; | 591 | int fd = 0; |
650 | int treble = percent; | 592 | int treble = percent; |
651 | #ifdef QT_QWS_DEVFS | 593 | #ifdef QT_QWS_DEVFS |
652 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 594 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
653 | #else | 595 | #else |
654 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 596 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
655 | #endif | 597 | #endif |
656 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 598 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
657 | ::close( fd ); | 599 | ::close( fd ); |
658 | } | 600 | } |
659 | #endif | 601 | #endif |
660 | } | 602 | } |
661 | break; | 603 | break; |
662 | } | 604 | } |
663 | } | 605 | } |
664 | 606 | ||
665 | 607 | ||
666 | /** | 608 | /** |
667 | \class QPEApplication | 609 | \class QPEApplication |
668 | \brief The QPEApplication class implements various system services | 610 | \brief The QPEApplication class implements various system services |
669 | that are available to all Qtopia applications. | 611 | that are available to all Qtopia applications. |
670 | 612 | ||
671 | Simply by using QPEApplication instead of QApplication, a standard Qt | 613 | Simply by using QPEApplication instead of QApplication, a standard Qt |
672 | application becomes a Qtopia application. It automatically follows | 614 | application becomes a Qtopia application. It automatically follows |
673 | style changes, quits and raises, and in the | 615 | style changes, quits and raises, and in the |
674 | case of \link docwidget.html document-oriented\endlink applications, | 616 | case of \link docwidget.html document-oriented\endlink applications, |
675 | changes the currently displayed document in response to the environment. | 617 | changes the currently displayed document in response to the environment. |
676 | 618 | ||
677 | To create a \link docwidget.html document-oriented\endlink | 619 | To create a \link docwidget.html document-oriented\endlink |
678 | application use showMainDocumentWidget(); to create a | 620 | application use showMainDocumentWidget(); to create a |
679 | non-document-oriented application use showMainWidget(). The | 621 | non-document-oriented application use showMainWidget(). The |
680 | keepRunning() function indicates whether the application will | 622 | keepRunning() function indicates whether the application will |
681 | continue running after it's processed the last \link qcop.html | 623 | continue running after it's processed the last \link qcop.html |
682 | QCop\endlink message. This can be changed using setKeepRunning(). | 624 | QCop\endlink message. This can be changed using setKeepRunning(). |
683 | 625 | ||
684 | A variety of signals are emitted when certain events occur, for | 626 | A variety of signals are emitted when certain events occur, for |
685 | example, timeChanged(), clockChanged(), weekChanged(), | 627 | example, timeChanged(), clockChanged(), weekChanged(), |
686 | dateFormatChanged() and volumeChanged(). If the application receives | 628 | dateFormatChanged() and volumeChanged(). If the application receives |
687 | a \link qcop.html QCop\endlink message on the application's | 629 | a \link qcop.html QCop\endlink message on the application's |
688 | QPE/Application/\e{appname} channel, the appMessage() signal is | 630 | QPE/Application/\e{appname} channel, the appMessage() signal is |
689 | emitted. There are also flush() and reload() signals, which | 631 | emitted. There are also flush() and reload() signals, which |
690 | are emitted when synching begins and ends respectively - upon these | 632 | are emitted when synching begins and ends respectively - upon these |
691 | signals, the application should save and reload any data | 633 | signals, the application should save and reload any data |
692 | files that are involved in synching. Most of these signals will initially | 634 | files that are involved in synching. Most of these signals will initially |
693 | be received and unfiltered through the appMessage() signal. | 635 | be received and unfiltered through the appMessage() signal. |
694 | 636 | ||
695 | This class also provides a set of useful static functions. The | 637 | This class also provides a set of useful static functions. The |
696 | qpeDir() and documentDir() functions return the respective paths. | 638 | qpeDir() and documentDir() functions return the respective paths. |
697 | The grabKeyboard() and ungrabKeyboard() functions are used to | 639 | The grabKeyboard() and ungrabKeyboard() functions are used to |
698 | control whether the application takes control of the device's | 640 | control whether the application takes control of the device's |
699 | physical buttons (e.g. application launch keys). The stylus' mode of | 641 | physical buttons (e.g. application launch keys). The stylus' mode of |
700 | operation is set with setStylusOperation() and retrieved with | 642 | operation is set with setStylusOperation() and retrieved with |
701 | stylusOperation(). There are also setInputMethodHint() and | 643 | stylusOperation(). There are also setInputMethodHint() and |
702 | inputMethodHint() functions. | 644 | inputMethodHint() functions. |
703 | 645 | ||
704 | \ingroup qtopiaemb | 646 | \ingroup qtopiaemb |
705 | */ | 647 | */ |
706 | 648 | ||
707 | /*! | 649 | /*! |
708 | \fn void QPEApplication::clientMoused() | 650 | \fn void QPEApplication::clientMoused() |
709 | 651 | ||
710 | \internal | 652 | \internal |
711 | */ | 653 | */ |
712 | 654 | ||
713 | /*! | 655 | /*! |
714 | \fn void QPEApplication::timeChanged(); | 656 | \fn void QPEApplication::timeChanged(); |
715 | This signal is emitted when the time changes outside the normal | 657 | This signal is emitted when the time changes outside the normal |
716 | passage of time, i.e. if the time is set backwards or forwards. | 658 | passage of time, i.e. if the time is set backwards or forwards. |
717 | */ | 659 | */ |
718 | 660 | ||
719 | /*! | 661 | /*! |
720 | \fn void QPEApplication::clockChanged( bool ampm ); | 662 | \fn void QPEApplication::clockChanged( bool ampm ); |
721 | 663 | ||
722 | This signal is emitted when the user changes the clock's style. If | 664 | This signal is emitted when the user changes the clock's style. If |
723 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 665 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
724 | they want a 24-hour clock. | 666 | they want a 24-hour clock. |
725 | */ | 667 | */ |
726 | 668 | ||
727 | /*! | 669 | /*! |
728 | \fn void QPEApplication::volumeChanged( bool muted ) | 670 | \fn void QPEApplication::volumeChanged( bool muted ) |
729 | 671 | ||
730 | This signal is emitted whenever the mute state is changed. If \a | 672 | This signal is emitted whenever the mute state is changed. If \a |
731 | muted is TRUE, then sound output has been muted. | 673 | muted is TRUE, then sound output has been muted. |
732 | */ | 674 | */ |
733 | 675 | ||
734 | /*! | 676 | /*! |
735 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 677 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
736 | 678 | ||
737 | This signal is emitted if the week start day is changed. If \a | 679 | This signal is emitted if the week start day is changed. If \a |
738 | startOnMonday is TRUE then the first day of the week is Monday; if | 680 | startOnMonday is TRUE then the first day of the week is Monday; if |
739 | \a startOnMonday is FALSE then the first day of the week is | 681 | \a startOnMonday is FALSE then the first day of the week is |
740 | Sunday. | 682 | Sunday. |
741 | */ | 683 | */ |
742 | 684 | ||
743 | /*! | 685 | /*! |
744 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 686 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
745 | 687 | ||
746 | This signal is emitted whenever the date format is changed. | 688 | This signal is emitted whenever the date format is changed. |
747 | */ | 689 | */ |
748 | 690 | ||
749 | /*! | 691 | /*! |
750 | \fn void QPEApplication::flush() | 692 | \fn void QPEApplication::flush() |
751 | 693 | ||
752 | ### | 694 | ### |
753 | */ | 695 | */ |
754 | 696 | ||
755 | /*! | 697 | /*! |
756 | \fn void QPEApplication::reload() | 698 | \fn void QPEApplication::reload() |
757 | 699 | ||
758 | */ | 700 | */ |
759 | 701 | ||
760 | 702 | ||
761 | 703 | ||
762 | void QPEApplication::processQCopFile() | 704 | void QPEApplication::processQCopFile() |
763 | { | 705 | { |
764 | QString qcopfn("/tmp/qcop-msg-"); | 706 | QString qcopfn("/tmp/qcop-msg-"); |
765 | qcopfn += d->appName; // append command name | 707 | qcopfn += d->appName; // append command name |
766 | 708 | ||
767 | QFile f(qcopfn); | 709 | QFile f(qcopfn); |
768 | if ( f.open(IO_ReadWrite) ) { | 710 | if ( f.open(IO_ReadWrite) ) { |
769 | #ifndef Q_OS_WIN32 | 711 | #ifndef Q_OS_WIN32 |
770 | flock(f.handle(), LOCK_EX); | 712 | flock(f.handle(), LOCK_EX); |
771 | #endif | 713 | #endif |
772 | QDataStream ds(&f); | 714 | QDataStream ds(&f); |
773 | QCString channel, message; | 715 | QCString channel, message; |
774 | QByteArray data; | 716 | QByteArray data; |
775 | while(!ds.atEnd()) { | 717 | while(!ds.atEnd()) { |
776 | ds >> channel >> message >> data; | 718 | ds >> channel >> message >> data; |
777 | d->enqueueQCop(channel,message,data); | 719 | d->enqueueQCop(channel,message,data); |
778 | } | 720 | } |
779 | ::ftruncate(f.handle(), 0); | 721 | ::ftruncate(f.handle(), 0); |
780 | #ifndef Q_OS_WIN32 | 722 | #ifndef Q_OS_WIN32 |
781 | f.flush(); | 723 | f.flush(); |
782 | flock(f.handle(), LOCK_UN); | 724 | flock(f.handle(), LOCK_UN); |
783 | #endif | 725 | #endif |
784 | } | 726 | } |
785 | #endif | 727 | #endif |
786 | } | 728 | } |
787 | 729 | ||
788 | 730 | ||
789 | /*! | 731 | /*! |
790 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 732 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
791 | 733 | ||
792 | This signal is emitted when a message is received on this | 734 | This signal is emitted when a message is received on this |
793 | application's QPE/Application/<i>appname</i> \link qcop.html | 735 | application's QPE/Application/<i>appname</i> \link qcop.html |
794 | QCop\endlink channel. | 736 | QCop\endlink channel. |
795 | 737 | ||
796 | The slot to which you connect this signal uses \a msg and \a data | 738 | The slot to which you connect this signal uses \a msg and \a data |
797 | in the following way: | 739 | in the following way: |
798 | 740 | ||
799 | \code | 741 | \code |
800 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 742 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
801 | { | 743 | { |
802 | QDataStream stream( data, IO_ReadOnly ); | 744 | QDataStream stream( data, IO_ReadOnly ); |
803 | if ( msg == "someMessage(int,int,int)" ) { | 745 | if ( msg == "someMessage(int,int,int)" ) { |
804 | int a,b,c; | 746 | int a,b,c; |
805 | stream >> a >> b >> c; | 747 | stream >> a >> b >> c; |
806 | ... | 748 | ... |
807 | } else if ( msg == "otherMessage(QString)" ) { | 749 | } else if ( msg == "otherMessage(QString)" ) { |
808 | ... | 750 | ... |
809 | } | 751 | } |
810 | } | 752 | } |
811 | \endcode | 753 | \endcode |
812 | 754 | ||
813 | \sa qcop.html | 755 | \sa qcop.html |
814 | Note that messages received here may be processed by qpe application | 756 | Note that messages received here may be processed by qpe application |
815 | and emitted as signals, such as flush() and reload(). | 757 | and emitted as signals, such as flush() and reload(). |
816 | */ | 758 | */ |
817 | 759 | ||
818 | /*! | 760 | /*! |
819 | Constructs a QPEApplication just as you would construct | 761 | Constructs a QPEApplication just as you would construct |
820 | a QApplication, passing \a argc, \a argv, and \a t. | 762 | a QApplication, passing \a argc, \a argv, and \a t. |
821 | 763 | ||
822 | For applications, \a t should be the default, GuiClient. Only | 764 | For applications, \a t should be the default, GuiClient. Only |
823 | the Qtopia server passes GuiServer. | 765 | the Qtopia server passes GuiServer. |
824 | */ | 766 | */ |
825 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 767 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
826 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 768 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
827 | { | 769 | { |
828 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. | 770 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. |
829 | 771 | ||
830 | d = new QPEApplicationData; | 772 | d = new QPEApplicationData; |
831 | d->loadTextCodecs(); | 773 | d->loadTextCodecs(); |
832 | d->loadImageCodecs(); | 774 | d->loadImageCodecs(); |
833 | 775 | ||
834 | setFont( QFont( d->fontFamily, d->fontSize ) ); | 776 | setFont( QFont( d->fontFamily, d->fontSize ) ); |
835 | AppLnk::setSmallIconSize( d->smallIconSize ); | 777 | AppLnk::setSmallIconSize( d->smallIconSize ); |
836 | AppLnk::setBigIconSize( d->bigIconSize ); | 778 | AppLnk::setBigIconSize( d->bigIconSize ); |
837 | 779 | ||
838 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 780 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
839 | 781 | ||
840 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 782 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
841 | 783 | ||
842 | 784 | ||
843 | sysChannel = new QCopChannel( "QPE/System", this ); | 785 | sysChannel = new QCopChannel( "QPE/System", this ); |
844 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 786 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
845 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 787 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
846 | 788 | ||
847 | /* COde now in initapp */ | 789 | /* COde now in initapp */ |
848 | #if 0 | 790 | #if 0 |
849 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 791 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
850 | 792 | ||
851 | QString qcopfn( "/tmp/qcop-msg-" ); | 793 | QString qcopfn( "/tmp/qcop-msg-" ); |
852 | qcopfn += QString( argv[ 0 ] ); // append command name | 794 | qcopfn += QString( argv[ 0 ] ); // append command name |
853 | 795 | ||
854 | QFile f( qcopfn ); | 796 | QFile f( qcopfn ); |
855 | if ( f.open( IO_ReadOnly ) ) { | 797 | if ( f.open( IO_ReadOnly ) ) { |
856 | flock( f.handle(), LOCK_EX ); | 798 | flock( f.handle(), LOCK_EX ); |
857 | } | 799 | } |
858 | 800 | ||
859 | 801 | ||
860 | 802 | ||
861 | QCString channel = QCString( argv[ 0 ] ); | 803 | QCString channel = QCString( argv[ 0 ] ); |
862 | channel.replace( QRegExp( ".*/" ), "" ); | 804 | channel.replace( QRegExp( ".*/" ), "" ); |
863 | d->appName = channel; | 805 | d->appName = channel; |
864 | channel = "QPE/Application/" + channel; | 806 | channel = "QPE/Application/" + channel; |
865 | pidChannel = new QCopChannel( channel, this ); | 807 | pidChannel = new QCopChannel( channel, this ); |
866 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 808 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
867 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); | 809 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); |
868 | 810 | ||
869 | if ( f.isOpen() ) { | 811 | if ( f.isOpen() ) { |
870 | d->keep_running = FALSE; | 812 | d->keep_running = FALSE; |
871 | QDataStream ds( &f ); | 813 | QDataStream ds( &f ); |
872 | QCString channel, message; | 814 | QCString channel, message; |
873 | QByteArray data; | 815 | QByteArray data; |
874 | while ( !ds.atEnd() ) { | 816 | while ( !ds.atEnd() ) { |
875 | ds >> channel >> message >> data; | 817 | ds >> channel >> message >> data; |
876 | d->enqueueQCop( channel, message, data ); | 818 | d->enqueueQCop( channel, message, data ); |
877 | } | 819 | } |
878 | 820 | ||
879 | flock( f.handle(), LOCK_UN ); | 821 | flock( f.handle(), LOCK_UN ); |
880 | f.close(); | 822 | f.close(); |
881 | f.remove(); | 823 | f.remove(); |
882 | } | 824 | } |
883 | 825 | ||
884 | for ( int a = 0; a < argc; a++ ) { | 826 | for ( int a = 0; a < argc; a++ ) { |
885 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 827 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
886 | argv[ a ] = argv[ a + 1 ]; | 828 | argv[ a ] = argv[ a + 1 ]; |
887 | a++; | 829 | a++; |
888 | d->preloaded = TRUE; | 830 | d->preloaded = TRUE; |
889 | argc -= 1; | 831 | argc -= 1; |
890 | } | 832 | } |
891 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 833 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
892 | argv[ a ] = argv[ a + 1 ]; | 834 | argv[ a ] = argv[ a + 1 ]; |
893 | a++; | 835 | a++; |
894 | d->preloaded = TRUE; | 836 | d->preloaded = TRUE; |
895 | d->forceshow = TRUE; | 837 | d->forceshow = TRUE; |
896 | argc -= 1; | 838 | argc -= 1; |
897 | } | 839 | } |
898 | } | 840 | } |
899 | 841 | ||
900 | /* overide stored arguments */ | 842 | /* overide stored arguments */ |
901 | setArgs( argc, argv ); | 843 | setArgs( argc, argv ); |
902 | 844 | ||
903 | #endif | 845 | #endif |
904 | #else | 846 | #else |
905 | initApp( argc, argv ); | 847 | initApp( argc, argv ); |
906 | #endif | 848 | #endif |
907 | #ifdef Q_WS_QWS | 849 | #ifdef Q_WS_QWS |
908 | /* load the font renderer factories */ | 850 | /* load the font renderer factories */ |
909 | FontDatabase::loadRenderers(); | 851 | FontDatabase::loadRenderers(); |
910 | #endif | 852 | #endif |
911 | #ifndef QT_NO_TRANSLATION | 853 | #ifndef QT_NO_TRANSLATION |
912 | 854 | ||
913 | d->langs = Global::languageList(); | 855 | d->langs = Global::languageList(); |
914 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { | 856 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { |
915 | QString lang = *it; | 857 | QString lang = *it; |
916 | 858 | ||
917 | installTranslation( lang + "/libopie.qm"); | 859 | installTranslation( lang + "/libopie.qm"); |
918 | installTranslation( lang + "/libqpe.qm" ); | 860 | installTranslation( lang + "/libqpe.qm" ); |
919 | installTranslation( lang + "/" + d->appName + ".qm" ); | 861 | installTranslation( lang + "/" + d->appName + ".qm" ); |
920 | 862 | ||
921 | 863 | ||
922 | //###language/font hack; should look it up somewhere | 864 | //###language/font hack; should look it up somewhere |
923 | #ifdef QWS | 865 | #ifdef QWS |
924 | 866 | ||
925 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 867 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
926 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 868 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
927 | setFont( fn ); | 869 | setFont( fn ); |
928 | } | 870 | } |
929 | #endif | 871 | #endif |
930 | } | 872 | } |
931 | #endif | 873 | #endif |
932 | 874 | ||
933 | applyStyle(); | 875 | applyStyle(); |
934 | 876 | ||
935 | if ( type() == GuiServer ) { | 877 | if ( type() == GuiServer ) { |
936 | setVolume(); | 878 | setVolume(); |
937 | } | 879 | } |
938 | 880 | ||
939 | installEventFilter( this ); | 881 | installEventFilter( this ); |
940 | 882 | ||
941 | QPEMenuToolFocusManager::initialize(); | 883 | QPEMenuToolFocusManager::initialize(); |
942 | 884 | ||
943 | #ifdef QT_NO_QWS_CURSOR | 885 | #ifdef QT_NO_QWS_CURSOR |
944 | // if we have no cursor, probably don't want tooltips | 886 | // if we have no cursor, probably don't want tooltips |
945 | QToolTip::setEnabled( FALSE ); | 887 | QToolTip::setEnabled( FALSE ); |
946 | #endif | 888 | #endif |
947 | } | 889 | } |
948 | 890 | ||
949 | 891 | ||
950 | #ifdef QTOPIA_INTERNAL_INITAPP | 892 | #ifdef QTOPIA_INTERNAL_INITAPP |
951 | void QPEApplication::initApp( int argc, char **argv ) | 893 | void QPEApplication::initApp( int argc, char **argv ) |
952 | { | 894 | { |
953 | delete pidChannel; | 895 | delete pidChannel; |
954 | d->keep_running = TRUE; | 896 | d->keep_running = TRUE; |
955 | d->preloaded = FALSE; | 897 | d->preloaded = FALSE; |
956 | d->forceshow = FALSE; | 898 | d->forceshow = FALSE; |
957 | 899 | ||
958 | QCString channel = QCString(argv[0]); | 900 | QCString channel = QCString(argv[0]); |
959 | 901 | ||
960 | channel.replace(QRegExp(".*/"),""); | 902 | channel.replace(QRegExp(".*/"),""); |
961 | d->appName = channel; | 903 | d->appName = channel; |
962 | 904 | ||
963 | #if QT_VERSION > 235 | 905 | #if QT_VERSION > 235 |
964 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | 906 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 |
965 | #endif | 907 | #endif |
966 | 908 | ||
967 | channel = "QPE/Application/" + channel; | 909 | channel = "QPE/Application/" + channel; |
968 | pidChannel = new QCopChannel( channel, this); | 910 | pidChannel = new QCopChannel( channel, this); |
969 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 911 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
970 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); | 912 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); |
971 | 913 | ||
972 | 914 | ||
973 | 915 | ||
974 | processQCopFile(); | 916 | processQCopFile(); |
975 | d->keep_running = d->qcopq.isEmpty(); | 917 | d->keep_running = d->qcopq.isEmpty(); |
976 | 918 | ||
977 | for (int a=0; a<argc; a++) { | 919 | for (int a=0; a<argc; a++) { |
978 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 920 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
979 | argv[a] = argv[a+1]; | 921 | argv[a] = argv[a+1]; |
980 | a++; | 922 | a++; |
981 | d->preloaded = TRUE; | 923 | d->preloaded = TRUE; |
982 | argc-=1; | 924 | argc-=1; |
983 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 925 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
984 | argv[a] = argv[a+1]; | 926 | argv[a] = argv[a+1]; |
985 | a++; | 927 | a++; |
986 | d->preloaded = TRUE; | 928 | d->preloaded = TRUE; |
987 | d->forceshow = TRUE; | 929 | d->forceshow = TRUE; |
988 | argc-=1; | 930 | argc-=1; |
989 | } | 931 | } |
990 | } | 932 | } |
991 | 933 | ||
992 | /* overide stored arguments */ | 934 | /* overide stored arguments */ |
993 | setArgs(argc, argv); | 935 | setArgs(argc, argv); |
994 | 936 | ||
995 | /* install translation here */ | 937 | /* install translation here */ |
996 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) | 938 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) |
997 | installTranslation( (*it) + "/" + d->appName + ".qm" ); | 939 | installTranslation( (*it) + "/" + d->appName + ".qm" ); |
998 | } | 940 | } |
999 | #endif | 941 | #endif |
1000 | 942 | ||
1001 | 943 | ||
1002 | static QPtrDict<void>* inputMethodDict = 0; | 944 | static QPtrDict<void>* inputMethodDict = 0; |
1003 | static void createInputMethodDict() | 945 | static void createInputMethodDict() |
1004 | { | 946 | { |
1005 | if ( !inputMethodDict ) | 947 | if ( !inputMethodDict ) |
1006 | inputMethodDict = new QPtrDict<void>; | 948 | inputMethodDict = new QPtrDict<void>; |
1007 | } | 949 | } |
1008 | 950 | ||
1009 | /*! | 951 | /*! |
1010 | Returns the currently set hint to the system as to whether | 952 | Returns the currently set hint to the system as to whether |
1011 | widget \a w has any use for text input methods. | 953 | widget \a w has any use for text input methods. |
1012 | 954 | ||
1013 | 955 | ||
1014 | \sa setInputMethodHint() InputMethodHint | 956 | \sa setInputMethodHint() InputMethodHint |
1015 | */ | 957 | */ |
1016 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 958 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
1017 | { | 959 | { |
1018 | if ( inputMethodDict && w ) | 960 | if ( inputMethodDict && w ) |
1019 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 961 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
1020 | return Normal; | 962 | return Normal; |
1021 | } | 963 | } |
1022 | 964 | ||
1023 | /*! | 965 | /*! |
1024 | \enum QPEApplication::InputMethodHint | 966 | \enum QPEApplication::InputMethodHint |
1025 | 967 | ||
1026 | \value Normal the application sometimes needs text input (the default). | 968 | \value Normal the application sometimes needs text input (the default). |
1027 | \value AlwaysOff the application never needs text input. | 969 | \value AlwaysOff the application never needs text input. |
1028 | \value AlwaysOn the application always needs text input. | 970 | \value AlwaysOn the application always needs text input. |
1029 | */ | 971 | */ |
1030 | 972 | ||
1031 | /*! | 973 | /*! |
1032 | Hints to the system that widget \a w has use for text input methods | 974 | Hints to the system that widget \a w has use for text input methods |
1033 | as specified by \a mode. | 975 | as specified by \a mode. |
1034 | 976 | ||
1035 | \sa inputMethodHint() InputMethodHint | 977 | \sa inputMethodHint() InputMethodHint |
1036 | */ | 978 | */ |
1037 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 979 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
1038 | { | 980 | { |
1039 | createInputMethodDict(); | 981 | createInputMethodDict(); |
1040 | if ( mode == Normal ) { | 982 | if ( mode == Normal ) { |
1041 | inputMethodDict->remove | 983 | inputMethodDict->remove |
1042 | ( w ); | 984 | ( w ); |
1043 | } | 985 | } |
1044 | else { | 986 | else { |
1045 | inputMethodDict->insert( w, ( void* ) mode ); | 987 | inputMethodDict->insert( w, ( void* ) mode ); |
1046 | } | 988 | } |
1047 | } | 989 | } |
1048 | 990 | ||
1049 | class HackDialog : public QDialog | 991 | class HackDialog : public QDialog |
1050 | { | 992 | { |
1051 | public: | 993 | public: |
1052 | void acceptIt() | 994 | void acceptIt() |
1053 | { | 995 | { |
1054 | accept(); | 996 | accept(); |
1055 | } | 997 | } |
1056 | void rejectIt() | 998 | void rejectIt() |
1057 | { | 999 | { |
1058 | reject(); | 1000 | reject(); |
1059 | } | 1001 | } |
1060 | }; | 1002 | }; |
1061 | 1003 | ||
1062 | 1004 | ||
1063 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 1005 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
1064 | { | 1006 | { |
1065 | // specialised actions for certain widgets. May want to | 1007 | // specialised actions for certain widgets. May want to |
1066 | // add more stuff here. | 1008 | // add more stuff here. |
1067 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 1009 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
1068 | && activePopupWidget() ->parentWidget() | 1010 | && activePopupWidget() ->parentWidget() |
1069 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 1011 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
1070 | key = Qt::Key_Return; | 1012 | key = Qt::Key_Return; |
1071 | 1013 | ||
1072 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 1014 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
1073 | key = Qt::Key_Return; | 1015 | key = Qt::Key_Return; |
1074 | 1016 | ||
1075 | #ifdef QWS | 1017 | #ifdef QWS |
1076 | 1018 | ||
1077 | ke->simpleData.keycode = key; | 1019 | ke->simpleData.keycode = key; |