From 93a955c984a1ff29659db8575bd193ac68df542f Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Wed, 7 Jul 2010 15:17:48 +0000 Subject: [PATCH] do the proper animation when deleting the current tab svn path=/trunk/KDE/kdelibs/; revision=1147189 --- widgets/tabbar.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/widgets/tabbar.cpp b/widgets/tabbar.cpp index 2dbd29365..3ec2fdc1a 100644 --- a/widgets/tabbar.cpp +++ b/widgets/tabbar.cpp @@ -452,22 +452,24 @@ void TabBar::removeTab(int index) int oldCurrentIndex = d->tabProxy->native->currentIndex(); d->tabProxy->native->removeTab(index); - QGraphicsWidget *page = d->pages.takeAt(index); + d->currentIndex = oldCurrentIndex; int currentIndex = d->tabProxy->native->currentIndex(); if (oldCurrentIndex == index) { d->tabWidgetLayout->removeAt(1); + if (d->tabProxy->native->count() > 0) { + setCurrentIndex(currentIndex >= oldCurrentIndex ? currentIndex + 1 : currentIndex); + } } + QGraphicsWidget *page = d->pages.takeAt(index); scene()->removeItem(page); page->deleteLater(); - if (oldCurrentIndex != currentIndex) { - setCurrentIndex(currentIndex); + if (d->pages.count() > 0) { + d->updateTabWidgetMode(); } - - d->updateTabWidgetMode(); d->tabProxy->setPreferredSize(d->tabProxy->native->sizeHint()); }