From 9a6bb0444d7346902622555e88914754dc0a9f42 Mon Sep 17 00:00:00 2001 From: nowrep Date: Thu, 13 Mar 2014 12:07:05 +0100 Subject: [PATCH] [TabBar] Make sure adding new background tab make it visible in tabbar --- src/lib/tools/combotabbar.cpp | 7 ++++++- src/lib/tools/combotabbar.h | 19 ++++++++++--------- src/lib/webview/tabwidget.cpp | 5 +++++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/lib/tools/combotabbar.cpp b/src/lib/tools/combotabbar.cpp index 53d0048ef..a791ade54 100644 --- a/src/lib/tools/combotabbar.cpp +++ b/src/lib/tools/combotabbar.cpp @@ -707,6 +707,11 @@ void ComboTabBar::tabRemoved(int index) Q_UNUSED(index) } +TabBarHelper* ComboTabBar::mainTabBar() const +{ + return m_mainTabBar; +} + TabBarHelper* ComboTabBar::localTabBar(int index) const { if (index < 0 || index >= pinnedTabsCount()) { @@ -1289,7 +1294,7 @@ void TabBarScrollWidget::overFlowChanged(bool overflowed) m_leftScrollButton->setVisible(overflowed && m_usesScrollButtons); m_rightScrollButton->setVisible(overflowed && m_usesScrollButtons); - // a workaround for UI issue of buttons on very fast resizing + // Workaround for UI issue of buttons on very fast resizing if (m_rightContainer->isVisible()) { m_rightContainer->hide(); m_rightContainer->show(); diff --git a/src/lib/tools/combotabbar.h b/src/lib/tools/combotabbar.h index 74bc9f714..a7dcbf5eb 100644 --- a/src/lib/tools/combotabbar.h +++ b/src/lib/tools/combotabbar.h @@ -136,6 +136,13 @@ public slots: void ensureVisible(int index = -1, int xmargin = -1); void setCurrentIndex(int index); +signals: + void overFlowChanged(bool overFlow); + void currentChanged(int index); + void tabCloseRequested(int index); + void tabMoved(int from, int to); + void scrollBarValueChanged(int value); + private slots: void setMinimumWidths(); void slotCurrentChanged(int index); @@ -147,6 +154,7 @@ private slots: protected: int mainTabBarWidth() const; int pinTabBarWidth() const; + void wheelEvent(QWheelEvent* event); void showEvent(QShowEvent* event); void enterEvent(QEvent* event); @@ -160,10 +168,10 @@ protected: virtual void tabRemoved(int index); private: + TabBarHelper* mainTabBar() const; TabBarHelper* localTabBar(int index = -1) const; - int toLocalIndex(int globalIndex) const; - inline TabBarHelper* mainTabBar() { return m_mainTabBar; } + int toLocalIndex(int globalIndex) const; void updatePinnedTabBarVisibility(); QHBoxLayout* m_mainLayout; @@ -177,13 +185,6 @@ private: QString m_closeButtonsToolTip; bool m_mainBarOverFlowed; bool m_usesScrollButtons; - -signals: - void overFlowChanged(bool overFlow); - void currentChanged(int index); - void tabCloseRequested(int index); - void tabMoved(int from, int to); - void scrollBarValueChanged(int value); }; class QUPZILLA_EXPORT TabBarHelper : public QTabBar diff --git a/src/lib/webview/tabwidget.cpp b/src/lib/webview/tabwidget.cpp index 4d20aba7c..ab678bb97 100644 --- a/src/lib/webview/tabwidget.cpp +++ b/src/lib/webview/tabwidget.cpp @@ -410,6 +410,11 @@ int TabWidget::addView(QNetworkRequest req, const QString &title, const Qz::NewT } } + // Make sure user notice opening new background tabs + if (!(openFlags & Qz::NT_SelectedTab)) { + m_tabBar->ensureVisible(index); + } + setUpdatesEnabled(true); emit changed();