summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mainview.cpp28
-rw-r--r--src/mainview.h3
-rw-r--r--src/tabbar.cpp16
-rw-r--r--src/webpage.cpp2
4 files changed, 38 insertions, 11 deletions
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 5fc24512..c0294af5 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -107,13 +107,10 @@ void MainView::addTabButtonPosition()
{
static bool ButtonInCorner = false;
- QSize s1 = frameSize();
- int tabWidgetWidth = s1.width();
+ int tabWidgetWidth = frameSize().width();
+ int tabBarWidth = tabBar()->tabSizeHint(0).width()*tabBar()->count();
- QSize s2 = tabBar()->sizeHint();
- int newPos = s2.width();
-
- if( newPos > tabWidgetWidth )
+ if (tabBarWidth + m_addTabButton->width() > tabWidgetWidth)
{
if(ButtonInCorner)
return;
@@ -128,9 +125,15 @@ void MainView::addTabButtonPosition()
m_addTabButton->show();
ButtonInCorner = false;
}
+
+ int newPos = tabWidgetWidth - m_addTabButton->width();
m_addTabButton->move(newPos, 0);
- }
+ if (tabBar()->tabSizeHint(0).width()>=sizeHint().width()/4)
+ m_addTabButton->move(tabBarWidth, 0);
+ else
+ m_addTabButton->move(tabWidgetWidth - m_addTabButton->width(), 0);
+ }
}
@@ -145,6 +148,10 @@ TabBar *MainView::tabBar() const
return m_tabBar;
}
+QToolButton *MainView::addTabButton() const
+{
+ return m_addTabButton;
+}
StackedUrlBar *MainView::urlBarStack() const
{
@@ -675,3 +682,10 @@ void MainView::mouseDoubleClickEvent(QMouseEvent *event) //WARNING Need to be fi
}
KTabWidget::mouseDoubleClickEvent(event);
}
+
+
+void MainView::resizeEvent(QResizeEvent *event)
+{
+ addTabButtonPosition();
+ KTabWidget::resizeEvent(event);
+} \ No newline at end of file
diff --git a/src/mainview.h b/src/mainview.h
index d7f7675b..3b8ccfae 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -66,6 +66,7 @@ public:
UrlBar *urlBar(int index) const;
UrlBar *currentUrlBar() const;
WebView *webView(int index) const;
+ QToolButton *addTabButton() const;
// inlines
TabBar *tabBar() const;
@@ -148,7 +149,7 @@ private slots:
protected:
virtual void mouseDoubleClickEvent(QMouseEvent *event);
-
+ virtual void resizeEvent(QResizeEvent *event);
private:
diff --git a/src/tabbar.cpp b/src/tabbar.cpp
index 08603789..fd27db85 100644
--- a/src/tabbar.cpp
+++ b/src/tabbar.cpp
@@ -70,9 +70,21 @@ TabBar::~TabBar()
QSize TabBar::tabSizeHint(int index) const
{
- QSize s = m_parent->sizeHint();
+ //TODO Create a SuperTabWidget class
+
+ int buttonSize = ((MainView *)m_parent)->addTabButton()->size().width();
+ int tabBarWidth = m_parent->size().width() - buttonSize;
+ int baseWidth = m_parent->sizeHint().width()/4;
+ int minWidth = m_parent->sizeHint().width()/8;
+
+ int w;
+ if (baseWidth*count()<tabBarWidth)
+ w=baseWidth;
+ else if (tabBarWidth/count()>minWidth)
+ w=tabBarWidth/count();
+ else
+ w=minWidth;
- int w = s.width() / 4;
int h = KTabBar::tabSizeHint(index).height();
QSize ts = QSize(w, h);
diff --git a/src/webpage.cpp b/src/webpage.cpp
index fc0d585e..337f4a39 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -117,7 +117,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r
WebPage *WebPage::createWindow(QWebPage::WebWindowType type)
{
kDebug() << "WebPage createWindow slot";
-
+
return newWindow(type);
}