summaryrefslogtreecommitdiff
authordrw <drw>2002-11-22 01:13:36 (UTC)
committer drw <drw>2002-11-22 01:13:36 (UTC)
commit380dc82f6e03f1357e91c0c6e3dd48bcc38969a5 (patch) (unidiff)
tree3b23d8b7afe2f6a9f77c9700ffe812f349f21628
parent1c2a0db4c2454a36ebf5c676f8ce803b285e60b8 (diff)
downloadopie-380dc82f6e03f1357e91c0c6e3dd48bcc38969a5.zip
opie-380dc82f6e03f1357e91c0c6e3dd48bcc38969a5.tar.gz
opie-380dc82f6e03f1357e91c0c6e3dd48bcc38969a5.tar.bz2
Hopefully corrects bug #467
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/otabwidget.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/libopie/otabwidget.cpp b/libopie/otabwidget.cpp
index 5fc3e8e..1fee919 100644
--- a/libopie/otabwidget.cpp
+++ b/libopie/otabwidget.cpp
@@ -201,134 +201,141 @@ void OTabWidget::setCurrentTab( const QString &tabname )
201 } 201 }
202} 202}
203 203
204void OTabWidget::setCurrentTab(int tabindex) { 204void OTabWidget::setCurrentTab(int tabindex) {
205 OTabInfo *newtab = tabs.first(); 205 OTabInfo *newtab = tabs.first();
206 while ( newtab && newtab->id() != tabindex ) 206 while ( newtab && newtab->id() != tabindex )
207 { 207 {
208 newtab = tabs.next(); 208 newtab = tabs.next();
209 } 209 }
210 if ( newtab && newtab->id() == tabindex ) 210 if ( newtab && newtab->id() == tabindex )
211 { 211 {
212 selectTab( newtab ); 212 selectTab( newtab );
213 } 213 }
214} 214}
215 215
216 216
217OTabWidget::TabStyle OTabWidget::tabStyle() const 217OTabWidget::TabStyle OTabWidget::tabStyle() const
218{ 218{
219 return tabBarStyle; 219 return tabBarStyle;
220} 220}
221 221
222void OTabWidget::setTabStyle( TabStyle s ) 222void OTabWidget::setTabStyle( TabStyle s )
223{ 223{
224 tabBarStyle = s; 224 tabBarStyle = s;
225} 225}
226 226
227OTabWidget::TabPosition OTabWidget::tabPosition() const 227OTabWidget::TabPosition OTabWidget::tabPosition() const
228{ 228{
229 return tabBarPosition; 229 return tabBarPosition;
230} 230}
231 231
232void OTabWidget::setTabPosition( TabPosition p ) 232void OTabWidget::setTabPosition( TabPosition p )
233{ 233{
234 tabBarPosition = p; 234 tabBarPosition = p;
235} 235}
236 236
237void OTabWidget::slotTabBarSelected( int id ) 237void OTabWidget::slotTabBarSelected( int id )
238{ 238{
239 OTabInfo *newtab = tabs.first(); 239 OTabInfo *newtab = tabs.first();
240 while ( newtab && newtab->id() != id ) 240 while ( newtab && newtab->id() != id )
241 { 241 {
242 newtab = tabs.next(); 242 newtab = tabs.next();
243 } 243 }
244 if ( newtab && newtab->id() == id ) 244 if ( newtab && newtab->id() == id )
245 { 245 {
246 selectTab( newtab ); 246 selectTab( newtab );
247 } 247 }
248} 248}
249 249
250void OTabWidget::slotTabListSelected( int index ) 250void OTabWidget::slotTabListSelected( int index )
251{ 251{
252 OTabInfo *newtab = tabs.at( index ); 252 OTabInfo *newtab = tabs.at( index );
253 if ( newtab ) 253 if ( newtab )
254 { 254 {
255 selectTab( newtab ); 255 selectTab( newtab );
256 } 256 }
257} 257}
258 258
259QPixmap OTabWidget::loadSmooth( const QString &name ) 259QPixmap OTabWidget::loadSmooth( const QString &name )
260{ 260{
261 QImage image = Resource::loadImage( name ); 261 QImage image = Resource::loadImage( name );
262 QPixmap pixmap; 262 QPixmap pixmap;
263 pixmap.convertFromImage( image.smoothScale( 16, 16 ) ); 263 pixmap.convertFromImage( image.smoothScale( 16, 16 ) );
264 return pixmap; 264 return pixmap;
265} 265}
266 266
267void OTabWidget::selectTab( OTabInfo *tab ) 267void OTabWidget::selectTab( OTabInfo *tab )
268{ 268{
269 if ( tabBarStyle == IconTab ) 269 if ( tabBarStyle == IconTab )
270 { 270 {
271 if ( currentTab ) 271 if ( currentTab )
272 { 272 {
273 tabBar->tab( currentTab->id() )->setText( "" ); 273 tabBar->tab( currentTab->id() )->setText( "" );
274 setUpLayout(); 274 setUpLayout();
275 } 275 }
276 tabBar->tab( tab->id() )->setText( tab->label() ); 276 tabBar->tab( tab->id() )->setText( tab->label() );
277 tabBar->setCurrentTab( tab->id() ); 277 tabBar->setCurrentTab( tab->id() );
278 setUpLayout(); 278 setUpLayout();
279 tabBar->update(); 279 tabBar->update();
280 } 280 }
281 else 281 else
282 { 282 {
283 tabBar->setCurrentTab( tab->id() ); 283 tabBar->setCurrentTab( tab->id() );
284 } 284 }
285 285
286 widgetStack->raiseWidget( tab->control() ); 286 widgetStack->raiseWidget( tab->control() );
287 287
288 emit currentChanged( tab->control() ); 288 emit currentChanged( tab->control() );
289 289
290 currentTab = tab; 290 currentTab = tab;
291} 291}
292 292
293void OTabWidget::setUpLayout() 293void OTabWidget::setUpLayout()
294{ 294{
295 tabBar->layoutTabs(); 295 tabBar->layoutTabs();
296 QSize t( tabBarStack->sizeHint() ); 296 QSize t( tabBarStack->sizeHint() );
297 if ( t.width() > width() ) 297 if ( tabBarStyle == IconTab )
298 {
299 if ( t.width() > width() )
300 t.setWidth( width() );
301 }
302 else
303 {
298 t.setWidth( width() ); 304 t.setWidth( width() );
305 }
299 int lw = widgetStack->lineWidth(); 306 int lw = widgetStack->lineWidth();
300 if ( tabBarPosition == Bottom ) 307 if ( tabBarPosition == Bottom )
301 { 308 {
302 tabBarStack->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); 309 tabBarStack->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() );
303 widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) ); 310 widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) );
304 } 311 }
305 else 312 else
306 { 313 {
307 tabBarStack->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); 314 tabBarStack->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() );
308 widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX(0, lw-2)); 315 widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) );
309 } 316 }
310 317
311 if ( autoMask() ) 318 if ( autoMask() )
312 updateMask(); 319 updateMask();
313} 320}
314 321
315QSize OTabWidget::sizeHint() const 322QSize OTabWidget::sizeHint() const
316{ 323{
317 QSize s( widgetStack->sizeHint() ); 324 QSize s( widgetStack->sizeHint() );
318 QSize t( tabBarStack->sizeHint() ); 325 QSize t( tabBarStack->sizeHint() );
319 return QSize( QMAX( s.width(), t.width()), s.height() + t.height() ); 326 return QSize( QMAX( s.width(), t.width() ), s.height() + t.height() );
320} 327}
321 328
322void OTabWidget::resizeEvent( QResizeEvent * ) 329void OTabWidget::resizeEvent( QResizeEvent * )
323{ 330{
324 setUpLayout(); 331 setUpLayout();
325} 332}
326 333
327int OTabWidget::getCurrentTab() { 334int OTabWidget::getCurrentTab() {
328 if ( currentTab ) 335 if ( currentTab )
329 { 336 {
330 return currentTab->id(); 337 return currentTab->id();
331 } 338 }
332 return -1; 339 return -1;
333} 340}
334 341