summaryrefslogtreecommitdiff
authorar <ar>2005-03-10 16:21:07 (UTC)
committer ar <ar>2005-03-10 16:21:07 (UTC)
commit3bf4809c4f2263f0130472c41aa6c85e46e61db9 (patch) (unidiff)
tree82c34fddb63bb6ca8cbd53709ab2642795241d38
parent95a99e7b75eddc5629e839698b762f594be42b9f (diff)
downloadopie-3bf4809c4f2263f0130472c41aa6c85e46e61db9.zip
opie-3bf4809c4f2263f0130472c41aa6c85e46e61db9.tar.gz
opie-3bf4809c4f2263f0130472c41aa6c85e46e61db9.tar.bz2
- implement nomax.patch from openembedded
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp8
-rw-r--r--library/widget_showing.cpp4
2 files changed, 9 insertions, 3 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 953f9d0..0f3e4a4 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -229,140 +229,142 @@ public:
229 } 229 }
230 } else { 230 } else {
231 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 231 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
232 mw->resize(s); 232 mw->resize(s);
233 mw->move(p); 233 mw->move(p);
234 } else { //no stored rectangle, make an estimation 234 } else { //no stored rectangle, make an estimation
235 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; 235 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2;
236 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; 236 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2;
237 mw->move( QMAX(x,0), QMAX(y,0) ); 237 mw->move( QMAX(x,0), QMAX(y,0) );
238#ifdef Q_WS_QWS 238#ifdef Q_WS_QWS
239 if ( !nomaximize ) 239 if ( !nomaximize )
240 mw->showMaximized(); 240 mw->showMaximized();
241#endif 241#endif
242 } 242 }
243 if ( max && !nomaximize ) 243 if ( max && !nomaximize )
244 mw->showMaximized(); 244 mw->showMaximized();
245 else 245 else
246 mw->show(); 246 mw->show();
247 } 247 }
248 } 248 }
249 } 249 }
250 250
251 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) 251 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s)
252 { 252 {
253#ifndef OPIE_NO_WINDOWED
253 maximized = TRUE; 254 maximized = TRUE;
254 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 255 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
255 if ( qApp->desktop()->width() <= 350 ) 256 if ( qApp->desktop()->width() <= 350 )
256 return FALSE; 257 return FALSE;
257 258
258 Config cfg( "qpe" ); 259 Config cfg( "qpe" );
259 cfg.setGroup("ApplicationPositions"); 260 cfg.setGroup("ApplicationPositions");
260 QString str = cfg.readEntry( app, QString::null ); 261 QString str = cfg.readEntry( app, QString::null );
261 QStringList l = QStringList::split(",", str); 262 QStringList l = QStringList::split(",", str);
262 263
263 if ( l.count() == 5) { 264 if ( l.count() == 5) {
264 p.setX( l[0].toInt() ); 265 p.setX( l[0].toInt() );
265 p.setY( l[1].toInt() ); 266 p.setY( l[1].toInt() );
266 267
267 s.setWidth( l[2].toInt() ); 268 s.setWidth( l[2].toInt() );
268 s.setHeight( l[3].toInt() ); 269 s.setHeight( l[3].toInt() );
269 270
270 maximized = l[4].toInt(); 271 maximized = l[4].toInt();
271 272
272 return TRUE; 273 return TRUE;
273 } 274 }
274 275#endif
275 return FALSE; 276 return FALSE;
276 } 277 }
277 278
278 279
279 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) 280 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s)
280 { 281 {
281#ifndef Q_WS_QWS 282#ifndef Q_WS_QWS
282 QRect qt_maxWindowRect = qApp->desktop()->geometry(); 283 QRect qt_maxWindowRect = qApp->desktop()->geometry();
283#endif 284#endif
284 int maxX = qt_maxWindowRect.width(); 285 int maxX = qt_maxWindowRect.width();
285 int maxY = qt_maxWindowRect.height(); 286 int maxY = qt_maxWindowRect.height();
286 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); 287 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() );
287 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); 288 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() );
288 289
289 // total window size is not allowed to be larger than desktop window size 290 // total window size is not allowed to be larger than desktop window size
290 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) 291 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) )
291 return FALSE; 292 return FALSE;
292 293
293 if ( wWidth > maxX ) { 294 if ( wWidth > maxX ) {
294 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); 295 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) );
295 wWidth = maxX; 296 wWidth = maxX;
296 } 297 }
297 298
298 if ( wHeight > maxY ) { 299 if ( wHeight > maxY ) {
299 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); 300 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) );
300 wHeight = maxY; 301 wHeight = maxY;
301 } 302 }
302 303
303 // any smaller than this and the maximize/close/help buttons will be overlapping 304 // any smaller than this and the maximize/close/help buttons will be overlapping
304 if ( wWidth < 80 || wHeight < 60 ) 305 if ( wWidth < 80 || wHeight < 60 )
305 return FALSE; 306 return FALSE;
306 307
307 if ( p.x() < 0 ) 308 if ( p.x() < 0 )
308 p.setX(0); 309 p.setX(0);
309 if ( p.y() < 0 ) 310 if ( p.y() < 0 )
310 p.setY(0); 311 p.setY(0);
311 312
312 if ( p.x() + wWidth > maxX ) 313 if ( p.x() + wWidth > maxX )
313 p.setX( maxX - wWidth ); 314 p.setX( maxX - wWidth );
314 if ( p.y() + wHeight > maxY ) 315 if ( p.y() + wHeight > maxY )
315 p.setY( maxY - wHeight ); 316 p.setY( maxY - wHeight );
316 317
317 return TRUE; 318 return TRUE;
318 } 319 }
319 320
320 static void store_widget_rect(QWidget *w, QString &app) 321 static void store_widget_rect(QWidget *w, QString &app)
321 { 322 {
322 if( !w ) 323 if( !w )
323 return; 324 return;
324 325#ifndef OPIE_NO_WINDOWED
325 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 326 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
326 if ( qApp->desktop()->width() <= 350 ) 327 if ( qApp->desktop()->width() <= 350 )
327 return; 328 return;
328 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to 329 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to
329 // get the non-maximized version, so we have to do it the hard way ) 330 // get the non-maximized version, so we have to do it the hard way )
330 int offsetX = w->x() - w->geometry().left(); 331 int offsetX = w->x() - w->geometry().left();
331 int offsetY = w->y() - w->geometry().top(); 332 int offsetY = w->y() - w->geometry().top();
332 333
333 QRect r; 334 QRect r;
334 if ( w->isMaximized() ) 335 if ( w->isMaximized() )
335 r = ( (HackWidget *) w)->normalGeometry(); 336 r = ( (HackWidget *) w)->normalGeometry();
336 else 337 else
337 r = w->geometry(); 338 r = w->geometry();
338 339
339 // Stores the window placement as pos(), size() (due to the offset mapping) 340 // Stores the window placement as pos(), size() (due to the offset mapping)
340 Config cfg( "qpe" ); 341 Config cfg( "qpe" );
341 cfg.setGroup("ApplicationPositions"); 342 cfg.setGroup("ApplicationPositions");
342 QString s; 343 QString s;
343 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); 344 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() );
344 cfg.writeEntry( app, s ); 345 cfg.writeEntry( app, s );
346#endif
345 } 347 }
346 348
347 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 349 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
348 { 350 {
349 /* 351 /*
350 // This works but disable it for now until it is safe to apply 352 // This works but disable it for now until it is safe to apply
351 // What is does is scan the .desktop files of all the apps for 353 // What is does is scan the .desktop files of all the apps for
352 // the applnk that has the corresponding argv[0] as this program 354 // the applnk that has the corresponding argv[0] as this program
353 // then it uses the name stored in the .desktop file as the caption 355 // then it uses the name stored in the .desktop file as the caption
354 // for the main widget. This saves duplicating translations for 356 // for the main widget. This saves duplicating translations for
355 // the app name in the program and in the .desktop files. 357 // the app name in the program and in the .desktop files.
356 358
357 AppLnkSet apps( appsPath ); 359 AppLnkSet apps( appsPath );
358 360
359 QList<AppLnk> appsList = apps.children(); 361 QList<AppLnk> appsList = apps.children();
360 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 362 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
361 if ( (*it)->exec() == appName ) { 363 if ( (*it)->exec() == appName ) {
362 mw->setCaption( (*it)->name() ); 364 mw->setCaption( (*it)->name() );
363 return TRUE; 365 return TRUE;
364 } 366 }
365 } 367 }
366 */ 368 */
367 return FALSE; 369 return FALSE;
368 } 370 }
diff --git a/library/widget_showing.cpp b/library/widget_showing.cpp
index 43ece64..43d19b0 100644
--- a/library/widget_showing.cpp
+++ b/library/widget_showing.cpp
@@ -31,44 +31,48 @@
31 31
32#include <qtopia/qpeapplication.h> 32#include <qtopia/qpeapplication.h>
33 33
34#ifdef Q_WS_QWS 34#ifdef Q_WS_QWS
35extern Q_EXPORT QRect qt_maxWindowRect; 35extern Q_EXPORT QRect qt_maxWindowRect;
36#endif 36#endif
37 37
38void QPEApplication::showDialog( QDialog* d, bool nomax ) 38void QPEApplication::showDialog( QDialog* d, bool nomax )
39{ 39{
40 showWidget( d, nomax ); 40 showWidget( d, nomax );
41} 41}
42 42
43int QPEApplication::execDialog( QDialog* d, bool nomax ) 43int QPEApplication::execDialog( QDialog* d, bool nomax )
44{ 44{
45 showDialog( d, nomax ); 45 showDialog( d, nomax );
46 return d->exec(); 46 return d->exec();
47} 47}
48 48
49void QPEApplication::showWidget( QWidget* wg, bool nomax ) { 49void QPEApplication::showWidget( QWidget* wg, bool nomax ) {
50 if ( wg->isVisible() ) { 50 if ( wg->isVisible() ) {
51 wg->show(); 51 wg->show();
52 return; 52 return;
53 } 53 }
54 54
55#ifndef OPIE_NO_WINDOWED
56 if ( TRUE ) {
57#else
55 if ( !nomax 58 if ( !nomax
56 && ( qApp->desktop()->width() <= 320 ) ){ 59 && ( qApp->desktop()->width() <= 320 ) ){
60#endif
57 wg->showMaximized(); 61 wg->showMaximized();
58 } else { 62 } else {
59#ifdef Q_WS_QWS 63#ifdef Q_WS_QWS
60 QSize desk = QSize( qApp->desktop()->width(), qApp->desktop()->height() ); 64 QSize desk = QSize( qApp->desktop()->width(), qApp->desktop()->height() );
61#else 65#else
62 QSize desk = QSize( qt_maxWindowRect.width(), qt_maxWindowRect.height() ); 66 QSize desk = QSize( qt_maxWindowRect.width(), qt_maxWindowRect.height() );
63#endif 67#endif
64 68
65 QSize sh = wg->sizeHint(); 69 QSize sh = wg->sizeHint();
66 int w = QMAX( sh.width(), wg->width() ); 70 int w = QMAX( sh.width(), wg->width() );
67 int h = QMAX( sh.height(), wg->height() ); 71 int h = QMAX( sh.height(), wg->height() );
68// desktop widget-frame taskbar 72// desktop widget-frame taskbar
69 w = QMIN( w, ( desk.width() - ( wg->frameGeometry().width() - wg->geometry().width() ) - 25 ) ); 73 w = QMIN( w, ( desk.width() - ( wg->frameGeometry().width() - wg->geometry().width() ) - 25 ) );
70 h = QMIN( h, ( desk.height() - ( wg->frameGeometry().height() - wg->geometry().height() ) - 25 ) ); 74 h = QMIN( h, ( desk.height() - ( wg->frameGeometry().height() - wg->geometry().height() ) - 25 ) );
71 wg->resize( w, h ); 75 wg->resize( w, h );
72 wg->show(); 76 wg->show();
73 } 77 }
74} 78}