From 604a10c4fc3e927e0e3265dc37e163366e00cd86 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Sun, 5 Aug 2012 14:22:44 +0200 Subject: * Split updateTabBar() into two separate methods - updateTabBarVisibility(): used to react only on "alwaysShowTabBar" settings - updateAddTabButton(): used to react only on tabbar changes * Improve handling of the add tab button. updateAddTabButton() is now called on any tab layout changed instead of being called in any function which manipulate tabs. * Use a tab height computed with KTabBar instead of the add tab button height with a magical number. It fixes some issues with the Bespin theme. BUG: 304325 --- src/mainview.cpp | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 861a6b1f..17c320b2 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -90,6 +90,9 @@ MainView::MainView(QWidget *parent) connect(tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(tabBar, SIGNAL(tabMoved(int, int)), m_widgetBar, SLOT(moveBar(int, int))); + // Update the add tab button for each tabbar layout change + connect(tabBar, SIGNAL(tabLayoutChanged()), this, SLOT(updateAddTabButton())); + // current page index changing connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); connect(this, SIGNAL(currentChanged(int)), rApp->sessionManager(), SLOT(saveSession())); @@ -155,7 +158,7 @@ QList MainView::recentlyClosedTabs() } -void MainView::updateTabBar() +void MainView::updateTabBarVisibility() { if (ReKonfig::alwaysShowTabBar() || count() > 1) { @@ -184,30 +187,29 @@ void MainView::updateTabBar() m_addTabButton->hide(); return; } +} + +void MainView::updateAddTabButton() +{ // update tab button position - static bool ButtonInCorner = false; int tabWidgetWidth = frameSize().width(); - int tabBarWidth = tabBar()->tabSizeHint(0).width() * tabBar()->count(); + int tabBarWidth = tabBar()->sizeHint().width(); if (tabBarWidth + m_addTabButton->width() > tabWidgetWidth) { - if (ButtonInCorner) - return; setCornerWidget(m_addTabButton); - ButtonInCorner = true; } else { - if (ButtonInCorner) - { - setCornerWidget(0); - ButtonInCorner = false; - } - + setCornerWidget(0); m_addTabButton->move(tabBarWidth, 0); } + + // Make sure the add tab button is correctly shown + // For some reason, it's being hidden during a "fixed pos to corner" change + m_addTabButton->show(); } @@ -336,7 +338,6 @@ WebTab *MainView::newWebTab(bool focused) addTab(tab, i18n("(Untitled)")); m_widgetBar->addWidget(tab->urlBar()); } - updateTabBar(); if (focused) { @@ -509,7 +510,6 @@ void MainView::closeTab(int index, bool del) // else... removeTab(index); - updateTabBar(); // UI operation: do it ASAP!! m_widgetBar->removeWidget(tabToClose->urlBar()); m_widgetBar->setCurrentIndex(m_currentTabIndex); @@ -746,13 +746,6 @@ QLabel *MainView::animatedLoading(int index, bool addMovie) } -void MainView::resizeEvent(QResizeEvent *event) -{ - updateTabBar(); - KTabWidget::resizeEvent(event); -} - - void MainView::detachTab(int index, MainWindow *toWindow) { if (index < 0) @@ -781,7 +774,6 @@ void MainView::detachTab(int index, MainWindow *toWindow) w->mainView()->addTab(tab, label); w->mainView()->widgetBar()->insertWidget(0, bar); - w->mainView()->updateTabBar(); // reconnect signals to the new mainview // Code copied from newWebTab(), any new changes there should be applied here -- cgit v1.2.1