┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-10-10 23:26:08 +0200
committerPeter Penz <[email protected]>2011-10-10 23:30:33 +0200
commitd7c4fdedd0dcca4465eaf68a1904cde46c33a74c (patch)
tree283699f8c414a7b771910180fd5ee5d16c3cd81d /src
parent90e39e3116b5821addce8035b82619b726a49eab (diff)
Remove workaround to draw the focus indicator manually
In Oxygen the focus-indicator has only been drawn for widget instances derived from QAbstractItemView and Q3ListView, so it was not possible in Dolphin to use the style for drawing. This has been fixed now in Oxygen, so using the style works now. The custom code for drawing the text background will be removed and replaced by a style-code later. CCMAIL: [email protected]
Diffstat (limited to 'src')
-rw-r--r--src/kitemviews/kitemlistwidget.cpp32
-rw-r--r--src/kitemviews/kitemlistwidget.h1
2 files changed, 6 insertions, 27 deletions
diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp
index 5aa6e1baa..025b8e883 100644
--- a/src/kitemviews/kitemlistwidget.cpp
+++ b/src/kitemviews/kitemlistwidget.cpp
@@ -117,7 +117,12 @@ void KItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* o
}
if (isCurrent()) {
- drawFocusIndicator(painter);
+ QStyleOptionViewItemV4 viewItemOption;
+ viewItemOption.initFrom(widget);
+ viewItemOption.rect = textBoundingRect().toRect();
+ viewItemOption.state = QStyle::State_Enabled | QStyle::State_Item;
+ viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne;
+ style()->drawPrimitive(QStyle::PE_FrameFocusRect, &viewItemOption, painter, widget);
}
if (m_hoverOpacity <= 0.0) {
@@ -357,31 +362,6 @@ void KItemListWidget::clearHoverCache()
m_hoverCache = 0;
}
-void KItemListWidget::drawFocusIndicator(QPainter* painter)
-{
- // Ideally style()->drawPrimitive(QStyle::PE_FrameFocusRect...)
- // should be used, but Oxygen only draws indicators within classes
- // derived from QAbstractItemView or Q3ListView. As a workaround
- // the indicator is drawn manually. Code copied from oxygenstyle.cpp
- // Copyright ( C ) 2009-2010 Hugo Pereira Da Costa <[email protected]>
- // TODO: Clarify with Oxygen maintainers how to proceed with this.
-
- const KItemListStyleOption& option = styleOption();
- const QPalette palette = option.palette;
- const QRect rect = textBoundingRect().toRect().adjusted(0, 0, 0, -1);
-
- QLinearGradient gradient(rect.bottomLeft(), rect.bottomRight());
- gradient.setColorAt(0.0, Qt::transparent);
- gradient.setColorAt(1.0, Qt::transparent);
- gradient.setColorAt(0.2, palette.color(QPalette::Text));
- gradient.setColorAt(0.8, palette.color(QPalette::Text));
-
- painter->setRenderHint(QPainter::Antialiasing, false);
- painter->setPen(QPen(gradient, 1));
- painter->drawLine(rect.bottomLeft(), rect.bottomRight());
- painter->setRenderHint(QPainter::Antialiasing, true);
-}
-
void KItemListWidget::drawTextBackground(QPainter* painter)
{
const qreal opacity = painter->opacity();
diff --git a/src/kitemviews/kitemlistwidget.h b/src/kitemviews/kitemlistwidget.h
index b1df7bff4..eae4c39da 100644
--- a/src/kitemviews/kitemlistwidget.h
+++ b/src/kitemviews/kitemlistwidget.h
@@ -132,7 +132,6 @@ protected:
private:
void setHoverOpacity(qreal opacity);
void clearHoverCache();
- void drawFocusIndicator(QPainter* painter);
void drawTextBackground(QPainter* painter);
private: