Changeset View
Changeset View
Standalone View
Standalone View
icons/CategoryDrawer.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 37 | { | |||
---|---|---|---|---|---|
43 | 43 | | |||
44 | const QRect optRect = option.rect; | 44 | const QRect optRect = option.rect; | ||
45 | QFont font(QApplication::font()); | 45 | QFont font(QApplication::font()); | ||
46 | font.setBold(true); | 46 | font.setBold(true); | ||
47 | const QFontMetrics fontMetrics = QFontMetrics(font); | 47 | const QFontMetrics fontMetrics = QFontMetrics(font); | ||
48 | const int height = categoryHeight(index, option); | 48 | const int height = categoryHeight(index, option); | ||
49 | const bool leftToRight = painter->layoutDirection() == Qt::LeftToRight; | 49 | const bool leftToRight = painter->layoutDirection() == Qt::LeftToRight; | ||
50 | 50 | | |||
51 | //BEGIN: decoration gradient | | |||
52 | { | | |||
53 | QPainterPath path(optRect.bottomLeft()); | | |||
54 | | ||||
55 | path.lineTo(QPoint(optRect.topLeft().x(), optRect.topLeft().y() - 3)); | | |||
56 | const QPointF topLeft(optRect.topLeft()); | | |||
57 | QRectF arc(topLeft, QSizeF(4, 4)); | | |||
58 | path.arcTo(arc, 180, -90); | | |||
59 | path.lineTo(optRect.topRight()); | | |||
60 | path.lineTo(optRect.bottomRight()); | | |||
61 | path.lineTo(optRect.bottomLeft()); | | |||
62 | | ||||
63 | QColor window(option.palette.window().color()); | | |||
64 | const QColor base(option.palette.base().color()); | | |||
65 | | ||||
66 | window.setAlphaF(0.4); | | |||
67 | | ||||
68 | QLinearGradient decoGradient1; | | |||
69 | if (leftToRight) { | | |||
70 | decoGradient1.setStart(optRect.topLeft()); | | |||
71 | decoGradient1.setFinalStop(optRect.bottomLeft()); | | |||
72 | } else { | | |||
73 | decoGradient1.setStart(optRect.topRight()); | | |||
74 | decoGradient1.setFinalStop(optRect.bottomRight()); | | |||
75 | } | | |||
76 | decoGradient1.setColorAt(0, window); | | |||
77 | decoGradient1.setColorAt(1, Qt::transparent); | | |||
78 | | ||||
79 | QLinearGradient decoGradient2; | | |||
80 | if (leftToRight) { | | |||
81 | decoGradient2.setStart(optRect.topLeft()); | | |||
82 | decoGradient2.setFinalStop(optRect.topRight()); | | |||
83 | } else { | | |||
84 | decoGradient2.setStart(optRect.topRight()); | | |||
85 | decoGradient2.setFinalStop(optRect.topLeft()); | | |||
86 | } | | |||
87 | decoGradient2.setColorAt(0, Qt::transparent); | | |||
88 | decoGradient2.setColorAt(1, base); | | |||
89 | | ||||
90 | painter->fillPath(path, decoGradient1); | | |||
91 | painter->fillPath(path, decoGradient2); | | |||
92 | } | | |||
93 | //END: decoration gradient | | |||
94 | | ||||
95 | { | 51 | { | ||
96 | QRect newOptRect(optRect); | 52 | QRect newOptRect(optRect); | ||
97 | 53 | | |||
98 | if (leftToRight) { | 54 | if (leftToRight) { | ||
99 | newOptRect.translate(1, 1); | 55 | newOptRect.translate(1, 1); | ||
100 | } else { | 56 | } else { | ||
101 | newOptRect.translate(-1, 1); | 57 | newOptRect.translate(-1, 1); | ||
102 | } | 58 | } | ||
▲ Show 20 Lines • Show All 182 Lines • Show Last 20 Lines |