1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 17:52:10 +02:00

TabBar: Use correct duration for showing add tab button after releasing dragged tab

This commit is contained in:
David Rosca 2017-01-28 10:31:45 +01:00
parent 60e272862a
commit bcb633fcd0
3 changed files with 12 additions and 5 deletions

View File

@ -36,9 +36,6 @@
#include <QApplication> #include <QApplication>
#include <QToolTip> #include <QToolTip>
// taken from qtabbar_p.h
#define ANIMATION_DURATION 250
ComboTabBar::ComboTabBar(QWidget* parent) ComboTabBar::ComboTabBar(QWidget* parent)
: QWidget(parent) : QWidget(parent)
, m_mainTabBar(0) , 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) void ComboTabBar::ensureVisible(int index, int xmargin)
{ {
if (index == -1) { if (index == -1) {
@ -1234,7 +1238,7 @@ void TabBarHelper::mouseReleaseEvent(QMouseEvent* event)
QTabBar::mouseReleaseEvent(event); QTabBar::mouseReleaseEvent(event);
if (m_pressedIndex >= 0 && m_pressedIndex < count()) { 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_pressedIndex = -1;
m_pressedGlobalX = -1; m_pressedGlobalX = -1;

View File

@ -145,6 +145,9 @@ public:
// Add widget to the left/right corner // Add widget to the left/right corner
void addCornerWidget(QWidget* widget, Qt::Corner corner); void addCornerWidget(QWidget* widget, Qt::Corner corner);
// Duration of tab slide animation when releasing dragged tab
static int slideAnimationDuration();
public slots: public slots:
void setUpLayout(); void setUpLayout();
void ensureVisible(int index = -1, int xmargin = -1); void ensureVisible(int index = -1, int xmargin = -1);

View File

@ -584,7 +584,7 @@ void TabBar::mouseReleaseEvent(QMouseEvent* event)
} }
if (m_tabWidget->buttonAddTab()->isHidden() && !isMainBarOverflowed()) { 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())) { if (!rect().contains(event->pos())) {