From 79170a62caf1cea6ab167ef6fe49d319a6eb9f29 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 21 Aug 2012 17:24:57 +0200 Subject: Fix tabbar size & new tab button position Also, set tab preview popup width fixed This is heavily based on commits about this problem by Yoann Laissus. I modified a bit them to fit there + added (based on his idea) a double fixed size (default + minimal) for tabs --- src/tabwindow/tabwindow.cpp | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) (limited to 'src/tabwindow/tabwindow.cpp') 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) { -- cgit v1.2.1