summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tabwindow/tabbar.cpp26
-rw-r--r--src/tabwindow/tabbar.h11
-rw-r--r--src/tabwindow/tabwindow.cpp33
-rw-r--r--src/tabwindow/tabwindow.h13
4 files changed, 34 insertions, 49 deletions
diff --git a/src/tabwindow/tabbar.cpp b/src/tabwindow/tabbar.cpp
index 6f7586d0..91d5e402 100644
--- a/src/tabwindow/tabbar.cpp
+++ b/src/tabwindow/tabbar.cpp
@@ -89,16 +89,15 @@ QSize TabBar::tabSizeHint(int index) const
QWidget* p = qobject_cast<QWidget *>(parent());
- int maxTabBarWidth = p->size().width();
-
- int baseTabWidth = maxTabBarWidth / genericTabNumber;
-
- int minTabWidth = p->sizeHint().width() / genericTabNumber;
-
- int w = baseTabWidth;
- if (count() > genericTabNumber)
+ int tabWidgetWidth = p->size().width();
+ int w = c_baseTabWidth;
+ if (w * count() > tabWidgetWidth)
{
- w = minTabWidth;
+ w = tabWidgetWidth / count();
+ if (w < c_minTabWidth)
+ {
+ w = c_minTabWidth;
+ }
}
int h = size().height();
@@ -394,6 +393,13 @@ void TabBar::mousePressEvent(QMouseEvent *event)
}
+void TabBar::tabLayoutChange()
+{
+ KTabBar::tabLayoutChange();
+ emit tabLayoutChanged();
+}
+
+
void TabBar::showTabPreview()
{
if (m_isFirstTimeOnTab)
@@ -416,7 +422,7 @@ void TabBar::showTabPreview()
if (indexedTab->isLoading())
return;
- int w = tabSizeHint(0).width();
+ int w = c_baseTabWidth;
int h = w * tabW->size().height() / tabW->size().width();
m_previewPopup = new TabPreviewPopup(indexedTab->tabPreview(w,h), indexedTab->url().url() , this);
diff --git a/src/tabwindow/tabbar.h b/src/tabwindow/tabbar.h
index 68ff3361..8dcab051 100644
--- a/src/tabwindow/tabbar.h
+++ b/src/tabwindow/tabbar.h
@@ -54,8 +54,6 @@ public:
void setTabHighlighted(int index, bool b);
QRect tabTextRect(int index);
- static const int genericTabNumber = 6;
-
protected:
virtual QSize tabSizeHint(int index) const;
@@ -64,7 +62,8 @@ protected:
virtual void mousePressEvent(QMouseEvent *event);
virtual void tabRemoved(int index);
-
+ virtual void tabLayoutChange();
+
Q_SIGNALS:
void cloneTab(int);
void closeTab(int);
@@ -72,7 +71,8 @@ Q_SIGNALS:
void reloadTab(int);
void detachTab(int);
void restoreClosedTab(int);
-
+ void tabLayoutChanged();
+
private Q_SLOTS:
void cloneTab();
void closeTab();
@@ -99,6 +99,9 @@ private:
QWeakPointer<TabPreviewPopup> m_previewPopup;
int m_currentTabPreviewIndex;
bool m_isFirstTimeOnTab;
+
+ static const int c_baseTabWidth = 200;
+ static const int c_minTabWidth = 100;
};
#endif // TAB_BAR
diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp
index 89ee76b9..0aafeb0d 100644
--- a/src/tabwindow/tabwindow.cpp
+++ b/src/tabwindow/tabwindow.cpp
@@ -85,6 +85,8 @@ TabWindow::TabWindow(bool withTab, QWidget *parent)
connect(tabBar, SIGNAL(detachTab(int)), this, SLOT(detachTab(int)));
connect(tabBar, SIGNAL(restoreClosedTab(int)), this, SLOT(restoreClosedTab(int)));
+ connect(tabBar, SIGNAL(tabLayoutChanged()), this, SLOT(updateNewTabButtonPosition()));
+
// new tab button
KAction* a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this);
_addTabButton->setDefaultAction(a);
@@ -195,8 +197,6 @@ void TabWindow::loadUrl(const KUrl &url, Rekonq::OpenType type, TabHistory *hist
{
history->applyHistory(tab->page()->history());
}
-
- updateTabBar();
}
@@ -214,9 +214,6 @@ void TabWindow::pageCreated(WebPage *page)
// Now, the dirty jobs...
_openedTabsCounter++;
insertTab(currentIndex() + _openedTabsCounter, tab, i18n("new tab"));
-
- // Finally, update tab bar...
- updateTabBar();
}
@@ -238,39 +235,22 @@ void TabWindow::currentChanged(int newIndex)
}
-void TabWindow::resizeEvent(QResizeEvent *event)
-{
- QTabWidget::resizeEvent(event);
- updateTabBar();
-}
-
-
-void TabWindow::updateTabBar()
+void TabWindow::updateNewTabButtonPosition()
{
- // update tab button position
- static bool ButtonInCorner = false;
-
int tabWidgetWidth = frameSize().width();
int tabBarWidth = tabBar()->sizeHint().width();
if (tabBarWidth + _addTabButton->width() > tabWidgetWidth)
{
- if (ButtonInCorner)
- return;
setCornerWidget(_addTabButton);
- ButtonInCorner = true;
}
else
{
- if (ButtonInCorner)
- {
- setCornerWidget(0);
- ButtonInCorner = false;
- }
-
+ setCornerWidget(0);
_addTabButton->move(tabBarWidth, 0);
- _addTabButton->show();
}
+
+ _addTabButton->show();
}
@@ -411,7 +391,6 @@ void TabWindow::closeTab(int index, bool del)
}
removeTab(index);
- updateTabBar(); // UI operation: do it ASAP!!
if (del)
{
diff --git a/src/tabwindow/tabwindow.h b/src/tabwindow/tabwindow.h
index 421b5ed4..b247d4d2 100644
--- a/src/tabwindow/tabwindow.h
+++ b/src/tabwindow/tabwindow.h
@@ -71,16 +71,16 @@ public Q_SLOTS:
private:
/**
- * Updates tabbar and add new tab button position
- */
- void updateTabBar();
-
- /**
* Prepares the new WebWindow to be open
*/
WebWindow *prepareNewTab(WebPage *page = 0);
private Q_SLOTS:
+ /**
+ * Updates new tab button position
+ */
+ void updateNewTabButtonPosition();
+
void tabTitleChanged(const QString &);
void tabLoadStarted();
@@ -99,9 +99,6 @@ private Q_SLOTS:
void reloadAllTabs();
void restoreClosedTab(int i);
-protected:
- virtual void resizeEvent(QResizeEvent *);
-
private:
// the new tab button
QToolButton *_addTabButton;