From 3aaf7be9670b09a2f7f9d5a2484e854135453c46 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 14 Oct 2009 12:23:22 +0200 Subject: Another fix for the new tab button... I'm starting hating it!! --- src/tabbar.cpp | 82 ++++++++++++++++++++++++---------------------------------- 1 file changed, 34 insertions(+), 48 deletions(-) (limited to 'src/tabbar.cpp') diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 94f2c274..b1b727ae 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -89,11 +89,6 @@ TabBar::~TabBar() void TabBar::postLaunch() { - // HACK this is used to fix add tab button position - QToolButton *secondAddTabButton = new QToolButton(this); - secondAddTabButton->setAutoRaise(true); - secondAddTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - // Find the correct MainWindow of this tab button MainWindowList list = Application::instance()->mainWindowList(); Q_FOREACH(QPointer w, list) @@ -101,7 +96,6 @@ void TabBar::postLaunch() if (w->isAncestorOf(this)) { m_addTabButton->setDefaultAction(w->actionByName("new_tab")); - secondAddTabButton->setDefaultAction(w->actionByName("new_tab")); break; } } @@ -109,10 +103,6 @@ void TabBar::postLaunch() m_addTabButton->setAutoRaise(true); m_addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); m_addTabButton->show(); - - // stupid tabbar, that's what you gain... - m_parent->setCornerWidget(secondAddTabButton); - m_parent->cornerWidget()->hide(); } @@ -147,13 +137,6 @@ QSize TabBar::tabSizeHint(int index) const } -void TabBar::tabLayoutChange() -{ - setTabButtonPosition(); - KTabBar::tabLayoutChange(); -} - - void TabBar::contextMenuRequested(const QPoint &position) { KMenu menu; @@ -205,37 +188,6 @@ void TabBar::reloadTab() } -void TabBar::setTabButtonPosition() -{ - if(count() >= MIN_WIDTH_DIVISOR - 1) - { - if(m_addTabButton->isVisible()) - { - m_addTabButton->hide(); - m_parent->cornerWidget()->show(); - } - return; - } - - if(m_addTabButton->isHidden()) - { - m_addTabButton->show(); - m_parent->cornerWidget()->hide(); - } - - int tabWidgetWidth = frameSize().width(); - int tabBarWidth = tabSizeHint(0).width()*count(); - int newPosY = height() - m_addTabButton->height(); - int newPosX = tabWidgetWidth - m_addTabButton->width(); - - if (tabBarWidth + m_addTabButton->width() < tabWidgetWidth) - newPosX = tabBarWidth; - - m_addTabButton->move(newPosX, newPosY); - m_addTabButton->show(); -} - - void TabBar::showTabPreview(int tab) { WebView *view = m_parent->webView(tab); @@ -316,3 +268,37 @@ void TabBar::leaveEvent(QEvent *event) KTabBar::leaveEvent(event); } + + +void TabBar::updateNewTabButton() +{ + static bool ButtonInCorner = false; + + int tabWidgetWidth = m_parent->frameSize().width(); + int tabBarWidth = tabSizeHint(0).width() * count(); + + if (tabBarWidth + m_addTabButton->width() > tabWidgetWidth) + { + if(ButtonInCorner) + return; + m_parent->setCornerWidget(m_addTabButton); + ButtonInCorner = true; + } + else + { + if(ButtonInCorner) + { + m_parent->setCornerWidget(0); + m_addTabButton->show(); + ButtonInCorner = false; + } + + int newPosX = tabWidgetWidth - m_addTabButton->width(); + int newPosY = height() - m_addTabButton->height(); + + if (tabBarWidth + m_addTabButton->width() < tabWidgetWidth) + newPosX = tabBarWidth; + + m_addTabButton->move(newPosX, newPosY); + } +} -- cgit v1.2.1 From e74a510859d79df4f90d49ac977fbd30f026f8cc Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 14 Oct 2009 12:26:08 +0200 Subject: little fix again.. --- src/tabbar.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/tabbar.cpp') diff --git a/src/tabbar.cpp b/src/tabbar.cpp index b1b727ae..bde1e63e 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -102,7 +102,6 @@ void TabBar::postLaunch() m_addTabButton->setAutoRaise(true); m_addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - m_addTabButton->show(); } -- cgit v1.2.1