┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kcategorydrawer.cpp
diff options
context:
space:
mode:
authorRafael Fernández López <[email protected]>2007-09-17 06:03:40 +0000
committerRafael Fernández López <[email protected]>2007-09-17 06:03:40 +0000
commitb3db0a708a630d9f59857ab7dcbfe8f29e3e8eb9 (patch)
tree625306a1db97804e096591ad92a54350c73f2e6c /src/kcategorydrawer.cpp
parent3c77e0f7204dcc7933b2f91ed462d61e92301b29 (diff)
Give feedback to user when clicking on a category and the user is not dragging from it. Beauty, come to me :)
CCMAIL: [email protected] svn path=/trunk/KDE/kdebase/apps/; revision=713337
Diffstat (limited to 'src/kcategorydrawer.cpp')
-rw-r--r--src/kcategorydrawer.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/kcategorydrawer.cpp b/src/kcategorydrawer.cpp
index 4c59864a0..56c538d4e 100644
--- a/src/kcategorydrawer.cpp
+++ b/src/kcategorydrawer.cpp
@@ -40,7 +40,16 @@ void KCategoryDrawer::drawCategory(const QModelIndex &index,
{
const QString category = index.model()->data(index, KCategorizedSortFilterProxyModel::CategoryRole).toString();
- QColor color = option.palette.color(QPalette::Text);
+ QColor color;
+
+ if (option.state & QStyle::State_Selected)
+ {
+ color = option.palette.color(QPalette::HighlightedText);
+ }
+ else
+ {
+ color = option.palette.color(QPalette::Text);
+ }
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
@@ -52,18 +61,30 @@ void KCategoryDrawer::drawCategory(const QModelIndex &index,
opt.direction = option.direction;
opt.text = category;
- if (option.state & QStyle::State_MouseOver)
+ if (option.state & QStyle::State_Selected)
+ {
+ QColor selected = option.palette.color(QPalette::Highlight);
+
+ QLinearGradient gradient(option.rect.topLeft(),
+ option.rect.bottomRight());
+ gradient.setColorAt(option.direction == Qt::LeftToRight ? 0
+ : 1, selected);
+ gradient.setColorAt(option.direction == Qt::LeftToRight ? 1
+ : 0, Qt::transparent);
+
+ painter->fillRect(option.rect, gradient);
+ }
+ else if (option.state & QStyle::State_MouseOver)
{
- const QPalette::ColorGroup group =
- option.state & QStyle::State_Enabled ?
- QPalette::Normal : QPalette::Disabled;
+ QColor hover = option.palette.color(QPalette::Highlight).light();
+ hover.setAlpha(88);
QLinearGradient gradient(option.rect.topLeft(),
option.rect.bottomRight());
- gradient.setColorAt(0,
- option.palette.color(group,
- QPalette::Highlight).light());
- gradient.setColorAt(1, Qt::transparent);
+ gradient.setColorAt(option.direction == Qt::LeftToRight ? 0
+ : 1, hover);
+ gradient.setColorAt(option.direction == Qt::LeftToRight ? 1
+ : 0, Qt::transparent);
painter->fillRect(option.rect, gradient);
}