diff options
author | Yoann Laissus <yoann.laissus@gmail.com> | 2012-08-05 14:22:44 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-08-14 17:47:41 +0200 |
commit | 604a10c4fc3e927e0e3265dc37e163366e00cd86 (patch) | |
tree | eb76089c9c149dec65de9bd59b0391eb0eac67b0 /src | |
parent | Get sure rekonq makes use of djvu plugin (diff) | |
download | rekonq-604a10c4fc3e927e0e3265dc37e163366e00cd86.tar.xz |
* Split updateTabBar() into two separate methods
- updateTabBarVisibility(): used to react only on "alwaysShowTabBar" settings
- updateAddTabButton(): used to react only on tabbar changes
* Improve handling of the add tab button. updateAddTabButton() is now called on any
tab layout changed instead of being called in any function which manipulate tabs.
* Use a tab height computed with KTabBar instead of the add tab button height with a magical number.
It fixes some issues with the Bespin theme.
BUG: 304325
Diffstat (limited to 'src')
-rw-r--r-- | src/application.cpp | 2 | ||||
-rw-r--r-- | src/mainview.cpp | 36 | ||||
-rw-r--r-- | src/mainview.h | 11 | ||||
-rw-r--r-- | src/tabbar.cpp | 9 | ||||
-rw-r--r-- | src/tabbar.h | 2 |
5 files changed, 27 insertions, 33 deletions
diff --git a/src/application.cpp b/src/application.cpp index 2127ca94..de306170 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -571,7 +571,7 @@ void Application::updateConfiguration() Q_FOREACH(const QWeakPointer<MainWindow> &w, m_mainWindows) { MainView *mv = w.data()->mainView(); - mv->updateTabBar(); + mv->updateTabBarVisibility(); mv->tabBar()->setAnimatedTabHighlighting(ReKonfig::animatedTabHighlighting()); diff --git a/src/mainview.cpp b/src/mainview.cpp index 861a6b1f..17c320b2 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -90,6 +90,9 @@ MainView::MainView(QWidget *parent) connect(tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(tabBar, SIGNAL(tabMoved(int, int)), m_widgetBar, SLOT(moveBar(int, int))); + // Update the add tab button for each tabbar layout change + connect(tabBar, SIGNAL(tabLayoutChanged()), this, SLOT(updateAddTabButton())); + // current page index changing connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); connect(this, SIGNAL(currentChanged(int)), rApp->sessionManager(), SLOT(saveSession())); @@ -155,7 +158,7 @@ QList<TabHistory> MainView::recentlyClosedTabs() } -void MainView::updateTabBar() +void MainView::updateTabBarVisibility() { if (ReKonfig::alwaysShowTabBar() || count() > 1) { @@ -184,30 +187,29 @@ void MainView::updateTabBar() m_addTabButton->hide(); return; } +} + +void MainView::updateAddTabButton() +{ // update tab button position - static bool ButtonInCorner = false; int tabWidgetWidth = frameSize().width(); - int tabBarWidth = tabBar()->tabSizeHint(0).width() * tabBar()->count(); + int tabBarWidth = tabBar()->sizeHint().width(); if (tabBarWidth + m_addTabButton->width() > tabWidgetWidth) { - if (ButtonInCorner) - return; setCornerWidget(m_addTabButton); - ButtonInCorner = true; } else { - if (ButtonInCorner) - { - setCornerWidget(0); - ButtonInCorner = false; - } - + setCornerWidget(0); m_addTabButton->move(tabBarWidth, 0); } + + // Make sure the add tab button is correctly shown + // For some reason, it's being hidden during a "fixed pos to corner" change + m_addTabButton->show(); } @@ -336,7 +338,6 @@ WebTab *MainView::newWebTab(bool focused) addTab(tab, i18n("(Untitled)")); m_widgetBar->addWidget(tab->urlBar()); } - updateTabBar(); if (focused) { @@ -509,7 +510,6 @@ void MainView::closeTab(int index, bool del) // else... removeTab(index); - updateTabBar(); // UI operation: do it ASAP!! m_widgetBar->removeWidget(tabToClose->urlBar()); m_widgetBar->setCurrentIndex(m_currentTabIndex); @@ -746,13 +746,6 @@ QLabel *MainView::animatedLoading(int index, bool addMovie) } -void MainView::resizeEvent(QResizeEvent *event) -{ - updateTabBar(); - KTabWidget::resizeEvent(event); -} - - void MainView::detachTab(int index, MainWindow *toWindow) { if (index < 0) @@ -781,7 +774,6 @@ void MainView::detachTab(int index, MainWindow *toWindow) w->mainView()->addTab(tab, label); w->mainView()->widgetBar()->insertWidget(0, bar); - w->mainView()->updateTabBar(); // reconnect signals to the new mainview // Code copied from newWebTab(), any new changes there should be applied here diff --git a/src/mainview.h b/src/mainview.h index 9378f4bd..89ee36ec 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -79,12 +79,7 @@ public: void addNewTabButton(QAction *); - /** - * show and hide TabBar if user doesn't choose - * "Always Show TabBar" option - * - */ - void updateTabBar(); + void updateTabBarVisibility(); inline QToolButton *addTabButton() const { @@ -158,6 +153,7 @@ public Q_SLOTS: private Q_SLOTS: void currentChanged(int index); + void updateAddTabButton(); void webViewLoadStarted(); void webViewLoadFinished(bool ok); @@ -169,9 +165,6 @@ private Q_SLOTS: void openClosedTab(); -protected: - virtual void resizeEvent(QResizeEvent *event); - private: /** * This function creates (if not exists) and returns a QLabel diff --git a/src/tabbar.cpp b/src/tabbar.cpp index ac257d12..2f0803f8 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -131,7 +131,7 @@ QSize TabBar::tabSizeHint(int index) const } } - int h = view->addTabButton()->height() + 6; + int h = KTabBar::tabSizeHint(index).height(); QSize ts = QSize(w, h); return ts; @@ -552,3 +552,10 @@ bool TabBar::isURLValid(const QString &url) isValid = true; return isValid; } + + +void TabBar::tabLayoutChange() +{ + KTabBar::tabLayoutChange(); + emit tabLayoutChanged(); +} diff --git a/src/tabbar.h b/src/tabbar.h index 161612c2..6bdbdc09 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -74,6 +74,7 @@ Q_SIGNALS: void reloadTab(int index); void reloadAllTabs(); void detachTab(int index); + void tabLayoutChanged(); protected: /** @@ -87,6 +88,7 @@ protected: virtual void leaveEvent(QEvent *event); virtual void mousePressEvent(QMouseEvent *event); + virtual void tabLayoutChange(); virtual void tabRemoved(int index); void dropEvent(QDropEvent *event); void dragEnterEvent(QDragEnterEvent *event); |