From fc669e0bf82018baa70a8b59529e1a571d5ad820 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 10 Feb 2011 19:05:45 +0100 Subject: highlights inactive tabs if title changes Courtesy patch by Johannes Troscher. Thanks :) Reviewed by: adjam Reviewed by: elproxy --- src/tabbar.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'src/tabbar.cpp') diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 7a8419a3..655b93c0 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -41,18 +41,22 @@ #include "webpage.h" #include "webtab.h" #include "websnap.h" +#include "tabhighlighteffect.h" // KDE Includes #include #include #include #include +#include // Qt Includes #include #include #include #include +#include +#include #define BASE_WIDTH_DIVISOR 4 @@ -64,6 +68,7 @@ TabBar::TabBar(QWidget *parent) , m_actualIndex(-1) , m_currentTabPreviewIndex(-1) , m_isFirstTimeOnTab(true) + , m_tabHighlightEffect(new TabHighlightEffect(this)) { setElideMode(Qt::ElideRight); @@ -75,6 +80,8 @@ TabBar::TabBar(QWidget *parent) connect(this, SIGNAL(contextMenu(int, const QPoint &)), this, SLOT(contextMenu(int, const QPoint &))); connect(this, SIGNAL(emptyAreaContextMenu(const QPoint &)), this, SLOT(emptyAreaContextMenu(const QPoint &))); + + setGraphicsEffect(m_tabHighlightEffect); } @@ -351,7 +358,7 @@ void TabBar::mouseReleaseEvent(QMouseEvent *event) } -void TabBar::tabRemoved(int /*index*/) +void TabBar::tabRemoved(int index) { if (ReKonfig::hoveringTabOption() == 0) { @@ -361,6 +368,9 @@ void TabBar::tabRemoved(int /*index*/) } m_currentTabPreviewIndex = -1; } + + QString propertyName = QString("hAnim").append(QString::number(index)); + setProperty(propertyName.toAscii(), QVariant()); //destroy property } @@ -394,3 +404,36 @@ void TabBar::setupHistoryActions() am->addAction(a); } } + + +QRect TabBar::tabTextRect(int index) +{ + QStyleOptionTabV3 option; + initStyleOption(&option, index); + return style()->subElementRect(QStyle::SE_TabBarTabText, &option, this); +} + + +void TabBar::setTabHighlighted(int index, bool highlighted) +{ + QString propertyName = QString("hAnim").append(QString::number(index)); + if (highlighted) + { + m_tabHighlightEffect->setProperty(propertyName.toAscii(), qreal(0.9)); + QPropertyAnimation *highlightAnimation = new QPropertyAnimation(m_tabHighlightEffect, propertyName.toAscii()); + + //setup the animation + highlightAnimation->setStartValue(0.9); + highlightAnimation->setEndValue(0.0); + highlightAnimation->setDuration(500); + highlightAnimation->setLoopCount(2); + highlightAnimation->start(QAbstractAnimation::DeleteWhenStopped); + + setTabTextColor(index, KColorScheme(QPalette::Active, KColorScheme::Window).foreground(KColorScheme::PositiveText).color()); + } + else + { + m_tabHighlightEffect->setProperty(propertyName.toAscii(), QVariant()); //destroy the property + setTabTextColor(index, QApplication::palette().text().color()); + } +} \ No newline at end of file -- cgit v1.2.1