From 491f63610fc9f74ca8097a516347f1399cbc71c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Ander=20Pe=C3=B1alba?= Date: Tue, 30 Nov 2010 22:04:41 +0100 Subject: Show and hide the add-tab button automatically --- src/tabbar.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'src/tabbar.cpp') diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 0866bfd8..286d7d45 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -77,11 +77,6 @@ TabBar::TabBar(QWidget *parent) } -TabBar::~TabBar() -{ -} - - QSize TabBar::tabSizeHint(int index) const { MainView *view = qobject_cast(parent()); @@ -189,6 +184,26 @@ void TabBar::showTabPreview() } +void TabBar::hideEvent(QHideEvent *event) +{ + if (!event->spontaneous()) + { + qobject_cast(parent())->addTabButton()->hide(); + } + QTabBar::hideEvent(event); +} + + +void TabBar::showEvent(QShowEvent *event) +{ + QTabBar::showEvent(event); + if (!event->spontaneous()) + { + qobject_cast(parent())->addTabButton()->show(); + } +} + + void TabBar::mouseMoveEvent(QMouseEvent *event) { if (count() == 1) @@ -338,9 +353,8 @@ void TabBar::mouseReleaseEvent(QMouseEvent *event) } -void TabBar::tabRemoved(int index) +void TabBar::tabRemoved(int /*index*/) { - Q_UNUSED(index) if (ReKonfig::alwaysShowTabPreviews()) { if (!m_previewPopup.isNull()) @@ -374,7 +388,7 @@ void TabBar::setupHistoryActions() if(!isEnabled) return; - foreach (const HistoryItem &item, mv->recentlyClosedTabs()) + Q_FOREACH(const HistoryItem &item, mv->recentlyClosedTabs()) { KAction *a = new KAction(Application::iconManager()->iconForUrl(item.url), item.title, this); a->setData(item.url); -- cgit v1.2.1