summaryrefslogtreecommitdiff
path: root/src/mainview.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-02-16 18:09:34 +0100
committerAndrea Diamantini <adjam7@gmail.com>2011-02-16 18:09:34 +0100
commitdd81e53fff6cfdccfa7459f6631182de4fbd8e3d (patch)
tree204c2e002c95834e12c17359d34b32a4b2a93658 /src/mainview.cpp
parentCalm down kDebug messages (diff)
downloadrekonq-dd81e53fff6cfdccfa7459f6631182de4fbd8e3d.tar.xz
This patch cleans up tabbar update: show/hide when ReKonfig::alwaysShowTabBar() is off
and update tab button position. It also removes a "feature" introduced to hide/show tab button on tab moving: it has negative effects on tab middle click closing. Reviewed by: NOBODY (oops..)
Diffstat (limited to 'src/mainview.cpp')
-rw-r--r--src/mainview.cpp86
1 files changed, 42 insertions, 44 deletions
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 1cf003e9..fe6413a1 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -58,11 +58,11 @@
MainView::MainView(MainWindow *parent)
- : KTabWidget(parent)
- , m_widgetBar(new StackedUrlBar(this))
- , m_addTabButton(0)
- , m_currentTabIndex(0)
- , m_parentWindow(parent)
+ : KTabWidget(parent)
+ , m_widgetBar(new StackedUrlBar(this))
+ , m_addTabButton(0)
+ , m_currentTabIndex(0)
+ , m_parentWindow(parent)
{
// setting tabbar
TabBar *tabBar = new TabBar(this);
@@ -121,43 +121,6 @@ void MainView::postLaunch()
}
-void MainView::updateTabButtonPosition()
-{
- static bool ButtonInCorner = false;
-
- int tabWidgetWidth = frameSize().width();
- int tabBarWidth = tabBar()->tabSizeHint(0).width() * tabBar()->count();
-
- if (tabBarWidth + m_addTabButton->width() > tabWidgetWidth)
- {
- if (ButtonInCorner)
- return;
- setCornerWidget(m_addTabButton);
- ButtonInCorner = true;
- }
- else
- {
- if (ButtonInCorner)
- {
- setCornerWidget(0);
- // new window problem
- if(count()>1)
- m_addTabButton->show();
- ButtonInCorner = false;
- }
-
- // detecting X position
- int newPosX = tabBarWidth;
- int tabWidthHint = tabBar()->tabSizeHint(0).width();
- if (tabWidthHint < sizeHint().width() / 4)
- newPosX = tabWidgetWidth - m_addTabButton->width();
-
- m_addTabButton->move(newPosX, 0);
- m_addTabButton->show();
- }
-}
-
-
TabBar *MainView::tabBar() const
{
TabBar *tabBar = qobject_cast<TabBar *>(KTabWidget::tabBar());
@@ -179,21 +142,56 @@ WebTab *MainView::currentWebTab() const
void MainView::updateTabBar()
{
- if (ReKonfig::alwaysShowTabBar() || tabBar()->count() > 1)
+ if (ReKonfig::alwaysShowTabBar() || count() > 1)
{
if (tabBar()->isHidden())
{
tabBar()->show();
+ }
+
+ // this to ensure tab button visibility also on new window creation
+ if(m_addTabButton->isHidden())
+ {
m_addTabButton->show();
}
+
}
else
{
tabBar()->hide();
m_addTabButton->hide();
+ return;
+ }
+
+ // update tab button position
+ static bool ButtonInCorner = false;
+
+ int tabWidgetWidth = frameSize().width();
+ int tabBarWidth = tabBar()->tabSizeHint(0).width() * tabBar()->count();
+
+ if (tabBarWidth + m_addTabButton->width() > tabWidgetWidth)
+ {
+ if (ButtonInCorner)
+ return;
+ setCornerWidget(m_addTabButton);
+ ButtonInCorner = true;
}
+ else
+ {
+ if (ButtonInCorner)
+ {
+ setCornerWidget(0);
+ ButtonInCorner = false;
+ }
- updateTabButtonPosition();
+ // detecting X position
+ int newPosX = tabBarWidth;
+ int tabWidthHint = tabBar()->tabSizeHint(0).width();
+ if (tabWidthHint < sizeHint().width() / 4)
+ newPosX = tabWidgetWidth - m_addTabButton->width();
+
+ m_addTabButton->move(newPosX, 0);
+ }
}