-rw-r--r-- | libopie/otabwidget.cpp | 9 |
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 | |||
@@ -283,128 +283,137 @@ void OTabWidget::setTabStyle( TabStyle s ) | |||
283 | setUpLayout(); | 283 | setUpLayout(); |
284 | } | 284 | } |
285 | 285 | ||
286 | OTabWidget::TabPosition OTabWidget::tabPosition() const | 286 | OTabWidget::TabPosition OTabWidget::tabPosition() const |
287 | { | 287 | { |
288 | return tabBarPosition; | 288 | return tabBarPosition; |
289 | } | 289 | } |
290 | 290 | ||
291 | void OTabWidget::setTabPosition( TabPosition p ) | 291 | void OTabWidget::setTabPosition( TabPosition p ) |
292 | { | 292 | { |
293 | tabBarPosition = p; | 293 | tabBarPosition = p; |
294 | if ( tabBarPosition == Top ) | 294 | if ( tabBarPosition == Top ) |
295 | { | 295 | { |
296 | tabBar->setShape( QTabBar::RoundedAbove ); | 296 | tabBar->setShape( QTabBar::RoundedAbove ); |
297 | } | 297 | } |
298 | else | 298 | else |
299 | { | 299 | { |
300 | tabBar->setShape( QTabBar::RoundedBelow ); | 300 | tabBar->setShape( QTabBar::RoundedBelow ); |
301 | } | 301 | } |
302 | setUpLayout(); | 302 | setUpLayout(); |
303 | } | 303 | } |
304 | 304 | ||
305 | void OTabWidget::slotTabBarSelected( int id ) | 305 | void OTabWidget::slotTabBarSelected( int id ) |
306 | { | 306 | { |
307 | OTabInfo *newtab = tabs.first(); | 307 | OTabInfo *newtab = tabs.first(); |
308 | while ( newtab && newtab->id() != id ) | 308 | while ( newtab && newtab->id() != id ) |
309 | { | 309 | { |
310 | newtab = tabs.next(); | 310 | newtab = tabs.next(); |
311 | } | 311 | } |
312 | if ( newtab && newtab->id() == id ) | 312 | if ( newtab && newtab->id() == id ) |
313 | { | 313 | { |
314 | selectTab( newtab ); | 314 | selectTab( newtab ); |
315 | } | 315 | } |
316 | } | 316 | } |
317 | 317 | ||
318 | void OTabWidget::slotTabListSelected( int index ) | 318 | void 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 | ||
327 | QPixmap OTabWidget::loadSmooth( const QString &name ) | 327 | QPixmap 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 | ||
335 | void OTabWidget::selectTab( OTabInfo *tab ) | 335 | void 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 | ||
361 | void OTabWidget::setUpLayout() | 361 | void 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 | ||
390 | QSize OTabWidget::sizeHint() const | 390 | QSize 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 | ||
397 | void OTabWidget::resizeEvent( QResizeEvent * ) | 397 | void OTabWidget::resizeEvent( QResizeEvent * ) |
398 | { | 398 | { |
399 | setUpLayout(); | 399 | setUpLayout(); |
400 | } | 400 | } |
401 | 401 | ||
402 | int OTabWidget::currentTab() | 402 | int 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 | ||
411 | QWidget* OTabWidget::currentWidget()const | ||
412 | { | ||
413 | if ( currTab ) | ||
414 | { | ||
415 | return currTab->control(); | ||
416 | } | ||
417 | |||
418 | return 0; | ||
419 | } | ||