author | llornkcor <llornkcor> | 2004-04-25 08:49:01 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-04-25 08:49:01 (UTC) |
commit | ea4380df897798cf4bbadaf786868a18b3dee975 (patch) (unidiff) | |
tree | 14838fcf9c381d4e27bd2ad4bb2c0b759cad12b7 /library/qpeapplication.cpp | |
parent | fc1f0001f53f57b625f337a68532984959e6d8dd (diff) | |
download | opie-ea4380df897798cf4bbadaf786868a18b3dee975.zip opie-ea4380df897798cf4bbadaf786868a18b3dee975.tar.gz opie-ea4380df897798cf4bbadaf786868a18b3dee975.tar.bz2 |
remove non needed qdebugs
-rw-r--r-- | library/qpeapplication.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index ae1632e..5ce3011 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -117,457 +117,455 @@ public: | |||
117 | {} | 117 | {} |
118 | 118 | ||
119 | int presstimer; | 119 | int presstimer; |
120 | QWidget* presswidget; | 120 | QWidget* presswidget; |
121 | QPoint presspos; | 121 | QPoint presspos; |
122 | 122 | ||
123 | bool rightpressed : 1; | 123 | bool rightpressed : 1; |
124 | bool kbgrabbed : 1; | 124 | bool kbgrabbed : 1; |
125 | bool notbusysent : 1; | 125 | bool notbusysent : 1; |
126 | bool preloaded : 1; | 126 | bool preloaded : 1; |
127 | bool forceshow : 1; | 127 | bool forceshow : 1; |
128 | bool nomaximize : 1; | 128 | bool nomaximize : 1; |
129 | bool keep_running : 1; | 129 | bool keep_running : 1; |
130 | bool qcopQok : 1; | 130 | bool qcopQok : 1; |
131 | 131 | ||
132 | 132 | ||
133 | QStringList langs; | 133 | QStringList langs; |
134 | QString appName; | 134 | QString appName; |
135 | struct QCopRec | 135 | struct QCopRec |
136 | { | 136 | { |
137 | QCopRec( const QCString &ch, const QCString &msg, | 137 | QCopRec( const QCString &ch, const QCString &msg, |
138 | const QByteArray &d ) : | 138 | const QByteArray &d ) : |
139 | channel( ch ), message( msg ), data( d ) | 139 | channel( ch ), message( msg ), data( d ) |
140 | { } | 140 | { } |
141 | 141 | ||
142 | QCString channel; | 142 | QCString channel; |
143 | QCString message; | 143 | QCString message; |
144 | QByteArray data; | 144 | QByteArray data; |
145 | }; | 145 | }; |
146 | QWidget* qpe_main_widget; | 146 | QWidget* qpe_main_widget; |
147 | QGuardedPtr<QWidget> lastraised; | 147 | QGuardedPtr<QWidget> lastraised; |
148 | QQueue<QCopRec> qcopq; | 148 | QQueue<QCopRec> qcopq; |
149 | QString styleName; | 149 | QString styleName; |
150 | QString decorationName; | 150 | QString decorationName; |
151 | 151 | ||
152 | void enqueueQCop( const QCString &ch, const QCString &msg, | 152 | void enqueueQCop( const QCString &ch, const QCString &msg, |
153 | const QByteArray &data ) | 153 | const QByteArray &data ) |
154 | { | 154 | { |
155 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 155 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
156 | } | 156 | } |
157 | void sendQCopQ() | 157 | void sendQCopQ() |
158 | { | 158 | { |
159 | if (!qcopQok ) | 159 | if (!qcopQok ) |
160 | return; | 160 | return; |
161 | 161 | ||
162 | QCopRec * r; | 162 | QCopRec * r; |
163 | 163 | ||
164 | while((r=qcopq.dequeue())) { | 164 | while((r=qcopq.dequeue())) { |
165 | // remove from queue before sending... | 165 | // remove from queue before sending... |
166 | // event loop can come around again before getting | 166 | // event loop can come around again before getting |
167 | // back from sendLocally | 167 | // back from sendLocally |
168 | #ifndef QT_NO_COP | 168 | #ifndef QT_NO_COP |
169 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 169 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
170 | #endif | 170 | #endif |
171 | 171 | ||
172 | delete r; | 172 | delete r; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName/* = QString::null */) | 176 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName/* = QString::null */) |
177 | { | 177 | { |
178 | QPoint p; | 178 | QPoint p; |
179 | QSize s; | 179 | QSize s; |
180 | bool max; | 180 | bool max; |
181 | if ( mw->isVisible() ) { | 181 | if ( mw->isVisible() ) { |
182 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 182 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
183 | mw->resize(s); | 183 | mw->resize(s); |
184 | mw->move(p); | 184 | mw->move(p); |
185 | } | 185 | } |
186 | mw->raise(); | 186 | mw->raise(); |
187 | } else { | 187 | } else { |
188 | 188 | ||
189 | if ( mw->layout() && mw->inherits("QDialog") ) { | 189 | if ( mw->layout() && mw->inherits("QDialog") ) { |
190 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 190 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
191 | mw->resize(s); | 191 | mw->resize(s); |
192 | mw->move(p); | 192 | mw->move(p); |
193 | 193 | ||
194 | if ( max && !nomaximize ) { | 194 | if ( max && !nomaximize ) { |
195 | mw->showMaximized(); | 195 | mw->showMaximized(); |
196 | } else { | 196 | } else { |
197 | mw->show(); | 197 | mw->show(); |
198 | } | 198 | } |
199 | } else { | 199 | } else { |
200 | qpe_show_dialog((QDialog*)mw,nomaximize); | 200 | qpe_show_dialog((QDialog*)mw,nomaximize); |
201 | } | 201 | } |
202 | } else { | 202 | } else { |
203 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 203 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
204 | mw->resize(s); | 204 | mw->resize(s); |
205 | mw->move(p); | 205 | mw->move(p); |
206 | } else { //no stored rectangle, make an estimation | 206 | } else { //no stored rectangle, make an estimation |
207 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | 207 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
208 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | 208 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
209 | mw->move( QMAX(x,0), QMAX(y,0) ); | 209 | mw->move( QMAX(x,0), QMAX(y,0) ); |
210 | #ifdef Q_WS_QWS | 210 | #ifdef Q_WS_QWS |
211 | if ( !nomaximize ) | 211 | if ( !nomaximize ) |
212 | mw->showMaximized(); | 212 | mw->showMaximized(); |
213 | #endif | 213 | #endif |
214 | } | 214 | } |
215 | if ( max && !nomaximize ) | 215 | if ( max && !nomaximize ) |
216 | mw->showMaximized(); | 216 | mw->showMaximized(); |
217 | else | 217 | else |
218 | mw->show(); | 218 | mw->show(); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | } | 221 | } |
222 | // // ugly hack, remove that later after finding a sane solution | 222 | // // ugly hack, remove that later after finding a sane solution |
223 | // // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, | 223 | // // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, |
224 | // // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has | 224 | // // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has |
225 | // // a (physically) large enough display to use the small icons | 225 | // // a (physically) large enough display to use the small icons |
226 | // #if defined(OPIE_HIGH_RES_SMALL_PHY) | 226 | // #if defined(OPIE_HIGH_RES_SMALL_PHY) |
227 | // if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { | 227 | // if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { |
228 | // ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); | 228 | // ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); |
229 | // } | 229 | // } |
230 | // #endif | 230 | // #endif |
231 | 231 | ||
232 | // if ( mw->layout() && mw->inherits("QDialog") ) { | 232 | // if ( mw->layout() && mw->inherits("QDialog") ) { |
233 | // QPEApplication::showDialog((QDialog*)mw, nomaximize); | 233 | // QPEApplication::showDialog((QDialog*)mw, nomaximize); |
234 | // } | 234 | // } |
235 | // else { | 235 | // else { |
236 | // #ifdef Q_WS_QWS | 236 | // #ifdef Q_WS_QWS |
237 | // if ( !nomaximize ) { | 237 | // if ( !nomaximize ) { |
238 | // qDebug("QDialog special case XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); | 238 | // qDebug("QDialog special case XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); |
239 | // mw->showMaximized(); | 239 | // mw->showMaximized(); |
240 | // //QPEApplication::showWidget( mw, !nomaximize ); | 240 | // //QPEApplication::showWidget( mw, !nomaximize ); |
241 | // }else | 241 | // }else |
242 | // #endif | 242 | // #endif |
243 | // mw->show(); | 243 | // mw->show(); |
244 | // } | 244 | // } |
245 | //} | 245 | //} |
246 | 246 | ||
247 | 247 | ||
248 | static void qpe_show_dialog( QDialog* d, bool nomax ) | 248 | static void qpe_show_dialog( QDialog* d, bool nomax ) |
249 | { | 249 | { |
250 | QSize sh = d->sizeHint(); | 250 | QSize sh = d->sizeHint(); |
251 | int w = QMAX(sh.width(),d->width()); | 251 | int w = QMAX(sh.width(),d->width()); |
252 | int h = QMAX(sh.height(),d->height()); | 252 | int h = QMAX(sh.height(),d->height()); |
253 | 253 | ||
254 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) | 254 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) |
255 | nomax = TRUE; | 255 | nomax = TRUE; |
256 | 256 | ||
257 | #ifndef Q_WS_QWS | 257 | #ifndef Q_WS_QWS |
258 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); | 258 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); |
259 | #else | 259 | #else |
260 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); | 260 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); |
261 | #endif | 261 | #endif |
262 | 262 | ||
263 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); | 263 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); |
264 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); | 264 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); |
265 | 265 | ||
266 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { | 266 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { |
267 | d->showMaximized(); | 267 | d->showMaximized(); |
268 | } else { | 268 | } else { |
269 | // try centering the dialog around its parent | 269 | // try centering the dialog around its parent |
270 | QPoint p(0,0); | 270 | QPoint p(0,0); |
271 | if ( d->parentWidget() ) { | 271 | if ( d->parentWidget() ) { |
272 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); | 272 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); |
273 | p = QPoint( pp.x() + d->parentWidget()->width()/2, | 273 | p = QPoint( pp.x() + d->parentWidget()->width()/2, |
274 | pp.y() + d->parentWidget()->height()/ 2 ); | 274 | pp.y() + d->parentWidget()->height()/ 2 ); |
275 | } else { | 275 | } else { |
276 | p = QPoint( maxX/2, maxY/2 ); | 276 | p = QPoint( maxX/2, maxY/2 ); |
277 | } | 277 | } |
278 | 278 | ||
279 | p = QPoint( p.x() - w/2, p.y() - h/2 ); | 279 | p = QPoint( p.x() - w/2, p.y() - h/2 ); |
280 | //qDebug("p(x,y) is %d %d", p.x(), p.y() ); | 280 | //qDebug("p(x,y) is %d %d", p.x(), p.y() ); |
281 | 281 | ||
282 | if ( w >= maxX ) { | 282 | if ( w >= maxX ) { |
283 | if ( p.y() < 0 ) | 283 | if ( p.y() < 0 ) |
284 | p.setY(0); | 284 | p.setY(0); |
285 | if ( p.y() + h > maxY ) | 285 | if ( p.y() + h > maxY ) |
286 | p.setY( maxY - h); | 286 | p.setY( maxY - h); |
287 | 287 | ||
288 | d->resize(maxX, h); | 288 | d->resize(maxX, h); |
289 | d->move(0, p.y() ); | 289 | d->move(0, p.y() ); |
290 | } else if ( h >= maxY ) { | 290 | } else if ( h >= maxY ) { |
291 | if ( p.x() < 0 ) | 291 | if ( p.x() < 0 ) |
292 | p.setX(0); | 292 | p.setX(0); |
293 | if ( p.x() + w > maxX ) | 293 | if ( p.x() + w > maxX ) |
294 | p.setX( maxX - w); | 294 | p.setX( maxX - w); |
295 | 295 | ||
296 | d->resize(w, maxY); | 296 | d->resize(w, maxY); |
297 | d->move(p.x(),0); | 297 | d->move(p.x(),0); |
298 | } else { | 298 | } else { |
299 | d->resize(w, h); | 299 | d->resize(w, h); |
300 | } | 300 | } |
301 | 301 | ||
302 | d->show(); | 302 | d->show(); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) | 306 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) |
307 | { | 307 | { |
308 | maximized = TRUE; | 308 | maximized = TRUE; |
309 | qDebug("read_widget_rect"); | ||
310 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 309 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
311 | if ( qApp->desktop()->width() <= 350 ) | 310 | if ( qApp->desktop()->width() <= 350 ) |
312 | return FALSE; | 311 | return FALSE; |
313 | 312 | ||
314 | Config cfg( "qpe" ); | 313 | Config cfg( "qpe" ); |
315 | cfg.setGroup("ApplicationPositions"); | 314 | cfg.setGroup("ApplicationPositions"); |
316 | QString str = cfg.readEntry( app, QString::null ); | 315 | QString str = cfg.readEntry( app, QString::null ); |
317 | QStringList l = QStringList::split(",", str); | 316 | QStringList l = QStringList::split(",", str); |
318 | 317 | ||
319 | if ( l.count() == 5) { | 318 | if ( l.count() == 5) { |
320 | p.setX( l[0].toInt() ); | 319 | p.setX( l[0].toInt() ); |
321 | p.setY( l[1].toInt() ); | 320 | p.setY( l[1].toInt() ); |
322 | 321 | ||
323 | s.setWidth( l[2].toInt() ); | 322 | s.setWidth( l[2].toInt() ); |
324 | s.setHeight( l[3].toInt() ); | 323 | s.setHeight( l[3].toInt() ); |
325 | 324 | ||
326 | maximized = l[4].toInt(); | 325 | maximized = l[4].toInt(); |
327 | 326 | ||
328 | return TRUE; | 327 | return TRUE; |
329 | } | 328 | } |
330 | 329 | ||
331 | return FALSE; | 330 | return FALSE; |
332 | } | 331 | } |
333 | 332 | ||
334 | 333 | ||
335 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) | 334 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) |
336 | { | 335 | { |
337 | #ifndef Q_WS_QWS | 336 | #ifndef Q_WS_QWS |
338 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); | 337 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); |
339 | #endif | 338 | #endif |
340 | int maxX = qt_maxWindowRect.width(); | 339 | int maxX = qt_maxWindowRect.width(); |
341 | int maxY = qt_maxWindowRect.height(); | 340 | int maxY = qt_maxWindowRect.height(); |
342 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); | 341 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); |
343 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); | 342 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); |
344 | 343 | ||
345 | // total window size is not allowed to be larger than desktop window size | 344 | // total window size is not allowed to be larger than desktop window size |
346 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) | 345 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) |
347 | return FALSE; | 346 | return FALSE; |
348 | 347 | ||
349 | if ( wWidth > maxX ) { | 348 | if ( wWidth > maxX ) { |
350 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); | 349 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); |
351 | wWidth = maxX; | 350 | wWidth = maxX; |
352 | } | 351 | } |
353 | 352 | ||
354 | if ( wHeight > maxY ) { | 353 | if ( wHeight > maxY ) { |
355 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); | 354 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); |
356 | wHeight = maxY; | 355 | wHeight = maxY; |
357 | } | 356 | } |
358 | 357 | ||
359 | // any smaller than this and the maximize/close/help buttons will be overlapping | 358 | // any smaller than this and the maximize/close/help buttons will be overlapping |
360 | if ( wWidth < 80 || wHeight < 60 ) | 359 | if ( wWidth < 80 || wHeight < 60 ) |
361 | return FALSE; | 360 | return FALSE; |
362 | 361 | ||
363 | if ( p.x() < 0 ) | 362 | if ( p.x() < 0 ) |
364 | p.setX(0); | 363 | p.setX(0); |
365 | if ( p.y() < 0 ) | 364 | if ( p.y() < 0 ) |
366 | p.setY(0); | 365 | p.setY(0); |
367 | 366 | ||
368 | if ( p.x() + wWidth > maxX ) | 367 | if ( p.x() + wWidth > maxX ) |
369 | p.setX( maxX - wWidth ); | 368 | p.setX( maxX - wWidth ); |
370 | if ( p.y() + wHeight > maxY ) | 369 | if ( p.y() + wHeight > maxY ) |
371 | p.setY( maxY - wHeight ); | 370 | p.setY( maxY - wHeight ); |
372 | 371 | ||
373 | return TRUE; | 372 | return TRUE; |
374 | } | 373 | } |
375 | 374 | ||
376 | static void store_widget_rect(QWidget *w, QString &app) | 375 | static void store_widget_rect(QWidget *w, QString &app) |
377 | { | 376 | { |
378 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 377 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
379 | if ( qApp->desktop()->width() <= 350 ) | 378 | if ( qApp->desktop()->width() <= 350 ) |
380 | return; | 379 | return; |
381 | qDebug("store_widget_rect"); | ||
382 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to | 380 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to |
383 | // get the non-maximized version, so we have to do it the hard way ) | 381 | // get the non-maximized version, so we have to do it the hard way ) |
384 | int offsetX = w->x() - w->geometry().left(); | 382 | int offsetX = w->x() - w->geometry().left(); |
385 | int offsetY = w->y() - w->geometry().top(); | 383 | int offsetY = w->y() - w->geometry().top(); |
386 | 384 | ||
387 | QRect r; | 385 | QRect r; |
388 | if ( w->isMaximized() ) | 386 | if ( w->isMaximized() ) |
389 | r = ( (HackWidget *) w)->normalGeometry(); | 387 | r = ( (HackWidget *) w)->normalGeometry(); |
390 | else | 388 | else |
391 | r = w->geometry(); | 389 | r = w->geometry(); |
392 | 390 | ||
393 | // Stores the window placement as pos(), size() (due to the offset mapping) | 391 | // Stores the window placement as pos(), size() (due to the offset mapping) |
394 | Config cfg( "qpe" ); | 392 | Config cfg( "qpe" ); |
395 | cfg.setGroup("ApplicationPositions"); | 393 | cfg.setGroup("ApplicationPositions"); |
396 | QString s; | 394 | QString s; |
397 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | 395 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); |
398 | cfg.writeEntry( app, s ); | 396 | cfg.writeEntry( app, s ); |
399 | } | 397 | } |
400 | 398 | ||
401 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 399 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
402 | { | 400 | { |
403 | /* | 401 | /* |
404 | // This works but disable it for now until it is safe to apply | 402 | // This works but disable it for now until it is safe to apply |
405 | // What is does is scan the .desktop files of all the apps for | 403 | // What is does is scan the .desktop files of all the apps for |
406 | // the applnk that has the corresponding argv[0] as this program | 404 | // the applnk that has the corresponding argv[0] as this program |
407 | // then it uses the name stored in the .desktop file as the caption | 405 | // then it uses the name stored in the .desktop file as the caption |
408 | // for the main widget. This saves duplicating translations for | 406 | // for the main widget. This saves duplicating translations for |
409 | // the app name in the program and in the .desktop files. | 407 | // the app name in the program and in the .desktop files. |
410 | 408 | ||
411 | AppLnkSet apps( appsPath ); | 409 | AppLnkSet apps( appsPath ); |
412 | 410 | ||
413 | QList<AppLnk> appsList = apps.children(); | 411 | QList<AppLnk> appsList = apps.children(); |
414 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 412 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
415 | if ( (*it)->exec() == appName ) { | 413 | if ( (*it)->exec() == appName ) { |
416 | mw->setCaption( (*it)->name() ); | 414 | mw->setCaption( (*it)->name() ); |
417 | return TRUE; | 415 | return TRUE; |
418 | } | 416 | } |
419 | } | 417 | } |
420 | */ | 418 | */ |
421 | return FALSE; | 419 | return FALSE; |
422 | } | 420 | } |
423 | 421 | ||
424 | 422 | ||
425 | void show(QWidget* mw, bool nomax) | 423 | void show(QWidget* mw, bool nomax) |
426 | { | 424 | { |
427 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 425 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
428 | nomaximize = nomax; | 426 | nomaximize = nomax; |
429 | qpe_main_widget = mw; | 427 | qpe_main_widget = mw; |
430 | qcopQok = TRUE; | 428 | qcopQok = TRUE; |
431 | #ifndef QT_NO_COP | 429 | #ifndef QT_NO_COP |
432 | 430 | ||
433 | sendQCopQ(); | 431 | sendQCopQ(); |
434 | #endif | 432 | #endif |
435 | 433 | ||
436 | if ( preloaded ) { | 434 | if ( preloaded ) { |
437 | if (forceshow) | 435 | if (forceshow) |
438 | show_mx(mw, nomax, appName); | 436 | show_mx(mw, nomax, appName); |
439 | } | 437 | } |
440 | else if ( keep_running ) { | 438 | else if ( keep_running ) { |
441 | show_mx(mw, nomax, appName); | 439 | show_mx(mw, nomax, appName); |
442 | } | 440 | } |
443 | } | 441 | } |
444 | 442 | ||
445 | void loadTextCodecs() | 443 | void loadTextCodecs() |
446 | { | 444 | { |
447 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 445 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
448 | #ifdef Q_OS_MACX | 446 | #ifdef Q_OS_MACX |
449 | QDir dir( path, "lib*.dylib" ); | 447 | QDir dir( path, "lib*.dylib" ); |
450 | #else | 448 | #else |
451 | QDir dir( path, "lib*.so" ); | 449 | QDir dir( path, "lib*.so" ); |
452 | #endif | 450 | #endif |
453 | QStringList list; | 451 | QStringList list; |
454 | if ( dir. exists ( )) | 452 | if ( dir. exists ( )) |
455 | list = dir.entryList(); | 453 | list = dir.entryList(); |
456 | QStringList::Iterator it; | 454 | QStringList::Iterator it; |
457 | for ( it = list.begin(); it != list.end(); ++it ) { | 455 | for ( it = list.begin(); it != list.end(); ++it ) { |
458 | TextCodecInterface *iface = 0; | 456 | TextCodecInterface *iface = 0; |
459 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 457 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
460 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 458 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
461 | QValueList<int> mibs = iface->mibEnums(); | 459 | QValueList<int> mibs = iface->mibEnums(); |
462 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 460 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
463 | (void)iface->createForMib(*i); | 461 | (void)iface->createForMib(*i); |
464 | // ### it exists now; need to remember if we can delete it | 462 | // ### it exists now; need to remember if we can delete it |
465 | } | 463 | } |
466 | } | 464 | } |
467 | else { | 465 | else { |
468 | lib->unload(); | 466 | lib->unload(); |
469 | delete lib; | 467 | delete lib; |
470 | } | 468 | } |
471 | } | 469 | } |
472 | } | 470 | } |
473 | 471 | ||
474 | void loadImageCodecs() | 472 | void loadImageCodecs() |
475 | { | 473 | { |
476 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 474 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
477 | #ifdef Q_OS_MACX | 475 | #ifdef Q_OS_MACX |
478 | QDir dir( path, "lib*.dylib" ); | 476 | QDir dir( path, "lib*.dylib" ); |
479 | #else | 477 | #else |
480 | QDir dir( path, "lib*.so" ); | 478 | QDir dir( path, "lib*.so" ); |
481 | #endif | 479 | #endif |
482 | QStringList list; | 480 | QStringList list; |
483 | if ( dir. exists ( )) | 481 | if ( dir. exists ( )) |
484 | list = dir.entryList(); | 482 | list = dir.entryList(); |
485 | QStringList::Iterator it; | 483 | QStringList::Iterator it; |
486 | for ( it = list.begin(); it != list.end(); ++it ) { | 484 | for ( it = list.begin(); it != list.end(); ++it ) { |
487 | ImageCodecInterface *iface = 0; | 485 | ImageCodecInterface *iface = 0; |
488 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 486 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
489 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 487 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
490 | QStringList formats = iface->keys(); | 488 | QStringList formats = iface->keys(); |
491 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 489 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
492 | (void)iface->installIOHandler(*i); | 490 | (void)iface->installIOHandler(*i); |
493 | // ### it exists now; need to remember if we can delete it | 491 | // ### it exists now; need to remember if we can delete it |
494 | } | 492 | } |
495 | } | 493 | } |
496 | else { | 494 | else { |
497 | lib->unload(); | 495 | lib->unload(); |
498 | delete lib; | 496 | delete lib; |
499 | } | 497 | } |
500 | } | 498 | } |
501 | } | 499 | } |
502 | }; | 500 | }; |
503 | 501 | ||
504 | class ResourceMimeFactory : public QMimeSourceFactory | 502 | class ResourceMimeFactory : public QMimeSourceFactory |
505 | { | 503 | { |
506 | public: | 504 | public: |
507 | ResourceMimeFactory() : resImage( 0 ) | 505 | ResourceMimeFactory() : resImage( 0 ) |
508 | { | 506 | { |
509 | setFilePath( Global::helpPath() ); | 507 | setFilePath( Global::helpPath() ); |
510 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 508 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
511 | } | 509 | } |
512 | ~ResourceMimeFactory() { | 510 | ~ResourceMimeFactory() { |
513 | delete resImage; | 511 | delete resImage; |
514 | } | 512 | } |
515 | 513 | ||
516 | const QMimeSource* data( const QString& abs_name ) const | 514 | const QMimeSource* data( const QString& abs_name ) const |
517 | { | 515 | { |
518 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 516 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
519 | if ( !r ) { | 517 | if ( !r ) { |
520 | int sl = abs_name.length(); | 518 | int sl = abs_name.length(); |
521 | do { | 519 | do { |
522 | sl = abs_name.findRev( '/', sl - 1 ); | 520 | sl = abs_name.findRev( '/', sl - 1 ); |
523 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 521 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
524 | int dot = name.findRev( '.' ); | 522 | int dot = name.findRev( '.' ); |
525 | if ( dot >= 0 ) | 523 | if ( dot >= 0 ) |
526 | name = name.left( dot ); | 524 | name = name.left( dot ); |
527 | QImage img = Resource::loadImage( name ); | 525 | QImage img = Resource::loadImage( name ); |
528 | if ( !img.isNull() ) { | 526 | if ( !img.isNull() ) { |
529 | delete resImage; | 527 | delete resImage; |
530 | resImage = new QImageDrag( img ); | 528 | resImage = new QImageDrag( img ); |
531 | r = resImage; | 529 | r = resImage; |
532 | } | 530 | } |
533 | } | 531 | } |
534 | while ( !r && sl > 0 ); | 532 | while ( !r && sl > 0 ); |
535 | } | 533 | } |
536 | return r; | 534 | return r; |
537 | } | 535 | } |
538 | private: | 536 | private: |
539 | mutable QImageDrag *resImage; | 537 | mutable QImageDrag *resImage; |
540 | }; | 538 | }; |
541 | 539 | ||
542 | static int& hack(int& i) | 540 | static int& hack(int& i) |
543 | { | 541 | { |
544 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 542 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
545 | // These should be created, but aren't in Qt 2.3.0 | 543 | // These should be created, but aren't in Qt 2.3.0 |
546 | (void)new QUtf8Codec; | 544 | (void)new QUtf8Codec; |
547 | (void)new QUtf16Codec; | 545 | (void)new QUtf16Codec; |
548 | #endif | 546 | #endif |
549 | return i; | 547 | return i; |
550 | } | 548 | } |
551 | 549 | ||
552 | static int muted = 0; | 550 | static int muted = 0; |
553 | static int micMuted = 0; | 551 | static int micMuted = 0; |
554 | 552 | ||
555 | static void setVolume( int t = 0, int percent = -1 ) | 553 | static void setVolume( int t = 0, int percent = -1 ) |
556 | { | 554 | { |
557 | switch ( t ) { | 555 | switch ( t ) { |
558 | case 0: { | 556 | case 0: { |
559 | Config cfg( "qpe" ); | 557 | Config cfg( "qpe" ); |
560 | cfg.setGroup( "Volume" ); | 558 | cfg.setGroup( "Volume" ); |
561 | if ( percent < 0 ) | 559 | if ( percent < 0 ) |
562 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 560 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
563 | #ifndef QT_NO_SOUND | 561 | #ifndef QT_NO_SOUND |
564 | int fd = 0; | 562 | int fd = 0; |
565 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 563 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
566 | int vol = muted ? 0 : percent; | 564 | int vol = muted ? 0 : percent; |
567 | // set both channels to same volume | 565 | // set both channels to same volume |
568 | vol |= vol << 8; | 566 | vol |= vol << 8; |
569 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); | 567 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); |
570 | ::close( fd ); | 568 | ::close( fd ); |
571 | } | 569 | } |
572 | #endif | 570 | #endif |
573 | } | 571 | } |