summaryrefslogtreecommitdiff
path: root/libopie/otabwidget.cpp
Unidiff
Diffstat (limited to 'libopie/otabwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/otabwidget.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/libopie/otabwidget.cpp b/libopie/otabwidget.cpp
index fe2c60f..1b8c085 100644
--- a/libopie/otabwidget.cpp
+++ b/libopie/otabwidget.cpp
@@ -315,96 +315,105 @@ void OTabWidget::slotTabBarSelected( int id )
315 } 315 }
316} 316}
317 317
318void OTabWidget::slotTabListSelected( int index ) 318void OTabWidget::slotTabListSelected( int index )
319{ 319{
320 OTabInfo *newtab = tabs.at( index ); 320 OTabInfo *newtab = tabs.at( index );
321 if ( newtab ) 321 if ( newtab )
322 { 322 {
323 selectTab( newtab ); 323 selectTab( newtab );
324 } 324 }
325} 325}
326 326
327QPixmap OTabWidget::loadSmooth( const QString &name ) 327QPixmap OTabWidget::loadSmooth( const QString &name )
328{ 328{
329 QImage image = Resource::loadImage( name ); 329 QImage image = Resource::loadImage( name );
330 QPixmap pixmap; 330 QPixmap pixmap;
331 pixmap.convertFromImage( image.smoothScale( 14, 14 ) ); 331 pixmap.convertFromImage( image.smoothScale( 14, 14 ) );
332 return pixmap; 332 return pixmap;
333} 333}
334 334
335void OTabWidget::selectTab( OTabInfo *tab ) 335void OTabWidget::selectTab( OTabInfo *tab )
336{ 336{
337 if ( tabBarStyle == IconTab ) 337 if ( tabBarStyle == IconTab )
338 { 338 {
339 if ( currTab ) 339 if ( currTab )
340 { 340 {
341 tabBar->tab( currTab->id() )->setText( QString::null ); 341 tabBar->tab( currTab->id() )->setText( QString::null );
342 setUpLayout(); 342 setUpLayout();
343 } 343 }
344 tabBar->tab( tab->id() )->setText( tab->label() ); 344 tabBar->tab( tab->id() )->setText( tab->label() );
345 tabBar->setCurrentTab( tab->id() ); 345 tabBar->setCurrentTab( tab->id() );
346 setUpLayout(); 346 setUpLayout();
347 tabBar->update(); 347 tabBar->update();
348 } 348 }
349 else 349 else
350 { 350 {
351 tabBar->setCurrentTab( tab->id() ); 351 tabBar->setCurrentTab( tab->id() );
352 } 352 }
353 353
354 widgetStack->raiseWidget( tab->control() ); 354 widgetStack->raiseWidget( tab->control() );
355 355
356 emit currentChanged( tab->control() ); 356 emit currentChanged( tab->control() );
357 357
358 currTab = tab; 358 currTab = tab;
359} 359}
360 360
361void OTabWidget::setUpLayout() 361void OTabWidget::setUpLayout()
362{ 362{
363 tabBar->layoutTabs(); 363 tabBar->layoutTabs();
364 QSize t( tabBarStack->sizeHint() ); 364 QSize t( tabBarStack->sizeHint() );
365 if ( tabBarStyle == IconTab ) 365 if ( tabBarStyle == IconTab )
366 { 366 {
367 if ( t.width() > width() ) 367 if ( t.width() > width() )
368 t.setWidth( width() ); 368 t.setWidth( width() );
369 } 369 }
370 else 370 else
371 { 371 {
372 t.setWidth( width() ); 372 t.setWidth( width() );
373 } 373 }
374 int lw = widgetStack->lineWidth(); 374 int lw = widgetStack->lineWidth();
375 if ( tabBarPosition == Bottom ) 375 if ( tabBarPosition == Bottom )
376 { 376 {
377 tabBarStack->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); 377 tabBarStack->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() );
378 widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) ); 378 widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) );
379 } 379 }
380 else 380 else
381 { 381 {
382 tabBarStack->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); 382 tabBarStack->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() );
383 widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) ); 383 widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) );
384 } 384 }
385 385
386 if ( autoMask() ) 386 if ( autoMask() )
387 updateMask(); 387 updateMask();
388} 388}
389 389
390QSize OTabWidget::sizeHint() const 390QSize OTabWidget::sizeHint() const
391{ 391{
392 QSize s( widgetStack->sizeHint() ); 392 QSize s( widgetStack->sizeHint() );
393 QSize t( tabBarStack->sizeHint() ); 393 QSize t( tabBarStack->sizeHint() );
394 return QSize( QMAX( s.width(), t.width() ), s.height() + t.height() ); 394 return QSize( QMAX( s.width(), t.width() ), s.height() + t.height() );
395} 395}
396 396
397void OTabWidget::resizeEvent( QResizeEvent * ) 397void OTabWidget::resizeEvent( QResizeEvent * )
398{ 398{
399 setUpLayout(); 399 setUpLayout();
400} 400}
401 401
402int OTabWidget::currentTab() 402int OTabWidget::currentTab()
403{ 403{
404 if ( currTab ) 404 if ( currTab )
405 { 405 {
406 return currTab->id(); 406 return currTab->id();
407 } 407 }
408 return -1; 408 return -1;
409} 409}
410 410
411QWidget* OTabWidget::currentWidget()const
412{
413 if ( currTab )
414 {
415 return currTab->control();
416 }
417
418 return 0;
419}