summaryrefslogtreecommitdiff
path: root/src/tabbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tabbar.cpp')
-rw-r--r--src/tabbar.cpp83
1 files changed, 34 insertions, 49 deletions
diff --git a/src/tabbar.cpp b/src/tabbar.cpp
index 94f2c274..bde1e63e 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<MainWindow> w, list)
@@ -101,18 +96,12 @@ void TabBar::postLaunch()
if (w->isAncestorOf(this))
{
m_addTabButton->setDefaultAction(w->actionByName("new_tab"));
- secondAddTabButton->setDefaultAction(w->actionByName("new_tab"));
break;
}
}
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 +136,6 @@ QSize TabBar::tabSizeHint(int index) const
}
-void TabBar::tabLayoutChange()
-{
- setTabButtonPosition();
- KTabBar::tabLayoutChange();
-}
-
-
void TabBar::contextMenuRequested(const QPoint &position)
{
KMenu menu;
@@ -205,37 +187,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 +267,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);
+ }
+}