diff --git a/src/lib/tabwidget/combotabbar.cpp b/src/lib/tabwidget/combotabbar.cpp index 4c286c2e6..1e6512711 100644 --- a/src/lib/tabwidget/combotabbar.cpp +++ b/src/lib/tabwidget/combotabbar.cpp @@ -34,6 +34,7 @@ #include #include #include +#include // taken from qtabbar_p.h #define ANIMATION_DURATION 250 @@ -578,6 +579,24 @@ int ComboTabBar::pinTabBarWidth() const return m_pinnedTabBarWidget->isHidden() ? 0 : m_pinnedTabBarWidget->width(); } +bool ComboTabBar::event(QEvent *event) +{ + switch (event->type()) { + case QEvent::ToolTip: + if (!isDragInProgress() && !isScrollInProgress()) { + int index = tabAt(mapFromGlobal(QCursor::pos())); + if (index >= 0) + QToolTip::showText(QCursor::pos(), tabToolTip(index)); + } + break; + + default: + break; + } + + return QWidget::event(event); +} + void ComboTabBar::wheelEvent(QWheelEvent* event) { event->accept(); @@ -748,6 +767,11 @@ bool ComboTabBar::isDragInProgress() const return m_mainTabBar->isDragInProgress() || m_pinnedTabBar->isDragInProgress(); } +bool ComboTabBar::isScrollInProgress() const +{ + return m_mainTabBarWidget->scrollBar()->isScrolling() || m_pinnedTabBarWidget->scrollBar()->isScrolling(); +} + bool ComboTabBar::isMainBarOverflowed() const { return m_mainBarOverFlowed; @@ -1281,6 +1305,11 @@ TabScrollBar::~TabScrollBar() { } +bool TabScrollBar::isScrolling() const +{ + return m_animation->state() == QPropertyAnimation::Running; +} + void TabScrollBar::animateToValue(int to, QEasingCurve::Type type) { to = qBound(minimum(), to, maximum()); diff --git a/src/lib/tabwidget/combotabbar.h b/src/lib/tabwidget/combotabbar.h index 184a726a6..0938eb264 100644 --- a/src/lib/tabwidget/combotabbar.h +++ b/src/lib/tabwidget/combotabbar.h @@ -133,6 +133,7 @@ public: void setUsesScrollButtons(bool useButtons); bool isDragInProgress() const; + bool isScrollInProgress() const; bool isMainBarOverflowed() const; // Width of all widgets in the corner @@ -165,6 +166,7 @@ protected: int mainTabBarWidth() const; int pinTabBarWidth() const; + bool event(QEvent *event); void wheelEvent(QWheelEvent* event); void showEvent(QShowEvent* event); void enterEvent(QEvent* event); @@ -266,9 +268,10 @@ class QUPZILLA_EXPORT TabScrollBar : public QScrollBar Q_OBJECT public: explicit TabScrollBar(QWidget* parent = 0); - ~TabScrollBar(); + bool isScrolling() const; + void animateToValue(int to, QEasingCurve::Type type = QEasingCurve::OutQuad); private: diff --git a/src/lib/tabwidget/tabbar.cpp b/src/lib/tabwidget/tabbar.cpp index 27bff4455..34ac0f00f 100644 --- a/src/lib/tabwidget/tabbar.cpp +++ b/src/lib/tabwidget/tabbar.cpp @@ -37,7 +37,6 @@ #include #include #include -#include TabBar::TabBar(BrowserWindow* window, TabWidget* tabWidget) : ComboTabBar() @@ -586,27 +585,6 @@ void TabBar::mouseReleaseEvent(QMouseEvent* event) ComboTabBar::mouseReleaseEvent(event); } -bool TabBar::event(QEvent* event) -{ - switch (event->type()) { - case QEvent::ToolTip: - if (!isDragInProgress()) { - QHelpEvent* ev = static_cast(event); - int index = tabAt(ev->pos()); - - if (index >= 0) { - QToolTip::showText(mapToGlobal(ev->pos()), tabToolTip(index)); - } - } - break; - - default: - break; - } - - return ComboTabBar::event(event); -} - void TabBar::wheelEvent(QWheelEvent* event) { if (mApp->plugins()->processWheelEvent(Qz::ON_TabBar, this, event)) { diff --git a/src/lib/tabwidget/tabbar.h b/src/lib/tabwidget/tabbar.h index 86191aebc..cc2048fa9 100644 --- a/src/lib/tabwidget/tabbar.h +++ b/src/lib/tabwidget/tabbar.h @@ -88,7 +88,6 @@ private: void mousePressEvent(QMouseEvent* event); void mouseMoveEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event); - bool event(QEvent* event); void dragEnterEvent(QDragEnterEvent* event); void dropEvent(QDropEvent* event);