Changeset View
Changeset View
Standalone View
Standalone View
krusader/GUI/krstyleproxy.cpp
Show All 29 Lines | |||||
30 | 30 | | |||
31 | #include "krstyleproxy.h" | 31 | #include "krstyleproxy.h" | ||
32 | 32 | | |||
33 | // QtGui | 33 | // QtGui | ||
34 | #include <QPen> | 34 | #include <QPen> | ||
35 | #include <QPainter> | 35 | #include <QPainter> | ||
36 | // QtWidgets | 36 | // QtWidgets | ||
37 | #include <QStyleOptionViewItem> | 37 | #include <QStyleOptionViewItem> | ||
38 | #include <QApplication> | | |||
39 | 38 | | |||
40 | void KrStyleProxy::drawComplexControl(ComplexControl control, const QStyleOptionComplex * option, QPainter * painter, const QWidget * widget) const | 39 | void KrStyleProxy::drawPrimitive(PrimitiveElement element, const QStyleOption *option, | ||
41 | { | 40 | QPainter *painter, const QWidget *widget) const | ||
42 | QApplication::style()->drawComplexControl(control, option, painter, widget); | | |||
43 | } | | |||
44 | | ||||
45 | void KrStyleProxy::drawControl(ControlElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget) const | | |||
46 | { | | |||
47 | QApplication::style()->drawControl(element, option, painter, widget); | | |||
48 | } | | |||
49 | | ||||
50 | void KrStyleProxy::drawItemPixmap(QPainter * painter, const QRect & rectangle, int alignment, const QPixmap & pixmap) const | | |||
51 | { | | |||
52 | QApplication::style()->drawItemPixmap(painter, rectangle, alignment, pixmap); | | |||
53 | } | | |||
54 | | ||||
55 | void KrStyleProxy::drawItemText(QPainter * painter, const QRect & rectangle, int alignment, const QPalette & palette, bool enabled, const QString & text, QPalette::ColorRole textRole) const | | |||
56 | { | | |||
57 | QApplication::style()->drawItemText(painter, rectangle, alignment, palette, enabled, text, textRole); | | |||
58 | } | | |||
59 | | ||||
60 | void KrStyleProxy::drawPrimitive(PrimitiveElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget) const | | |||
61 | { | 41 | { | ||
62 | if (element == QStyle::PE_FrameFocusRect) { | 42 | if (element == QStyle::PE_FrameFocusRect) { | ||
63 | if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(option)) { | 43 | if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(option)) { | ||
64 | QColor bg = fropt->backgroundColor; | 44 | QColor bg = fropt->backgroundColor; | ||
65 | QPen oldPen = painter->pen(); | 45 | QPen oldPen = painter->pen(); | ||
66 | QPen newPen; | 46 | QPen newPen; | ||
67 | if (bg.isValid()) { | 47 | if (bg.isValid()) { | ||
68 | int h, s, v; | 48 | int h, s, v; | ||
69 | bg.getHsv(&h, &s, &v); | 49 | bg.getHsv(&h, &s, &v); | ||
70 | if (v >= 128) | 50 | if (v >= 128) | ||
71 | newPen.setColor(Qt::black); | 51 | newPen.setColor(Qt::black); | ||
72 | else | 52 | else | ||
73 | newPen.setColor(Qt::white); | 53 | newPen.setColor(Qt::white); | ||
74 | } else { | 54 | } else { | ||
75 | newPen.setColor(option->palette.foreground().color()); | 55 | newPen.setColor(option->palette.foreground().color()); | ||
76 | } | 56 | } | ||
77 | newPen.setWidth(0); | 57 | newPen.setWidth(0); | ||
78 | newPen.setStyle(Qt::DotLine); | 58 | newPen.setStyle(Qt::DotLine); | ||
79 | painter->setPen(newPen); | 59 | painter->setPen(newPen); | ||
80 | QRect focusRect = option->rect /*.adjusted(1, 1, -1, -1) */; | 60 | QRect focusRect = option->rect /*.adjusted(1, 1, -1, -1) */; | ||
81 | painter->drawRect(focusRect.adjusted(0, 0, -1, -1)); //draw pen inclusive | 61 | painter->drawRect(focusRect.adjusted(0, 0, -1, -1)); //draw pen inclusive | ||
82 | painter->setPen(oldPen); | 62 | painter->setPen(oldPen); | ||
83 | } | 63 | } | ||
84 | } else | 64 | } else | ||
85 | QApplication::style()->drawPrimitive(element, option, painter, widget); | 65 | QProxyStyle::drawPrimitive(element, option, painter, widget); | ||
86 | } | | |||
87 | | ||||
88 | QPixmap KrStyleProxy::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap & pixmap, const QStyleOption * option) const | | |||
89 | { | | |||
90 | return QApplication::style()->generatedIconPixmap(iconMode, pixmap, option); | | |||
91 | } | | |||
92 | | ||||
93 | QStyle::SubControl KrStyleProxy::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex * option, const QPoint & position, const QWidget * widget) const | | |||
94 | { | | |||
95 | return QApplication::style()->hitTestComplexControl(control, option, position, widget); | | |||
96 | } | | |||
97 | | ||||
98 | QRect KrStyleProxy::itemPixmapRect(const QRect & rectangle, int alignment, const QPixmap & pixmap) const | | |||
99 | { | | |||
100 | return QApplication::style()->itemPixmapRect(rectangle, alignment, pixmap); | | |||
101 | } | | |||
102 | | ||||
103 | QRect KrStyleProxy::itemTextRect(const QFontMetrics & metrics, const QRect & rectangle, int alignment, bool enabled, const QString & text) const | | |||
104 | { | | |||
105 | return QApplication::style()->itemTextRect(metrics, rectangle, alignment, enabled, text); | | |||
106 | } | | |||
107 | | ||||
108 | int KrStyleProxy::layoutSpacing(QSizePolicy::ControlType ctrl1, QSizePolicy::ControlType ctrl2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget) const | | |||
109 | { | | |||
110 | return QApplication::style()->layoutSpacing(ctrl1, ctrl2, orientation, option, widget); | | |||
111 | } | | |||
112 | | ||||
113 | int KrStyleProxy::pixelMetric(PixelMetric metric, const QStyleOption * option, const QWidget * widget) const | | |||
114 | { | | |||
115 | return QApplication::style()->pixelMetric(metric, option, widget); | | |||
116 | } | | |||
117 | | ||||
118 | void KrStyleProxy::polish(QWidget * widget) | | |||
119 | { | | |||
120 | QApplication::style()->polish(widget); | | |||
121 | } | | |||
122 | | ||||
123 | void KrStyleProxy::polish(QApplication * application) | | |||
124 | { | | |||
125 | QApplication::style()->polish(application); | | |||
126 | } | | |||
127 | | ||||
128 | void KrStyleProxy::polish(QPalette & palette) | | |||
129 | { | | |||
130 | QApplication::style()->polish(palette); | | |||
131 | } | | |||
132 | | ||||
133 | QSize KrStyleProxy::sizeFromContents(ContentsType type, const QStyleOption * option, const QSize & contentsSize, const QWidget * widget) const | | |||
134 | { | | |||
135 | return QApplication::style()->sizeFromContents(type, option, contentsSize, widget); | | |||
136 | } | | |||
137 | | ||||
138 | QIcon KrStyleProxy::standardIcon(StandardPixmap stdIcon, const QStyleOption *option, const QWidget *widget) const | | |||
139 | { | | |||
140 | return QApplication::style()->standardIcon(stdIcon, option, widget); | | |||
141 | } | | |||
142 | | ||||
143 | QPalette KrStyleProxy::standardPalette() const | | |||
144 | { | | |||
145 | return QApplication::style()->standardPalette(); | | |||
146 | } | | |||
147 | | ||||
148 | int KrStyleProxy::styleHint(StyleHint hint, const QStyleOption * option, const QWidget * widget, QStyleHintReturn * returnData) const | | |||
149 | { | | |||
150 | return QApplication::style()->styleHint(hint, option, widget, returnData); | | |||
151 | } | | |||
152 | | ||||
153 | QRect KrStyleProxy::subControlRect(ComplexControl control, const QStyleOptionComplex * option, SubControl subControl, const QWidget * widget) const | | |||
154 | { | | |||
155 | return QApplication::style()->subControlRect(control, option, subControl, widget); | | |||
156 | } | | |||
157 | | ||||
158 | QRect KrStyleProxy::subElementRect(SubElement element, const QStyleOption * option, const QWidget * widget) const | | |||
159 | { | | |||
160 | return QApplication::style()->subElementRect(element, option, widget); | | |||
161 | } | | |||
162 | | ||||
163 | QPixmap KrStyleProxy::standardPixmap(QStyle::StandardPixmap pixmap, const QStyleOption* option, const QWidget*widget) const | | |||
164 | { | | |||
165 | return QApplication::style()->standardPixmap(pixmap, option, widget); | | |||
166 | } | | |||
167 | | ||||
168 | void KrStyleProxy::unpolish(QWidget * widget) | | |||
169 | { | | |||
170 | QApplication::style()->unpolish(widget); | | |||
171 | } | | |||
172 | | ||||
173 | void KrStyleProxy::unpolish(QApplication * application) | | |||
174 | { | | |||
175 | QApplication::style()->unpolish(application); | | |||
176 | } | 66 | } |