summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/big-screen/owidgetstack.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/libopie2/opieui/big-screen/owidgetstack.cpp b/libopie2/opieui/big-screen/owidgetstack.cpp
index 00194b4..ac46cca 100644
--- a/libopie2/opieui/big-screen/owidgetstack.cpp
+++ b/libopie2/opieui/big-screen/owidgetstack.cpp
@@ -264,177 +264,182 @@ void OWidgetStack::raiseWidget( int id) {
264 264
265/** 265/**
266 * This is an overloaded function and only differs in its parameters. 266 * This is an overloaded function and only differs in its parameters.
267 * @see raiseWidget( int ) 267 * @see raiseWidget( int )
268 */ 268 */
269void OWidgetStack::raiseWidget( QWidget* wid) { 269void OWidgetStack::raiseWidget( QWidget* wid) {
270 m_last = wid; 270 m_last = wid;
271 if (m_mode == SmallScreen ) 271 if (m_mode == SmallScreen )
272 m_stack->raiseWidget( wid ); 272 m_stack->raiseWidget( wid );
273 else { 273 else {
274 int ide; 274 int ide;
275 emit aboutToShow( wid ); 275 emit aboutToShow( wid );
276 /* if someone is connected and the widget is actually available */ 276 /* if someone is connected and the widget is actually available */
277 if ( receivers( SIGNAL(aboutToShow(int) ) ) && 277 if ( receivers( SIGNAL(aboutToShow(int) ) ) &&
278 ( (ide = id( wid ) ) != -1 ) ) 278 ( (ide = id( wid ) ) != -1 ) )
279 emit aboutToShow( ide ); 279 emit aboutToShow( ide );
280 280
281 /* ### FIXME PLACE THE WIDGET right */ 281 /* ### FIXME PLACE THE WIDGET right */
282 wid->show(); 282 wid->show();
283 } 283 }
284} 284}
285 285
286/** 286/**
287 * This will hide the currently visible widget 287 * This will hide the currently visible widget
288 * and raise the widget specified by the parameter. 288 * and raise the widget specified by the parameter.
289 * Note that this method does not use visibleWIdget but remembers 289 * Note that this method does not use visibleWIdget but remembers
290 * the last raisedWidget 290 * the last raisedWidget
291 */ 291 */
292void OWidgetStack::hideWidget( int id) { 292void OWidgetStack::hideWidget( int id) {
293 /* hiding our main widget wouldn't be smart */ 293 /* hiding our main widget wouldn't be smart */
294 if ( m_mode == BigScreen && m_last != m_mWidget ) 294 if ( m_mode == BigScreen && m_last != m_mWidget )
295 m_last->hide(); 295 m_last->hide();
296 raiseWidget( id ); 296 raiseWidget( id );
297} 297}
298 298
299/** 299/**
300 * This is overloaded and only differs in the parameters 300 * This is overloaded and only differs in the parameters
301 * it takes. 301 * it takes.
302 */ 302 */
303void OWidgetStack::hideWidget( QWidget* wid) { 303void OWidgetStack::hideWidget( QWidget* wid) {
304 /* still not smart */ 304 /* still not smart */
305 if ( m_mode == BigScreen && m_last != m_mWidget ) 305 if ( m_mode == BigScreen && m_last != m_mWidget )
306 m_last->hide(); 306 m_last->hide();
307 307
308 raiseWidget( wid ); 308 raiseWidget( wid );
309} 309}
310 310
311 311
312bool OWidgetStack::eventFilter( QObject* obj, QEvent* e) { 312bool OWidgetStack::eventFilter( QObject*, QEvent* e) {
313 if ( e->type() == QEvent::Resize && !m_forced ) { 313 if ( e->type() == QEvent::Resize && !m_forced ) {
314 QResizeEvent *res = static_cast<QResizeEvent*>( e ); 314 QResizeEvent *res = static_cast<QResizeEvent*>( e );
315 QSize size = res->size(); 315 QSize size = res->size();
316 if ( size.width() >= mode_size ) 316 if ( size.width() >= mode_size )
317 switchTop(); 317 switchTop();
318 else 318 else
319 switchStack(); 319 switchStack();
320 } 320 }
321 return false; 321 return false;
322} 322}
323 323
324 324
325/** 325/**
326 * @internal_resons 326 * @internal_resons
327 */ 327 */
328void OWidgetStack::resizeEvent( QResizeEvent* ev ) { 328void OWidgetStack::resizeEvent( QResizeEvent* ev ) {
329 QFrame::resizeEvent( ev ); 329 QFrame::resizeEvent( ev );
330 if (m_mode == SmallScreen ) 330 if (m_mode == SmallScreen )
331 m_stack->setGeometry( frameRect() ); 331 m_stack->setGeometry( frameRect() );
332 else 332 else
333 if (m_mWidget ) 333 if (m_mWidget )
334 m_mWidget->setGeometry( frameRect() ); 334 m_mWidget->setGeometry( frameRect() );
335 335
336} 336}
337 337
338/** 338/**
339 * setMainWindow gives the OWidgetStack a hint which 339 * setMainWindow gives the OWidgetStack a hint which
340 * window should always stay inside the stack. 340 * window should always stay inside the stack.
341 * Normally the first added widget is considered to be 341 * Normally the first added widget is considered to be
342 * the mainwindow but you can change this with this 342 * the mainwindow but you can change this with this
343 * function. 343 * function.
344 * If in BigScreen mode the current mainwindow will be reparented 344 * If in BigScreen mode the current mainwindow will be reparented
345 * and hidden. The position will be taken by the new one. 345 * and hidden. The position will be taken by the new one.
346 * If the old MainWindow was hidden the new window will 346 * If the old MainWindow was hidden the new window will
347 * also be hidden. If the window was visible the new mainwindow 347 * also be hidden. If the window was visible the new mainwindow
348 * will be made visible too and the old one hidden. If there 348 * will be made visible too and the old one hidden. If there
349 * was no mainwindow it will be hidden as well. 349 * was no mainwindow it will be hidden as well.
350 * 350 *
351 * @param wid The new mainwindow 351 * @param wid The new mainwindow
352 */ 352 */
353void OWidgetStack::setMainWindow( QWidget* wid ) { 353void OWidgetStack::setMainWindow( QWidget* wid ) {
354 if (m_mode == BigScreen ) { 354 if (m_mode == BigScreen ) {
355 bool wasVisible = false; 355 bool wasVisible = false;
356 if (m_mWidget ) { 356 if (m_mWidget ) {
357 wasVisible = !m_mWidget->isHidden(); 357 wasVisible = !m_mWidget->isHidden();
358 /* hidden by default */ 358 /* hidden by default */
359 m_mWidget->reparent(0, WType_TopLevel, QPoint(10, 10) ); 359 m_mWidget->reparent(0, WType_TopLevel, QPoint(10, 10) );
360 } 360 }
361 wid->reparent(this, 0, frameRect().topLeft() ); 361 wid->reparent(this, 0, frameRect().topLeft() );
362 362
363 if (wasVisible) 363 if (wasVisible)
364 wid->show(); 364 wid->show();
365 } 365 }
366 366
367 m_mWidget = wid; 367 m_mWidget = wid;
368} 368}
369 369
370/** 370/**
371 * this is an overloaded member and only differs 371 * this is an overloaded member and only differs
372 * in the type of arguments. 372 * in the type of arguments.
373 * @see setMainWindow(QWidget*) 373 * @see setMainWindow(QWidget*)
374 */ 374 */
375void OWidgetStack::setMainWindow( int id) { 375void OWidgetStack::setMainWindow( int id) {
376 setMainWindow( widget( id ) ); 376 setMainWindow( widget( id ) );
377} 377}
378 378
379 379
380/* 380/*
381 * this function switches to a stack ;) 381 * this function switches to a stack ;)
382 */ 382 */
383void OWidgetStack::switchStack() { 383void OWidgetStack::switchStack() {
384 if (m_stack ) { 384 if (m_stack ) {
385 m_stack->setGeometry( frameRect() ); 385 m_stack->setGeometry( frameRect() );
386 return; 386 return;
387 } 387 }
388 388
389 m_mode = SmallScreen; 389 m_mode = SmallScreen;
390 m_stack = new QWidgetStack(this); 390 m_stack = new QWidgetStack(this);
391 m_stack->setGeometry( frameRect() );
392 m_stack->show();
391 393
392 connect(m_stack, SIGNAL(aboutToShow(QWidget*) ), 394 connect(m_stack, SIGNAL(aboutToShow(QWidget*) ),
393 this, SIGNAL(aboutToShow(QWidget*) ) ); 395 this, SIGNAL(aboutToShow(QWidget*) ) );
394 connect(m_stack, SIGNAL(aboutToShow(int) ), 396 connect(m_stack, SIGNAL(aboutToShow(int) ),
395 this, SIGNAL(aboutToShow(int) ) ); 397 this, SIGNAL(aboutToShow(int) ) );
396 398
397 /* now reparent the widgets... luckily QWidgetSatck does most of the work */ 399 /* now reparent the widgets... luckily QWidgetSatck does most of the work */
398 if (m_list.isEmpty() ) 400 if (m_list.isEmpty() )
399 return; 401 return;
400 402
401 QMap<int, QWidget*>::Iterator it = m_list.begin(); 403 QMap<int, QWidget*>::Iterator it = m_list.begin();
402 for ( ; it != m_list.end(); ++it ) 404 for ( ; it != m_list.end(); ++it )
403 m_stack->addWidget( it.data(), it.key() ); 405 m_stack->addWidget( it.data(), it.key() );
404 406
407 if ( m_mWidget )
408 m_stack->raiseWidget( m_mWidget );
409
405 410
406} 411}
407 412
408/* 413/*
409 * we will switch to top level mode 414 * we will switch to top level mode
410 * reparent the list of widgets and then delete the stack 415 * reparent the list of widgets and then delete the stack
411 */ 416 */
412void OWidgetStack::switchTop() { 417void OWidgetStack::switchTop() {
413 m_mode = BigScreen; 418 m_mode = BigScreen;
414 /* this works because it is guaranteed that switchStack was called at least once*/ 419 /* this works because it is guaranteed that switchStack was called at least once*/
415 if (!m_stack && m_mWidget) { 420 if (!m_stack && m_mWidget) {
416 m_mWidget->setGeometry( frameRect() ); 421 m_mWidget->setGeometry( frameRect() );
417 return; 422 return;
418 }else if (!m_stack) 423 }else if (!m_stack)
419 return; 424 return;
420 425
421 if (!m_list.isEmpty() ) { 426 if (!m_list.isEmpty() ) {
422 QMap<int, QWidget*>::Iterator it = m_list.begin(); 427 QMap<int, QWidget*>::Iterator it = m_list.begin();
423 for ( ; it != m_list.end(); ++it ) { 428 for ( ; it != m_list.end(); ++it ) {
424 /* better than reparenting twice */ 429 /* better than reparenting twice */
425 if ( it.data() == m_mWidget ) { 430 if ( it.data() == m_mWidget ) {
426 m_mWidget->reparent(this, 0, frameRect().topLeft() ); 431 m_mWidget->reparent(this, 0, frameRect().topLeft() );
427 m_mWidget->setGeometry( frameRect() ); 432 m_mWidget->setGeometry( frameRect() );
428 m_mWidget->show(); 433 m_mWidget->show();
429 }else 434 }else
430 /* ### FIXME we need to place the widget better */ 435 /* ### FIXME we need to place the widget better */
431 it.data()->reparent(0, WType_TopLevel, QPoint(10, 10) ); 436 it.data()->reparent(0, WType_TopLevel, QPoint(10, 10) );
432 } 437 }
433 } 438 }
434 439
435 delete m_stack; 440 delete m_stack;
436 m_stack = 0; 441 m_stack = 0;
437} 442}
438 443
439} 444}
440} 445}