From bcb633fcd02f22253f510e0521ecaa90dc86fb2c Mon Sep 17 00:00:00 2001 From: David Rosca Date: Sat, 28 Jan 2017 10:31:45 +0100 Subject: [PATCH] TabBar: Use correct duration for showing add tab button after releasing dragged tab --- src/lib/tabwidget/combotabbar.cpp | 12 ++++++++---- src/lib/tabwidget/combotabbar.h | 3 +++ src/lib/tabwidget/tabbar.cpp | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/lib/tabwidget/combotabbar.cpp b/src/lib/tabwidget/combotabbar.cpp index 0caa64ee1..572adb396 100644 --- a/src/lib/tabwidget/combotabbar.cpp +++ b/src/lib/tabwidget/combotabbar.cpp @@ -36,9 +36,6 @@ #include #include -// taken from qtabbar_p.h -#define ANIMATION_DURATION 250 - ComboTabBar::ComboTabBar(QWidget* parent) : QWidget(parent) , m_mainTabBar(0) @@ -842,6 +839,13 @@ void ComboTabBar::addCornerWidget(QWidget* widget, Qt::Corner corner) } } +// static +int ComboTabBar::slideAnimationDuration() +{ + // taken from qtabbar_p.h + return 250; +} + void ComboTabBar::ensureVisible(int index, int xmargin) { if (index == -1) { @@ -1234,7 +1238,7 @@ void TabBarHelper::mouseReleaseEvent(QMouseEvent* event) QTabBar::mouseReleaseEvent(event); if (m_pressedIndex >= 0 && m_pressedIndex < count()) { - QTimer::singleShot(ANIMATION_DURATION, this, &TabBarHelper::resetDragState); + QTimer::singleShot(ComboTabBar::slideAnimationDuration(), this, &TabBarHelper::resetDragState); m_pressedIndex = -1; m_pressedGlobalX = -1; diff --git a/src/lib/tabwidget/combotabbar.h b/src/lib/tabwidget/combotabbar.h index 902c2bf4c..84afe5c0b 100644 --- a/src/lib/tabwidget/combotabbar.h +++ b/src/lib/tabwidget/combotabbar.h @@ -145,6 +145,9 @@ public: // Add widget to the left/right corner void addCornerWidget(QWidget* widget, Qt::Corner corner); + // Duration of tab slide animation when releasing dragged tab + static int slideAnimationDuration(); + public slots: void setUpLayout(); void ensureVisible(int index = -1, int xmargin = -1); diff --git a/src/lib/tabwidget/tabbar.cpp b/src/lib/tabwidget/tabbar.cpp index 7588e6820..9bee62964 100644 --- a/src/lib/tabwidget/tabbar.cpp +++ b/src/lib/tabwidget/tabbar.cpp @@ -584,7 +584,7 @@ void TabBar::mouseReleaseEvent(QMouseEvent* event) } if (m_tabWidget->buttonAddTab()->isHidden() && !isMainBarOverflowed()) { - QTimer::singleShot(500, m_tabWidget->buttonAddTab(), SLOT(show())); + QTimer::singleShot(ComboTabBar::slideAnimationDuration(), m_tabWidget->buttonAddTab(), &AddTabButton::show); } if (!rect().contains(event->pos())) {