From 3300735fe4710d7cf9d4fedbc965a80c56721f1a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 22 Jan 2011 18:59:55 +0100 Subject: Fix tab preview flickering on mouse hover. Patch by Furkan Uzumcu, cleaned up and reviewed by me --- src/tabbar.cpp | 12 +++++++++++- src/tabbar.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tabbar.cpp b/src/tabbar.cpp index fcc7b789..7a8419a3 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -54,6 +54,7 @@ #include #include + #define BASE_WIDTH_DIVISOR 4 #define MIN_WIDTH_DIVISOR 8 @@ -62,6 +63,7 @@ TabBar::TabBar(QWidget *parent) : KTabBar(parent) , m_actualIndex(-1) , m_currentTabPreviewIndex(-1) + , m_isFirstTimeOnTab(true) { setElideMode(Qt::ElideRight); @@ -146,6 +148,9 @@ void TabBar::detachTab() void TabBar::showTabPreview() { + if(m_isFirstTimeOnTab) + m_isFirstTimeOnTab = false; + //delete previous tab preview delete m_previewPopup.data(); m_previewPopup.clear(); @@ -232,7 +237,11 @@ void TabBar::mouseMoveEvent(QMouseEvent *event) ) { m_currentTabPreviewIndex = tabIndex; - QTimer::singleShot(200, this, SLOT( showTabPreview() ) ); + + // if first time over tab, apply a small delay. If not, show it now! + m_isFirstTimeOnTab + ? QTimer::singleShot(200, this, SLOT(showTabPreview())) + : showTabPreview(); } // if current tab or not found then hide previous tab preview @@ -258,6 +267,7 @@ void TabBar::leaveEvent(QEvent *event) m_previewPopup.data()->hide(); } m_currentTabPreviewIndex = -1; + m_isFirstTimeOnTab = true; } KTabBar::leaveEvent(event); diff --git a/src/tabbar.h b/src/tabbar.h index 41707865..b505f78b 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -103,6 +103,7 @@ private: * the index of the tab preview shown */ int m_currentTabPreviewIndex; + bool m_isFirstTimeOnTab; }; #endif -- cgit v1.2.1