1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

ComboTabBar: Fix showing tooltip when animating scrolling

This commit is contained in:
David Rosca 2015-10-11 10:51:16 +02:00
parent c0a7ef8d9e
commit 53e4512d31
4 changed files with 33 additions and 24 deletions

View File

@ -34,6 +34,7 @@
#include <QTabBar>
#include <QMouseEvent>
#include <QApplication>
#include <QToolTip>
// 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());

View File

@ -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:

View File

@ -37,7 +37,6 @@
#include <QLabel>
#include <QScrollArea>
#include <QHBoxLayout>
#include <QToolTip>
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<QHelpEvent*>(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)) {

View File

@ -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);