From 15215cf154c7d31f1520c259529b719b1fe84b48 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 16 Mar 2011 23:48:39 +0100 Subject: Set an option to disable the disable graphics effects on the tabbar highlight animation. CCBUG:267234 To see if this really works, please deselect the "animated tab highlights" in the Tabs Settings section --- src/application.cpp | 2 ++ src/rekonq.kcfg | 3 ++ src/settings/settings_tabs.ui | 7 ++++ src/tabbar.cpp | 75 +++++++++++++++++++++++++++++++------------ src/tabbar.h | 1 + 5 files changed, 67 insertions(+), 21 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index 1813d798..b1712d3e 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -443,6 +443,8 @@ void Application::updateConfiguration() MainView *mv = w.data()->mainView(); mv->updateTabBar(); + mv->tabBar()->setAnimatedTabHighlighting( ReKonfig::animatedTabHighlighting() ); + if (b) mv->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); else diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index 8795104c..dba770b6 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -126,6 +126,9 @@ false + + true + diff --git a/src/settings/settings_tabs.ui b/src/settings/settings_tabs.ui index 0edc5cae..eb775d5d 100644 --- a/src/settings/settings_tabs.ui +++ b/src/settings/settings_tabs.ui @@ -221,6 +221,13 @@ + + + + Animated tab highlighting + + + diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 118bba45..557fae96 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -70,12 +70,12 @@ static inline QByteArray highlightPropertyName(int index) TabBar::TabBar(QWidget *parent) - : KTabBar(parent) - , m_actualIndex(-1) - , m_currentTabPreviewIndex(-1) - , m_isFirstTimeOnTab(true) - , m_tabHighlightEffect(new TabHighlightEffect(this)) - , m_animationMapper(new QSignalMapper(this)) + : KTabBar(parent) + , m_actualIndex(-1) + , m_currentTabPreviewIndex(-1) + , m_isFirstTimeOnTab(true) + , m_tabHighlightEffect(new TabHighlightEffect(this)) + , m_animationMapper(new QSignalMapper(this)) { setElideMode(Qt::ElideRight); @@ -90,6 +90,8 @@ TabBar::TabBar(QWidget *parent) connect(m_animationMapper, SIGNAL(mapped(int)), this, SLOT(removeAnimation(int))); setGraphicsEffect(m_tabHighlightEffect); + + setAnimatedTabHighlighting( ReKonfig::animatedTabHighlighting() ); } @@ -361,7 +363,9 @@ void TabBar::tabRemoved(int index) m_currentTabPreviewIndex = -1; } - removeAnimation(index); + if (ReKonfig::animatedTabHighlighting()) + removeAnimation(index); + m_tabHighlightEffect->update(); } @@ -420,19 +424,23 @@ void TabBar::setTabHighlighted(int index) if (tabTextColor(index) != highlightColor) { - m_tabHighlightEffect->setProperty(propertyName, qreal(0.9)); - QPropertyAnimation *anim = new QPropertyAnimation(m_tabHighlightEffect, propertyName); - m_highlightAnimation.insert(propertyName, anim); - - //setup the animation - anim->setStartValue(0.9); - anim->setEndValue(0.0); - anim->setDuration(500); - anim->setLoopCount(2); - anim->start(QAbstractAnimation::DeleteWhenStopped); - - m_animationMapper->setMapping(anim, index); - connect(anim, SIGNAL(finished()), m_animationMapper, SLOT(map())); + if (ReKonfig::animatedTabHighlighting) + { + m_tabHighlightEffect->setProperty(propertyName, qreal(0.9)); + QPropertyAnimation *anim = new QPropertyAnimation(m_tabHighlightEffect, propertyName); + m_highlightAnimation.insert(propertyName, anim); + + //setup the animation + anim->setStartValue(0.9); + anim->setEndValue(0.0); + anim->setDuration(500); + anim->setLoopCount(2); + anim->start(QAbstractAnimation::DeleteWhenStopped); + + m_animationMapper->setMapping(anim, index); + connect(anim, SIGNAL(finished()), m_animationMapper, SLOT(map())); + } + setTabTextColor(index, highlightColor); } } @@ -440,7 +448,9 @@ void TabBar::setTabHighlighted(int index) void TabBar::resetTabHighlighted(int index) { - removeAnimation(index); + if (ReKonfig::animatedTabHighlighting()) + removeAnimation(index); + setTabTextColor(index, palette().text().color()); } @@ -454,3 +464,26 @@ void TabBar::removeAnimation(int index) m_animationMapper->removeMappings(anim); delete anim; } + + +void TabBar::setAnimatedTabHighlighting(bool enabled) +{ + if (enabled) + m_tabHighlightEffect->setEnabled(true); + else + { + m_tabHighlightEffect->setEnabled(false); + + //cleanup + QHashIterator i(m_highlightAnimation); + while (i.hasNext()) + { + i.next(); + m_tabHighlightEffect->setProperty(i.key(), QVariant()); //destroy the property + + QPropertyAnimation *anim = m_highlightAnimation.take(i.key()); + m_animationMapper->removeMappings(anim); + delete anim; + } + } +} diff --git a/src/tabbar.h b/src/tabbar.h index 58516f14..0137065d 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -61,6 +61,7 @@ public: void setTabHighlighted(int index); void resetTabHighlighted(int index); QRect tabTextRect(int index); + void setAnimatedTabHighlighting(bool enabled); signals: void cloneTab(int index); -- cgit v1.2.1