summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mainview.cpp41
-rw-r--r--src/mainview.h7
-rw-r--r--src/tabbar.cpp19
3 files changed, 49 insertions, 18 deletions
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 6f3ad926..ce43cbc2 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -65,6 +65,7 @@ MainView::MainView(QWidget *parent)
, m_recentlyClosedTabsMenu(new KMenu(this))
, m_urlBars(new StackedUrlBar(this))
, m_tabBar(new TabBar(this))
+ , m_addTabButton(new QToolButton(this))
{
// setting tabbar
setTabBar(m_tabBar);
@@ -97,6 +98,11 @@ MainView::~MainView()
void MainView::postLaunch()
{
+ m_addTabButton->setDefaultAction(Application::instance()->mainWindow()->actionByName("new_tab"));
+ m_addTabButton->setAutoRaise(true);
+ m_addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
+
+
// Recently Closed Tab Action
connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu()));
connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *)));
@@ -106,6 +112,37 @@ void MainView::postLaunch()
}
+void MainView::addTabButtonPosition()
+{
+ static bool ButtonInCorner = false;
+
+ QSize s1 = frameSize();
+ int tabWidgetWidth = s1.width();
+
+ QSize s2 = tabBar()->sizeHint();
+ int newPos = s2.width();
+
+ if( newPos > tabWidgetWidth )
+ {
+ if(ButtonInCorner)
+ return;
+ setCornerWidget(m_addTabButton);
+ ButtonInCorner = true;
+ }
+ else
+ {
+ if(ButtonInCorner)
+ {
+ setCornerWidget(0);
+ m_addTabButton->show();
+ ButtonInCorner = false;
+ }
+ m_addTabButton->move(newPos, 0);
+ }
+
+}
+
+
UrlBar *MainView::currentUrlBar() const
{
return urlBar(-1);
@@ -387,6 +424,7 @@ WebView *MainView::newWebView(Rekonq::OpenType type)
emit tabsChanged();
showTabBar();
+ addTabButtonPosition();
return webView;
}
@@ -446,6 +484,7 @@ void MainView::slotCloseOtherTabs(int index)
}
showTabBar();
+ addTabButtonPosition();
}
@@ -460,6 +499,7 @@ void MainView::slotCloneTab(int index)
tab->setUrl(webView(index)->url());
showTabBar();
+ addTabButtonPosition();
}
@@ -521,6 +561,7 @@ void MainView::slotCloseTab(int index)
}
showTabBar();
+ addTabButtonPosition();
}
diff --git a/src/mainview.h b/src/mainview.h
index 8a8ae3dc..8ff32473 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -30,6 +30,9 @@
// KDE Includes
#include <KTabWidget>
+// Qt Includes
+#include <QtGui/QToolButton>
+
// Forward Declarations
class QUrl;
class QWebFrame;
@@ -160,6 +163,8 @@ protected:
private:
+ void addTabButtonPosition();
+
/**
* This function creates (if not exists) and returns a QLabel
* with a loading QMovie.
@@ -184,6 +189,8 @@ private:
QString m_loadingGitPath;
bool m_makeBackTab;
+
+ QToolButton *m_addTabButton;
};
#endif
diff --git a/src/tabbar.cpp b/src/tabbar.cpp
index 96e3d19c..2680dfb7 100644
--- a/src/tabbar.cpp
+++ b/src/tabbar.cpp
@@ -70,25 +70,8 @@ TabBar::~TabBar()
QSize TabBar::tabSizeHint(int index) const
{
QSize s = m_parent->sizeHint();
- int w;
- int n = count();
-
- if (n > 6)
- {
- w = s.width() / 5;
- }
- else
- {
- if (n > 3)
- {
- w = s.width() / 4;
- }
- else
- {
- w = s.width() / 3;
- }
- }
+ int w = s.width() / 4;
int h = KTabBar::tabSizeHint(index).height();
QSize ts = QSize(w, h);