author | drw <drw> | 2005-03-03 21:05:50 (UTC) |
---|---|---|
committer | drw <drw> | 2005-03-03 21:05:50 (UTC) |
commit | b92ff0d96359e7f383c5fc1c54271c3819bef413 (patch) (unidiff) | |
tree | ef1dc4c57f1af409464bc430c04a25e9d45aca6e | |
parent | 67ddc501f2a52c7f35ca4044fb0094e759a45d76 (diff) | |
download | opie-b92ff0d96359e7f383c5fc1c54271c3819bef413.zip opie-b92ff0d96359e7f383c5fc1c54271c3819bef413.tar.gz opie-b92ff0d96359e7f383c5fc1c54271c3819bef413.tar.bz2 |
Some minor fixes to drawing of tab bar
-rw-r--r-- | libopie2/opieui/otabwidget.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/libopie2/opieui/otabwidget.cpp b/libopie2/opieui/otabwidget.cpp index ae396b9..8d7806c 100644 --- a/libopie2/opieui/otabwidget.cpp +++ b/libopie2/opieui/otabwidget.cpp | |||
@@ -327,142 +327,156 @@ void OTabWidget::setTabStyle( TabStyle s ) | |||
327 | // Redraw widget | 327 | // Redraw widget |
328 | setUpLayout(); | 328 | setUpLayout(); |
329 | } | 329 | } |
330 | 330 | ||
331 | OTabWidget::TabPosition OTabWidget::tabPosition() const | 331 | OTabWidget::TabPosition OTabWidget::tabPosition() const |
332 | { | 332 | { |
333 | return m_tabBarPosition; | 333 | return m_tabBarPosition; |
334 | } | 334 | } |
335 | 335 | ||
336 | void OTabWidget::setTabPosition( TabPosition p ) | 336 | void OTabWidget::setTabPosition( TabPosition p ) |
337 | { | 337 | { |
338 | m_tabBarPosition = p; | 338 | m_tabBarPosition = p; |
339 | 339 | ||
340 | // If using the tab bar selector, set its shape | 340 | // If using the tab bar selector, set its shape |
341 | if ( m_usingTabs ) | 341 | if ( m_usingTabs ) |
342 | { | 342 | { |
343 | ( m_tabBarPosition == Top ) ? m_tabBar->setShape( QTabBar::RoundedAbove ) | 343 | ( m_tabBarPosition == Top ) ? m_tabBar->setShape( QTabBar::RoundedAbove ) |
344 | : m_tabBar->setShape( QTabBar::RoundedBelow ); | 344 | : m_tabBar->setShape( QTabBar::RoundedBelow ); |
345 | } | 345 | } |
346 | 346 | ||
347 | // Redraw widget | 347 | // Redraw widget |
348 | setUpLayout(); | 348 | setUpLayout(); |
349 | } | 349 | } |
350 | 350 | ||
351 | void OTabWidget::slotTabBarSelected( int id ) | 351 | void OTabWidget::slotTabBarSelected( int id ) |
352 | { | 352 | { |
353 | OTabInfo *newtab = m_tabs.first(); | 353 | OTabInfo *newtab = m_tabs.first(); |
354 | while ( newtab && newtab->id() != id ) | 354 | while ( newtab && newtab->id() != id ) |
355 | newtab = m_tabs.next(); | 355 | newtab = m_tabs.next(); |
356 | 356 | ||
357 | if ( newtab && newtab->id() == id ) | 357 | if ( newtab && newtab->id() == id ) |
358 | selectTab( newtab ); | 358 | selectTab( newtab ); |
359 | } | 359 | } |
360 | 360 | ||
361 | void OTabWidget::slotTabListSelected( int index ) | 361 | void OTabWidget::slotTabListSelected( int index ) |
362 | { | 362 | { |
363 | OTabInfo *newtab = m_tabs.at( index ); | 363 | OTabInfo *newtab = m_tabs.at( index ); |
364 | if ( newtab ) | 364 | if ( newtab ) |
365 | selectTab( newtab ); | 365 | selectTab( newtab ); |
366 | } | 366 | } |
367 | 367 | ||
368 | QPixmap OTabWidget::loadSmooth( const QString &name ) | 368 | QPixmap OTabWidget::loadSmooth( const QString &name ) |
369 | { | 369 | { |
370 | QPixmap p; | 370 | QPixmap p; |
371 | p.convertFromImage( Resource::loadImage( name ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 371 | p.convertFromImage( Resource::loadImage( name ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
372 | return p; | 372 | return p; |
373 | } | 373 | } |
374 | 374 | ||
375 | void OTabWidget::selectTab( OTabInfo *tab ) | 375 | void OTabWidget::selectTab( OTabInfo *tab ) |
376 | { | 376 | { |
377 | if ( m_tabBarStyle == IconTab ) | 377 | if ( m_tabBarStyle == IconTab ) |
378 | { | 378 | { |
379 | // Remove text label from currently selected tab | 379 | // Remove text label from currently selected tab |
380 | if ( m_currTab ) | 380 | if ( m_currTab ) |
381 | { | 381 | { |
382 | m_tabBar->tab( m_currTab->id() )->setText( QString::null ); | 382 | m_tabBar->tab( m_currTab->id() )->setText( QString::null ); |
383 | //setUpLayout(); | 383 | //setUpLayout(); |
384 | } | 384 | } |
385 | 385 | ||
386 | // Set text label for newly selected tab | 386 | // Set text label for newly selected tab |
387 | m_tabBar->tab( tab->id() )->setText( tab->label() ); | 387 | m_tabBar->tab( tab->id() )->setText( tab->label() ); |
388 | m_tabBar->setCurrentTab( tab->id() ); | 388 | m_tabBar->setCurrentTab( tab->id() ); |
389 | 389 | ||
390 | setUpLayout(); | 390 | setUpLayout(); |
391 | |||
392 | QSize t; | ||
393 | |||
394 | t = m_tabBar->sizeHint(); | ||
395 | if ( t.width() > width() ) | ||
396 | t.setWidth( width() ); | ||
397 | int lw = m_widgetStack->lineWidth(); | ||
398 | if ( m_tabBarPosition == Bottom ) | ||
399 | m_tabBar->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); | ||
400 | else | ||
401 | m_tabBar->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); | ||
391 | } | 402 | } |
392 | else if ( m_tabBarStyle == TextTab ) | 403 | else if ( m_tabBarStyle == TextTab ) |
393 | { | 404 | { |
394 | m_tabBar->setCurrentTab( tab->id() ); | 405 | m_tabBar->setCurrentTab( tab->id() ); |
395 | } | 406 | } |
396 | 407 | ||
397 | m_widgetStack->raiseWidget( tab->control() ); | 408 | m_widgetStack->raiseWidget( tab->control() ); |
398 | 409 | ||
399 | emit currentChanged( tab->control() ); | 410 | emit currentChanged( tab->control() ); |
400 | 411 | ||
401 | m_currTab = tab; | 412 | m_currTab = tab; |
402 | } | 413 | } |
403 | 414 | ||
404 | void OTabWidget::setUpLayout() | 415 | void OTabWidget::setUpLayout() |
405 | { | 416 | { |
406 | if ( m_usingTabs ) | 417 | if ( m_usingTabs ) |
407 | { | 418 | { |
408 | m_tabBar->update(); | 419 | m_tabBar->update(); |
409 | m_tabBar->layoutTabs(); | 420 | m_tabBar->layoutTabs(); |
410 | } | 421 | } |
411 | } | 422 | } |
412 | 423 | ||
413 | void OTabWidget::resizeEvent( QResizeEvent * ) | 424 | void OTabWidget::resizeEvent( QResizeEvent * ) |
414 | { | 425 | { |
415 | QSize t; | 426 | QSize t; |
416 | 427 | ||
417 | if ( m_usingTabs ) | 428 | if ( m_usingTabs ) |
418 | { | 429 | { |
419 | m_tabBar->layoutTabs(); | 430 | m_tabBar->layoutTabs(); |
420 | t = m_tabBar->sizeHint(); | 431 | t = m_tabBar->sizeHint(); |
432 | if ( t.width() > width() ) | ||
433 | t.setWidth( width() ); | ||
421 | } | 434 | } |
422 | else | 435 | else |
436 | { | ||
423 | t = m_tabList->sizeHint(); | 437 | t = m_tabList->sizeHint(); |
424 | 438 | t.setWidth( width() ); | |
425 | t.setWidth( width() ); | 439 | } |
426 | 440 | ||
427 | int lw = m_widgetStack->lineWidth(); | 441 | int lw = m_widgetStack->lineWidth(); |
428 | if ( m_tabBarPosition == Bottom ) | 442 | if ( m_tabBarPosition == Bottom ) |
429 | { | 443 | { |
430 | if ( m_usingTabs ) | 444 | if ( m_usingTabs ) |
431 | m_tabBar->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); | 445 | m_tabBar->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); |
432 | else | 446 | else |
433 | m_tabList->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); | 447 | m_tabList->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); |
434 | 448 | ||
435 | m_widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) ); | 449 | m_widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) ); |
436 | } | 450 | } |
437 | else | 451 | else |
438 | { | 452 | { |
439 | if ( m_usingTabs ) | 453 | if ( m_usingTabs ) |
440 | m_tabBar->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); | 454 | m_tabBar->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); |
441 | else | 455 | else |
442 | m_tabList->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); | 456 | m_tabList->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); |
443 | 457 | ||
444 | m_widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) ); | 458 | m_widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) ); |
445 | } | 459 | } |
446 | 460 | ||
447 | if ( autoMask() ) | 461 | if ( autoMask() ) |
448 | updateMask(); | 462 | updateMask(); |
449 | } | 463 | } |
450 | 464 | ||
451 | int OTabWidget::currentTab() | 465 | int OTabWidget::currentTab() |
452 | { | 466 | { |
453 | if ( m_currTab ) | 467 | if ( m_currTab ) |
454 | { | 468 | { |
455 | return m_currTab->id(); | 469 | return m_currTab->id(); |
456 | } | 470 | } |
457 | return -1; | 471 | return -1; |
458 | } | 472 | } |
459 | 473 | ||
460 | QWidget* OTabWidget::currentWidget()const | 474 | QWidget* OTabWidget::currentWidget()const |
461 | { | 475 | { |
462 | if ( m_currTab ) | 476 | if ( m_currTab ) |
463 | { | 477 | { |
464 | return m_currTab->control(); | 478 | return m_currTab->control(); |
465 | } | 479 | } |
466 | 480 | ||
467 | return 0; | 481 | return 0; |
468 | } | 482 | } |