┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
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
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
-rw-r--r--src/dolphincategorydrawer.cpp26
-rw-r--r--src/kcategorizedview.cpp15
-rw-r--r--src/kcategorydrawer.cpp39
3 files changed, 69 insertions, 11 deletions
diff --git a/src/dolphincategorydrawer.cpp b/src/dolphincategorydrawer.cpp
index 039b395a4..42f55f473 100644
--- a/src/dolphincategorydrawer.cpp
+++ b/src/dolphincategorydrawer.cpp
@@ -62,7 +62,16 @@ void DolphinCategoryDrawer::drawCategory(const QModelIndex &index, int sortRole,
const QString category = categoryVariant.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);
@@ -74,7 +83,20 @@ void DolphinCategoryDrawer::drawCategory(const QModelIndex &index, int sortRole,
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)
{
QColor hover = option.palette.color(QPalette::Highlight).light();
hover.setAlpha(88);
diff --git a/src/kcategorizedview.cpp b/src/kcategorizedview.cpp
index 7bc0055ae..026f56c24 100644
--- a/src/kcategorizedview.cpp
+++ b/src/kcategorizedview.cpp
@@ -357,10 +357,23 @@ void KCategorizedView::Private::drawNewCategory(const QModelIndex &index,
QStyleOption optionCopy = option;
const QString category = proxyModel->data(index, KCategorizedSortFilterProxyModel::CategoryRole).toString();
+ optionCopy.state &= ~QStyle::State_Selected;
+
if ((category == hoveredCategory) && !mouseButtonPressed)
{
optionCopy.state |= QStyle::State_MouseOver;
}
+ else if ((category == hoveredCategory) && mouseButtonPressed)
+ {
+ QPoint initialPressPosition = listView->viewport()->mapFromGlobal(QCursor::pos());
+ initialPressPosition.setY(initialPressPosition.y() + listView->verticalOffset());
+ initialPressPosition.setX(initialPressPosition.x() + listView->horizontalOffset());
+
+ if (initialPressPosition == this->initialPressPosition)
+ {
+ optionCopy.state |= QStyle::State_Selected;
+ }
+ }
categoryDrawer->drawCategory(index,
sortRole,
@@ -891,6 +904,8 @@ void KCategorizedView::mousePressEvent(QMouseEvent *event)
}
QListView::mousePressEvent(event);
+
+ viewport()->update(d->categoryVisualRect(d->hoveredCategory));
}
void KCategorizedView::mouseReleaseEvent(QMouseEvent *event)
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);
}