author | mickeyl <mickeyl> | 2004-06-25 12:49:30 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-06-25 12:49:30 (UTC) |
commit | d3276bd5098fa4418efae6e3f87521f56653872f (patch) (unidiff) | |
tree | 906ff0338c780924e035822ce0629948d8ff2413 /library | |
parent | 09451308ca73f7b58a8ec0766df01bcb188f4b3f (diff) | |
download | opie-d3276bd5098fa4418efae6e3f87521f56653872f.zip opie-d3276bd5098fa4418efae6e3f87521f56653872f.tar.gz opie-d3276bd5098fa4418efae6e3f87521f56653872f.tar.bz2 |
- get rid of HIGH_RES_LOW_PHYS to allow shipping one libqpe for all devices
- honor FontFamily and FontSize as set in qpe/Appearance
- NOTE to packagers: Remember to ship appropriate qpe.conf files for the different devices!
-rw-r--r-- | library/qpeapplication.cpp | 2499 |
1 files changed, 1247 insertions, 1252 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 26e310a..4bc0c5f 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -96,6 +96,8 @@ | |||
96 | #endif | 96 | #endif |
97 | #include "qt_override_p.h" | 97 | #include "qt_override_p.h" |
98 | 98 | ||
99 | static bool useBigPixmaps = 0; | ||
100 | |||
99 | class HackWidget : public QWidget | 101 | class HackWidget : public QWidget |
100 | { | 102 | { |
101 | public: | 103 | public: |
@@ -109,57 +111,70 @@ public: | |||
109 | class QPEApplicationData | 111 | class QPEApplicationData |
110 | { | 112 | { |
111 | public: | 113 | public: |
112 | QPEApplicationData ( ) | 114 | QPEApplicationData ( ) |
113 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 115 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
114 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 116 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
115 | keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) | 117 | keep_running( true ), qcopQok( false ), |
116 | 118 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), | |
117 | {} | 119 | bigIconSize( 32 ), qpe_main_widget( 0 ) |
120 | { | ||
121 | Config cfg( "qpe" ); | ||
122 | cfg.setGroup( "Appearance" ); | ||
123 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); | ||
124 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); | ||
125 | fontSize = cfg.readNumEntry( "FontSize", 10 ); | ||
126 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); | ||
127 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); | ||
128 | } | ||
118 | 129 | ||
119 | int presstimer; | 130 | int presstimer; |
120 | QWidget* presswidget; | 131 | QWidget* presswidget; |
121 | QPoint presspos; | 132 | QPoint presspos; |
122 | 133 | ||
123 | bool rightpressed : 1; | 134 | bool rightpressed : 1; |
124 | bool kbgrabbed : 1; | 135 | bool kbgrabbed : 1; |
125 | bool notbusysent : 1; | 136 | bool notbusysent : 1; |
126 | bool preloaded : 1; | 137 | bool preloaded : 1; |
127 | bool forceshow : 1; | 138 | bool forceshow : 1; |
128 | bool nomaximize : 1; | 139 | bool nomaximize : 1; |
129 | bool keep_running : 1; | 140 | bool keep_running : 1; |
130 | bool qcopQok : 1; | 141 | bool qcopQok : 1; |
131 | 142 | ||
143 | QCString fontFamily; | ||
144 | int fontSize; | ||
145 | int smallIconSize; | ||
146 | int bigIconSize; | ||
132 | 147 | ||
133 | QStringList langs; | 148 | QStringList langs; |
134 | QString appName; | 149 | QString appName; |
135 | struct QCopRec | 150 | struct QCopRec |
136 | { | 151 | { |
137 | QCopRec( const QCString &ch, const QCString &msg, | 152 | QCopRec( const QCString &ch, const QCString &msg, |
138 | const QByteArray &d ) : | 153 | const QByteArray &d ) : |
139 | channel( ch ), message( msg ), data( d ) | 154 | channel( ch ), message( msg ), data( d ) |
140 | { } | 155 | { } |
141 | 156 | ||
142 | QCString channel; | 157 | QCString channel; |
143 | QCString message; | 158 | QCString message; |
144 | QByteArray data; | 159 | QByteArray data; |
145 | }; | 160 | }; |
146 | QWidget* qpe_main_widget; | 161 | QWidget* qpe_main_widget; |
147 | QGuardedPtr<QWidget> lastraised; | 162 | QGuardedPtr<QWidget> lastraised; |
148 | QQueue<QCopRec> qcopq; | 163 | QQueue<QCopRec> qcopq; |
149 | QString styleName; | 164 | QString styleName; |
150 | QString decorationName; | 165 | QString decorationName; |
151 | 166 | ||
152 | void enqueueQCop( const QCString &ch, const QCString &msg, | 167 | void enqueueQCop( const QCString &ch, const QCString &msg, |
153 | const QByteArray &data ) | 168 | const QByteArray &data ) |
154 | { | 169 | { |
155 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 170 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
156 | } | 171 | } |
157 | void sendQCopQ() | 172 | void sendQCopQ() |
158 | { | 173 | { |
159 | if (!qcopQok ) | 174 | if (!qcopQok ) |
160 | return; | 175 | return; |
161 | 176 | ||
162 | QCopRec * r; | 177 | QCopRec * r; |
163 | 178 | ||
164 | while((r=qcopq.dequeue())) { | 179 | while((r=qcopq.dequeue())) { |
165 | // remove from queue before sending... | 180 | // remove from queue before sending... |
@@ -169,66 +184,60 @@ public: | |||
169 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 184 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
170 | #endif | 185 | #endif |
171 | 186 | ||
172 | delete r; | 187 | delete r; |
173 | } | 188 | } |
174 | } | 189 | } |
175 | 190 | ||
176 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName/* = QString::null */) | 191 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) |
177 | { | 192 | { |
178 | // ugly hack, remove that later after finding a sane solution | 193 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) |
179 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, | 194 | { |
180 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has | 195 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); |
181 | // a (physically) large enough display to use the small icons | ||
182 | #if defined(OPIE_HIGH_RES_SMALL_PHY) | ||
183 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { | ||
184 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); | ||
185 | } | 196 | } |
186 | #endif | 197 | QPoint p; |
198 | QSize s; | ||
199 | bool max; | ||
200 | if ( mw->isVisible() ) { | ||
201 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | ||
202 | mw->resize(s); | ||
203 | mw->move(p); | ||
204 | } | ||
205 | mw->raise(); | ||
206 | } else { | ||
187 | 207 | ||
188 | QPoint p; | 208 | if ( mw->layout() && mw->inherits("QDialog") ) { |
189 | QSize s; | 209 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
190 | bool max; | 210 | mw->resize(s); |
191 | if ( mw->isVisible() ) { | 211 | mw->move(p); |
192 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 212 | |
193 | mw->resize(s); | 213 | if ( max && !nomaximize ) { |
194 | mw->move(p); | 214 | mw->showMaximized(); |
195 | } | 215 | } else { |
196 | mw->raise(); | 216 | mw->show(); |
197 | } else { | 217 | } |
198 | 218 | } else { | |
199 | if ( mw->layout() && mw->inherits("QDialog") ) { | 219 | qpe_show_dialog((QDialog*)mw,nomaximize); |
200 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 220 | } |
201 | mw->resize(s); | 221 | } else { |
202 | mw->move(p); | 222 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
203 | 223 | mw->resize(s); | |
204 | if ( max && !nomaximize ) { | 224 | mw->move(p); |
205 | mw->showMaximized(); | 225 | } else { //no stored rectangle, make an estimation |
206 | } else { | 226 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
207 | mw->show(); | 227 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
208 | } | 228 | mw->move( QMAX(x,0), QMAX(y,0) ); |
209 | } else { | ||
210 | qpe_show_dialog((QDialog*)mw,nomaximize); | ||
211 | } | ||
212 | } else { | ||
213 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | ||
214 | mw->resize(s); | ||
215 | mw->move(p); | ||
216 | } else { //no stored rectangle, make an estimation | ||
217 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | ||
218 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | ||
219 | mw->move( QMAX(x,0), QMAX(y,0) ); | ||
220 | #ifdef Q_WS_QWS | 229 | #ifdef Q_WS_QWS |
221 | if ( !nomaximize ) | 230 | if ( !nomaximize ) |
222 | mw->showMaximized(); | 231 | mw->showMaximized(); |
223 | #endif | 232 | #endif |
224 | } | 233 | } |
225 | if ( max && !nomaximize ) | 234 | if ( max && !nomaximize ) |
226 | mw->showMaximized(); | 235 | mw->showMaximized(); |
227 | else | 236 | else |
228 | mw->show(); | 237 | mw->show(); |
229 | } | 238 | } |
230 | } | 239 | } |
231 | } | 240 | } |
232 | 241 | ||
233 | static void qpe_show_dialog( QDialog* d, bool nomax ) | 242 | static void qpe_show_dialog( QDialog* d, bool nomax ) |
234 | { | 243 | { |
@@ -237,287 +246,287 @@ static void qpe_show_dialog( QDialog* d, bool nomax ) | |||
237 | int h = QMAX(sh.height(),d->height()); | 246 | int h = QMAX(sh.height(),d->height()); |
238 | 247 | ||
239 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) | 248 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) |
240 | nomax = TRUE; | 249 | nomax = TRUE; |
241 | 250 | ||
242 | #ifndef Q_WS_QWS | 251 | #ifndef Q_WS_QWS |
243 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); | 252 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); |
244 | #else | 253 | #else |
245 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); | 254 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); |
246 | #endif | 255 | #endif |
247 | 256 | ||
248 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); | 257 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); |
249 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); | 258 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); |
250 | 259 | ||
251 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { | 260 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { |
252 | d->showMaximized(); | 261 | d->showMaximized(); |
262 | } else { | ||
263 | // try centering the dialog around its parent | ||
264 | QPoint p(0,0); | ||
265 | if ( d->parentWidget() ) { | ||
266 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); | ||
267 | p = QPoint( pp.x() + d->parentWidget()->width()/2, | ||
268 | pp.y() + d->parentWidget()->height()/ 2 ); | ||
253 | } else { | 269 | } else { |
254 | // try centering the dialog around its parent | 270 | p = QPoint( maxX/2, maxY/2 ); |
255 | QPoint p(0,0); | 271 | } |
256 | if ( d->parentWidget() ) { | 272 | |
257 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); | 273 | p = QPoint( p.x() - w/2, p.y() - h/2 ); |
258 | p = QPoint( pp.x() + d->parentWidget()->width()/2, | 274 | // qDebug("p(x,y) is %d %d", p.x(), p.y() ); |
259 | pp.y() + d->parentWidget()->height()/ 2 ); | 275 | |
260 | } else { | 276 | if ( w >= maxX ) { |
261 | p = QPoint( maxX/2, maxY/2 ); | 277 | if ( p.y() < 0 ) |
262 | } | 278 | p.setY(0); |
263 | 279 | if ( p.y() + h > maxY ) | |
264 | p = QPoint( p.x() - w/2, p.y() - h/2 ); | 280 | p.setY( maxY - h); |
265 | //qDebug("p(x,y) is %d %d", p.x(), p.y() ); | 281 | |
266 | 282 | d->resize(maxX, h); | |
267 | if ( w >= maxX ) { | 283 | d->move(0, p.y() ); |
268 | if ( p.y() < 0 ) | 284 | } else if ( h >= maxY ) { |
269 | p.setY(0); | 285 | if ( p.x() < 0 ) |
270 | if ( p.y() + h > maxY ) | 286 | p.setX(0); |
271 | p.setY( maxY - h); | 287 | if ( p.x() + w > maxX ) |
272 | 288 | p.setX( maxX - w); | |
273 | d->resize(maxX, h); | 289 | |
274 | d->move(0, p.y() ); | 290 | d->resize(w, maxY); |
275 | } else if ( h >= maxY ) { | 291 | d->move(p.x(),0); |
276 | if ( p.x() < 0 ) | 292 | } else { |
277 | p.setX(0); | 293 | d->resize(w, h); |
278 | if ( p.x() + w > maxX ) | 294 | } |
279 | p.setX( maxX - w); | 295 | |
280 | 296 | d->show(); | |
281 | d->resize(w, maxY); | ||
282 | d->move(p.x(),0); | ||
283 | } else { | ||
284 | d->resize(w, h); | ||
285 | } | ||
286 | |||
287 | d->show(); | ||
288 | } | 297 | } |
289 | } | 298 | } |
290 | 299 | ||
291 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) | 300 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) |
292 | { | 301 | { |
293 | maximized = TRUE; | 302 | maximized = TRUE; |
294 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 303 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
295 | if ( qApp->desktop()->width() <= 350 ) | 304 | if ( qApp->desktop()->width() <= 350 ) |
296 | return FALSE; | 305 | return FALSE; |
297 | 306 | ||
298 | Config cfg( "qpe" ); | 307 | Config cfg( "qpe" ); |
299 | cfg.setGroup("ApplicationPositions"); | 308 | cfg.setGroup("ApplicationPositions"); |
300 | QString str = cfg.readEntry( app, QString::null ); | 309 | QString str = cfg.readEntry( app, QString::null ); |
301 | QStringList l = QStringList::split(",", str); | 310 | QStringList l = QStringList::split(",", str); |
302 | 311 | ||
303 | if ( l.count() == 5) { | 312 | if ( l.count() == 5) { |
304 | p.setX( l[0].toInt() ); | 313 | p.setX( l[0].toInt() ); |
305 | p.setY( l[1].toInt() ); | 314 | p.setY( l[1].toInt() ); |
306 | 315 | ||
307 | s.setWidth( l[2].toInt() ); | 316 | s.setWidth( l[2].toInt() ); |
308 | s.setHeight( l[3].toInt() ); | 317 | s.setHeight( l[3].toInt() ); |
309 | 318 | ||
310 | maximized = l[4].toInt(); | 319 | maximized = l[4].toInt(); |
311 | 320 | ||
312 | return TRUE; | 321 | return TRUE; |
313 | } | 322 | } |
314 | 323 | ||
315 | return FALSE; | 324 | return FALSE; |
316 | } | 325 | } |
317 | 326 | ||
318 | 327 | ||
319 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) | 328 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) |
320 | { | 329 | { |
321 | #ifndef Q_WS_QWS | 330 | #ifndef Q_WS_QWS |
322 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); | 331 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); |
323 | #endif | 332 | #endif |
324 | int maxX = qt_maxWindowRect.width(); | 333 | int maxX = qt_maxWindowRect.width(); |
325 | int maxY = qt_maxWindowRect.height(); | 334 | int maxY = qt_maxWindowRect.height(); |
326 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); | 335 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); |
327 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); | 336 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); |
337 | |||
338 | // total window size is not allowed to be larger than desktop window size | ||
339 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) | ||
340 | return FALSE; | ||
341 | |||
342 | if ( wWidth > maxX ) { | ||
343 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); | ||
344 | wWidth = maxX; | ||
345 | } | ||
328 | 346 | ||
329 | // total window size is not allowed to be larger than desktop window size | 347 | if ( wHeight > maxY ) { |
330 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) | 348 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); |
331 | return FALSE; | 349 | wHeight = maxY; |
350 | } | ||
332 | 351 | ||
333 | if ( wWidth > maxX ) { | 352 | // any smaller than this and the maximize/close/help buttons will be overlapping |
334 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); | 353 | if ( wWidth < 80 || wHeight < 60 ) |
335 | wWidth = maxX; | 354 | return FALSE; |
336 | } | ||
337 | 355 | ||
338 | if ( wHeight > maxY ) { | 356 | if ( p.x() < 0 ) |
339 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); | 357 | p.setX(0); |
340 | wHeight = maxY; | 358 | if ( p.y() < 0 ) |
341 | } | 359 | p.setY(0); |
342 | 360 | ||
343 | // any smaller than this and the maximize/close/help buttons will be overlapping | 361 | if ( p.x() + wWidth > maxX ) |
344 | if ( wWidth < 80 || wHeight < 60 ) | 362 | p.setX( maxX - wWidth ); |
345 | return FALSE; | 363 | if ( p.y() + wHeight > maxY ) |
364 | p.setY( maxY - wHeight ); | ||
346 | 365 | ||
347 | if ( p.x() < 0 ) | 366 | return TRUE; |
348 | p.setX(0); | 367 | } |
349 | if ( p.y() < 0 ) | ||
350 | p.setY(0); | ||
351 | 368 | ||
352 | if ( p.x() + wWidth > maxX ) | 369 | static void store_widget_rect(QWidget *w, QString &app) |
353 | p.setX( maxX - wWidth ); | 370 | { |
354 | if ( p.y() + wHeight > maxY ) | 371 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
355 | p.setY( maxY - wHeight ); | 372 | if ( qApp->desktop()->width() <= 350 ) |
373 | return; | ||
374 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to | ||
375 | // get the non-maximized version, so we have to do it the hard way ) | ||
376 | int offsetX = w->x() - w->geometry().left(); | ||
377 | int offsetY = w->y() - w->geometry().top(); | ||
378 | |||
379 | QRect r; | ||
380 | if ( w->isMaximized() ) | ||
381 | r = ( (HackWidget *) w)->normalGeometry(); | ||
382 | else | ||
383 | r = w->geometry(); | ||
384 | |||
385 | // Stores the window placement as pos(), size() (due to the offset mapping) | ||
386 | Config cfg( "qpe" ); | ||
387 | cfg.setGroup("ApplicationPositions"); | ||
388 | QString s; | ||
389 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | ||
390 | cfg.writeEntry( app, s ); | ||
391 | } | ||
356 | 392 | ||
357 | return TRUE; | 393 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
394 | { | ||
395 | /* | ||
396 | // This works but disable it for now until it is safe to apply | ||
397 | // What is does is scan the .desktop files of all the apps for | ||
398 | // the applnk that has the corresponding argv[0] as this program | ||
399 | // then it uses the name stored in the .desktop file as the caption | ||
400 | // for the main widget. This saves duplicating translations for | ||
401 | // the app name in the program and in the .desktop files. | ||
402 | |||
403 | AppLnkSet apps( appsPath ); | ||
404 | |||
405 | QList<AppLnk> appsList = apps.children(); | ||
406 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | ||
407 | if ( (*it)->exec() == appName ) { | ||
408 | mw->setCaption( (*it)->name() ); | ||
409 | return TRUE; | ||
410 | } | ||
411 | } | ||
412 | */ | ||
413 | return FALSE; | ||
358 | } | 414 | } |
359 | 415 | ||
360 | static void store_widget_rect(QWidget *w, QString &app) | 416 | |
417 | void show(QWidget* mw, bool nomax) | ||
361 | { | 418 | { |
362 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 419 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
363 | if ( qApp->desktop()->width() <= 350 ) | 420 | nomaximize = nomax; |
364 | return; | 421 | qpe_main_widget = mw; |
365 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to | ||
366 | // get the non-maximized version, so we have to do it the hard way ) | ||
367 | int offsetX = w->x() - w->geometry().left(); | ||
368 | int offsetY = w->y() - w->geometry().top(); | ||
369 | |||
370 | QRect r; | ||
371 | if ( w->isMaximized() ) | ||
372 | r = ( (HackWidget *) w)->normalGeometry(); | ||
373 | else | ||
374 | r = w->geometry(); | ||
375 | |||
376 | // Stores the window placement as pos(), size() (due to the offset mapping) | ||
377 | Config cfg( "qpe" ); | ||
378 | cfg.setGroup("ApplicationPositions"); | ||
379 | QString s; | ||
380 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | ||
381 | cfg.writeEntry( app, s ); | ||
382 | } | ||
383 | |||
384 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | ||
385 | { | ||
386 | /* | ||
387 | // This works but disable it for now until it is safe to apply | ||
388 | // What is does is scan the .desktop files of all the apps for | ||
389 | // the applnk that has the corresponding argv[0] as this program | ||
390 | // then it uses the name stored in the .desktop file as the caption | ||
391 | // for the main widget. This saves duplicating translations for | ||
392 | // the app name in the program and in the .desktop files. | ||
393 | |||
394 | AppLnkSet apps( appsPath ); | ||
395 | |||
396 | QList<AppLnk> appsList = apps.children(); | ||
397 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | ||
398 | if ( (*it)->exec() == appName ) { | ||
399 | mw->setCaption( (*it)->name() ); | ||
400 | return TRUE; | ||
401 | } | ||
402 | } | ||
403 | */ | ||
404 | return FALSE; | ||
405 | } | ||
406 | |||
407 | |||
408 | void show(QWidget* mw, bool nomax) | ||
409 | { | ||
410 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | ||
411 | nomaximize = nomax; | ||
412 | qpe_main_widget = mw; | ||
413 | qcopQok = TRUE; | 422 | qcopQok = TRUE; |
414 | #ifndef QT_NO_COP | 423 | #ifndef QT_NO_COP |
415 | 424 | ||
416 | sendQCopQ(); | 425 | sendQCopQ(); |
417 | #endif | 426 | #endif |
418 | 427 | ||
419 | if ( preloaded ) { | 428 | if ( preloaded ) { |
420 | if (forceshow) | 429 | if (forceshow) |
421 | show_mx(mw, nomax, appName); | 430 | show_mx(mw, nomax, appName); |
422 | } | 431 | } |
423 | else if ( keep_running ) { | 432 | else if ( keep_running ) { |
424 | show_mx(mw, nomax, appName); | 433 | show_mx(mw, nomax, appName); |
425 | } | 434 | } |
426 | } | 435 | } |
427 | 436 | ||
428 | void loadTextCodecs() | 437 | void loadTextCodecs() |
429 | { | 438 | { |
430 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 439 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
431 | #ifdef Q_OS_MACX | 440 | #ifdef Q_OS_MACX |
432 | QDir dir( path, "lib*.dylib" ); | 441 | QDir dir( path, "lib*.dylib" ); |
433 | #else | 442 | #else |
434 | QDir dir( path, "lib*.so" ); | 443 | QDir dir( path, "lib*.so" ); |
435 | #endif | 444 | #endif |
436 | QStringList list; | 445 | QStringList list; |
437 | if ( dir. exists ( )) | 446 | if ( dir. exists ( )) |
438 | list = dir.entryList(); | 447 | list = dir.entryList(); |
439 | QStringList::Iterator it; | 448 | QStringList::Iterator it; |
440 | for ( it = list.begin(); it != list.end(); ++it ) { | 449 | for ( it = list.begin(); it != list.end(); ++it ) { |
441 | TextCodecInterface *iface = 0; | 450 | TextCodecInterface *iface = 0; |
442 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 451 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
443 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 452 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
444 | QValueList<int> mibs = iface->mibEnums(); | 453 | QValueList<int> mibs = iface->mibEnums(); |
445 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 454 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
446 | (void)iface->createForMib(*i); | 455 | (void)iface->createForMib(*i); |
447 | // ### it exists now; need to remember if we can delete it | 456 | // ### it exists now; need to remember if we can delete it |
448 | } | 457 | } |
449 | } | 458 | } |
450 | else { | 459 | else { |
451 | lib->unload(); | 460 | lib->unload(); |
452 | delete lib; | 461 | delete lib; |
453 | } | 462 | } |
454 | } | 463 | } |
455 | } | 464 | } |
456 | 465 | ||
457 | void loadImageCodecs() | 466 | void loadImageCodecs() |
458 | { | 467 | { |
459 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 468 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
460 | #ifdef Q_OS_MACX | 469 | #ifdef Q_OS_MACX |
461 | QDir dir( path, "lib*.dylib" ); | 470 | QDir dir( path, "lib*.dylib" ); |
462 | #else | 471 | #else |
463 | QDir dir( path, "lib*.so" ); | 472 | QDir dir( path, "lib*.so" ); |
464 | #endif | 473 | #endif |
465 | QStringList list; | 474 | QStringList list; |
466 | if ( dir. exists ( )) | 475 | if ( dir. exists ( )) |
467 | list = dir.entryList(); | 476 | list = dir.entryList(); |
468 | QStringList::Iterator it; | 477 | QStringList::Iterator it; |
469 | for ( it = list.begin(); it != list.end(); ++it ) { | 478 | for ( it = list.begin(); it != list.end(); ++it ) { |
470 | ImageCodecInterface *iface = 0; | 479 | ImageCodecInterface *iface = 0; |
471 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 480 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
472 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 481 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
473 | QStringList formats = iface->keys(); | 482 | QStringList formats = iface->keys(); |
474 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 483 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
475 | (void)iface->installIOHandler(*i); | 484 | (void)iface->installIOHandler(*i); |
476 | // ### it exists now; need to remember if we can delete it | 485 | // ### it exists now; need to remember if we can delete it |
477 | } | 486 | } |
478 | } | 487 | } |
479 | else { | 488 | else { |
480 | lib->unload(); | 489 | lib->unload(); |
481 | delete lib; | 490 | delete lib; |
482 | } | 491 | } |
483 | } | 492 | } |
484 | } | 493 | } |
485 | }; | 494 | }; |
486 | 495 | ||
487 | class ResourceMimeFactory : public QMimeSourceFactory | 496 | class ResourceMimeFactory : public QMimeSourceFactory |
488 | { | 497 | { |
489 | public: | 498 | public: |
490 | ResourceMimeFactory() : resImage( 0 ) | 499 | ResourceMimeFactory() : resImage( 0 ) |
491 | { | 500 | { |
492 | setFilePath( Global::helpPath() ); | 501 | setFilePath( Global::helpPath() ); |
493 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 502 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
494 | } | 503 | } |
495 | ~ResourceMimeFactory() { | 504 | ~ResourceMimeFactory() { |
496 | delete resImage; | 505 | delete resImage; |
497 | } | 506 | } |
498 | 507 | ||
499 | const QMimeSource* data( const QString& abs_name ) const | 508 | const QMimeSource* data( const QString& abs_name ) const |
500 | { | 509 | { |
501 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 510 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
502 | if ( !r ) { | 511 | if ( !r ) { |
503 | int sl = abs_name.length(); | 512 | int sl = abs_name.length(); |
504 | do { | 513 | do { |
505 | sl = abs_name.findRev( '/', sl - 1 ); | 514 | sl = abs_name.findRev( '/', sl - 1 ); |
506 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 515 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
507 | int dot = name.findRev( '.' ); | 516 | int dot = name.findRev( '.' ); |
508 | if ( dot >= 0 ) | 517 | if ( dot >= 0 ) |
509 | name = name.left( dot ); | 518 | name = name.left( dot ); |
510 | QImage img = Resource::loadImage( name ); | 519 | QImage img = Resource::loadImage( name ); |
511 | if ( !img.isNull() ) { | 520 | if ( !img.isNull() ) { |
512 | delete resImage; | 521 | delete resImage; |
513 | resImage = new QImageDrag( img ); | 522 | resImage = new QImageDrag( img ); |
514 | r = resImage; | 523 | r = resImage; |
515 | } | 524 | } |
516 | } | 525 | } |
517 | while ( !r && sl > 0 ); | 526 | while ( !r && sl > 0 ); |
518 | } | 527 | } |
519 | return r; | 528 | return r; |
520 | } | 529 | } |
521 | private: | 530 | private: |
522 | mutable QImageDrag *resImage; | 531 | mutable QImageDrag *resImage; |
523 | }; | 532 | }; |
@@ -537,93 +546,93 @@ static int micMuted = 0; | |||
537 | 546 | ||
538 | static void setVolume( int t = 0, int percent = -1 ) | 547 | static void setVolume( int t = 0, int percent = -1 ) |
539 | { | 548 | { |
540 | switch ( t ) { | 549 | switch ( t ) { |
541 | case 0: { | 550 | case 0: { |
542 | Config cfg( "qpe" ); | 551 | Config cfg( "qpe" ); |
543 | cfg.setGroup( "Volume" ); | 552 | cfg.setGroup( "Volume" ); |
544 | if ( percent < 0 ) | 553 | if ( percent < 0 ) |
545 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 554 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
546 | #ifndef QT_NO_SOUND | 555 | #ifndef QT_NO_SOUND |
547 | int fd = 0; | 556 | int fd = 0; |
548 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 557 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
549 | int vol = muted ? 0 : percent; | 558 | int vol = muted ? 0 : percent; |
550 | // set both channels to same volume | 559 | // set both channels to same volume |
551 | vol |= vol << 8; | 560 | vol |= vol << 8; |
552 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); | 561 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); |
553 | ::close( fd ); | 562 | ::close( fd ); |
554 | } | 563 | } |
555 | #endif | 564 | #endif |
556 | } | 565 | } |
557 | break; | 566 | break; |
558 | } | 567 | } |
559 | } | 568 | } |
560 | 569 | ||
561 | static void setMic( int t = 0, int percent = -1 ) | 570 | static void setMic( int t = 0, int percent = -1 ) |
562 | { | 571 | { |
563 | switch ( t ) { | 572 | switch ( t ) { |
564 | case 0: { | 573 | case 0: { |
565 | Config cfg( "qpe" ); | 574 | Config cfg( "qpe" ); |
566 | cfg.setGroup( "Volume" ); | 575 | cfg.setGroup( "Volume" ); |
567 | if ( percent < 0 ) | 576 | if ( percent < 0 ) |
568 | percent = cfg.readNumEntry( "Mic", 50 ); | 577 | percent = cfg.readNumEntry( "Mic", 50 ); |
569 | 578 | ||
570 | #ifndef QT_NO_SOUND | 579 | #ifndef QT_NO_SOUND |
571 | int fd = 0; | 580 | int fd = 0; |
572 | int mic = micMuted ? 0 : percent; | 581 | int mic = micMuted ? 0 : percent; |
573 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 582 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
574 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 583 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
575 | ::close( fd ); | 584 | ::close( fd ); |
576 | } | 585 | } |
577 | #endif | 586 | #endif |
578 | } | 587 | } |
579 | break; | 588 | break; |
580 | } | 589 | } |
581 | } | 590 | } |
582 | 591 | ||
583 | 592 | ||
584 | static void setBass( int t = 0, int percent = -1 ) | 593 | static void setBass( int t = 0, int percent = -1 ) |
585 | { | 594 | { |
586 | switch ( t ) { | 595 | switch ( t ) { |
587 | case 0: { | 596 | case 0: { |
588 | Config cfg( "qpe" ); | 597 | Config cfg( "qpe" ); |
589 | cfg.setGroup( "Volume" ); | 598 | cfg.setGroup( "Volume" ); |
590 | if ( percent < 0 ) | 599 | if ( percent < 0 ) |
591 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 600 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
592 | 601 | ||
593 | #ifndef QT_NO_SOUND | 602 | #ifndef QT_NO_SOUND |
594 | int fd = 0; | 603 | int fd = 0; |
595 | int bass = percent; | 604 | int bass = percent; |
596 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 605 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
597 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 606 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
598 | ::close( fd ); | 607 | ::close( fd ); |
599 | } | 608 | } |
600 | #endif | 609 | #endif |
601 | } | 610 | } |
602 | break; | 611 | break; |
603 | } | 612 | } |
604 | } | 613 | } |
605 | 614 | ||
606 | 615 | ||
607 | static void setTreble( int t = 0, int percent = -1 ) | 616 | static void setTreble( int t = 0, int percent = -1 ) |
608 | { | 617 | { |
609 | switch ( t ) { | 618 | switch ( t ) { |
610 | case 0: { | 619 | case 0: { |
611 | Config cfg( "qpe" ); | 620 | Config cfg( "qpe" ); |
612 | cfg.setGroup( "Volume" ); | 621 | cfg.setGroup( "Volume" ); |
613 | if ( percent < 0 ) | 622 | if ( percent < 0 ) |
614 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 623 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
615 | 624 | ||
616 | #ifndef QT_NO_SOUND | 625 | #ifndef QT_NO_SOUND |
617 | int fd = 0; | 626 | int fd = 0; |
618 | int treble = percent; | 627 | int treble = percent; |
619 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 628 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
620 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 629 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
621 | ::close( fd ); | 630 | ::close( fd ); |
622 | } | 631 | } |
623 | #endif | 632 | #endif |
624 | } | 633 | } |
625 | break; | 634 | break; |
626 | } | 635 | } |
627 | } | 636 | } |
628 | 637 | ||
629 | 638 | ||
@@ -731,19 +740,19 @@ void QPEApplication::processQCopFile() | |||
731 | QFile f(qcopfn); | 740 | QFile f(qcopfn); |
732 | if ( f.open(IO_ReadWrite) ) { | 741 | if ( f.open(IO_ReadWrite) ) { |
733 | #ifndef Q_OS_WIN32 | 742 | #ifndef Q_OS_WIN32 |
734 | flock(f.handle(), LOCK_EX); | 743 | flock(f.handle(), LOCK_EX); |
735 | #endif | 744 | #endif |
736 | QDataStream ds(&f); | 745 | QDataStream ds(&f); |
737 | QCString channel, message; | 746 | QCString channel, message; |
738 | QByteArray data; | 747 | QByteArray data; |
739 | while(!ds.atEnd()) { | 748 | while(!ds.atEnd()) { |
740 | ds >> channel >> message >> data; | 749 | ds >> channel >> message >> data; |
741 | d->enqueueQCop(channel,message,data); | 750 | d->enqueueQCop(channel,message,data); |
742 | } | 751 | } |
743 | ::ftruncate(f.handle(), 0); | 752 | ::ftruncate(f.handle(), 0); |
744 | #ifndef Q_OS_WIN32 | 753 | #ifndef Q_OS_WIN32 |
745 | f.flush(); | 754 | f.flush(); |
746 | flock(f.handle(), LOCK_UN); | 755 | flock(f.handle(), LOCK_UN); |
747 | #endif | 756 | #endif |
748 | } | 757 | } |
749 | #endif | 758 | #endif |
@@ -787,116 +796,102 @@ void QPEApplication::processQCopFile() | |||
787 | the Qtopia server passes GuiServer. | 796 | the Qtopia server passes GuiServer. |
788 | */ | 797 | */ |
789 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 798 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
790 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 799 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
791 | { | 800 | { |
792 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. | 801 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. |
793 | 802 | ||
794 | d = new QPEApplicationData; | 803 | d = new QPEApplicationData; |
795 | d->loadTextCodecs(); | 804 | d->loadTextCodecs(); |
796 | d->loadImageCodecs(); | 805 | d->loadImageCodecs(); |
797 | int dw = desktop() ->width(); | 806 | int dw = desktop() ->width(); |
798 | 807 | ||
799 | if ( dw < 200 ) { | 808 | setFont( QFont( d->fontFamily, d->fontSize ) ); |
800 | setFont( QFont( "vera", 8 ) ); | 809 | AppLnk::setSmallIconSize( d->smallIconSize ); |
801 | AppLnk::setSmallIconSize( 10 ); | 810 | AppLnk::setBigIconSize( d->bigIconSize ); |
802 | AppLnk::setBigIconSize( 28 ); | ||
803 | } | ||
804 | #if defined(OPIE_HIGH_RES_SMALL_PHY) | ||
805 | else if ( dw > 600 ) { | ||
806 | setFont( QFont( "vera", 16 ) ); | ||
807 | AppLnk::setSmallIconSize( 24 ); | ||
808 | AppLnk::setBigIconSize( 48 ); | ||
809 | } | ||
810 | #endif | ||
811 | else if ( dw > 200 ) { | ||
812 | setFont( QFont( "vera", 10 ) ); | ||
813 | AppLnk::setSmallIconSize( 14 ); | ||
814 | AppLnk::setBigIconSize( 32 ); | ||
815 | } | ||
816 | 811 | ||
817 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 812 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
818 | 813 | ||
819 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 814 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
820 | 815 | ||
821 | 816 | ||
822 | sysChannel = new QCopChannel( "QPE/System", this ); | 817 | sysChannel = new QCopChannel( "QPE/System", this ); |
823 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 818 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
824 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 819 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
825 | 820 | ||
826 | /* COde now in initapp */ | 821 | /* COde now in initapp */ |
827 | #if 0 | 822 | #if 0 |
828 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 823 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
829 | 824 | ||
830 | QString qcopfn( "/tmp/qcop-msg-" ); | 825 | QString qcopfn( "/tmp/qcop-msg-" ); |
831 | qcopfn += QString( argv[ 0 ] ); // append command name | 826 | qcopfn += QString( argv[ 0 ] ); // append command name |
832 | 827 | ||
833 | QFile f( qcopfn ); | 828 | QFile f( qcopfn ); |
834 | if ( f.open( IO_ReadOnly ) ) { | 829 | if ( f.open( IO_ReadOnly ) ) { |
835 | flock( f.handle(), LOCK_EX ); | 830 | flock( f.handle(), LOCK_EX ); |
836 | } | 831 | } |
837 | 832 | ||
838 | 833 | ||
839 | 834 | ||
840 | QCString channel = QCString( argv[ 0 ] ); | 835 | QCString channel = QCString( argv[ 0 ] ); |
841 | channel.replace( QRegExp( ".*/" ), "" ); | 836 | channel.replace( QRegExp( ".*/" ), "" ); |
842 | d->appName = channel; | 837 | d->appName = channel; |
843 | channel = "QPE/Application/" + channel; | 838 | channel = "QPE/Application/" + channel; |
844 | pidChannel = new QCopChannel( channel, this ); | 839 | pidChannel = new QCopChannel( channel, this ); |
845 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 840 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
846 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); | 841 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); |
847 | 842 | ||
848 | if ( f.isOpen() ) { | 843 | if ( f.isOpen() ) { |
849 | d->keep_running = FALSE; | 844 | d->keep_running = FALSE; |
850 | QDataStream ds( &f ); | 845 | QDataStream ds( &f ); |
851 | QCString channel, message; | 846 | QCString channel, message; |
852 | QByteArray data; | 847 | QByteArray data; |
853 | while ( !ds.atEnd() ) { | 848 | while ( !ds.atEnd() ) { |
854 | ds >> channel >> message >> data; | 849 | ds >> channel >> message >> data; |
855 | d->enqueueQCop( channel, message, data ); | 850 | d->enqueueQCop( channel, message, data ); |
856 | } | 851 | } |
857 | 852 | ||
858 | flock( f.handle(), LOCK_UN ); | 853 | flock( f.handle(), LOCK_UN ); |
859 | f.close(); | 854 | f.close(); |
860 | f.remove(); | 855 | f.remove(); |
861 | } | 856 | } |
862 | 857 | ||
863 | for ( int a = 0; a < argc; a++ ) { | 858 | for ( int a = 0; a < argc; a++ ) { |
864 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 859 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
865 | argv[ a ] = argv[ a + 1 ]; | 860 | argv[ a ] = argv[ a + 1 ]; |
866 | a++; | 861 | a++; |
867 | d->preloaded = TRUE; | 862 | d->preloaded = TRUE; |
868 | argc -= 1; | 863 | argc -= 1; |
869 | } | 864 | } |
870 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 865 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
871 | argv[ a ] = argv[ a + 1 ]; | 866 | argv[ a ] = argv[ a + 1 ]; |
872 | a++; | 867 | a++; |
873 | d->preloaded = TRUE; | 868 | d->preloaded = TRUE; |
874 | d->forceshow = TRUE; | 869 | d->forceshow = TRUE; |
875 | argc -= 1; | 870 | argc -= 1; |
876 | } | 871 | } |
877 | } | 872 | } |
878 | 873 | ||
879 | /* overide stored arguments */ | 874 | /* overide stored arguments */ |
880 | setArgs( argc, argv ); | 875 | setArgs( argc, argv ); |
881 | 876 | ||
882 | #endif | 877 | #endif |
883 | #else | 878 | #else |
884 | initApp( argc, argv ); | 879 | initApp( argc, argv ); |
885 | #endif | 880 | #endif |
886 | // qwsSetDecoration( new QPEDecoration() ); | 881 | // qwsSetDecoration( new QPEDecoration() ); |
887 | 882 | ||
888 | #ifndef QT_NO_TRANSLATION | 883 | #ifndef QT_NO_TRANSLATION |
889 | 884 | ||
890 | d->langs = Global::languageList(); | 885 | d->langs = Global::languageList(); |
891 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { | 886 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { |
892 | QString lang = *it; | 887 | QString lang = *it; |
893 | 888 | ||
894 | installTranslation( lang + "/libopie.qm"); | 889 | installTranslation( lang + "/libopie.qm"); |
895 | installTranslation( lang + "/libqpe.qm" ); | 890 | installTranslation( lang + "/libqpe.qm" ); |
896 | installTranslation( lang + "/" + d->appName + ".qm" ); | 891 | installTranslation( lang + "/" + d->appName + ".qm" ); |
897 | 892 | ||
898 | 893 | ||
899 | //###language/font hack; should look it up somewhere | 894 | //###language/font hack; should look it up somewhere |
900 | #ifdef QWS | 895 | #ifdef QWS |
901 | 896 | ||
902 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 897 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
@@ -907,19 +902,19 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
907 | } | 902 | } |
908 | #endif | 903 | #endif |
909 | 904 | ||
910 | applyStyle(); | 905 | applyStyle(); |
911 | 906 | ||
912 | if ( type() == GuiServer ) { | 907 | if ( type() == GuiServer ) { |
913 | setVolume(); | 908 | setVolume(); |
914 | } | 909 | } |
915 | 910 | ||
916 | installEventFilter( this ); | 911 | installEventFilter( this ); |
917 | 912 | ||
918 | QPEMenuToolFocusManager::initialize(); | 913 | QPEMenuToolFocusManager::initialize(); |
919 | 914 | ||
920 | #ifdef QT_NO_QWS_CURSOR | 915 | #ifdef QT_NO_QWS_CURSOR |
921 | // if we have no cursor, probably don't want tooltips | 916 | // if we have no cursor, probably don't want tooltips |
922 | QToolTip::setEnabled( FALSE ); | 917 | QToolTip::setEnabled( FALSE ); |
923 | #endif | 918 | #endif |
924 | } | 919 | } |
925 | 920 | ||
@@ -944,7 +939,7 @@ void QPEApplication::initApp( int argc, char **argv ) | |||
944 | channel = "QPE/Application/" + channel; | 939 | channel = "QPE/Application/" + channel; |
945 | pidChannel = new QCopChannel( channel, this); | 940 | pidChannel = new QCopChannel( channel, this); |
946 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 941 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
947 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); | 942 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); |
948 | 943 | ||
949 | 944 | ||
950 | 945 | ||
@@ -952,18 +947,18 @@ void QPEApplication::initApp( int argc, char **argv ) | |||
952 | d->keep_running = d->qcopq.isEmpty(); | 947 | d->keep_running = d->qcopq.isEmpty(); |
953 | 948 | ||
954 | for (int a=0; a<argc; a++) { | 949 | for (int a=0; a<argc; a++) { |
955 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 950 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
956 | argv[a] = argv[a+1]; | 951 | argv[a] = argv[a+1]; |
957 | a++; | 952 | a++; |
958 | d->preloaded = TRUE; | 953 | d->preloaded = TRUE; |
959 | argc-=1; | 954 | argc-=1; |
960 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 955 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
961 | argv[a] = argv[a+1]; | 956 | argv[a] = argv[a+1]; |
962 | a++; | 957 | a++; |
963 | d->preloaded = TRUE; | 958 | d->preloaded = TRUE; |
964 | d->forceshow = TRUE; | 959 | d->forceshow = TRUE; |
965 | argc-=1; | 960 | argc-=1; |
966 | } | 961 | } |
967 | } | 962 | } |
968 | 963 | ||
969 | /* overide stored arguments */ | 964 | /* overide stored arguments */ |
@@ -979,8 +974,8 @@ void QPEApplication::initApp( int argc, char **argv ) | |||
979 | static QPtrDict<void>* inputMethodDict = 0; | 974 | static QPtrDict<void>* inputMethodDict = 0; |
980 | static void createInputMethodDict() | 975 | static void createInputMethodDict() |
981 | { | 976 | { |
982 | if ( !inputMethodDict ) | 977 | if ( !inputMethodDict ) |
983 | inputMethodDict = new QPtrDict<void>; | 978 | inputMethodDict = new QPtrDict<void>; |
984 | } | 979 | } |
985 | 980 | ||
986 | /*! | 981 | /*! |
@@ -992,9 +987,9 @@ static void createInputMethodDict() | |||
992 | */ | 987 | */ |
993 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 988 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
994 | { | 989 | { |
995 | if ( inputMethodDict && w ) | 990 | if ( inputMethodDict && w ) |
996 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 991 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
997 | return Normal; | 992 | return Normal; |
998 | } | 993 | } |
999 | 994 | ||
1000 | /*! | 995 | /*! |
@@ -1013,45 +1008,45 @@ QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | |||
1013 | */ | 1008 | */ |
1014 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 1009 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
1015 | { | 1010 | { |
1016 | createInputMethodDict(); | 1011 | createInputMethodDict(); |
1017 | if ( mode == Normal ) { | 1012 | if ( mode == Normal ) { |
1018 | inputMethodDict->remove | 1013 | inputMethodDict->remove |
1019 | ( w ); | 1014 | ( w ); |
1020 | } | 1015 | } |
1021 | else { | 1016 | else { |
1022 | inputMethodDict->insert( w, ( void* ) mode ); | 1017 | inputMethodDict->insert( w, ( void* ) mode ); |
1023 | } | 1018 | } |
1024 | } | 1019 | } |
1025 | 1020 | ||
1026 | class HackDialog : public QDialog | 1021 | class HackDialog : public QDialog |
1027 | { | 1022 | { |
1028 | public: | 1023 | public: |
1029 | void acceptIt() | 1024 | void acceptIt() |
1030 | { | 1025 | { |
1031 | accept(); | 1026 | accept(); |
1032 | } | 1027 | } |
1033 | void rejectIt() | 1028 | void rejectIt() |
1034 | { | 1029 | { |
1035 | reject(); | 1030 | reject(); |
1036 | } | 1031 | } |
1037 | }; | 1032 | }; |
1038 | 1033 | ||
1039 | 1034 | ||
1040 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 1035 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
1041 | { | 1036 | { |
1042 | // specialised actions for certain widgets. May want to | 1037 | // specialised actions for certain widgets. May want to |
1043 | // add more stuff here. | 1038 | // add more stuff here. |
1044 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 1039 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
1045 | && activePopupWidget() ->parentWidget() | 1040 | && activePopupWidget() ->parentWidget() |
1046 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 1041 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
1047 | key = Qt::Key_Return; | 1042 | key = Qt::Key_Return; |
1048 | 1043 | ||
1049 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 1044 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
1050 | key = Qt::Key_Return; | 1045 | key = Qt::Key_Return; |
1051 | 1046 | ||
1052 | #ifdef QWS | 1047 | #ifdef QWS |
1053 | 1048 | ||
1054 | ke->simpleData.keycode = key; | 1049 | ke->simpleData.keycode = key; |
1055 | #endif | 1050 | #endif |
1056 | } | 1051 | } |
1057 | 1052 | ||
@@ -1063,136 +1058,136 @@ void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | |||
1063 | #ifdef QWS | 1058 | #ifdef QWS |
1064 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 1059 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
1065 | { | 1060 | { |
1066 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 1061 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
1067 | if ( qApp->type() != QApplication::GuiServer ) { | 1062 | if ( qApp->type() != QApplication::GuiServer ) { |
1068 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 1063 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
1069 | e << d->appName; | 1064 | e << d->appName; |
1070 | } | 1065 | } |
1071 | d->notbusysent = TRUE; | 1066 | d->notbusysent = TRUE; |
1072 | } | 1067 | } |
1073 | if ( type() == GuiServer ) { | 1068 | if ( type() == GuiServer ) { |
1074 | switch ( e->type ) { | 1069 | switch ( e->type ) { |
1075 | case QWSEvent::Mouse: | 1070 | case QWSEvent::Mouse: |
1076 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 1071 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
1077 | emit clientMoused(); | 1072 | emit clientMoused(); |
1078 | break; | 1073 | break; |
1079 | default: | 1074 | default: |
1080 | break; | 1075 | break; |
1081 | } | 1076 | } |
1082 | } | 1077 | } |
1083 | if ( e->type == QWSEvent::Key ) { | 1078 | if ( e->type == QWSEvent::Key ) { |
1084 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 1079 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
1085 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 1080 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
1086 | // Use special "OK" key to press "OK" on top level widgets | 1081 | // Use special "OK" key to press "OK" on top level widgets |
1087 | QWidget * active = activeWindow(); | 1082 | QWidget * active = activeWindow(); |
1088 | QWidget *popup = 0; | 1083 | QWidget *popup = 0; |
1089 | if ( active && active->isPopup() ) { | 1084 | if ( active && active->isPopup() ) { |
1090 | popup = active; | 1085 | popup = active; |
1091 | active = active->parentWidget(); | 1086 | active = active->parentWidget(); |
1092 | } | 1087 | } |
1093 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 1088 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
1094 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 1089 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
1095 | if ( ke->simpleData.is_press ) { | 1090 | if ( ke->simpleData.is_press ) { |
1096 | if ( popup ) | 1091 | if ( popup ) |
1097 | popup->close(); | 1092 | popup->close(); |
1098 | if ( active->inherits( "QDialog" ) ) { | 1093 | if ( active->inherits( "QDialog" ) ) { |
1099 | HackDialog * d = ( HackDialog * ) active; | 1094 | HackDialog * d = ( HackDialog * ) active; |
1100 | d->acceptIt(); | 1095 | d->acceptIt(); |
1101 | return TRUE; | 1096 | return TRUE; |
1102 | } | 1097 | } |
1103 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 1098 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
1104 | QSignal s; | 1099 | QSignal s; |
1105 | s.connect( active, SLOT( accept() ) ); | 1100 | s.connect( active, SLOT( accept() ) ); |
1106 | s.activate(); | 1101 | s.activate(); |
1107 | } | 1102 | } |
1108 | else { | 1103 | else { |
1109 | // do the same as with the select key: Map to the default action of the widget: | 1104 | // do the same as with the select key: Map to the default action of the widget: |
1110 | mapToDefaultAction( ke, Qt::Key_Return ); | 1105 | mapToDefaultAction( ke, Qt::Key_Return ); |
1111 | } | 1106 | } |
1112 | } | 1107 | } |
1113 | } | 1108 | } |
1114 | } | 1109 | } |
1115 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 1110 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
1116 | // Use special "select" key to do whatever default action a widget has | 1111 | // Use special "select" key to do whatever default action a widget has |
1117 | mapToDefaultAction( ke, Qt::Key_Space ); | 1112 | mapToDefaultAction( ke, Qt::Key_Space ); |
1118 | } | 1113 | } |
1119 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 1114 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
1120 | ke->simpleData.is_press ) { | 1115 | ke->simpleData.is_press ) { |
1121 | // Escape key closes app if focus on toplevel | 1116 | // Escape key closes app if focus on toplevel |
1122 | QWidget * active = activeWindow(); | 1117 | QWidget * active = activeWindow(); |
1123 | if ( active && active->testWFlags( WType_TopLevel ) && | 1118 | if ( active && active->testWFlags( WType_TopLevel ) && |
1124 | ( int ) active->winId() == ke->simpleData.window && | 1119 | ( int ) active->winId() == ke->simpleData.window && |
1125 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 1120 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
1126 | if ( active->inherits( "QDialog" ) ) { | 1121 | if ( active->inherits( "QDialog" ) ) { |
1127 | HackDialog * d = ( HackDialog * ) active; | 1122 | HackDialog * d = ( HackDialog * ) active; |
1128 | d->rejectIt(); | 1123 | d->rejectIt(); |
1129 | return TRUE; | 1124 | return TRUE; |
1130 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { | 1125 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { |
1131 | active->close(); | 1126 | active->close(); |
1132 | } | 1127 | } |
1133 | } | 1128 | } |
1134 | 1129 | ||
1135 | } | 1130 | } |
1136 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { | 1131 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { |
1137 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) | 1132 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
1138 | // but we cannot access libopie function within libqpe :( | 1133 | // but we cannot access libopie function within libqpe :( |
1139 | 1134 | ||
1140 | QWidget * active = activeWindow ( ); | 1135 | QWidget * active = activeWindow ( ); |
1141 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { | 1136 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
1142 | if ( d-> kbgrabbed ) { // we grabbed the keyboard | 1137 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
1143 | QChar ch ( ke-> simpleData.unicode ); | 1138 | QChar ch ( ke-> simpleData.unicode ); |
1144 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | 1139 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, |
1145 | ke-> simpleData.keycode, | 1140 | ke-> simpleData.keycode, |
1146 | ch. latin1 ( ), | 1141 | ch. latin1 ( ), |
1147 | ke-> simpleData.modifiers, | 1142 | ke-> simpleData.modifiers, |
1148 | QString ( ch ), | 1143 | QString ( ch ), |
1149 | ke-> simpleData.is_auto_repeat, 1 ); | 1144 | ke-> simpleData.is_auto_repeat, 1 ); |
1150 | 1145 | ||
1151 | QObject *which = QWidget::keyboardGrabber ( ); | 1146 | QObject *which = QWidget::keyboardGrabber ( ); |
1152 | if ( !which ) | 1147 | if ( !which ) |
1153 | which = QApplication::focusWidget ( ); | 1148 | which = QApplication::focusWidget ( ); |
1154 | if ( !which ) | 1149 | if ( !which ) |
1155 | which = QApplication::activeWindow ( ); | 1150 | which = QApplication::activeWindow ( ); |
1156 | if ( !which ) | 1151 | if ( !which ) |
1157 | which = qApp; | 1152 | which = qApp; |
1158 | 1153 | ||
1159 | QApplication::sendEvent ( which, &qke ); | 1154 | QApplication::sendEvent ( which, &qke ); |
1160 | } | 1155 | } |
1161 | else { // we didn't grab the keyboard, so send the event to the launcher | 1156 | else { // we didn't grab the keyboard, so send the event to the launcher |
1162 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 1157 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
1163 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | 1158 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); |
1164 | } | 1159 | } |
1165 | } | 1160 | } |
1166 | return true; | 1161 | return true; |
1167 | } | 1162 | } |
1168 | } | 1163 | } |
1169 | if ( e->type == QWSEvent::Focus ) { | 1164 | if ( e->type == QWSEvent::Focus ) { |
1170 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 1165 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
1171 | if ( !fe->simpleData.get_focus ) { | 1166 | if ( !fe->simpleData.get_focus ) { |
1172 | QWidget * active = activeWindow(); | 1167 | QWidget * active = activeWindow(); |
1173 | while ( active && active->isPopup() ) { | 1168 | while ( active && active->isPopup() ) { |
1174 | active->close(); | 1169 | active->close(); |
1175 | active = activeWindow(); | 1170 | active = activeWindow(); |
1176 | } | 1171 | } |
1177 | } | 1172 | } |
1178 | else { | 1173 | else { |
1179 | // make sure our modal widget is ALWAYS on top | 1174 | // make sure our modal widget is ALWAYS on top |
1180 | QWidget *topm = activeModalWidget(); | 1175 | QWidget *topm = activeModalWidget(); |
1181 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { | 1176 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { |
1182 | topm->raise(); | 1177 | topm->raise(); |
1183 | } | 1178 | } |
1184 | } | 1179 | } |
1185 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 1180 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
1186 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 1181 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
1187 | if ( m == AlwaysOff ) | 1182 | if ( m == AlwaysOff ) |
1188 | Global::hideInputMethod(); | 1183 | Global::hideInputMethod(); |
1189 | if ( m == AlwaysOn ) | 1184 | if ( m == AlwaysOn ) |
1190 | Global::showInputMethod(); | 1185 | Global::showInputMethod(); |
1191 | } | 1186 | } |
1192 | } | 1187 | } |
1193 | 1188 | ||
1194 | 1189 | ||
1195 | return QApplication::qwsEventFilter( e ); | 1190 | return QApplication::qwsEventFilter( e ); |
1196 | } | 1191 | } |
1197 | #endif | 1192 | #endif |
1198 | 1193 | ||
@@ -1201,15 +1196,15 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
1201 | */ | 1196 | */ |
1202 | QPEApplication::~QPEApplication() | 1197 | QPEApplication::~QPEApplication() |
1203 | { | 1198 | { |
1204 | ungrabKeyboard(); | 1199 | ungrabKeyboard(); |
1205 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 1200 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
1206 | // Need to delete QCopChannels early, since the display will | 1201 | // Need to delete QCopChannels early, since the display will |
1207 | // be gone by the time we get to ~QObject(). | 1202 | // be gone by the time we get to ~QObject(). |
1208 | delete sysChannel; | 1203 | delete sysChannel; |
1209 | delete pidChannel; | 1204 | delete pidChannel; |
1210 | #endif | 1205 | #endif |
1211 | 1206 | ||
1212 | delete d; | 1207 | delete d; |
1213 | } | 1208 | } |
1214 | 1209 | ||
1215 | /*! | 1210 | /*! |
@@ -1217,11 +1212,11 @@ QPEApplication::~QPEApplication() | |||
1217 | */ | 1212 | */ |
1218 | QString QPEApplication::qpeDir() | 1213 | QString QPEApplication::qpeDir() |
1219 | { | 1214 | { |
1220 | const char * base = getenv( "OPIEDIR" ); | 1215 | const char * base = getenv( "OPIEDIR" ); |
1221 | if ( base ) | 1216 | if ( base ) |
1222 | return QString( base ) + "/"; | 1217 | return QString( base ) + "/"; |
1223 | 1218 | ||
1224 | return QString( "../" ); | 1219 | return QString( "../" ); |
1225 | } | 1220 | } |
1226 | 1221 | ||
1227 | /*! | 1222 | /*! |
@@ -1230,11 +1225,11 @@ QString QPEApplication::qpeDir() | |||
1230 | */ | 1225 | */ |
1231 | QString QPEApplication::documentDir() | 1226 | QString QPEApplication::documentDir() |
1232 | { | 1227 | { |
1233 | const char* base = getenv( "HOME"); | 1228 | const char* base = getenv( "HOME"); |
1234 | if ( base ) | 1229 | if ( base ) |
1235 | return QString( base ) + "/Documents"; | 1230 | return QString( base ) + "/Documents"; |
1236 | 1231 | ||
1237 | return QString( "../Documents" ); | 1232 | return QString( "../Documents" ); |
1238 | } | 1233 | } |
1239 | 1234 | ||
1240 | static int deforient = -1; | 1235 | static int deforient = -1; |
@@ -1244,22 +1239,22 @@ static int deforient = -1; | |||
1244 | */ | 1239 | */ |
1245 | int QPEApplication::defaultRotation() | 1240 | int QPEApplication::defaultRotation() |
1246 | { | 1241 | { |
1247 | if ( deforient < 0 ) { | 1242 | if ( deforient < 0 ) { |
1248 | QString d = getenv( "QWS_DISPLAY" ); | 1243 | QString d = getenv( "QWS_DISPLAY" ); |
1249 | if ( d.contains( "Rot90" ) ) { | 1244 | if ( d.contains( "Rot90" ) ) { |
1250 | deforient = 90; | 1245 | deforient = 90; |
1251 | } | 1246 | } |
1252 | else if ( d.contains( "Rot180" ) ) { | 1247 | else if ( d.contains( "Rot180" ) ) { |
1253 | deforient = 180; | 1248 | deforient = 180; |
1254 | } | 1249 | } |
1255 | else if ( d.contains( "Rot270" ) ) { | 1250 | else if ( d.contains( "Rot270" ) ) { |
1256 | deforient = 270; | 1251 | deforient = 270; |
1257 | } | 1252 | } |
1258 | else { | 1253 | else { |
1259 | deforient = 0; | 1254 | deforient = 0; |
1260 | } | 1255 | } |
1261 | } | 1256 | } |
1262 | return deforient; | 1257 | return deforient; |
1263 | } | 1258 | } |
1264 | 1259 | ||
1265 | /*! | 1260 | /*! |
@@ -1267,21 +1262,21 @@ int QPEApplication::defaultRotation() | |||
1267 | */ | 1262 | */ |
1268 | void QPEApplication::setDefaultRotation( int r ) | 1263 | void QPEApplication::setDefaultRotation( int r ) |
1269 | { | 1264 | { |
1270 | if ( qApp->type() == GuiServer ) { | 1265 | if ( qApp->type() == GuiServer ) { |
1271 | deforient = r; | 1266 | deforient = r; |
1272 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 1267 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
1273 | Config config("qpe"); | 1268 | Config config("qpe"); |
1274 | config.setGroup( "Rotation" ); | 1269 | config.setGroup( "Rotation" ); |
1275 | config.writeEntry( "Rot", r ); | 1270 | config.writeEntry( "Rot", r ); |
1276 | } | 1271 | } |
1277 | else { | 1272 | else { |
1278 | #ifndef QT_NO_COP | 1273 | #ifndef QT_NO_COP |
1279 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1274 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
1280 | e << r; | 1275 | e << r; |
1281 | } | 1276 | } |
1282 | #endif | 1277 | #endif |
1283 | 1278 | ||
1284 | } | 1279 | } |
1285 | } | 1280 | } |
1286 | 1281 | ||
1287 | #include <qgfx_qws.h> | 1282 | #include <qgfx_qws.h> |
@@ -1324,91 +1319,91 @@ extern bool qt_left_hand_scrollbars __attribute__(( weak )); | |||
1324 | */ | 1319 | */ |
1325 | void QPEApplication::applyStyle() | 1320 | void QPEApplication::applyStyle() |
1326 | { | 1321 | { |
1327 | Config config( "qpe" ); | 1322 | Config config( "qpe" ); |
1328 | config.setGroup( "Appearance" ); | 1323 | config.setGroup( "Appearance" ); |
1329 | 1324 | ||
1330 | #if QT_VERSION > 233 | 1325 | #if QT_VERSION > 233 |
1331 | #if !defined(OPIE_NO_OVERRIDE_QT) | 1326 | #if !defined(OPIE_NO_OVERRIDE_QT) |
1332 | // don't block ourselves ... | 1327 | // don't block ourselves ... |
1333 | Opie::force_appearance = 0; | 1328 | Opie::force_appearance = 0; |
1334 | 1329 | ||
1335 | static QString appname = Opie::binaryName ( ); | 1330 | static QString appname = Opie::binaryName ( ); |
1336 | 1331 | ||
1337 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 1332 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
1338 | int nostyle = 0; | 1333 | int nostyle = 0; |
1339 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 1334 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
1340 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 1335 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
1341 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 1336 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
1342 | break; | 1337 | break; |
1343 | } | 1338 | } |
1344 | } | 1339 | } |
1345 | #else | 1340 | #else |
1346 | int nostyle = 0; | 1341 | int nostyle = 0; |
1347 | #endif | 1342 | #endif |
1348 | 1343 | ||
1349 | // Widget style | 1344 | // Widget style |
1350 | QString style = config.readEntry( "Style", "FlatStyle" ); | 1345 | QString style = config.readEntry( "Style", "FlatStyle" ); |
1351 | 1346 | ||
1352 | // don't set a custom style | 1347 | // don't set a custom style |
1353 | if ( nostyle & Opie::Force_Style ) | 1348 | if ( nostyle & Opie::Force_Style ) |
1354 | style = "FlatStyle"; | 1349 | style = "FlatStyle"; |
1355 | 1350 | ||
1356 | internalSetStyle ( style ); | 1351 | internalSetStyle ( style ); |
1357 | 1352 | ||
1358 | // Colors - from /etc/colors/Liquid.scheme | 1353 | // Colors - from /etc/colors/Liquid.scheme |
1359 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); | 1354 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); |
1360 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); | 1355 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); |
1361 | QPalette pal( btncolor, bgcolor ); | 1356 | QPalette pal( btncolor, bgcolor ); |
1362 | QString color = config.readEntry( "Highlight", "#73adef" ); | 1357 | QString color = config.readEntry( "Highlight", "#73adef" ); |
1363 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 1358 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
1364 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 1359 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
1365 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 1360 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
1366 | color = config.readEntry( "Text", "#000000" ); | 1361 | color = config.readEntry( "Text", "#000000" ); |
1367 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 1362 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
1368 | color = config.readEntry( "ButtonText", "#000000" ); | 1363 | color = config.readEntry( "ButtonText", "#000000" ); |
1369 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 1364 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
1370 | color = config.readEntry( "Base", "#FFFFFF" ); | 1365 | color = config.readEntry( "Base", "#FFFFFF" ); |
1371 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1366 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1372 | 1367 | ||
1373 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1368 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1374 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1369 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1375 | 1370 | ||
1376 | setPalette( pal, TRUE ); | 1371 | setPalette( pal, TRUE ); |
1377 | 1372 | ||
1378 | 1373 | ||
1379 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present | 1374 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present |
1380 | if (&qt_left_hand_scrollbars ) | 1375 | if (&qt_left_hand_scrollbars ) |
1381 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); | 1376 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); |
1382 | 1377 | ||
1383 | // Window Decoration | 1378 | // Window Decoration |
1384 | QString dec = config.readEntry( "Decoration", "Flat" ); | 1379 | QString dec = config.readEntry( "Decoration", "Flat" ); |
1385 | 1380 | ||
1386 | // don't set a custom deco | 1381 | // don't set a custom deco |
1387 | if ( nostyle & Opie::Force_Decoration ) | 1382 | if ( nostyle & Opie::Force_Decoration ) |
1388 | dec = ""; | 1383 | dec = ""; |
1389 | 1384 | ||
1390 | 1385 | ||
1391 | if ( dec != d->decorationName ) { | 1386 | if ( dec != d->decorationName ) { |
1392 | qwsSetDecoration( new QPEDecoration( dec ) ); | 1387 | qwsSetDecoration( new QPEDecoration( dec ) ); |
1393 | d->decorationName = dec; | 1388 | d->decorationName = dec; |
1394 | } | 1389 | } |
1395 | 1390 | ||
1396 | // Font | 1391 | // Font |
1397 | QString ff = config.readEntry( "FontFamily", font().family() ); | 1392 | QString ff = config.readEntry( "FontFamily", font().family() ); |
1398 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 1393 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
1399 | 1394 | ||
1400 | // don't set a custom font | 1395 | // don't set a custom font |
1401 | if ( nostyle & Opie::Force_Font ) { | 1396 | if ( nostyle & Opie::Force_Font ) { |
1402 | ff = "Vera"; | 1397 | ff = "Vera"; |
1403 | fs = 10; | 1398 | fs = 10; |
1404 | } | 1399 | } |
1405 | 1400 | ||
1406 | setFont ( QFont ( ff, fs ), true ); | 1401 | setFont ( QFont ( ff, fs ), true ); |
1407 | 1402 | ||
1408 | #if !defined(OPIE_NO_OVERRIDE_QT) | 1403 | #if !defined(OPIE_NO_OVERRIDE_QT) |
1409 | // revert to global blocking policy ... | 1404 | // revert to global blocking policy ... |
1410 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; | 1405 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; |
1411 | Opie::force_appearance &= ~nostyle; | 1406 | Opie::force_appearance &= ~nostyle; |
1412 | #endif | 1407 | #endif |
1413 | #endif | 1408 | #endif |
1414 | } | 1409 | } |
@@ -1416,174 +1411,174 @@ void QPEApplication::applyStyle() | |||
1416 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1411 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1417 | { | 1412 | { |
1418 | #ifdef Q_WS_QWS | 1413 | #ifdef Q_WS_QWS |
1419 | QDataStream stream( data, IO_ReadOnly ); | 1414 | QDataStream stream( data, IO_ReadOnly ); |
1420 | if ( msg == "applyStyle()" ) { | 1415 | if ( msg == "applyStyle()" ) { |
1421 | applyStyle(); | 1416 | applyStyle(); |
1422 | } | 1417 | } |
1423 | else if ( msg == "toggleApplicationMenu()" ) { | 1418 | else if ( msg == "toggleApplicationMenu()" ) { |
1424 | QWidget *active = activeWindow ( ); | 1419 | QWidget *active = activeWindow ( ); |
1425 | 1420 | ||
1426 | if ( active ) { | 1421 | if ( active ) { |
1427 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); | 1422 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); |
1428 | bool oldactive = man-> isActive ( ); | 1423 | bool oldactive = man-> isActive ( ); |
1429 | 1424 | ||
1430 | man-> setActive( !man-> isActive() ); | 1425 | man-> setActive( !man-> isActive() ); |
1431 | 1426 | ||
1432 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu | 1427 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu |
1433 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); | 1428 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); |
1434 | } | 1429 | } |
1435 | } | 1430 | } |
1436 | } | 1431 | } |
1437 | else if ( msg == "setDefaultRotation(int)" ) { | 1432 | else if ( msg == "setDefaultRotation(int)" ) { |
1438 | if ( type() == GuiServer ) { | 1433 | if ( type() == GuiServer ) { |
1439 | int r; | 1434 | int r; |
1440 | stream >> r; | 1435 | stream >> r; |
1441 | setDefaultRotation( r ); | 1436 | setDefaultRotation( r ); |
1442 | } | 1437 | } |
1443 | } | 1438 | } |
1444 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> | 1439 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> |
1445 | if ( type() == GuiServer ) { | 1440 | if ( type() == GuiServer ) { |
1446 | int x, y, depth; | 1441 | int x, y, depth; |
1447 | stream >> x; | 1442 | stream >> x; |
1448 | stream >> y; | 1443 | stream >> y; |
1449 | stream >> depth; | 1444 | stream >> depth; |
1450 | setCurrentMode( x, y, depth ); | 1445 | setCurrentMode( x, y, depth ); |
1451 | } | 1446 | } |
1452 | } | 1447 | } |
1453 | else if ( msg == "reset()" ) { | 1448 | else if ( msg == "reset()" ) { |
1454 | if ( type() != GuiServer ) | 1449 | if ( type() != GuiServer ) |
1455 | reset(); | 1450 | reset(); |
1456 | } | 1451 | } |
1457 | else if ( msg == "setCurrentRotation(int)" ) { | 1452 | else if ( msg == "setCurrentRotation(int)" ) { |
1458 | int r; | 1453 | int r; |
1459 | stream >> r; | 1454 | stream >> r; |
1460 | setCurrentRotation( r ); | 1455 | setCurrentRotation( r ); |
1461 | } | 1456 | } |
1462 | else if ( msg == "shutdown()" ) { | 1457 | else if ( msg == "shutdown()" ) { |
1463 | if ( type() == GuiServer ) | 1458 | if ( type() == GuiServer ) |
1464 | shutdown(); | 1459 | shutdown(); |
1465 | } | 1460 | } |
1466 | else if ( msg == "quit()" ) { | 1461 | else if ( msg == "quit()" ) { |
1467 | if ( type() != GuiServer ) | 1462 | if ( type() != GuiServer ) |
1468 | tryQuit(); | 1463 | tryQuit(); |
1469 | } | 1464 | } |
1470 | else if ( msg == "forceQuit()" ) { | 1465 | else if ( msg == "forceQuit()" ) { |
1471 | if ( type() != GuiServer ) | 1466 | if ( type() != GuiServer ) |
1472 | quit(); | 1467 | quit(); |
1473 | } | 1468 | } |
1474 | else if ( msg == "restart()" ) { | 1469 | else if ( msg == "restart()" ) { |
1475 | if ( type() == GuiServer ) | 1470 | if ( type() == GuiServer ) |
1476 | restart(); | 1471 | restart(); |
1477 | } | 1472 | } |
1478 | else if ( msg == "language(QString)" ) { | 1473 | else if ( msg == "language(QString)" ) { |
1479 | if ( type() == GuiServer ) { | 1474 | if ( type() == GuiServer ) { |
1480 | QString l; | 1475 | QString l; |
1481 | stream >> l; | 1476 | stream >> l; |
1482 | QString cl = getenv( "LANG" ); | 1477 | QString cl = getenv( "LANG" ); |
1483 | if ( cl != l ) { | 1478 | if ( cl != l ) { |
1484 | if ( l.isNull() ) | 1479 | if ( l.isNull() ) |
1485 | unsetenv( "LANG" ); | 1480 | unsetenv( "LANG" ); |
1486 | else | 1481 | else |
1487 | setenv( "LANG", l.latin1(), 1 ); | 1482 | setenv( "LANG", l.latin1(), 1 ); |
1488 | restart(); | 1483 | restart(); |
1489 | } | 1484 | } |
1490 | } | 1485 | } |
1491 | } | 1486 | } |
1492 | else if ( msg == "timeChange(QString)" ) { | 1487 | else if ( msg == "timeChange(QString)" ) { |
1493 | QString t; | 1488 | QString t; |
1494 | stream >> t; | 1489 | stream >> t; |
1495 | if ( t.isNull() ) | 1490 | if ( t.isNull() ) |
1496 | unsetenv( "TZ" ); | 1491 | unsetenv( "TZ" ); |
1497 | else | 1492 | else |
1498 | setenv( "TZ", t.latin1(), 1 ); | 1493 | setenv( "TZ", t.latin1(), 1 ); |
1499 | // emit the signal so everyone else knows... | 1494 | // emit the signal so everyone else knows... |
1500 | emit timeChanged(); | 1495 | emit timeChanged(); |
1501 | } | 1496 | } |
1502 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1497 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1503 | if ( type() == GuiServer ) { | 1498 | if ( type() == GuiServer ) { |
1504 | QDateTime when; | 1499 | QDateTime when; |
1505 | QCString channel, message; | 1500 | QCString channel, message; |
1506 | int data; | 1501 | int data; |
1507 | stream >> when >> channel >> message >> data; | 1502 | stream >> when >> channel >> message >> data; |
1508 | AlarmServer::addAlarm( when, channel, message, data ); | 1503 | AlarmServer::addAlarm( when, channel, message, data ); |
1509 | } | 1504 | } |
1510 | } | 1505 | } |
1511 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1506 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1512 | if ( type() == GuiServer ) { | 1507 | if ( type() == GuiServer ) { |
1513 | QDateTime when; | 1508 | QDateTime when; |
1514 | QCString channel, message; | 1509 | QCString channel, message; |
1515 | int data; | 1510 | int data; |
1516 | stream >> when >> channel >> message >> data; | 1511 | stream >> when >> channel >> message >> data; |
1517 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1512 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1518 | } | 1513 | } |
1519 | } | 1514 | } |
1520 | else if ( msg == "clockChange(bool)" ) { | 1515 | else if ( msg == "clockChange(bool)" ) { |
1521 | int tmp; | 1516 | int tmp; |
1522 | stream >> tmp; | 1517 | stream >> tmp; |
1523 | emit clockChanged( tmp ); | 1518 | emit clockChanged( tmp ); |
1524 | } | 1519 | } |
1525 | else if ( msg == "weekChange(bool)" ) { | 1520 | else if ( msg == "weekChange(bool)" ) { |
1526 | int tmp; | 1521 | int tmp; |
1527 | stream >> tmp; | 1522 | stream >> tmp; |
1528 | emit weekChanged( tmp ); | 1523 | emit weekChanged( tmp ); |
1529 | } | 1524 | } |
1530 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1525 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1531 | DateFormat tmp; | 1526 | DateFormat tmp; |
1532 | stream >> tmp; | 1527 | stream >> tmp; |
1533 | emit dateFormatChanged( tmp ); | 1528 | emit dateFormatChanged( tmp ); |
1534 | } | 1529 | } |
1535 | else if ( msg == "setVolume(int,int)" ) { | 1530 | else if ( msg == "setVolume(int,int)" ) { |
1536 | int t, v; | 1531 | int t, v; |
1537 | stream >> t >> v; | 1532 | stream >> t >> v; |
1538 | setVolume( t, v ); | 1533 | setVolume( t, v ); |
1539 | emit volumeChanged( muted ); | 1534 | emit volumeChanged( muted ); |
1540 | } | 1535 | } |
1541 | else if ( msg == "volumeChange(bool)" ) { | 1536 | else if ( msg == "volumeChange(bool)" ) { |
1542 | stream >> muted; | 1537 | stream >> muted; |
1543 | setVolume(); | 1538 | setVolume(); |
1544 | emit volumeChanged( muted ); | 1539 | emit volumeChanged( muted ); |
1545 | } | 1540 | } |
1546 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1541 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1547 | int t, v; | 1542 | int t, v; |
1548 | stream >> t >> v; | 1543 | stream >> t >> v; |
1549 | setMic( t, v ); | 1544 | setMic( t, v ); |
1550 | emit micChanged( micMuted ); | 1545 | emit micChanged( micMuted ); |
1551 | } | 1546 | } |
1552 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1547 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1553 | stream >> micMuted; | 1548 | stream >> micMuted; |
1554 | setMic(); | 1549 | setMic(); |
1555 | emit micChanged( micMuted ); | 1550 | emit micChanged( micMuted ); |
1556 | } | 1551 | } |
1557 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1552 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1558 | int t, v; | 1553 | int t, v; |
1559 | stream >> t >> v; | 1554 | stream >> t >> v; |
1560 | setBass( t, v ); | 1555 | setBass( t, v ); |
1561 | } | 1556 | } |
1562 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1557 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1563 | setBass(); | 1558 | setBass(); |
1564 | } | 1559 | } |
1565 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1560 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1566 | int t, v; | 1561 | int t, v; |
1567 | stream >> t >> v; | 1562 | stream >> t >> v; |
1568 | setTreble( t, v ); | 1563 | setTreble( t, v ); |
1569 | } | 1564 | } |
1570 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1565 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1571 | setTreble(); | 1566 | setTreble(); |
1572 | } else if ( msg == "getMarkedText()" ) { | 1567 | } else if ( msg == "getMarkedText()" ) { |
1573 | if ( type() == GuiServer ) { | 1568 | if ( type() == GuiServer ) { |
1574 | const ushort unicode = 'C'-'@'; | 1569 | const ushort unicode = 'C'-'@'; |
1575 | const int scan = Key_C; | 1570 | const int scan = Key_C; |
1576 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); | 1571 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); |
1577 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); | 1572 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); |
1578 | } | 1573 | } |
1579 | } else if ( msg == "newChannel(QString)") { | 1574 | } else if ( msg == "newChannel(QString)") { |
1580 | QString myChannel = "QPE/Application/" + d->appName; | 1575 | QString myChannel = "QPE/Application/" + d->appName; |
1581 | QString channel; | 1576 | QString channel; |
1582 | stream >> channel; | 1577 | stream >> channel; |
1583 | if (channel == myChannel) { | 1578 | if (channel == myChannel) { |
1584 | processQCopFile(); | 1579 | processQCopFile(); |
1585 | d->sendQCopQ(); | 1580 | d->sendQCopQ(); |
1586 | } | 1581 | } |
1587 | } | 1582 | } |
1588 | 1583 | ||
1589 | 1584 | ||
@@ -1606,18 +1601,18 @@ bool QPEApplication::raiseAppropriateWindow() | |||
1606 | if ( !top ) top = mainWidget(); | 1601 | if ( !top ) top = mainWidget(); |
1607 | 1602 | ||
1608 | if ( top && d->keep_running ) { | 1603 | if ( top && d->keep_running ) { |
1609 | if ( top->isVisible() ) | 1604 | if ( top->isVisible() ) |
1610 | r = TRUE; | 1605 | r = TRUE; |
1611 | else if (d->preloaded) { | 1606 | else if (d->preloaded) { |
1612 | // We are preloaded and not visible.. pretend we just started.. | 1607 | // We are preloaded and not visible.. pretend we just started.. |
1613 | #ifndef QT_NO_COP | 1608 | #ifndef QT_NO_COP |
1614 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1609 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1615 | e << d->appName; | 1610 | e << d->appName; |
1616 | #endif | 1611 | #endif |
1617 | } | 1612 | } |
1618 | 1613 | ||
1619 | d->show_mx(top,d->nomaximize, d->appName); | 1614 | d->show_mx(top,d->nomaximize, d->appName); |
1620 | top->raise(); | 1615 | top->raise(); |
1621 | } | 1616 | } |
1622 | 1617 | ||
1623 | QWidget *topm = activeModalWidget(); | 1618 | QWidget *topm = activeModalWidget(); |
@@ -1628,44 +1623,44 @@ bool QPEApplication::raiseAppropriateWindow() | |||
1628 | // that repeated calls cycle through widgets. | 1623 | // that repeated calls cycle through widgets. |
1629 | QWidgetList *list = topLevelWidgets(); | 1624 | QWidgetList *list = topLevelWidgets(); |
1630 | if ( list ) { | 1625 | if ( list ) { |
1631 | bool foundlast = FALSE; | 1626 | bool foundlast = FALSE; |
1632 | QWidget* topsub = 0; | 1627 | QWidget* topsub = 0; |
1633 | if ( d->lastraised ) { | 1628 | if ( d->lastraised ) { |
1634 | for (QWidget* w = list->first(); w; w = list->next()) { | 1629 | for (QWidget* w = list->first(); w; w = list->next()) { |
1635 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1630 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1636 | if ( w == d->lastraised ) | 1631 | if ( w == d->lastraised ) |
1637 | foundlast = TRUE; | 1632 | foundlast = TRUE; |
1638 | if ( foundlast ) { | 1633 | if ( foundlast ) { |
1639 | w->raise(); | 1634 | w->raise(); |
1640 | topsub = w; | 1635 | topsub = w; |
1641 | } | 1636 | } |
1642 | } | 1637 | } |
1643 | } | 1638 | } |
1644 | } | 1639 | } |
1645 | for (QWidget* w = list->first(); w; w = list->next()) { | 1640 | for (QWidget* w = list->first(); w; w = list->next()) { |
1646 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1641 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1647 | if ( w == d->lastraised ) | 1642 | if ( w == d->lastraised ) |
1648 | break; | 1643 | break; |
1649 | w->raise(); | 1644 | w->raise(); |
1650 | topsub = w; | 1645 | topsub = w; |
1651 | } | 1646 | } |
1652 | } | 1647 | } |
1653 | d->lastraised = topsub; | 1648 | d->lastraised = topsub; |
1654 | delete list; | 1649 | delete list; |
1655 | } | 1650 | } |
1656 | 1651 | ||
1657 | // 3. Raise the active modal widget. | 1652 | // 3. Raise the active modal widget. |
1658 | if ( topm ) { | 1653 | if ( topm ) { |
1659 | topm->show(); | 1654 | topm->show(); |
1660 | topm->raise(); | 1655 | topm->raise(); |
1661 | // If we haven't already handled the fastAppShowing message | 1656 | // If we haven't already handled the fastAppShowing message |
1662 | if (!top && d->preloaded) { | 1657 | if (!top && d->preloaded) { |
1663 | #ifndef QT_NO_COP | 1658 | #ifndef QT_NO_COP |
1664 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1659 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1665 | e << d->appName; | 1660 | e << d->appName; |
1666 | #endif | 1661 | #endif |
1667 | } | 1662 | } |
1668 | r = FALSE; | 1663 | r = FALSE; |
1669 | } | 1664 | } |
1670 | 1665 | ||
1671 | return r; | 1666 | return r; |
@@ -1676,56 +1671,56 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | |||
1676 | { | 1671 | { |
1677 | #ifdef Q_WS_QWS | 1672 | #ifdef Q_WS_QWS |
1678 | 1673 | ||
1679 | if ( msg == "quit()" ) { | 1674 | if ( msg == "quit()" ) { |
1680 | tryQuit(); | 1675 | tryQuit(); |
1681 | } | 1676 | } |
1682 | else if ( msg == "quitIfInvisible()" ) { | 1677 | else if ( msg == "quitIfInvisible()" ) { |
1683 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1678 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1684 | quit(); | 1679 | quit(); |
1685 | } | 1680 | } |
1686 | else if ( msg == "close()" ) { | 1681 | else if ( msg == "close()" ) { |
1687 | hideOrQuit(); | 1682 | hideOrQuit(); |
1688 | } | 1683 | } |
1689 | else if ( msg == "disablePreload()" ) { | 1684 | else if ( msg == "disablePreload()" ) { |
1690 | d->preloaded = FALSE; | 1685 | d->preloaded = FALSE; |
1691 | d->keep_running = TRUE; | 1686 | d->keep_running = TRUE; |
1692 | /* so that quit will quit */ | 1687 | /* so that quit will quit */ |
1693 | } | 1688 | } |
1694 | else if ( msg == "enablePreload()" ) { | 1689 | else if ( msg == "enablePreload()" ) { |
1695 | if (d->qpe_main_widget) | 1690 | if (d->qpe_main_widget) |
1696 | d->preloaded = TRUE; | 1691 | d->preloaded = TRUE; |
1697 | d->keep_running = TRUE; | 1692 | d->keep_running = TRUE; |
1698 | /* so next quit won't quit */ | 1693 | /* so next quit won't quit */ |
1699 | } | 1694 | } |
1700 | else if ( msg == "raise()" ) { | 1695 | else if ( msg == "raise()" ) { |
1701 | d->keep_running = TRUE; | 1696 | d->keep_running = TRUE; |
1702 | d->notbusysent = FALSE; | 1697 | d->notbusysent = FALSE; |
1703 | raiseAppropriateWindow(); | 1698 | raiseAppropriateWindow(); |
1704 | // Tell the system we're still chugging along... | 1699 | // Tell the system we're still chugging along... |
1705 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1700 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1706 | e << d->appName; | 1701 | e << d->appName; |
1707 | } | 1702 | } |
1708 | else if ( msg == "flush()" ) { | 1703 | else if ( msg == "flush()" ) { |
1709 | emit flush(); | 1704 | emit flush(); |
1710 | // we need to tell the desktop | 1705 | // we need to tell the desktop |
1711 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1706 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1712 | e << d->appName; | 1707 | e << d->appName; |
1713 | } | 1708 | } |
1714 | else if ( msg == "reload()" ) { | 1709 | else if ( msg == "reload()" ) { |
1715 | emit reload(); | 1710 | emit reload(); |
1716 | } | 1711 | } |
1717 | else if ( msg == "setDocument(QString)" ) { | 1712 | else if ( msg == "setDocument(QString)" ) { |
1718 | d->keep_running = TRUE; | 1713 | d->keep_running = TRUE; |
1719 | QDataStream stream( data, IO_ReadOnly ); | 1714 | QDataStream stream( data, IO_ReadOnly ); |
1720 | QString doc; | 1715 | QString doc; |
1721 | stream >> doc; | 1716 | stream >> doc; |
1722 | QWidget *mw = mainWidget(); | 1717 | QWidget *mw = mainWidget(); |
1723 | if ( !mw ) | 1718 | if ( !mw ) |
1724 | mw = d->qpe_main_widget; | 1719 | mw = d->qpe_main_widget; |
1725 | if ( mw ) | 1720 | if ( mw ) |
1726 | Global::setDocument( mw, doc ); | 1721 | Global::setDocument( mw, doc ); |
1727 | 1722 | ||
1728 | } else if ( msg == "QPEProcessQCop()" ) { | 1723 | } else if ( msg == "QPEProcessQCop()" ) { |
1729 | processQCopFile(); | 1724 | processQCopFile(); |
1730 | d->sendQCopQ(); | 1725 | d->sendQCopQ(); |
1731 | }else | 1726 | }else |
@@ -1746,7 +1741,7 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | |||
1746 | } | 1741 | } |
1747 | if ( p ) | 1742 | if ( p ) |
1748 | d->keep_running = p; | 1743 | d->keep_running = p; |
1749 | } | 1744 | } |
1750 | #endif | 1745 | #endif |
1751 | } | 1746 | } |
1752 | 1747 | ||
@@ -1759,7 +1754,7 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | |||
1759 | */ | 1754 | */ |
1760 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1755 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1761 | { | 1756 | { |
1762 | // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit | 1757 | // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit |
1763 | d->show(mw, nomaximize ); | 1758 | d->show(mw, nomaximize ); |
1764 | } | 1759 | } |
1765 | 1760 | ||
@@ -1776,12 +1771,12 @@ void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | |||
1776 | */ | 1771 | */ |
1777 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1772 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1778 | { | 1773 | { |
1779 | if ( mw && argc() == 2 ) | 1774 | if ( mw && argc() == 2 ) |
1780 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1775 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1781 | 1776 | ||
1782 | 1777 | ||
1783 | //setMainWidget(mw); see above | 1778 | // setMainWidget(mw); see above |
1784 | d->show(mw, nomaximize ); | 1779 | d->show(mw, nomaximize ); |
1785 | } | 1780 | } |
1786 | 1781 | ||
1787 | 1782 | ||
@@ -1797,10 +1792,10 @@ void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | |||
1797 | */ | 1792 | */ |
1798 | void QPEApplication::setKeepRunning() | 1793 | void QPEApplication::setKeepRunning() |
1799 | { | 1794 | { |
1800 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1795 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1801 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1796 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1802 | qpeApp->d->keep_running = TRUE; | 1797 | qpeApp->d->keep_running = TRUE; |
1803 | } | 1798 | } |
1804 | } | 1799 | } |
1805 | 1800 | ||
1806 | /*! | 1801 | /*! |
@@ -1811,7 +1806,7 @@ void QPEApplication::setKeepRunning() | |||
1811 | */ | 1806 | */ |
1812 | bool QPEApplication::keepRunning() const | 1807 | bool QPEApplication::keepRunning() const |
1813 | { | 1808 | { |
1814 | return d->keep_running; | 1809 | return d->keep_running; |
1815 | } | 1810 | } |
1816 | 1811 | ||
1817 | /*! | 1812 | /*! |
@@ -1820,85 +1815,85 @@ bool QPEApplication::keepRunning() const | |||
1820 | void QPEApplication::internalSetStyle( const QString &style ) | 1815 | void QPEApplication::internalSetStyle( const QString &style ) |
1821 | { | 1816 | { |
1822 | #if QT_VERSION >= 300 | 1817 | #if QT_VERSION >= 300 |
1823 | if ( style == "QPE" ) { | 1818 | if ( style == "QPE" ) { |
1824 | setStyle( new QPEStyle ); | 1819 | setStyle( new QPEStyle ); |
1825 | } | 1820 | } |
1826 | else { | 1821 | else { |
1827 | QStyle *s = QStyleFactory::create( style ); | 1822 | QStyle *s = QStyleFactory::create( style ); |
1828 | if ( s ) | 1823 | if ( s ) |
1829 | setStyle( s ); | 1824 | setStyle( s ); |
1830 | } | 1825 | } |
1831 | #else | 1826 | #else |
1832 | if ( style == "Windows" ) { | 1827 | if ( style == "Windows" ) { |
1833 | setStyle( new QWindowsStyle ); | 1828 | setStyle( new QWindowsStyle ); |
1834 | } | 1829 | } |
1835 | else if ( style == "QPE" ) { | 1830 | else if ( style == "QPE" ) { |
1836 | setStyle( new QPEStyle ); | 1831 | setStyle( new QPEStyle ); |
1837 | } | 1832 | } |
1838 | else if ( style == "Light" ) { | 1833 | else if ( style == "Light" ) { |
1839 | setStyle( new LightStyle ); | 1834 | setStyle( new LightStyle ); |
1840 | } | 1835 | } |
1841 | #ifndef QT_NO_STYLE_PLATINUM | 1836 | #ifndef QT_NO_STYLE_PLATINUM |
1842 | else if ( style == "Platinum" ) { | 1837 | else if ( style == "Platinum" ) { |
1843 | setStyle( new QPlatinumStyle ); | 1838 | setStyle( new QPlatinumStyle ); |
1844 | } | 1839 | } |
1845 | #endif | 1840 | #endif |
1846 | #ifndef QT_NO_STYLE_MOTIF | 1841 | #ifndef QT_NO_STYLE_MOTIF |
1847 | else if ( style == "Motif" ) { | 1842 | else if ( style == "Motif" ) { |
1848 | setStyle( new QMotifStyle ); | 1843 | setStyle( new QMotifStyle ); |
1849 | } | 1844 | } |
1850 | #endif | 1845 | #endif |
1851 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1846 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1852 | else if ( style == "MotifPlus" ) { | 1847 | else if ( style == "MotifPlus" ) { |
1853 | setStyle( new QMotifPlusStyle ); | 1848 | setStyle( new QMotifPlusStyle ); |
1854 | } | 1849 | } |
1855 | #endif | 1850 | #endif |
1856 | 1851 | ||
1857 | else { | 1852 | else { |
1858 | QStyle *sty = 0; | 1853 | QStyle *sty = 0; |
1859 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; | 1854 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; |
1860 | 1855 | ||
1861 | #ifdef Q_OS_MACX | 1856 | #ifdef Q_OS_MACX |
1862 | if ( style. find ( ".dylib" ) > 0 ) | 1857 | if ( style. find ( ".dylib" ) > 0 ) |
1863 | path += style; | 1858 | path += style; |
1864 | else | 1859 | else |
1865 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility | 1860 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility |
1866 | #else | 1861 | #else |
1867 | if ( style. find ( ".so" ) > 0 ) | 1862 | if ( style. find ( ".so" ) > 0 ) |
1868 | path += style; | 1863 | path += style; |
1869 | else | 1864 | else |
1870 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1865 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1871 | #endif | 1866 | #endif |
1872 | static QLibrary *lastlib = 0; | 1867 | static QLibrary *lastlib = 0; |
1873 | static StyleInterface *lastiface = 0; | 1868 | static StyleInterface *lastiface = 0; |
1874 | 1869 | ||
1875 | QLibrary *lib = new QLibrary ( path ); | 1870 | QLibrary *lib = new QLibrary ( path ); |
1876 | StyleInterface *iface = 0; | 1871 | StyleInterface *iface = 0; |
1877 | 1872 | ||
1878 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1873 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1879 | sty = iface-> style ( ); | 1874 | sty = iface-> style ( ); |
1880 | 1875 | ||
1881 | if ( sty ) { | 1876 | if ( sty ) { |
1882 | setStyle ( sty ); | 1877 | setStyle ( sty ); |
1883 | 1878 | ||
1884 | if ( lastiface ) | 1879 | if ( lastiface ) |
1885 | lastiface-> release ( ); | 1880 | lastiface-> release ( ); |
1886 | lastiface = iface; | 1881 | lastiface = iface; |
1887 | 1882 | ||
1888 | if ( lastlib ) { | 1883 | if ( lastlib ) { |
1889 | lastlib-> unload ( ); | 1884 | lastlib-> unload ( ); |
1890 | delete lastlib; | 1885 | delete lastlib; |
1891 | } | 1886 | } |
1892 | lastlib = lib; | 1887 | lastlib = lib; |
1893 | } | 1888 | } |
1894 | else { | 1889 | else { |
1895 | if ( iface ) | 1890 | if ( iface ) |
1896 | iface-> release ( ); | 1891 | iface-> release ( ); |
1897 | delete lib; | 1892 | delete lib; |
1898 | 1893 | ||
1899 | setStyle ( new LightStyle ( )); | 1894 | setStyle ( new LightStyle ( )); |
1900 | } | 1895 | } |
1901 | } | 1896 | } |
1902 | #endif | 1897 | #endif |
1903 | } | 1898 | } |
1904 | 1899 | ||
@@ -1907,24 +1902,24 @@ void QPEApplication::internalSetStyle( const QString &style ) | |||
1907 | */ | 1902 | */ |
1908 | void QPEApplication::prepareForTermination( bool willrestart ) | 1903 | void QPEApplication::prepareForTermination( bool willrestart ) |
1909 | { | 1904 | { |
1910 | if ( willrestart ) { | 1905 | if ( willrestart ) { |
1911 | // Draw a big wait icon, the image can be altered in later revisions | 1906 | // Draw a big wait icon, the image can be altered in later revisions |
1912 | // QWidget *d = QApplication::desktop(); | 1907 | // QWidget *d = QApplication::desktop(); |
1913 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1908 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1914 | QPixmap pix; | 1909 | QPixmap pix; |
1915 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); | 1910 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); |
1916 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | | 1911 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | |
1917 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1912 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1918 | lblWait->setPixmap( pix ); | 1913 | lblWait->setPixmap( pix ); |
1919 | lblWait->setAlignment( QWidget::AlignCenter ); | 1914 | lblWait->setAlignment( QWidget::AlignCenter ); |
1920 | lblWait->show(); | 1915 | lblWait->show(); |
1921 | lblWait->showMaximized(); | 1916 | lblWait->showMaximized(); |
1922 | } | 1917 | } |
1923 | #ifndef SINGLE_APP | 1918 | #ifndef SINGLE_APP |
1924 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1919 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1925 | } | 1920 | } |
1926 | processEvents(); // ensure the message goes out. | 1921 | processEvents(); // ensure the message goes out. |
1927 | sleep( 1 ); // You have 1 second to comply. | 1922 | sleep( 1 ); // You have 1 second to comply. |
1928 | #endif | 1923 | #endif |
1929 | } | 1924 | } |
1930 | 1925 | ||
@@ -1933,7 +1928,7 @@ void QPEApplication::prepareForTermination( bool willrestart ) | |||
1933 | */ | 1928 | */ |
1934 | void QPEApplication::shutdown() | 1929 | void QPEApplication::shutdown() |
1935 | { | 1930 | { |
1936 | // Implement in server's QPEApplication subclass | 1931 | // Implement in server's QPEApplication subclass |
1937 | } | 1932 | } |
1938 | 1933 | ||
1939 | /*! | 1934 | /*! |
@@ -1941,14 +1936,14 @@ void QPEApplication::shutdown() | |||
1941 | */ | 1936 | */ |
1942 | void QPEApplication::restart() | 1937 | void QPEApplication::restart() |
1943 | { | 1938 | { |
1944 | // Implement in server's QPEApplication subclass | 1939 | // Implement in server's QPEApplication subclass |
1945 | } | 1940 | } |
1946 | 1941 | ||
1947 | static QPtrDict<void>* stylusDict = 0; | 1942 | static QPtrDict<void>* stylusDict = 0; |
1948 | static void createDict() | 1943 | static void createDict() |
1949 | { | 1944 | { |
1950 | if ( !stylusDict ) | 1945 | if ( !stylusDict ) |
1951 | stylusDict = new QPtrDict<void>; | 1946 | stylusDict = new QPtrDict<void>; |
1952 | } | 1947 | } |
1953 | 1948 | ||
1954 | /*! | 1949 | /*! |
@@ -1958,9 +1953,9 @@ static void createDict() | |||
1958 | */ | 1953 | */ |
1959 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1954 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1960 | { | 1955 | { |
1961 | if ( stylusDict ) | 1956 | if ( stylusDict ) |
1962 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1957 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1963 | return LeftOnly; | 1958 | return LeftOnly; |
1964 | } | 1959 | } |
1965 | 1960 | ||
1966 | /*! | 1961 | /*! |
@@ -1982,17 +1977,17 @@ QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | |||
1982 | */ | 1977 | */ |
1983 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1978 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1984 | { | 1979 | { |
1985 | createDict(); | 1980 | createDict(); |
1986 | if ( mode == LeftOnly ) { | 1981 | if ( mode == LeftOnly ) { |
1987 | stylusDict->remove | 1982 | stylusDict->remove |
1988 | ( w ); | 1983 | ( w ); |
1989 | w->removeEventFilter( qApp ); | 1984 | w->removeEventFilter( qApp ); |
1990 | } | 1985 | } |
1991 | else { | 1986 | else { |
1992 | stylusDict->insert( w, ( void* ) mode ); | 1987 | stylusDict->insert( w, ( void* ) mode ); |
1993 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1988 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
1994 | w->installEventFilter( qApp ); | 1989 | w->installEventFilter( qApp ); |
1995 | } | 1990 | } |
1996 | } | 1991 | } |
1997 | 1992 | ||
1998 | 1993 | ||
@@ -2004,69 +1999,69 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | |||
2004 | if ( !o->isWidgetType() ) | 1999 | if ( !o->isWidgetType() ) |
2005 | return FALSE; | 2000 | return FALSE; |
2006 | 2001 | ||
2007 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 2002 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
2008 | QMouseEvent * me = ( QMouseEvent* ) e; | 2003 | QMouseEvent * me = ( QMouseEvent* ) e; |
2009 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 2004 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
2010 | switch (mode) { | 2005 | switch (mode) { |
2011 | case RightOnHold: | 2006 | case RightOnHold: |
2012 | switch ( me->type() ) { | 2007 | switch ( me->type() ) { |
2013 | case QEvent::MouseButtonPress: | 2008 | case QEvent::MouseButtonPress: |
2014 | if ( me->button() == LeftButton ) { | 2009 | if ( me->button() == LeftButton ) { |
2015 | if (!d->presstimer ) | 2010 | if (!d->presstimer ) |
2016 | d->presstimer = startTimer(500); // #### pref. | 2011 | d->presstimer = startTimer(500); // #### pref. |
2017 | d->presswidget = (QWidget*)o; | 2012 | d->presswidget = (QWidget*)o; |
2018 | d->presspos = me->pos(); | 2013 | d->presspos = me->pos(); |
2019 | d->rightpressed = FALSE; | 2014 | d->rightpressed = FALSE; |
2020 | } | 2015 | } |
2021 | break; | 2016 | break; |
2022 | case QEvent::MouseMove: | 2017 | case QEvent::MouseMove: |
2023 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 2018 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
2024 | killTimer(d->presstimer); | 2019 | killTimer(d->presstimer); |
2025 | d->presstimer = 0; | 2020 | d->presstimer = 0; |
2026 | } | 2021 | } |
2027 | break; | 2022 | break; |
2028 | case QEvent::MouseButtonRelease: | 2023 | case QEvent::MouseButtonRelease: |
2029 | if ( me->button() == LeftButton ) { | 2024 | if ( me->button() == LeftButton ) { |
2030 | if ( d->presstimer ) { | 2025 | if ( d->presstimer ) { |
2031 | killTimer(d->presstimer); | 2026 | killTimer(d->presstimer); |
2032 | d->presstimer = 0; | 2027 | d->presstimer = 0; |
2033 | } | 2028 | } |
2034 | if ( d->rightpressed && d->presswidget ) { | 2029 | if ( d->rightpressed && d->presswidget ) { |
2035 | // Right released | 2030 | // Right released |
2036 | postEvent( d->presswidget, | 2031 | postEvent( d->presswidget, |
2037 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 2032 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
2038 | RightButton, LeftButton + RightButton ) ); | 2033 | RightButton, LeftButton + RightButton ) ); |
2039 | // Left released, off-widget | 2034 | // Left released, off-widget |
2040 | postEvent( d->presswidget, | 2035 | postEvent( d->presswidget, |
2041 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 2036 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
2042 | LeftButton, LeftButton ) ); | 2037 | LeftButton, LeftButton ) ); |
2043 | postEvent( d->presswidget, | 2038 | postEvent( d->presswidget, |
2044 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 2039 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
2045 | LeftButton, LeftButton ) ); | 2040 | LeftButton, LeftButton ) ); |
2046 | d->rightpressed = FALSE; | 2041 | d->rightpressed = FALSE; |
2047 | return TRUE; // don't send the real Left release | 2042 | return TRUE; // don't send the real Left release |
2048 | } | 2043 | } |
2049 | } | 2044 | } |
2050 | break; | 2045 | break; |
2051 | default: | 2046 | default: |
2052 | break; | 2047 | break; |
2053 | } | 2048 | } |
2054 | break; | 2049 | break; |
2055 | default: | 2050 | default: |
2056 | ; | 2051 | ; |
2057 | } | 2052 | } |
2058 | } | 2053 | } |
2059 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 2054 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
2060 | QKeyEvent *ke = (QKeyEvent *)e; | 2055 | QKeyEvent *ke = (QKeyEvent *)e; |
2061 | if ( ke->key() == Key_Enter ) { | 2056 | if ( ke->key() == Key_Enter ) { |
2062 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 2057 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
2063 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 2058 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
2064 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 2059 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
2065 | return TRUE; | 2060 | return TRUE; |
2066 | } | 2061 | } |
2067 | } | 2062 | } |
2068 | } | 2063 | } |
2069 | return FALSE; | 2064 | return FALSE; |
2070 | } | 2065 | } |
2071 | 2066 | ||
2072 | /*! | 2067 | /*! |
@@ -2074,23 +2069,23 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | |||
2074 | */ | 2069 | */ |
2075 | void QPEApplication::timerEvent( QTimerEvent *e ) | 2070 | void QPEApplication::timerEvent( QTimerEvent *e ) |
2076 | { | 2071 | { |
2077 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 2072 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
2078 | // Right pressed | 2073 | // Right pressed |
2079 | postEvent( d->presswidget, | 2074 | postEvent( d->presswidget, |
2080 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 2075 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
2081 | RightButton, LeftButton ) ); | 2076 | RightButton, LeftButton ) ); |
2082 | killTimer( d->presstimer ); | 2077 | killTimer( d->presstimer ); |
2083 | d->presstimer = 0; | 2078 | d->presstimer = 0; |
2084 | d->rightpressed = TRUE; | 2079 | d->rightpressed = TRUE; |
2085 | } | 2080 | } |
2086 | } | 2081 | } |
2087 | 2082 | ||
2088 | void QPEApplication::removeSenderFromStylusDict() | 2083 | void QPEApplication::removeSenderFromStylusDict() |
2089 | { | 2084 | { |
2090 | stylusDict->remove | 2085 | stylusDict->remove |
2091 | ( ( void* ) sender() ); | 2086 | ( ( void* ) sender() ); |
2092 | if ( d->presswidget == sender() ) | 2087 | if ( d->presswidget == sender() ) |
2093 | d->presswidget = 0; | 2088 | d->presswidget = 0; |
2094 | } | 2089 | } |
2095 | 2090 | ||
2096 | /*! | 2091 | /*! |
@@ -2098,7 +2093,7 @@ void QPEApplication::removeSenderFromStylusDict() | |||
2098 | */ | 2093 | */ |
2099 | bool QPEApplication::keyboardGrabbed() const | 2094 | bool QPEApplication::keyboardGrabbed() const |
2100 | { | 2095 | { |
2101 | return d->kbgrabbed; | 2096 | return d->kbgrabbed; |
2102 | } | 2097 | } |
2103 | 2098 | ||
2104 | 2099 | ||
@@ -2108,7 +2103,7 @@ bool QPEApplication::keyboardGrabbed() const | |||
2108 | */ | 2103 | */ |
2109 | void QPEApplication::ungrabKeyboard() | 2104 | void QPEApplication::ungrabKeyboard() |
2110 | { | 2105 | { |
2111 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; | 2106 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; |
2112 | } | 2107 | } |
2113 | 2108 | ||
2114 | /*! | 2109 | /*! |
@@ -2122,7 +2117,7 @@ void QPEApplication::ungrabKeyboard() | |||
2122 | */ | 2117 | */ |
2123 | void QPEApplication::grabKeyboard() | 2118 | void QPEApplication::grabKeyboard() |
2124 | { | 2119 | { |
2125 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; | 2120 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; |
2126 | } | 2121 | } |
2127 | 2122 | ||
2128 | /*! | 2123 | /*! |
@@ -2132,24 +2127,24 @@ int QPEApplication::exec() | |||
2132 | { | 2127 | { |
2133 | d->qcopQok = true; | 2128 | d->qcopQok = true; |
2134 | #ifndef QT_NO_COP | 2129 | #ifndef QT_NO_COP |
2135 | d->sendQCopQ(); | 2130 | d->sendQCopQ(); |
2136 | if ( !d->keep_running ) | 2131 | if ( !d->keep_running ) |
2137 | processEvents(); // we may have received QCop messages in the meantime. | 2132 | processEvents(); // we may have received QCop messages in the meantime. |
2138 | #endif | 2133 | #endif |
2139 | 2134 | ||
2140 | if ( d->keep_running ) | 2135 | if ( d->keep_running ) |
2141 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 2136 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
2142 | return QApplication::exec(); | 2137 | return QApplication::exec(); |
2143 | 2138 | ||
2144 | #ifndef QT_NO_COP | 2139 | #ifndef QT_NO_COP |
2145 | 2140 | ||
2146 | { | 2141 | { |
2147 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2142 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2148 | e << d->appName; | 2143 | e << d->appName; |
2149 | } | 2144 | } |
2150 | #endif | 2145 | #endif |
2151 | processEvents(); | 2146 | processEvents(); |
2152 | return 0; | 2147 | return 0; |
2153 | } | 2148 | } |
2154 | 2149 | ||
2155 | /*! | 2150 | /*! |
@@ -2159,20 +2154,20 @@ int QPEApplication::exec() | |||
2159 | */ | 2154 | */ |
2160 | void QPEApplication::tryQuit() | 2155 | void QPEApplication::tryQuit() |
2161 | { | 2156 | { |
2162 | if ( activeModalWidget() ) | 2157 | if ( activeModalWidget() ) |
2163 | return ; // Inside modal loop or konsole. Too hard to save state. | 2158 | return ; // Inside modal loop or konsole. Too hard to save state. |
2164 | #ifndef QT_NO_COP | 2159 | #ifndef QT_NO_COP |
2165 | 2160 | ||
2166 | { | 2161 | { |
2167 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2162 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2168 | e << d->appName; | 2163 | e << d->appName; |
2169 | } | 2164 | } |
2170 | #endif | 2165 | #endif |
2171 | if ( d->keep_running ) | 2166 | if ( d->keep_running ) |
2172 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2167 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2173 | processEvents(); | 2168 | processEvents(); |
2174 | 2169 | ||
2175 | quit(); | 2170 | quit(); |
2176 | } | 2171 | } |
2177 | 2172 | ||
2178 | /*! | 2173 | /*! |
@@ -2196,22 +2191,22 @@ void QPEApplication::installTranslation( const QString& baseName ) { | |||
2196 | void QPEApplication::hideOrQuit() | 2191 | void QPEApplication::hideOrQuit() |
2197 | { | 2192 | { |
2198 | if ( d->keep_running ) | 2193 | if ( d->keep_running ) |
2199 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2194 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2200 | processEvents(); | 2195 | processEvents(); |
2201 | 2196 | ||
2202 | // If we are a preloaded application we don't actually quit, so emit | 2197 | // If we are a preloaded application we don't actually quit, so emit |
2203 | // a System message indicating we're quasi-closing. | 2198 | // a System message indicating we're quasi-closing. |
2204 | if ( d->preloaded && d->qpe_main_widget ) | 2199 | if ( d->preloaded && d->qpe_main_widget ) |
2205 | #ifndef QT_NO_COP | 2200 | #ifndef QT_NO_COP |
2206 | 2201 | ||
2207 | { | 2202 | { |
2208 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 2203 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
2209 | e << d->appName; | 2204 | e << d->appName; |
2210 | d->qpe_main_widget->hide(); | 2205 | d->qpe_main_widget->hide(); |
2211 | } | 2206 | } |
2212 | #endif | 2207 | #endif |
2213 | else | 2208 | else |
2214 | quit(); | 2209 | quit(); |
2215 | } | 2210 | } |
2216 | 2211 | ||
2217 | #if (__GNUC__ > 2 ) | 2212 | #if (__GNUC__ > 2 ) |
@@ -2236,33 +2231,33 @@ void __cxa_pure_virtual() | |||
2236 | 2231 | ||
2237 | void* operator new[]( size_t size ) | 2232 | void* operator new[]( size_t size ) |
2238 | { | 2233 | { |
2239 | return malloc( size ); | 2234 | return malloc( size ); |
2240 | } | 2235 | } |
2241 | 2236 | ||
2242 | void* operator new( size_t size ) | 2237 | void* operator new( size_t size ) |
2243 | { | 2238 | { |
2244 | return malloc( size ); | 2239 | return malloc( size ); |
2245 | } | 2240 | } |
2246 | 2241 | ||
2247 | void operator delete[]( void* p ) | 2242 | void operator delete[]( void* p ) |
2248 | { | 2243 | { |
2249 | free( p ); | 2244 | free( p ); |
2250 | } | 2245 | } |
2251 | 2246 | ||
2252 | void operator delete[]( void* p, size_t /*size*/ ) | 2247 | void operator delete[]( void* p, size_t /*size*/ ) |
2253 | { | 2248 | { |
2254 | free( p ); | 2249 | free( p ); |
2255 | } | 2250 | } |
2256 | 2251 | ||
2257 | 2252 | ||
2258 | void operator delete( void* p ) | 2253 | void operator delete( void* p ) |
2259 | { | 2254 | { |
2260 | free( p ); | 2255 | free( p ); |
2261 | } | 2256 | } |
2262 | 2257 | ||
2263 | void operator delete( void* p, size_t /*size*/ ) | 2258 | void operator delete( void* p, size_t /*size*/ ) |
2264 | { | 2259 | { |
2265 | free( p ); | 2260 | free( p ); |
2266 | } | 2261 | } |
2267 | 2262 | ||
2268 | #endif | 2263 | #endif |
@@ -2274,20 +2269,20 @@ void operator delete( void* p, size_t /*size*/ ) | |||
2274 | extern QRect qt_maxWindowRect; | 2269 | extern QRect qt_maxWindowRect; |
2275 | void qt_setMaxWindowRect(const QRect& r ) | 2270 | void qt_setMaxWindowRect(const QRect& r ) |
2276 | { | 2271 | { |
2277 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 2272 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
2278 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 2273 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
2279 | // Re-resize any maximized windows | 2274 | // Re-resize any maximized windows |
2280 | QWidgetList* l = QApplication::topLevelWidgets(); | 2275 | QWidgetList* l = QApplication::topLevelWidgets(); |
2281 | if ( l ) { | 2276 | if ( l ) { |
2282 | QWidget * w = l->first(); | 2277 | QWidget * w = l->first(); |
2283 | while ( w ) { | 2278 | while ( w ) { |
2284 | if ( w->isVisible() && w->isMaximized() ) { | 2279 | if ( w->isVisible() && w->isMaximized() ) { |
2285 | w->showMaximized(); | 2280 | w->showMaximized(); |
2286 | } | 2281 | } |
2287 | w = l->next(); | 2282 | w = l->next(); |
2288 | } | 2283 | } |
2289 | delete l; | 2284 | delete l; |
2290 | } | 2285 | } |
2291 | } | 2286 | } |
2292 | #endif | 2287 | #endif |
2293 | #endif | 2288 | #endif |