summaryrefslogtreecommitdiffstats
path: root/src/gui/styles/qgtkstyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/styles/qgtkstyle.cpp')
-rw-r--r--src/gui/styles/qgtkstyle.cpp56
1 files changed, 41 insertions, 15 deletions
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index 5465c7b..b59a033 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -67,6 +67,7 @@
#include <QtGui/QRadioButton>
#include <QtGui/QCheckBox>
#include <QtGui/QTreeView>
+#include <QtGui/QStyledItemDelegate>
#include <qpixmapcache.h>
#undef signals // Collides with GTK stymbols
#include <private/qgtkpainter_p.h>
@@ -817,24 +818,49 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
option->state & State_Open ? openState : closedState , gtkTreeView->style);
}
break;
+
+ case PE_PanelItemViewRow:
+ // This primitive is only used to draw selection behind selected expander arrows.
+ // We try not to decorate the tree branch background unless you inherit from StyledItemDelegate
+ // The reason for this is that a lot of code that relies on custom item delegates will look odd having
+ // a gradient on the branch but a flat shaded color on the item itself.
+ QCommonStyle::drawPrimitive(element, option, painter, widget);
+ if (!option->state & State_Selected) {
+ break;
+ } else {
+ if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(widget)) {
+ if (!qobject_cast<QStyledItemDelegate*>(view->itemDelegate()))
+ break;
+ }
+ } // fall through
+
case PE_PanelItemViewItem:
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
- if (vopt->state & State_Selected) {
- QLinearGradient gradient;
- gradient.setStart(option->rect.left(), option->rect.top());
- gradient.setFinalStop(option->rect.left(), option->rect.bottom());
- gradient.setColorAt(0, option->palette.highlight().color().lighter(105));
- gradient.setColorAt(0.5, option->palette.highlight().color().lighter(101));
- gradient.setColorAt(0.51, option->palette.highlight().color().darker(101));
- gradient.setColorAt(1, option->palette.highlight().color().darker(105));
- painter->fillRect(option->rect, gradient);
- } else {
- if (vopt->backgroundBrush.style() != Qt::NoBrush) {
- QPointF oldBO = painter->brushOrigin();
- painter->setBrushOrigin(vopt->rect.topLeft());
- painter->fillRect(vopt->rect, vopt->backgroundBrush);
- painter->setBrushOrigin(oldBO);
+ if (vopt->backgroundBrush.style() != Qt::NoBrush) {
+ QPointF oldBO = painter->brushOrigin();
+ painter->setBrushOrigin(vopt->rect.topLeft());
+ painter->fillRect(vopt->rect, vopt->backgroundBrush);
+ painter->setBrushOrigin(oldBO);
+ if (!(option->state & State_Selected))
+ break;
+ }
+ if (GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView")) {
+ const char *detail = "cell_even_ruled";
+ if (vopt && vopt->features & QStyleOptionViewItemV2::Alternate)
+ detail = "cell_odd_ruled";
+ bool isActive = option->state & State_Active;
+ QString key;
+ if (isActive ) {
+ // Required for active/non-active window appearance
+ key = QLS("a");
+ GTK_WIDGET_SET_FLAGS(gtkTreeView, GTK_HAS_FOCUS);
}
+ gtkPainter.paintFlatBox(gtkTreeView, detail, option->rect,
+ option->state & State_Selected ? GTK_STATE_SELECTED :
+ option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
+ GTK_SHADOW_OUT, gtkTreeView->style, key);
+ if (isActive )
+ GTK_WIDGET_UNSET_FLAGS(gtkTreeView, GTK_HAS_FOCUS);
}
}
break;