|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 //Qt includes |
|
22 #include <qapplication.h> |
|
23 #include <qpainter.h> |
|
24 #include <qstyleoption.h> |
|
25 #include <qevent.h> |
|
26 #include <qdebug.h> |
|
27 |
|
28 //Qt widgets |
|
29 #include <QtGui/qgroupbox.h> |
|
30 #include <QtGui/qheaderview.h> |
|
31 #include <QtGui/qlistwidget.h> |
|
32 #include <QtGui/qlistview.h> |
|
33 #include <QtGui/qpushbutton.h> |
|
34 #include <QtGui/qscrollbar.h> |
|
35 #include <QtGui/qtabbar.h> |
|
36 #include <QtGui/qtableview.h> |
|
37 #include <QtGui/qtablewidget.h> |
|
38 #include <QtGui/qtreeview.h> |
|
39 #include <QtGui/qtreewidget.h> |
|
40 #include <QtGui/qtextedit.h> |
|
41 #include <QtGui/qtoolbar.h> |
|
42 #include <QtGui/qtoolbutton.h> |
|
43 #include <QtGui/qradiobutton.h> |
|
44 #include <QtGui/qcheckbox.h> |
|
45 #include <QtGui/qprogressbar.h> |
|
46 #include <QtGui/qcombobox.h> |
|
47 #include <QtGui/qspinbox.h> |
|
48 #include <QtGui/qlineedit.h> |
|
49 |
|
50 //Animation |
|
51 #include <QParallelAnimationGroup> |
|
52 #include <QPropertyAnimation> |
|
53 #include <QTime> |
|
54 |
|
55 //Hb includes |
|
56 #include <hbinstance.h> |
|
57 #include <hbicon.h> |
|
58 #include <hbframedrawer.h> |
|
59 #include <hbstyle.h> |
|
60 #include <hbcolorscheme.h> |
|
61 #include <hbfontspec.h> |
|
62 |
|
63 #include "qhbstyle.h" |
|
64 #include "qhbstyle_p.h" |
|
65 #include "qhbstyleanimation.h" |
|
66 |
|
67 QT_BEGIN_NAMESPACE |
|
68 |
|
69 QHbStylePrivate::QHbStylePrivate() |
|
70 { |
|
71 m_frameDrawer = 0; |
|
72 m_styleManager = 0; |
|
73 |
|
74 m_animationGroup = q_check_ptr(new QParallelAnimationGroup()); |
|
75 } |
|
76 |
|
77 QHbStylePrivate::~QHbStylePrivate() |
|
78 { |
|
79 delete m_frameDrawer; |
|
80 delete m_animationGroup; |
|
81 } |
|
82 |
|
83 HbStyle* QHbStylePrivate::styleManager() |
|
84 { |
|
85 return m_styleManager; |
|
86 } |
|
87 |
|
88 void QHbStylePrivate::setStyleManager(HbStyle* style) |
|
89 { |
|
90 Q_ASSERT(style); |
|
91 m_styleManager = style; |
|
92 } |
|
93 |
|
94 QParallelAnimationGroup* QHbStylePrivate::animationGroup() |
|
95 { |
|
96 return m_animationGroup; |
|
97 } |
|
98 |
|
99 /*! |
|
100 \internal |
|
101 */ |
|
102 QHbStyle::QHbStyle() : QCommonStyle() |
|
103 { |
|
104 m_private = new QHbStylePrivate(); |
|
105 HbInstance *instance = HbInstance::instance(); |
|
106 |
|
107 m_private->setStyleManager(instance->style()); |
|
108 } |
|
109 |
|
110 /*! |
|
111 \internal |
|
112 */ |
|
113 QHbStyle::~QHbStyle() |
|
114 { |
|
115 delete m_private; |
|
116 } |
|
117 |
|
118 void QHbStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, |
|
119 QPainter *painter, const QWidget *widget) const |
|
120 { |
|
121 switch (element) { |
|
122 case PE_IndicatorViewItemCheck: { |
|
123 if (const QStyleOptionViewItemV4 *itemOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
|
124 ItemStates state; |
|
125 if (itemOption->state & State_Selected) |
|
126 state |= SS_Selected; |
|
127 m_private->drawItem(SP_ItemDecoration, painter, option->rect, state); |
|
128 } |
|
129 break; |
|
130 } |
|
131 case PE_IndicatorHeaderArrow: { |
|
132 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
|
133 ItemStates state; |
|
134 if (header->sortIndicator & QStyleOptionHeader::SortDown) |
|
135 m_private->drawItem(SP_HeaderOrderIndicator, painter, header->rect, ItemStates(state|SS_Flipped)); |
|
136 else if (header->sortIndicator & QStyleOptionHeader::SortUp) |
|
137 m_private->drawItem(SP_HeaderOrderIndicator, painter, header->rect, ItemStates(state)); |
|
138 } |
|
139 break; |
|
140 } |
|
141 case PE_IndicatorBranch: { |
|
142 if (option->state & State_Children) { |
|
143 QRect indicatorRect = option->rect; |
|
144 const int rectSide = proxy()->pixelMetric(PM_MenuButtonIndicator, option, widget); |
|
145 indicatorRect = QRect(0, 0, rectSide, rectSide); |
|
146 indicatorRect.moveCenter(option->rect.center()); |
|
147 if (option->state & State_Open) |
|
148 m_private->drawItem(SP_TreeViewExpanded, painter, indicatorRect); |
|
149 else |
|
150 m_private->drawItem(SP_TreeViewCollapsed, painter, indicatorRect); |
|
151 } |
|
152 break; |
|
153 } |
|
154 case PE_PanelItemViewRow: { |
|
155 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
|
156 ItemStates state = SS_Active; |
|
157 if (vopt->state & State_HasFocus) |
|
158 state |= SS_Focused; |
|
159 if (vopt->state & State_Sunken || vopt->state & State_Raised) |
|
160 state |= SS_Pressed; |
|
161 #ifndef QT_NO_TREEVIEW |
|
162 if (qobject_cast<const QTreeWidget*>(widget)) { |
|
163 if (option->state & State_Children) { |
|
164 m_private->drawMultiPartItem(SM_ListParent, painter, vopt->rect, state); |
|
165 break; |
|
166 } |
|
167 } |
|
168 #endif |
|
169 if (vopt->features & QStyleOptionViewItemV2::Alternate) |
|
170 state |= SS_Alternate; //@todo: how? |
|
171 m_private->drawMultiPartItem(SM_ItemViewItem, painter, vopt->rect, state); |
|
172 } |
|
173 break; |
|
174 } |
|
175 case PE_PanelItemViewItem: { |
|
176 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
|
177 ItemStates state = SS_Active; |
|
178 if (vopt->state & State_HasFocus) |
|
179 state |= SS_Focused; |
|
180 if (vopt->state & State_Sunken || vopt->state & State_Raised) |
|
181 state |= SS_Pressed; |
|
182 m_private->drawMultiPartItem(SM_ItemViewItem, painter, vopt->rect, state); |
|
183 } |
|
184 break; |
|
185 } |
|
186 case PE_IndicatorArrowLeft: |
|
187 case PE_IndicatorArrowRight: |
|
188 case PE_IndicatorArrowUp: |
|
189 case PE_IndicatorArrowDown: { |
|
190 ItemStates state; |
|
191 if (element == PE_IndicatorArrowRight) |
|
192 state = SS_Right; |
|
193 else if (element == PE_IndicatorArrowLeft) |
|
194 state = SS_Left; |
|
195 else if (element == PE_IndicatorArrowUp) |
|
196 state = SS_Up; |
|
197 else |
|
198 state = SS_Down; |
|
199 m_private->drawItem(SP_Arrow, painter, option->rect, state); |
|
200 break; |
|
201 } |
|
202 case PE_PanelTipLabel: { |
|
203 m_private->drawMultiPartItem(SM_ToolTip, painter, option->rect); |
|
204 break; |
|
205 } |
|
206 case PE_Frame: { |
|
207 if (const QStyleOptionFrameV3 *frame = qstyleoption_cast<const QStyleOptionFrameV3 *>(option)) { |
|
208 #ifndef QT_NO_TEXTEDIT |
|
209 if (qobject_cast<const QTextEdit *>(widget)) |
|
210 m_private->drawMultiPartItem(SM_TextEdit, painter, frame->rect); |
|
211 #endif //QT_NO_TEXTEDIT |
|
212 } |
|
213 break; |
|
214 } |
|
215 case PE_FrameTabWidget: { |
|
216 m_private->drawMultiPartItem(SM_Panel, painter, option->rect); |
|
217 break; |
|
218 } |
|
219 #ifndef QT_NO_LINEEDIT |
|
220 case PE_PanelLineEdit: { |
|
221 #ifndef QT_NO_COMBOBOX |
|
222 if (widget && qobject_cast<const QComboBox *>(widget->parentWidget())) |
|
223 break; |
|
224 #endif |
|
225 #ifndef QT_NO_SPINBOX |
|
226 if (widget && qobject_cast<const QSpinBox *>(widget->parentWidget())) |
|
227 break; |
|
228 #endif |
|
229 if (const QStyleOptionFrame *lineEdit = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
|
230 ItemStates state = (lineEdit->state & State_Enabled) ? SS_Active : SS_Inactive; |
|
231 if (lineEdit->state & State_HasFocus) |
|
232 state |= SS_Selected; |
|
233 m_private->drawMultiPartItem(SM_LineEdit, painter, lineEdit->rect, state); |
|
234 } |
|
235 break; |
|
236 } |
|
237 #endif // QT_NO_LINEEDIT |
|
238 case PE_PanelButtonTool: { |
|
239 if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
|
240 //draw button |
|
241 const bool isDisabled = !(toolbutton->state & State_Enabled); |
|
242 const bool isPressed = (toolbutton->state & State_Sunken) || |
|
243 (toolbutton->state & State_On); |
|
244 |
|
245 // 'latched' is a checkable button that is pressed down |
|
246 bool isLatched = false; |
|
247 #ifndef QT_NO_TOOLBUTTON |
|
248 if (const QToolButton *toolButtonWidget = qobject_cast<const QToolButton*>(widget)) |
|
249 isLatched = toolButtonWidget->isCheckable() && isPressed; |
|
250 #endif |
|
251 ItemStates state = (isDisabled) ? SS_Disabled : SS_Active; |
|
252 if (isLatched) |
|
253 state = state | SS_Latched; |
|
254 else if (isPressed) |
|
255 state = state | SS_Pressed; |
|
256 |
|
257 if (toolbutton->state & State_Selected || toolbutton->state & State_HasFocus) |
|
258 state = state | SS_Selected; |
|
259 #ifndef QT_NO_TOOLBAR |
|
260 if (widget && !qobject_cast<const QToolBar*>(widget->parentWidget())) |
|
261 m_private->drawMultiPartItem(SM_ToolButton, painter, toolbutton->rect, state); |
|
262 else |
|
263 #endif |
|
264 m_private->drawMultiPartItem(SM_ToolBarButton, painter, toolbutton->rect, state); |
|
265 } |
|
266 break; |
|
267 } |
|
268 case PE_IndicatorCheckBox: { |
|
269 ItemStates state = (option->state & State_On) ? SS_Active : SS_Inactive; |
|
270 if (option->direction == Qt::RightToLeft) state |= SS_Mirrored; |
|
271 m_private->drawItem(SP_CheckBoxIndicator, painter, option->rect, state); |
|
272 break; |
|
273 } |
|
274 case PE_IndicatorRadioButton: { |
|
275 const ItemStates state = (option->state & State_On) ? SS_Active : SS_Inactive; |
|
276 m_private->drawItem(SP_RadioButtonIndicator, painter, option->rect, state); |
|
277 break; |
|
278 } |
|
279 case PE_FrameFocusRect: { |
|
280 if (const QStyleOptionFocusRect *highlight = qstyleoption_cast<const QStyleOptionFocusRect *>(option)) { |
|
281 if (false |
|
282 #ifndef QT_NO_LISTVIEW |
|
283 || qobject_cast<const QListWidget *>(widget) |
|
284 #endif |
|
285 #ifndef QT_NO_TABLEVIEW |
|
286 || qobject_cast<const QTableWidget *>(widget) |
|
287 #endif |
|
288 #ifndef QT_NO_TREEVIEW |
|
289 || qobject_cast<const QTreeWidget *>(widget) |
|
290 #endif |
|
291 ) |
|
292 m_private->drawMultiPartItem(SM_ItemViewHighlight, painter, highlight->rect); |
|
293 } |
|
294 break; |
|
295 } |
|
296 case PE_FrameMenu: { |
|
297 break; |
|
298 } |
|
299 case PE_PanelMenu: { |
|
300 m_private->drawMultiPartItem(SM_Menu, painter, option->rect); |
|
301 break; |
|
302 } |
|
303 case PE_Widget: { |
|
304 if (m_private->isDialog(widget)) |
|
305 m_private->drawMultiPartItem(SM_Dialog, painter, option->rect); |
|
306 break; |
|
307 } |
|
308 case PE_IndicatorMenuCheckMark: { |
|
309 m_private->drawItem(SP_ItemDecoration, painter, option->rect); |
|
310 break; |
|
311 } |
|
312 case PE_FrameGroupBox: { |
|
313 ItemStates groupBoxStates; |
|
314 if ((option->state & State_Sunken) || (option->state & State_Raised)) |
|
315 groupBoxStates |= SS_Pressed; |
|
316 if (option->state & State_HasFocus) |
|
317 groupBoxStates |= SS_Selected; |
|
318 if (option->state & State_On) |
|
319 groupBoxStates |= SS_Active; |
|
320 else if (option->state & State_Off) |
|
321 groupBoxStates |= SS_Inactive; |
|
322 m_private->drawMultiPartItem(SM_GroupBox, painter, option->rect, groupBoxStates); |
|
323 break; |
|
324 } |
|
325 // Qt3 primitives are not supported |
|
326 case PE_Q3CheckListController: |
|
327 case PE_Q3CheckListExclusiveIndicator: |
|
328 case PE_Q3CheckListIndicator: |
|
329 case PE_Q3DockWindowSeparator: |
|
330 case PE_Q3Separator: { |
|
331 Q_ASSERT(false); |
|
332 break; |
|
333 } |
|
334 case PE_PanelScrollAreaCorner: //no corner for scroll area |
|
335 case PE_IndicatorTabTear: // no tab tear in uiemo |
|
336 case PE_PanelMenuBar: { //no panel menu in uiemo |
|
337 break; |
|
338 } |
|
339 default: { |
|
340 QCommonStyle::drawPrimitive(element, option, painter, widget); |
|
341 break; |
|
342 } |
|
343 } |
|
344 } |
|
345 |
|
346 void QHbStyle::drawControl(ControlElement element, const QStyleOption *option, |
|
347 QPainter *painter, const QWidget *widget) const |
|
348 { |
|
349 switch (element) { |
|
350 case CE_HeaderEmptyArea: { |
|
351 const bool isHorizontal = (option->state & State_Horizontal); |
|
352 ItemStates states = (isHorizontal) ? SS_Horizontal : ItemState(SS_Vertical); |
|
353 if (!isHorizontal) |
|
354 states |= (option->direction == Qt::LeftToRight) ? SS_RotatedRight : SS_RotatedLeft; |
|
355 m_private->drawMultiPartItem(SM_ListParent, painter, option->rect, states); |
|
356 break; |
|
357 } |
|
358 case CE_HeaderSection: { |
|
359 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
|
360 //Draw corner button as normal pushButton. |
|
361 if (qobject_cast<const QAbstractButton *>(widget)) { |
|
362 QStyleOptionButton cornerButton; |
|
363 cornerButton.initFrom(widget); |
|
364 drawControl(CE_PushButtonBevel, &cornerButton, painter, widget); |
|
365 } else { |
|
366 const bool isVertical = (header->orientation == Qt::Vertical); |
|
367 ItemStates states = (isVertical) ? SS_Vertical : ItemState(SS_Horizontal); |
|
368 if (isVertical) |
|
369 states |= (header->direction == Qt::LeftToRight) ? SS_RotatedRight : SS_RotatedLeft; |
|
370 m_private->drawMultiPartItem(SM_ListParent, painter, option->rect, states); |
|
371 } |
|
372 } |
|
373 break; |
|
374 } |
|
375 case CE_ItemViewItem: { |
|
376 if (const QStyleOptionViewItemV4 *itemOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
|
377 const QRect checkRect = subElementRect(SE_ItemViewItemCheckIndicator, itemOption, widget); |
|
378 const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, itemOption, widget); |
|
379 QRect textRect = subElementRect(SE_ItemViewItemText, itemOption, widget); |
|
380 |
|
381 //background for list items (other itemviews use PE_PanelItemViewRow drawing) |
|
382 if (qobject_cast<const QListWidget *>(widget)) |
|
383 proxy()->drawPrimitive(PE_PanelItemViewItem, itemOption, painter, widget); |
|
384 |
|
385 //checkbox |
|
386 if (itemOption->features & QStyleOptionViewItemV2::HasCheckIndicator && checkRect.isValid()) { |
|
387 QStyleOptionViewItemV4 checkOption; |
|
388 checkOption.QStyleOption::operator=(*itemOption); |
|
389 checkOption.rect = checkRect; |
|
390 proxy()->drawPrimitive(PE_IndicatorViewItemCheck, &checkOption, painter, widget); |
|
391 } |
|
392 |
|
393 //selection indication |
|
394 if (itemOption->state & State_Selected) { |
|
395 const QAbstractItemView *itemView = qobject_cast<const QAbstractItemView *>(widget); |
|
396 if (itemView->selectionMode() != QAbstractItemView::SingleSelection) { |
|
397 QStyleOptionViewItemV4 selectOption; |
|
398 selectOption.QStyleOption::operator=(*itemOption); |
|
399 int iconSize = 0; |
|
400 if (m_private->hbParameter(QLatin1String("hb-param-graphic-size-secondary"), iconSize)) { |
|
401 QRect selectRect = QRect(0, 0, iconSize, iconSize); |
|
402 if (itemOption->direction == Qt::LeftToRight) { |
|
403 //translate to end of text area and reduce text area |
|
404 selectRect.translate(textRect.topRight().x() - selectRect.width(), textRect.topRight().y()); |
|
405 } else { |
|
406 //translate to the beginning of textRect, move textRect to the right |
|
407 selectRect.translate(textRect.topLeft().x(), textRect.topRight().y()); |
|
408 textRect.translate(selectRect.width(), 0); |
|
409 } |
|
410 textRect.setWidth(textRect.width() - selectRect.width()); |
|
411 selectOption.rect = selectRect; |
|
412 proxy()->drawPrimitive(PE_IndicatorViewItemCheck, &selectOption, painter, widget); |
|
413 } |
|
414 } |
|
415 } |
|
416 |
|
417 //text |
|
418 if (itemOption->text.length() > 0) { |
|
419 uint flags = Qt::AlignVCenter | Qt::TextShowMnemonic; |
|
420 if (!proxy()->styleHint(SH_UnderlineShortcut, itemOption, widget)) |
|
421 flags |= Qt::TextHideMnemonic; |
|
422 |
|
423 drawItemText(painter, textRect, flags, itemOption->palette, (itemOption->state & State_Enabled), itemOption->text); |
|
424 } |
|
425 //icon |
|
426 if (!itemOption->icon.isNull()) { |
|
427 QIcon::Mode mode = QIcon::Normal; |
|
428 if (!(option->state & State_Enabled)) |
|
429 mode = QIcon::Disabled; |
|
430 else if (option->state & State_Selected) |
|
431 mode = QIcon::Selected; |
|
432 QIcon::State state = itemOption->state & State_Open ? QIcon::On : QIcon::Off; |
|
433 itemOption->icon.paint(painter, iconRect, itemOption->decorationAlignment, mode, state); |
|
434 } |
|
435 } |
|
436 break; |
|
437 } |
|
438 case CE_ShapedFrame: { |
|
439 if (const QStyleOptionFrameV3 *frame = qstyleoption_cast<const QStyleOptionFrameV3 *>(option)) { |
|
440 const int frameShape = frame->frameShape; |
|
441 const int lineWidth = frame->lineWidth; |
|
442 const int midLineWidth = frame->midLineWidth; |
|
443 QPalette::ColorRole foregroundRole = QPalette::WindowText; |
|
444 int frameShadow = QFrame::Plain; |
|
445 if (frame->state & State_Sunken) |
|
446 frameShadow = QFrame::Sunken; |
|
447 else if (frame->state & State_Raised) |
|
448 frameShadow = QFrame::Raised; |
|
449 |
|
450 switch (frameShape) { |
|
451 case QFrame::Box: |
|
452 case QFrame::WinPanel: |
|
453 if (frameShadow == QFrame::Plain) |
|
454 qDrawPlainRect(painter, frame->rect, frame->palette.color(foregroundRole), lineWidth); |
|
455 else |
|
456 qDrawShadeRect(painter, frame->rect, frame->palette, frameShadow == QFrame::Sunken, lineWidth, midLineWidth); |
|
457 break; |
|
458 case QFrame::StyledPanel: |
|
459 if (widget) |
|
460 widget->style()->drawPrimitive(PE_Frame, option, painter, widget); |
|
461 else |
|
462 proxy()->drawPrimitive(PE_Frame, option, painter, widget); |
|
463 break; |
|
464 case QFrame::Panel: |
|
465 //@todo: support sunken / raised? |
|
466 m_private->drawMultiPartItem(SM_Panel, painter, option->rect); |
|
467 break; |
|
468 case QFrame::HLine: |
|
469 case QFrame::VLine: { |
|
470 ItemStates states = (frameShape == QFrame::HLine) ? SS_Horizontal : SS_Vertical; |
|
471 //@todo: support sunken / raised separators? |
|
472 m_private->drawItem(SP_SeparatorLine, painter, frame->rect, states); |
|
473 break; |
|
474 } |
|
475 } |
|
476 } |
|
477 break; |
|
478 } |
|
479 #ifndef QT_NO_TABBAR |
|
480 case CE_TabBarTab: { |
|
481 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) { |
|
482 proxy()->drawControl(CE_TabBarTabShape, tab, painter, widget); |
|
483 proxy()->drawControl(CE_TabBarTabLabel, tab, painter, widget); |
|
484 } |
|
485 break; |
|
486 } |
|
487 case CE_TabBarTabShape: { |
|
488 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) { |
|
489 ItemStates states = (tab->shape == QTabBar::TriangularSouth || |
|
490 tab->shape == QTabBar::RoundedSouth || |
|
491 tab->shape == QTabBar::TriangularNorth || |
|
492 tab->shape == QTabBar::RoundedNorth) ? SS_Horizontal : SS_Vertical; |
|
493 if (tab->state & State_Selected) |
|
494 states |= SS_Selected; |
|
495 if (tab->state & State_Raised || tab->state & State_Sunken) |
|
496 states |= SS_Pressed; |
|
497 if (!(tab->state & State_Enabled)) |
|
498 states |= SS_Disabled; |
|
499 |
|
500 if (tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::TriangularSouth || |
|
501 tab->shape == QTabBar::RoundedEast || tab->shape == QTabBar::TriangularEast) |
|
502 states |= SS_Flipped; |
|
503 |
|
504 if (tab->direction == Qt::RightToLeft) states |= SS_Mirrored; |
|
505 |
|
506 //Tab's position |
|
507 if (tab->position == QStyleOptionTab::Beginning) |
|
508 states |= (states & SS_Flipped) ? SS_End : SS_Beginning; |
|
509 else if (tab->position == QStyleOptionTab::Middle) |
|
510 states |= SS_Middle; |
|
511 if (tab->position == QStyleOptionTab::End) |
|
512 states |= (states & SS_Flipped) ? SS_Beginning : SS_End; |
|
513 |
|
514 m_private->drawMultiPartItem(SM_TabShape, painter, tab->rect, states); |
|
515 } |
|
516 break; |
|
517 } |
|
518 case CE_TabBarTabLabel: { |
|
519 if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) { |
|
520 const bool enabled = tab->state & State_Enabled; |
|
521 const QPixmap icon = tab->icon.pixmap(proxy()->pixelMetric(PM_TabBarIconSize, tab, widget), |
|
522 enabled ? QIcon::Normal : QIcon::Disabled); |
|
523 |
|
524 const bool verticalTabs = tab->shape == QTabBar::RoundedEast |
|
525 || tab->shape == QTabBar::RoundedWest |
|
526 || tab->shape == QTabBar::TriangularEast |
|
527 || tab->shape == QTabBar::TriangularWest; |
|
528 |
|
529 QRect tr = tab->rect; |
|
530 //add a small space so that text/icon does not start from the border |
|
531 const int margin = proxy()->pixelMetric(PM_DefaultFrameWidth, tab, widget); |
|
532 if (!verticalTabs) |
|
533 tr.adjust(margin, 0, -margin, 0); |
|
534 else |
|
535 tr.adjust(0, margin, 0, -margin); |
|
536 |
|
537 // Need to do rotation separately here, instead of in drawItem/drawMultiItemPart, since we want to rotate text as well. |
|
538 if (verticalTabs) { |
|
539 painter->save(); |
|
540 int newX, newY, newRotation; |
|
541 if (tab->shape == QTabBar::RoundedEast || tab->shape == QTabBar::TriangularEast) { |
|
542 newX = tr.width(); |
|
543 newY = tr.y(); |
|
544 newRotation = 90; |
|
545 } else { |
|
546 newX = 0; |
|
547 newY = tr.y() + tr.height(); |
|
548 newRotation = -90; |
|
549 } |
|
550 tr.setRect(0, 0, tr.height(), tr.width()); |
|
551 QTransform m; |
|
552 m.translate(newX, newY); |
|
553 m.rotate(newRotation); |
|
554 painter->setTransform(m, true); |
|
555 } |
|
556 |
|
557 const int frameWidth = proxy()->pixelMetric((verticalTabs) ? |
|
558 PM_LayoutVerticalSpacing : PM_LayoutHorizontalSpacing, option, widget); |
|
559 const Qt::TextElideMode elideMode = (tab->direction == Qt::LeftToRight) ? Qt::ElideRight : Qt::ElideLeft; |
|
560 const QRect textRect = QRect(0, |
|
561 0, |
|
562 tab->rect.width() - icon.width() - frameWidth * 2, |
|
563 tab->rect.height() - icon.height() - frameWidth * 2); |
|
564 QString txt = tab->fontMetrics.elidedText(tab->text, elideMode, (verticalTabs ? textRect.height() : textRect.width())); |
|
565 |
|
566 //Icon |
|
567 if (!icon.isNull()) { |
|
568 if (tab->text.isEmpty()) |
|
569 painter->drawPixmap(tr.center().x() - (icon.height() >> 1), |
|
570 tr.center().y() - (icon.height() >> 1), |
|
571 icon); |
|
572 else |
|
573 painter->drawPixmap(tr.left(), |
|
574 tr.center().y() - (icon.height() >> 1), |
|
575 icon); |
|
576 tr.setLeft(tr.left() + icon.width() + frameWidth); |
|
577 } else { |
|
578 tr.setLeft(tr.left() + frameWidth); |
|
579 } |
|
580 |
|
581 //Text |
|
582 if (tab->text.length() > 0) { |
|
583 int alignment = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic; |
|
584 if (!proxy()->styleHint(SH_UnderlineShortcut, tab, widget)) |
|
585 alignment |= Qt::TextHideMnemonic; |
|
586 proxy()->drawItemText(painter, tr, alignment, tab->palette, enabled, txt, QPalette::ButtonText); |
|
587 } |
|
588 |
|
589 if (verticalTabs) |
|
590 painter->restore(); |
|
591 } |
|
592 break; |
|
593 } |
|
594 #ifndef QT_NO_COMBOBOX |
|
595 case CE_ComboBoxLabel: |
|
596 if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
597 QRect editRect = proxy()->subControlRect(CC_ComboBox, combo, SC_ComboBoxEditField, widget); |
|
598 const int spacing = proxy()->pixelMetric(PM_LayoutHorizontalSpacing, combo, widget); |
|
599 if (!combo->currentIcon.isNull()) { |
|
600 const QIcon::Mode mode = combo->state & State_Enabled ? QIcon::Normal |
|
601 : QIcon::Disabled; |
|
602 const QPixmap pixmap = combo->currentIcon.pixmap(combo->iconSize, mode); |
|
603 QRect iconRect(editRect); |
|
604 iconRect.setWidth(combo->iconSize.width() + spacing); |
|
605 iconRect = alignedRect(combo->direction, |
|
606 Qt::AlignLeft | Qt::AlignVCenter, |
|
607 iconRect.size(), editRect); |
|
608 if (combo->editable) |
|
609 painter->fillRect(iconRect, combo->palette.brush(QPalette::Base)); |
|
610 proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); |
|
611 |
|
612 if (combo->direction == Qt::RightToLeft) |
|
613 editRect.translate(-spacing - combo->iconSize.width(), 0); |
|
614 else |
|
615 editRect.translate(combo->iconSize.width() + spacing, 0); |
|
616 } |
|
617 if (!combo->currentText.isEmpty() && !combo->editable) { |
|
618 const Qt::TextElideMode elideMode = (combo->direction == Qt::LeftToRight) ? Qt::ElideRight : Qt::ElideLeft; |
|
619 const QString txt = combo->fontMetrics.elidedText(combo->currentText, elideMode, editRect.width()); |
|
620 proxy()->drawItemText(painter, editRect.adjusted(1, 0, -1, 0), |
|
621 visualAlignment(combo->direction, Qt::AlignLeft | Qt::AlignVCenter), |
|
622 combo->palette, combo->state & State_Enabled, txt); |
|
623 } |
|
624 } |
|
625 break; |
|
626 #endif // QT_NO_COMBOBOX |
|
627 #endif //QT_NO_TABBAR |
|
628 case CE_PushButton: { |
|
629 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
630 proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget); |
|
631 QStyleOptionButton subopt = *btn; |
|
632 subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); |
|
633 proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget); |
|
634 if ((btn->state & State_HasFocus)) { |
|
635 QStyleOptionFocusRect fropt; |
|
636 fropt.QStyleOption::operator=(*btn); |
|
637 fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget); |
|
638 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); |
|
639 } |
|
640 } |
|
641 break; |
|
642 } |
|
643 case CE_PushButtonBevel: { |
|
644 if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
645 const bool isDisabled = !(button->state & State_Enabled); |
|
646 const bool isFlat = button->features & QStyleOptionButton::Flat; |
|
647 const bool isPressed = (button->state & State_Sunken) || |
|
648 (button->state & State_On); |
|
649 // 'latched' is a checkable button that is pressed down |
|
650 const QPushButton *pbutton = qobject_cast<const QPushButton *>(widget); |
|
651 const bool isLatched = (!pbutton) ? false : (pbutton->isCheckable() && isPressed); |
|
652 |
|
653 ItemStates state = (isDisabled) ? SS_Disabled : SS_Active; |
|
654 if (isLatched) |
|
655 state = state | SS_Latched; |
|
656 else if (isPressed) |
|
657 state = state | SS_Pressed; |
|
658 |
|
659 if (button->state & State_Selected || button->state & State_HasFocus) |
|
660 state = state | SS_Selected; |
|
661 |
|
662 //todo: does Hb have flat buttons? |
|
663 if (button->features & QStyleOptionButton::HasMenu) { |
|
664 //draw menu indicator |
|
665 const int menuButtonIndicator = proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget); |
|
666 QStyleOptionButton menuOpt = *button; |
|
667 menuOpt.rect = QRect(button->rect.right() - menuButtonIndicator, |
|
668 button->rect.y() + (button->rect.height() - menuButtonIndicator) / 2, |
|
669 menuButtonIndicator, |
|
670 menuButtonIndicator); |
|
671 menuOpt.rect = visualRect(button->direction, button->rect, menuOpt.rect); |
|
672 proxy()->drawPrimitive(PE_IndicatorArrowDown, &menuOpt, painter, widget); |
|
673 } |
|
674 if (isFlat) //lets draw flat buttons as toolbuttons |
|
675 m_private->drawMultiPartItem(SM_ToolButton, painter, button->rect, state); |
|
676 else |
|
677 m_private->drawMultiPartItem(SM_PushButton, painter, button->rect, state); |
|
678 } |
|
679 break; |
|
680 } |
|
681 case CE_MenuScroller: { |
|
682 ItemStates states = (option->state & State_DownArrow) ? SS_Down : SS_Up; |
|
683 painter->fillRect(option->rect, option->palette.background()); |
|
684 m_private->drawMultiPartItem(SM_MenuScroller, painter, option->rect, states); |
|
685 QStyleOption arrowOpt = *option; |
|
686 arrowOpt.state |= State_Enabled; |
|
687 const int side = proxy()->pixelMetric(PM_MenuScrollerHeight, option, widget); |
|
688 arrowOpt.rect = option->rect; |
|
689 arrowOpt.rect.setWidth(side); |
|
690 arrowOpt.rect.moveCenter(option->rect.center()); |
|
691 proxy()->drawPrimitive(((option->state & State_DownArrow) ? PE_IndicatorArrowDown : PE_IndicatorArrowUp), |
|
692 &arrowOpt, painter, widget); |
|
693 break; |
|
694 } |
|
695 case CE_MenuItem: { |
|
696 if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
|
697 if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { |
|
698 const int margin = proxy()->pixelMetric(PM_MenuHMargin, menuItem, widget); |
|
699 const int yoff = menuItem->rect.y() - 1 + menuItem->rect.height() / 2; |
|
700 const int startX = menuItem->rect.x() + margin; |
|
701 const int endX = menuItem->rect.x() + menuItem->rect.width() - margin; |
|
702 QRect separatorRect = QRect(QPoint(startX, yoff), QPoint(endX, yoff)); |
|
703 m_private->drawItem(SP_MenuSeparator, painter, separatorRect); |
|
704 return; |
|
705 } |
|
706 |
|
707 const bool isDisabled = !(menuItem->state & State_Enabled); |
|
708 const bool isSelected = (menuItem->state & State_Selected); |
|
709 const bool isPressed = (menuItem->state & State_Sunken) || (menuItem->state & State_Raised); |
|
710 ItemStates state = (isDisabled) ? SS_Disabled : SS_Active; |
|
711 |
|
712 if (isSelected) |
|
713 state = state | SS_Selected; |
|
714 |
|
715 if (isPressed) |
|
716 state = state | SS_Pressed; |
|
717 |
|
718 m_private->drawMultiPartItem(SM_MenuItem, painter, menuItem->rect, state); |
|
719 |
|
720 uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip |
|
721 | Qt::TextSingleLine | Qt::AlignVCenter; |
|
722 if (!styleHint(SH_UnderlineShortcut, menuItem, widget)) |
|
723 text_flags |= Qt::TextHideMnemonic; |
|
724 |
|
725 if (menuItem->menuHasCheckableItems) { |
|
726 const QRect checkBoxRect = subElementRect(SE_ViewItemCheckIndicator, menuItem, widget); |
|
727 if (checkBoxRect.isValid()) { |
|
728 ItemStates checkBoxState; |
|
729 if (menuItem->checked) checkBoxState |= SS_Selected; |
|
730 if (menuItem->direction == Qt::RightToLeft) checkBoxState |= SS_Mirrored; |
|
731 m_private->drawItem(SP_ItemDecoration, painter, checkBoxRect, checkBoxState); |
|
732 } |
|
733 } |
|
734 |
|
735 if (!menuItem->icon.isNull()) { |
|
736 const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, menuItem, widget); |
|
737 if (iconRect.isValid()) { |
|
738 QPixmap pix = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize), |
|
739 !isDisabled ? QIcon::Normal : QIcon::Disabled); |
|
740 drawItemPixmap(painter, iconRect, text_flags, pix); |
|
741 } |
|
742 } |
|
743 |
|
744 if (menuItem->text.length() > 0) { |
|
745 const QRect textRect = subElementRect(SE_ItemViewItemText, menuItem, widget); |
|
746 if (textRect.isValid()) |
|
747 QCommonStyle::drawItemText(painter, textRect, text_flags, menuItem->palette, |
|
748 (menuItem->state & State_Enabled), menuItem->text, QPalette::Text); |
|
749 } |
|
750 } |
|
751 break; |
|
752 } |
|
753 case CE_MenuBarEmptyArea: |
|
754 case CE_MenuEmptyArea: { |
|
755 break; |
|
756 } |
|
757 #ifndef QT_NO_PROGRESSBAR |
|
758 case CE_ProgressBar: { |
|
759 if (const QStyleOptionProgressBarV2 *progressBar = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
760 drawControl(CE_ProgressBarGroove, progressBar, painter, widget); |
|
761 drawControl(CE_ProgressBarContents, progressBar, painter, widget); |
|
762 //drawControl(CE_ProgressBarLabel, progressBar, painter, widget); |
|
763 } |
|
764 break; |
|
765 } |
|
766 case CE_ProgressBarGroove: { |
|
767 if (const QStyleOptionProgressBarV2 *progressBar = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
768 const QRect progressBarGroove = subElementRect(SE_ProgressBarGroove, progressBar, widget); |
|
769 const bool horizontal = progressBar->orientation == Qt::Horizontal; |
|
770 ItemStates state = 0; |
|
771 if (horizontal) |
|
772 state = state | SS_Horizontal; |
|
773 else |
|
774 state = state | SS_Vertical; |
|
775 |
|
776 m_private->drawMultiPartItem(SM_ProgressBarGroove, painter, progressBarGroove, state); |
|
777 } |
|
778 break; |
|
779 } |
|
780 case CE_ProgressBarContents: { |
|
781 if (const QStyleOptionProgressBarV2 *progressBar = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
782 if (progressBar->minimum == 0 && progressBar->maximum == 0) { |
|
783 //waiting bar |
|
784 animateControl(CE_ProgressBarContents, option, painter, widget); |
|
785 } else { |
|
786 QRect rect = subElementRect(SE_ProgressBarGroove, progressBar, widget); |
|
787 const qint64 minimum = qint64(progressBar->minimum); |
|
788 const qint64 maximum = qint64(progressBar->maximum); |
|
789 const qint64 progress = qint64(progressBar->progress); |
|
790 if (progressBar->orientation == Qt::Horizontal) { |
|
791 const qreal scale = rect.width() / qreal(maximum - minimum); |
|
792 qint64 width = scale * progress; |
|
793 width = progress >= maximum ? rect.width() : width; |
|
794 |
|
795 if ((progressBar->direction == Qt::LeftToRight) ^ progressBar->invertedAppearance) { |
|
796 rect = QRect(rect.x(), rect.y(), width, rect.height()); |
|
797 } else { |
|
798 rect = QRect(rect.x() + (rect.width() - width), rect.y(), rect.width() - (rect.width() - width), rect.height()); |
|
799 } |
|
800 m_private->drawMultiPartItem(SM_ProgressBarIndicator, painter, rect, SS_Horizontal); |
|
801 } else{ //Vertical |
|
802 const qreal scale = rect.height() / qreal(maximum - minimum); |
|
803 qint64 height = scale * progress; |
|
804 height = progress >= maximum ? rect.height() : height; |
|
805 if (progressBar->invertedAppearance) { |
|
806 rect = QRect(rect.x(), rect.y(), rect.width(), height); |
|
807 } else { |
|
808 rect = QRect(rect.x(), rect.y() + (rect.height() - height), rect.width(), rect.height() - (rect.height() - height)); |
|
809 } |
|
810 m_private->drawMultiPartItem(SM_ProgressBarIndicator, painter, rect, SS_Vertical); |
|
811 } |
|
812 } |
|
813 } |
|
814 break; |
|
815 } |
|
816 case CE_ProgressBarLabel: { |
|
817 if (const QStyleOptionProgressBarV2 *progressBar = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
818 if (progressBar->textVisible && (progressBar->minimum != 0 || progressBar->maximum != 0)) { |
|
819 const QString minText = QString().setNum(progressBar->minimum); |
|
820 const QString maxText = QString().setNum(progressBar->maximum); |
|
821 const QRect textRect = subElementRect(SE_ProgressBarGroove, progressBar, widget); |
|
822 if (progressBar->orientation == Qt::Horizontal) { |
|
823 if (progressBar->invertedAppearance) { |
|
824 //minText |
|
825 proxy()->drawItemText(painter, textRect, Qt::AlignRight | Qt::TextSingleLine, progressBar->palette, |
|
826 progressBar->state & State_Enabled, minText, QPalette::Text); |
|
827 |
|
828 //maxText |
|
829 proxy()->drawItemText(painter, textRect, Qt::AlignLeft | Qt::TextSingleLine, progressBar->palette, |
|
830 progressBar->state & State_Enabled, maxText, QPalette::Text); |
|
831 |
|
832 } else { |
|
833 //minText |
|
834 proxy()->drawItemText(painter, textRect, Qt::AlignLeft | Qt::TextSingleLine, progressBar->palette, |
|
835 progressBar->state & State_Enabled, minText, QPalette::Text); |
|
836 |
|
837 //maxText |
|
838 proxy()->drawItemText(painter, textRect, Qt::AlignRight | Qt::TextSingleLine, progressBar->palette, |
|
839 progressBar->state & State_Enabled, maxText, QPalette::Text); |
|
840 } |
|
841 } else { //Vertical |
|
842 if (progressBar->invertedAppearance) { |
|
843 //minText |
|
844 proxy()->drawItemText(painter, textRect, Qt::AlignTop | Qt::TextSingleLine, progressBar->palette, |
|
845 progressBar->state & State_Enabled, minText, QPalette::Text); |
|
846 |
|
847 //maxText |
|
848 proxy()->drawItemText(painter, textRect, Qt::AlignBottom | Qt::TextSingleLine, progressBar->palette, |
|
849 progressBar->state & State_Enabled, maxText, QPalette::Text); |
|
850 |
|
851 } else { |
|
852 //minText |
|
853 proxy()->drawItemText(painter, textRect, Qt::AlignBottom | Qt::TextSingleLine, progressBar->palette, |
|
854 progressBar->state & State_Enabled, minText, QPalette::Text); |
|
855 |
|
856 //maxText |
|
857 proxy()->drawItemText(painter, textRect, Qt::AlignTop | Qt::TextSingleLine, progressBar->palette, |
|
858 progressBar->state & State_Enabled, maxText, QPalette::Text); |
|
859 } |
|
860 |
|
861 } |
|
862 |
|
863 } |
|
864 } |
|
865 break; |
|
866 } |
|
867 #endif //QT_NO_PROGRESSBAR |
|
868 case CE_ToolButtonLabel: |
|
869 default: { |
|
870 QCommonStyle::drawControl(element, option, painter, widget); |
|
871 break; |
|
872 } |
|
873 } |
|
874 } |
|
875 |
|
876 void QHbStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, |
|
877 QPainter *painter, const QWidget *widget) const |
|
878 { |
|
879 switch (control) { |
|
880 #ifndef QT_NO_COMBOBOX |
|
881 case CC_ComboBox: { |
|
882 if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
883 const QRect cmbxFrame = cmb->rect; |
|
884 ItemStates state = SS_Active; |
|
885 |
|
886 // Button frame |
|
887 QStyleOptionFrame buttonOption; |
|
888 buttonOption.QStyleOption::operator=(*cmb); |
|
889 const int buttonMaxHeight = cmbxFrame.height(); |
|
890 const int buttonMaxWidth = buttonMaxHeight; //button is rect |
|
891 const int topLeftPoint = (cmb->direction == Qt::LeftToRight) ? (cmbxFrame.width() - buttonMaxWidth) : 0; |
|
892 |
|
893 const QRect buttonRect(topLeftPoint, cmbxFrame.top(), buttonMaxHeight, buttonMaxWidth); |
|
894 buttonOption.rect = buttonRect; |
|
895 buttonOption.state = cmb->state; |
|
896 ItemStates buttonState = (buttonOption.state & State_Sunken) ? ItemStates(SS_Pressed | SS_Active) : ItemStates(SS_Active); |
|
897 if (cmb->direction == Qt::RightToLeft) |
|
898 buttonState |= SS_Mirrored; |
|
899 if (buttonOption.state & State_HasFocus) { |
|
900 buttonState |= SS_Selected; |
|
901 state |= SS_Selected; //set frame status to follow button status for highlight |
|
902 } |
|
903 |
|
904 m_private->drawItem(SP_BoxButton, painter, buttonRect.adjusted(0, 1, 0, -1), buttonState); //@todo: remove magic |
|
905 |
|
906 if (cmb->subControls & SC_ComboBoxFrame) { |
|
907 const bool isDisabled = !(cmb->state & State_Enabled); |
|
908 const bool isPressed = (cmb->state & State_Sunken); |
|
909 const bool isEditable = cmb->editable; |
|
910 |
|
911 if (isDisabled) |
|
912 state = SS_Disabled; |
|
913 else if (isPressed) |
|
914 state |= SS_Pressed; |
|
915 if (isEditable) |
|
916 state |= SS_Edited; |
|
917 QRect frameRect = QRect(cmb->rect); |
|
918 int frameWidth = pixelMetric(PM_DefaultFrameWidth); |
|
919 int maxRight = cmb->rect.height() - 2 * frameWidth; |
|
920 frameRect.adjust(0, 0, -maxRight, 0); |
|
921 int adjustX = 0; |
|
922 if (option->direction == Qt::RightToLeft) { |
|
923 adjustX = buttonOption.rect.topRight().x(); |
|
924 state |= SS_Mirrored; |
|
925 } |
|
926 const QRect frame = subControlRect(CC_ComboBox, option, SC_ComboBoxFrame, widget); |
|
927 // @todo: if SC_ComboBoxFrame needs adjusting, move that code to subControlRect |
|
928 m_private->drawMultiPartItem(SM_BoxFrame, painter, frame.adjusted(adjustX, 1, -4 + adjustX, -1), state); |
|
929 } |
|
930 } |
|
931 break; |
|
932 } |
|
933 #endif //QT_NO_COMBOBOX |
|
934 #ifndef QT_NO_SLIDER |
|
935 case CC_Slider: { |
|
936 if (const QStyleOptionSlider *optionSlider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
937 const QSlider* slider = qobject_cast<const QSlider*>(widget); |
|
938 const QRect sliderGroove = subControlRect(control, optionSlider, SC_SliderGroove, widget); |
|
939 const QRect sliderHandle = subControlRect(control, optionSlider, SC_SliderHandle, widget); |
|
940 const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
|
941 const bool isDisabled = !(optionSlider->state & State_Enabled); |
|
942 ItemStates grooveState = (isDisabled) ? SS_Disabled : SS_Active; |
|
943 if (horizontal) |
|
944 grooveState = grooveState | SS_Horizontal; |
|
945 else |
|
946 grooveState = grooveState | SS_Vertical; |
|
947 |
|
948 ItemStates handleState = grooveState; |
|
949 |
|
950 if (slider && slider->isSliderDown()) |
|
951 handleState = handleState | SS_Pressed; |
|
952 else if ((optionSlider->state & State_Sunken) || (optionSlider->state & State_On)) |
|
953 grooveState = grooveState | SS_Pressed; |
|
954 |
|
955 //Draw ticks |
|
956 if (optionSlider->subControls & SC_SliderTickmarks) { |
|
957 const QRect tickRect = subControlRect(control, optionSlider, SC_SliderTickmarks, widget); |
|
958 const bool ticksAbove = optionSlider->tickPosition & QSlider::TicksAbove; |
|
959 const bool ticksBelow = optionSlider->tickPosition & QSlider::TicksBelow; |
|
960 |
|
961 int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, optionSlider, widget); |
|
962 const int thickness = proxy()->pixelMetric(PM_SliderControlThickness, optionSlider, widget); |
|
963 const int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, optionSlider, widget); |
|
964 int interval = optionSlider->tickInterval; |
|
965 if (interval <= 0) { |
|
966 interval = optionSlider->singleStep; |
|
967 if (sliderPositionFromValue(optionSlider->minimum, optionSlider->maximum, interval,available) |
|
968 - sliderPositionFromValue(optionSlider->minimum, optionSlider->maximum, 0, available) < 3) |
|
969 interval = optionSlider->pageStep; |
|
970 } |
|
971 if (!interval) |
|
972 interval = 1; |
|
973 int pos; |
|
974 const int fudge = proxy()->pixelMetric(PM_SliderLength, optionSlider, widget) / 2; |
|
975 // Since there is no subrect for tickmarks do a translation here. |
|
976 int v = optionSlider->minimum; |
|
977 |
|
978 while (v <= (optionSlider->maximum + 1)) { |
|
979 if ((v == optionSlider->maximum + 1) && (interval == 1)) |
|
980 break; |
|
981 const int v_ = qMin(v, optionSlider->maximum); |
|
982 pos = sliderPositionFromValue(optionSlider->minimum, optionSlider->maximum, |
|
983 v_, available) + fudge; |
|
984 QRect destRect = QRect(); |
|
985 if (horizontal) { |
|
986 if (ticksAbove) { |
|
987 destRect = QRect(pos, tickRect.y() - tickOffset + 1, tickRect.width(), tickRect.height()); |
|
988 m_private->drawItem(SP_SliderTick, painter, destRect, grooveState); |
|
989 } |
|
990 if (ticksBelow) { |
|
991 destRect = QRect(pos, tickOffset + thickness - 1, tickRect.width(), tickRect.height()); |
|
992 m_private->drawItem(SP_SliderTick, painter, destRect, grooveState); |
|
993 } |
|
994 } else { |
|
995 if (ticksAbove) { |
|
996 destRect = QRect(tickRect.x() - tickOffset + 1, pos, tickRect.width(), tickRect.height()); |
|
997 m_private->drawItem(SP_SliderTick, painter, destRect, grooveState); |
|
998 } |
|
999 if (ticksBelow) { |
|
1000 destRect = QRect(tickOffset + thickness - 1, pos, tickRect.width(), tickRect.height()); |
|
1001 m_private->drawItem(SP_SliderTick, painter, destRect, grooveState); |
|
1002 } |
|
1003 } |
|
1004 // in the case where maximum is max int |
|
1005 int nextInterval = v + interval; |
|
1006 if (nextInterval < v) |
|
1007 break; |
|
1008 v = nextInterval; |
|
1009 } |
|
1010 } |
|
1011 QRect filledRect; |
|
1012 if ( horizontal ){ |
|
1013 const int sliderPosition = sliderHandle.center().x(); |
|
1014 const int sliderWidth = sliderHandle.width()/2; |
|
1015 if (slider && (slider->layoutDirection() == Qt::LeftToRight) ^ slider->invertedAppearance()){ |
|
1016 filledRect = QRect(sliderGroove.x(), sliderGroove.y(), sliderPosition+sliderWidth, sliderGroove.height()); |
|
1017 } else { |
|
1018 filledRect = QRect(sliderGroove.x()+sliderPosition-sliderWidth, sliderGroove.y(), sliderGroove.width()-sliderPosition+sliderWidth, sliderGroove.height()); |
|
1019 } |
|
1020 } else { |
|
1021 const int sliderPosition = sliderHandle.center().y(); |
|
1022 const int sliderHeight = sliderHandle.height()/2; |
|
1023 if (slider && (slider->layoutDirection() == Qt::LeftToRight) ^ slider->invertedAppearance()){ |
|
1024 filledRect = QRect(sliderGroove.x(), sliderGroove.y()+sliderPosition-sliderHeight, sliderGroove.width(), sliderGroove.height()-sliderPosition+sliderHeight); |
|
1025 } else { |
|
1026 filledRect = QRect(sliderGroove.x(), sliderGroove.y(), sliderGroove.width(), sliderPosition+sliderHeight); |
|
1027 } |
|
1028 } |
|
1029 |
|
1030 //Groove |
|
1031 m_private->drawMultiPartItem(SM_SliderGroove, painter, sliderGroove, grooveState); |
|
1032 |
|
1033 //Progress |
|
1034 m_private->drawMultiPartItem(SM_SliderProgress, painter, filledRect, grooveState | SS_Filled); |
|
1035 |
|
1036 //handle |
|
1037 m_private->drawItem(SP_SliderHandle, painter, sliderHandle, handleState); |
|
1038 } |
|
1039 break; |
|
1040 } |
|
1041 #endif //QT_NO_SLIDER |
|
1042 #ifndef QT_NO_SCROLLBAR |
|
1043 case CC_ScrollBar: { |
|
1044 if (const QStyleOptionSlider *optionSlider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
1045 ItemStates handleStates; |
|
1046 ItemStates grooveStates; |
|
1047 const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
|
1048 const QRect handleRect = subControlRect(control, optionSlider, SC_ScrollBarSlider, widget); |
|
1049 const QRect grooveRect = subControlRect(control, optionSlider, SC_ScrollBarGroove, widget); |
|
1050 if (horizontal) { |
|
1051 handleStates |= SS_Horizontal; |
|
1052 grooveStates |= SS_Horizontal; |
|
1053 } else { |
|
1054 handleStates |= SS_Vertical; |
|
1055 grooveStates |= SS_Vertical; |
|
1056 } |
|
1057 const SubControls subControls = optionSlider->subControls; |
|
1058 const bool sliderPressed = ((optionSlider->state & State_Sunken) && (subControls & SC_ScrollBarSlider)); |
|
1059 const bool groovePressed = ((optionSlider->state & State_Sunken) && (subControls & SC_ScrollBarGroove)); |
|
1060 |
|
1061 if (sliderPressed) |
|
1062 handleStates |= SS_Pressed; |
|
1063 if (groovePressed) |
|
1064 grooveStates |= SS_Pressed; |
|
1065 |
|
1066 m_private->drawMultiPartItem(SM_ScrollBarGroove, painter, grooveRect, grooveStates); |
|
1067 m_private->drawMultiPartItem(SM_ScrollBarHandle, painter, handleRect, handleStates); |
|
1068 } |
|
1069 break; |
|
1070 } |
|
1071 #endif // QT_NO_SCROLLBAR |
|
1072 #ifndef QT_NO_GROUPBOX |
|
1073 case CC_GroupBox: { |
|
1074 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { |
|
1075 // Draw frame |
|
1076 const QRect textRect = subControlRect(CC_GroupBox, option, SC_GroupBoxLabel, widget); |
|
1077 |
|
1078 QRect headerRect = textRect; |
|
1079 headerRect.setWidth(groupBox->rect.width()); |
|
1080 if (groupBox->subControls & SC_GroupBoxFrame) { |
|
1081 QStyleOptionFrameV2 frame; |
|
1082 frame.QStyleOption::operator=(*groupBox); |
|
1083 frame.features = groupBox->features; |
|
1084 frame.lineWidth = groupBox->lineWidth; |
|
1085 frame.midLineWidth = groupBox->midLineWidth; |
|
1086 frame.rect = subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget); |
|
1087 proxy()->drawPrimitive(PE_FrameGroupBox, &frame, painter, widget); |
|
1088 } |
|
1089 |
|
1090 // Draw title |
|
1091 if ((groupBox->subControls & SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { |
|
1092 // Draw title background |
|
1093 m_private->drawMultiPartItem(SM_GroupBoxTitle, painter, headerRect); |
|
1094 |
|
1095 const QColor textColor = groupBox->textColor; |
|
1096 painter->save(); |
|
1097 |
|
1098 if (textColor.isValid()) |
|
1099 painter->setPen(textColor); |
|
1100 int alignment = int(groupBox->textAlignment); |
|
1101 if (!styleHint(SH_UnderlineShortcut, option, widget)) |
|
1102 alignment |= Qt::TextHideMnemonic; |
|
1103 |
|
1104 proxy()->drawItemText(painter, headerRect, Qt::TextShowMnemonic | Qt::AlignHCenter | Qt::AlignVCenter | alignment, |
|
1105 groupBox->palette, groupBox->state & State_Enabled, groupBox->text, |
|
1106 textColor.isValid() ? QPalette::NoRole : QPalette::WindowText); |
|
1107 painter->restore(); |
|
1108 } |
|
1109 const QRect checkBoxRect = subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget); |
|
1110 // Draw checkbox |
|
1111 if (groupBox->subControls & SC_GroupBoxCheckBox) { |
|
1112 QStyleOptionButton box; |
|
1113 box.QStyleOption::operator=(*groupBox); |
|
1114 box.rect = checkBoxRect; |
|
1115 proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); |
|
1116 } |
|
1117 } |
|
1118 break; |
|
1119 } |
|
1120 #endif //QT_NO_GROUPBOX |
|
1121 #ifndef QT_NO_TOOLBUTTON |
|
1122 case CC_ToolButton: { |
|
1123 if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
|
1124 const QRect buttonRect(subControlRect(control, toolBtn, SC_ToolButton, widget)); |
|
1125 QRect menuRect = QRect(); |
|
1126 if (toolBtn->subControls & SC_ToolButtonMenu) |
|
1127 menuRect = subControlRect(control, toolBtn, SC_ToolButtonMenu, widget); |
|
1128 |
|
1129 // Draw button bevel |
|
1130 if (toolBtn->subControls & SC_ToolButton) |
|
1131 proxy()->drawPrimitive(PE_PanelButtonTool, toolBtn, painter, widget); |
|
1132 |
|
1133 //draw focus |
|
1134 if (toolBtn->state & State_HasFocus) { |
|
1135 QStyleOptionFocusRect frameOpt; |
|
1136 frameOpt.QStyleOption::operator=(*toolBtn); |
|
1137 frameOpt.rect = subElementRect(SE_PushButtonFocusRect, toolBtn, widget); //can we use this, or should we just reduce the button rect? |
|
1138 if (toolBtn->features & QStyleOptionToolButton::MenuButtonPopup) |
|
1139 frameOpt.rect.adjust(0, 0, -proxy()->pixelMetric(PM_MenuButtonIndicator), 0); |
|
1140 proxy()->drawPrimitive(PE_FrameFocusRect, &frameOpt, painter, widget); |
|
1141 } |
|
1142 |
|
1143 if (toolBtn->text.length() > 0 || !toolBtn->icon.isNull() || (toolBtn->features & QStyleOptionToolButton::Arrow)) { |
|
1144 //draw label |
|
1145 QStyleOptionToolButton label = *toolBtn; |
|
1146 int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); |
|
1147 label.rect = buttonRect.adjusted(fw, fw, -fw, -fw); |
|
1148 proxy()->drawControl(CE_ToolButtonLabel, &label, painter, widget); |
|
1149 } |
|
1150 if (toolBtn->subControls & SC_ToolButtonMenu) { |
|
1151 //draw menu indicator |
|
1152 const int menuButtonIndicator = proxy()->pixelMetric(PM_MenuButtonIndicator, toolBtn, widget); |
|
1153 QStyleOptionToolButton menuOpt = *toolBtn; |
|
1154 menuOpt.rect = QRect(toolBtn->rect.right() - menuButtonIndicator, |
|
1155 toolBtn->rect.y() + (toolBtn->rect.height() - menuButtonIndicator) / 2, |
|
1156 menuButtonIndicator, |
|
1157 menuButtonIndicator); |
|
1158 menuOpt.rect = visualRect(toolBtn->direction, toolBtn->rect, menuOpt.rect); |
|
1159 |
|
1160 PrimitiveElement pe; |
|
1161 bool arrow = true; |
|
1162 switch(toolBtn->arrowType) { |
|
1163 case Qt::UpArrow: { |
|
1164 pe = PE_IndicatorArrowUp; |
|
1165 break; |
|
1166 } |
|
1167 case Qt::LeftArrow: { |
|
1168 pe = PE_IndicatorArrowLeft; |
|
1169 break; |
|
1170 } |
|
1171 case Qt::RightArrow: { |
|
1172 pe = PE_IndicatorArrowRight; |
|
1173 break; |
|
1174 } |
|
1175 case Qt::DownArrow: { |
|
1176 pe = PE_IndicatorArrowDown; |
|
1177 break; |
|
1178 } |
|
1179 default: { |
|
1180 arrow = false; |
|
1181 } |
|
1182 } |
|
1183 if (arrow) |
|
1184 proxy()->drawPrimitive(pe, &menuOpt, painter, widget); |
|
1185 } |
|
1186 } |
|
1187 break; |
|
1188 } |
|
1189 #endif //QT_NO_TOOLBUTTON |
|
1190 case CC_SpinBox: { |
|
1191 if (const QStyleOptionSpinBox *optionSpinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
1192 const QRect spinboxFrame = subControlRect(control, optionSpinbox, SC_SpinBoxFrame, widget); |
|
1193 const QRect spinboxButtonUpRect = subControlRect(control, optionSpinbox, SC_SpinBoxUp, widget); |
|
1194 const QRect spinboxButtonDownRect = subControlRect(control, optionSpinbox, SC_SpinBoxDown, widget); |
|
1195 const QRect spinboxEditorRect = subControlRect(control, optionSpinbox, SC_SpinBoxEditField, widget); |
|
1196 |
|
1197 QStyleOptionSpinBox copy = *optionSpinbox; |
|
1198 |
|
1199 //Frame & background |
|
1200 const bool isDisabled = !(optionSpinbox->state & State_Enabled); |
|
1201 ItemStates state = (isDisabled) ? SS_Disabled : SS_Active; |
|
1202 if (optionSpinbox->state & State_HasFocus) |
|
1203 state |= SS_Selected; |
|
1204 m_private->drawMultiPartItem(SM_BoxFrame, painter, spinboxEditorRect, state); |
|
1205 |
|
1206 //Buttons |
|
1207 if (optionSpinbox->subControls & SC_SpinBoxUp) { |
|
1208 copy.subControls = SC_SpinBoxUp; |
|
1209 if (!(optionSpinbox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) |
|
1210 copy.state &= ~State_Enabled; |
|
1211 if (optionSpinbox->activeSubControls == SC_SpinBoxUp && (optionSpinbox->state & State_Sunken)) { |
|
1212 copy.state |= State_On; |
|
1213 copy.state |= State_Sunken; |
|
1214 } else { |
|
1215 copy.state |= State_Raised; |
|
1216 copy.state &= ~State_Sunken; |
|
1217 } |
|
1218 const bool isPressed = (copy.state & State_Sunken); |
|
1219 ItemStates upButtonState = (isPressed) ? ItemStates(SS_Pressed | SS_Active) : ItemStates(SS_Active); |
|
1220 if (optionSpinbox->direction == Qt::RightToLeft) |
|
1221 upButtonState = upButtonState | SS_Flipped; |
|
1222 else |
|
1223 upButtonState = upButtonState | SS_Flipped | SS_Mirrored; |
|
1224 if (optionSpinbox->state & State_HasFocus) |
|
1225 upButtonState |= SS_Selected; |
|
1226 if (!(copy.state & State_Enabled)) |
|
1227 upButtonState |= SS_Disabled; |
|
1228 m_private->drawItem(SP_BoxButton, painter, spinboxButtonUpRect, upButtonState); |
|
1229 } |
|
1230 |
|
1231 if (optionSpinbox->subControls & SC_SpinBoxDown) { |
|
1232 copy.subControls = SC_SpinBoxDown; |
|
1233 if (!(optionSpinbox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) |
|
1234 copy.state &= ~State_Enabled; |
|
1235 if (optionSpinbox->activeSubControls == SC_SpinBoxDown && (optionSpinbox->state & State_Sunken)) { |
|
1236 copy.state |= State_On; |
|
1237 copy.state |= State_Sunken; |
|
1238 } else { |
|
1239 copy.state |= State_Raised; |
|
1240 copy.state &= ~State_Sunken; |
|
1241 } |
|
1242 const bool isPressed = (copy.state & State_Sunken); |
|
1243 ItemStates downButtonState = (isPressed) ? ItemStates(SS_Pressed | SS_Active) : ItemStates(SS_Active); |
|
1244 if (optionSpinbox->direction == Qt::RightToLeft) |
|
1245 downButtonState = downButtonState; |
|
1246 else |
|
1247 downButtonState = downButtonState | SS_Mirrored; |
|
1248 if (optionSpinbox->state & State_HasFocus) |
|
1249 downButtonState |= SS_Selected; |
|
1250 if (!(copy.state & State_Enabled)) |
|
1251 downButtonState |= SS_Disabled; |
|
1252 m_private->drawItem(SP_BoxButton, painter, spinboxButtonDownRect, downButtonState); |
|
1253 } |
|
1254 } |
|
1255 break; |
|
1256 } |
|
1257 case CC_TitleBar: |
|
1258 case CC_Q3ListView: |
|
1259 case CC_Dial: |
|
1260 case CC_MdiControls: |
|
1261 default: { |
|
1262 QCommonStyle::drawComplexControl(control, option, painter, widget); |
|
1263 break; |
|
1264 } |
|
1265 } |
|
1266 } |
|
1267 |
|
1268 QSize QHbStyle::sizeFromContents(ContentsType type, const QStyleOption *option, |
|
1269 const QSize &size, const QWidget *widget) const |
|
1270 { |
|
1271 QSize newSize = QCommonStyle::sizeFromContents(type, option, size, widget); |
|
1272 switch (type) { |
|
1273 #ifndef QT_NO_MENU |
|
1274 case CT_MenuItem: { |
|
1275 if (qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
|
1276 const int verticalMargin = pixelMetric(PM_MenuVMargin); |
|
1277 const int horizontalMargin = pixelMetric(PM_MenuHMargin); |
|
1278 newSize += QSize(horizontalMargin, 2 * verticalMargin); |
|
1279 } |
|
1280 break; |
|
1281 } |
|
1282 #endif |
|
1283 #ifndef QT_NO_ITEMVIEWS |
|
1284 case CT_ItemViewItem: { |
|
1285 newSize += QSize(0,22); |
|
1286 break; |
|
1287 } |
|
1288 #endif |
|
1289 case CT_PushButton: { |
|
1290 newSize += QSize(0, 2 * proxy()->pixelMetric(PM_ButtonMargin, option, widget)); |
|
1291 break; |
|
1292 } |
|
1293 default: |
|
1294 break; |
|
1295 } |
|
1296 return newSize; |
|
1297 } |
|
1298 |
|
1299 QRect QHbStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const |
|
1300 { |
|
1301 const QRect baseSize = QCommonStyle::subElementRect(element, option, widget); |
|
1302 QRect elementSize = baseSize; |
|
1303 switch (element) { |
|
1304 case SE_ItemViewItemText: { |
|
1305 if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
|
1306 elementSize = menuItem->rect; |
|
1307 const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, option, widget); |
|
1308 const QRect checkBoxRect = subElementRect(SE_ViewItemCheckIndicator, option, widget); |
|
1309 const int indicatorSpacing = proxy()->pixelMetric(PM_LayoutHorizontalSpacing, option, widget); |
|
1310 int totalXMod = qMax(0, qMax((checkBoxRect.isValid() ? checkBoxRect.topRight().x() : 0), |
|
1311 (iconRect.isValid() ? iconRect.topRight().x() : 0))); |
|
1312 const int widthMod = checkBoxRect.width() + iconRect.width() + indicatorSpacing; |
|
1313 totalXMod = (menuItem->direction == Qt::LeftToRight) ? qMax(0, totalXMod - elementSize.topLeft().x()): 0; |
|
1314 totalXMod += indicatorSpacing; |
|
1315 elementSize.translate(totalXMod, 0); |
|
1316 elementSize.setWidth(menuItem->rect.width() - widthMod); |
|
1317 } else if (const QStyleOptionViewItemV4 *itemView = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
|
1318 elementSize = itemView->rect; |
|
1319 const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, option, widget); |
|
1320 const QRect checkBoxRect = subElementRect(SE_ViewItemCheckIndicator, option, widget); |
|
1321 const int indicatorSpacing = proxy()->pixelMetric(PM_LayoutHorizontalSpacing, option, widget); |
|
1322 int totalXMod = qMax(0, qMax((checkBoxRect.isValid() ? checkBoxRect.topRight().x() : 0), |
|
1323 (iconRect.isValid() ? iconRect.topRight().x() : 0))); |
|
1324 const int widthMod = checkBoxRect.width() + iconRect.width() + indicatorSpacing; |
|
1325 totalXMod = (itemView->direction == Qt::LeftToRight) ? qMax(0, totalXMod - elementSize.topLeft().x()): 0; |
|
1326 totalXMod += indicatorSpacing; |
|
1327 elementSize.translate(totalXMod, 0); |
|
1328 elementSize.setWidth(itemView->rect.width() - widthMod); |
|
1329 elementSize = visualRect(itemView->direction, itemView->rect, elementSize); |
|
1330 } |
|
1331 break; |
|
1332 } |
|
1333 case SE_ViewItemCheckIndicator: { |
|
1334 if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
|
1335 if (menuItem->menuHasCheckableItems) { |
|
1336 const int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget); |
|
1337 const int htAdjust = (menuItem->rect.height() - indicatorWidth) / 2; |
|
1338 elementSize = QRect(menuItem->rect.x(), menuItem->rect.y() + htAdjust, indicatorWidth, indicatorWidth); |
|
1339 elementSize = visualRect(menuItem->direction, menuItem->rect, elementSize); |
|
1340 } else { elementSize = QRect(); } |
|
1341 } else if (const QStyleOptionViewItemV4 *itemOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
|
1342 if (itemOption->features & QStyleOptionViewItemV2::HasCheckIndicator) { |
|
1343 const int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget); |
|
1344 const int htAdjust = (itemOption->rect.height() - indicatorWidth) / 2; |
|
1345 elementSize = QRect(itemOption->rect.x(), itemOption->rect.y() + htAdjust, indicatorWidth, indicatorWidth); |
|
1346 elementSize = visualRect(itemOption->direction, itemOption->rect, elementSize); |
|
1347 } else { elementSize = QRect(); } |
|
1348 } |
|
1349 break; |
|
1350 } |
|
1351 case SE_ItemViewItemDecoration: { |
|
1352 if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
|
1353 if (!menuItem->icon.isNull()) { |
|
1354 const QRect checkBoxRect = subElementRect(SE_ViewItemCheckIndicator, option, widget); |
|
1355 const int imageWidth = proxy()->pixelMetric(PM_SmallIconSize, option, widget); |
|
1356 const int indicatorSpacing = proxy()->pixelMetric(PM_LayoutHorizontalSpacing, option, widget); |
|
1357 const int htAdjust = (menuItem->rect.height() - imageWidth) / 2; |
|
1358 if (checkBoxRect.isValid()) { |
|
1359 elementSize = QRect(menuItem->rect.x() + checkBoxRect.width() + indicatorSpacing, menuItem->rect.y() + htAdjust, imageWidth, imageWidth); |
|
1360 } else { |
|
1361 elementSize = QRect(menuItem->rect.x() + indicatorSpacing, menuItem->rect.y() + htAdjust, imageWidth, imageWidth); |
|
1362 } |
|
1363 elementSize = visualRect(menuItem->direction, menuItem->rect, elementSize); |
|
1364 } else { elementSize = QRect(); } |
|
1365 } else if (const QStyleOptionViewItemV4 *itemOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
|
1366 if (!itemOption->icon.isNull()) { |
|
1367 const QRect checkBoxRect = subElementRect(SE_ViewItemCheckIndicator, option, widget); |
|
1368 const int imageWidth = proxy()->pixelMetric(PM_SmallIconSize, option, widget); |
|
1369 const int indicatorSpacing = proxy()->pixelMetric(PM_LayoutHorizontalSpacing, option, widget); |
|
1370 const int htAdjust = (itemOption->rect.height() - imageWidth) / 2; |
|
1371 if (checkBoxRect.isValid()) { |
|
1372 elementSize = QRect(itemOption->rect.x() + checkBoxRect.width() + indicatorSpacing, itemOption->rect.y() + htAdjust, imageWidth, imageWidth); |
|
1373 } else { |
|
1374 elementSize = QRect(itemOption->rect.x() + indicatorSpacing, itemOption->rect.y() + htAdjust, imageWidth, imageWidth); |
|
1375 } |
|
1376 elementSize = visualRect(itemOption->direction, itemOption->rect, elementSize); |
|
1377 } else { elementSize = QRect(); } |
|
1378 } |
|
1379 break; |
|
1380 } |
|
1381 case SE_PushButtonFocusRect: { |
|
1382 if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
1383 const int margin = proxy()->pixelMetric(PM_FocusFrameHMargin, button, widget); |
|
1384 elementSize = baseSize.adjusted(-margin, -margin, margin, margin); |
|
1385 } |
|
1386 break; |
|
1387 } |
|
1388 case SE_ProgressBarGroove: { |
|
1389 if (const QStyleOptionProgressBarV2 *progressBar = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
1390 elementSize = progressBar->rect; |
|
1391 } |
|
1392 break; |
|
1393 } |
|
1394 default: |
|
1395 break; |
|
1396 } |
|
1397 return elementSize; |
|
1398 } |
|
1399 |
|
1400 QRect QHbStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *option, |
|
1401 SubControl sc, const QWidget *widget) const |
|
1402 { |
|
1403 const QRect baseSize = QCommonStyle::subControlRect(cc, option, sc, widget); |
|
1404 QRect elementSize = baseSize; |
|
1405 switch (cc) { |
|
1406 case CC_ComboBox: { |
|
1407 if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
1408 const int buttonIconSize = pixelMetric(PM_ButtonIconSize); |
|
1409 const int buttonMargin = cmb->frame ? 2 : 0; |
|
1410 const int frameThickness = cmb->frame ? pixelMetric(PM_ComboBoxFrameWidth, cmb, widget) : 0; |
|
1411 const int buttonWidth = qMax(cmb->rect.height(), buttonIconSize); |
|
1412 |
|
1413 QSize buttonSize; |
|
1414 buttonSize.setWidth(buttonWidth + 2 * buttonMargin); |
|
1415 buttonSize.setHeight(qMax(8, (cmb->rect.height() >> 1) - frameThickness)); |
|
1416 buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
|
1417 switch (sc) { |
|
1418 case SC_ComboBoxArrow: { |
|
1419 elementSize = option->rect; |
|
1420 break; |
|
1421 } |
|
1422 case SC_ComboBoxFrame: { |
|
1423 QRect frameRect = QRect(cmb->rect); |
|
1424 int frameWidth = pixelMetric(PM_DefaultFrameWidth, cmb, widget); |
|
1425 int maxRight = cmb->rect.height() - 2 * frameWidth; |
|
1426 frameRect.adjust(0, 0, -maxRight, 0); |
|
1427 elementSize = frameRect; |
|
1428 break; |
|
1429 } |
|
1430 case SC_ComboBoxEditField: { |
|
1431 const int withFrameX = cmb->rect.x() + cmb->rect.width() - frameThickness - buttonSize.width(); |
|
1432 elementSize = QRect( |
|
1433 frameThickness, |
|
1434 frameThickness - 2, |
|
1435 withFrameX - frameThickness, |
|
1436 cmb->rect.height() - 2 * frameThickness ); |
|
1437 break; |
|
1438 } |
|
1439 case SC_ComboBoxListBoxPopup: { |
|
1440 QRect mover = cmb->rect; |
|
1441 mover.moveBottom(cmb->rect.top() - 2); |
|
1442 elementSize = mover; |
|
1443 break; |
|
1444 } |
|
1445 default: |
|
1446 break; |
|
1447 } |
|
1448 } |
|
1449 break; |
|
1450 } |
|
1451 #ifndef QT_NO_SCROLLBAR |
|
1452 //todo: this was lifted "as-is" from QS60Style. Check that it is valid for uiemo. |
|
1453 case CC_ScrollBar: { |
|
1454 if (const QStyleOptionSlider *scrollbarOption = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
1455 const QRect scrollBarRect = scrollbarOption->rect; |
|
1456 const bool isHorizontal = scrollbarOption->orientation == Qt::Horizontal; |
|
1457 const int maxlen = isHorizontal ? scrollBarRect.width() : scrollBarRect.height(); |
|
1458 int sliderlen; |
|
1459 |
|
1460 // calculate slider length |
|
1461 if (scrollbarOption->maximum != scrollbarOption->minimum) { |
|
1462 const uint range = scrollbarOption->maximum - scrollbarOption->minimum; |
|
1463 sliderlen = (qint64(scrollbarOption->pageStep) * maxlen) / (range + scrollbarOption->pageStep); |
|
1464 |
|
1465 const int slidermin = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollbarOption, widget); |
|
1466 if (sliderlen < slidermin || range > (INT_MAX >> 1)) |
|
1467 sliderlen = slidermin; |
|
1468 if (sliderlen > maxlen) |
|
1469 sliderlen = maxlen; |
|
1470 } else { |
|
1471 sliderlen = maxlen; |
|
1472 } |
|
1473 |
|
1474 const int sliderstart = sliderPositionFromValue(scrollbarOption->minimum, |
|
1475 scrollbarOption->maximum, |
|
1476 scrollbarOption->sliderPosition, |
|
1477 maxlen - sliderlen, |
|
1478 scrollbarOption->upsideDown); |
|
1479 |
|
1480 switch (sc) { |
|
1481 case SC_ScrollBarSubPage: { // between top/left button and slider |
|
1482 if (isHorizontal) |
|
1483 elementSize.setRect(0, 0, sliderstart, scrollBarRect.height()); |
|
1484 else |
|
1485 elementSize.setRect(0, 0, scrollBarRect.width(), sliderstart); |
|
1486 break; |
|
1487 } |
|
1488 case SC_ScrollBarAddPage: { // between bottom/right button and slider |
|
1489 const int addPageLength = sliderstart + sliderlen; |
|
1490 if (isHorizontal) |
|
1491 elementSize = scrollBarRect.adjusted(addPageLength, 0, 0, 0); |
|
1492 else |
|
1493 elementSize = scrollBarRect.adjusted(0, addPageLength, 0, 0); |
|
1494 break; |
|
1495 } |
|
1496 case SC_ScrollBarGroove: { |
|
1497 elementSize = scrollBarRect; |
|
1498 break; |
|
1499 } |
|
1500 case SC_ScrollBarSlider: { |
|
1501 if (scrollbarOption->orientation == Qt::Horizontal) |
|
1502 elementSize.setRect(sliderstart, 0, sliderlen, scrollBarRect.height()); |
|
1503 else |
|
1504 elementSize.setRect(0, sliderstart, scrollBarRect.width(), sliderlen); |
|
1505 break; |
|
1506 } |
|
1507 case SC_ScrollBarSubLine: // top/left button |
|
1508 case SC_ScrollBarAddLine: // bottom/right button |
|
1509 default: { |
|
1510 break; |
|
1511 } |
|
1512 } |
|
1513 elementSize = visualRect(scrollbarOption->direction, scrollBarRect, elementSize); |
|
1514 } |
|
1515 break; |
|
1516 } |
|
1517 #endif // QT_NO_SCROLLBAR |
|
1518 #ifndef QT_NO_GROUPBOX |
|
1519 case CC_GroupBox: { |
|
1520 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { |
|
1521 switch (sc) { |
|
1522 case SC_GroupBoxFrame: { |
|
1523 int topMargin = 0; |
|
1524 int topHeight = 0; |
|
1525 int verticalAlignment = proxy()->styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget); |
|
1526 if (groupBox->text.size() || (groupBox->subControls & SC_GroupBoxCheckBox)) { |
|
1527 topHeight = groupBox->fontMetrics.height(); |
|
1528 if (verticalAlignment & Qt::AlignVCenter) |
|
1529 topMargin = topHeight / 2; |
|
1530 else if (verticalAlignment & Qt::AlignTop) |
|
1531 topMargin = topHeight; |
|
1532 } |
|
1533 |
|
1534 QRect frameRect = groupBox->rect; |
|
1535 frameRect.setTop(topMargin); |
|
1536 elementSize = frameRect; |
|
1537 break; |
|
1538 } |
|
1539 case SC_GroupBoxContents: { |
|
1540 const QRect titleRect = proxy()->subControlRect(cc, option, SC_GroupBoxLabel, widget); |
|
1541 const QRect frameRect = proxy()->subControlRect(cc, option, SC_GroupBoxFrame, widget); |
|
1542 elementSize = frameRect; |
|
1543 elementSize.setHeight(frameRect.height() + titleRect.height()); |
|
1544 elementSize.translate((groupBox->direction == Qt::LeftToRight) ? titleRect.bottomLeft() : titleRect.bottomRight()); |
|
1545 break; |
|
1546 } |
|
1547 case SC_GroupBoxCheckBox: |
|
1548 case SC_GroupBoxLabel: { |
|
1549 QFontMetrics fontMetrics = groupBox->fontMetrics; |
|
1550 const int height = fontMetrics.height(); |
|
1551 //margins |
|
1552 int labelTopMargin = 0; int labelBottomMargin = 0; |
|
1553 m_private->hbParameter(QLatin1String("hb-param-margin-gene-top"), labelTopMargin); |
|
1554 m_private->hbParameter(QLatin1String("hb-param-margin-gene-bottom"), labelBottomMargin); |
|
1555 |
|
1556 //height |
|
1557 const int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget); |
|
1558 elementSize = groupBox->rect; |
|
1559 elementSize.setHeight(qMax(height, indicatorHeight) + labelTopMargin + labelBottomMargin); |
|
1560 |
|
1561 const int indicatorSpace = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, option, widget); |
|
1562 const bool hasCheckBox = groupBox->subControls & SC_GroupBoxCheckBox; |
|
1563 const int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget); |
|
1564 const int checkBoxSize = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0; |
|
1565 |
|
1566 QRect totalRect; |
|
1567 // Adjust totalRect if checkbox is set |
|
1568 if (hasCheckBox) { |
|
1569 int top = 0; int left = 0; int width = 0; |
|
1570 int height = elementSize.height(); |
|
1571 // Adjust for check box |
|
1572 if (sc == SC_GroupBoxCheckBox) { |
|
1573 top = labelTopMargin + elementSize.top() + (fontMetrics.height() - indicatorHeight) / 2; |
|
1574 const int right = elementSize.right() - checkBoxSize; |
|
1575 left = right - checkBoxSize; |
|
1576 width = height = checkBoxSize; |
|
1577 // Adjust for label |
|
1578 } else { |
|
1579 left = (groupBox->direction == Qt::LeftToRight) ? elementSize.left() |
|
1580 : (elementSize.left() + checkBoxSize); |
|
1581 width = elementSize.width() - checkBoxSize; |
|
1582 } |
|
1583 totalRect.setRect(left, top, width, height); |
|
1584 } |
|
1585 elementSize = visualRect(option->direction, option->rect, totalRect); |
|
1586 break; |
|
1587 } |
|
1588 default: { |
|
1589 break; |
|
1590 } |
|
1591 } |
|
1592 } |
|
1593 break; |
|
1594 } |
|
1595 #endif //QT_NO_GROUPBOX |
|
1596 #ifndef QT_NO_SLIDER |
|
1597 case CC_Slider: { |
|
1598 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
1599 qreal metric = 0; |
|
1600 m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-middle-horizontal"), metric); |
|
1601 const int metricValue = metric + 0.5; |
|
1602 switch (sc) { |
|
1603 //Hb differentiates between major and minor ticks. |
|
1604 //Unfortunately Qt does not, so we consider all ticks as major. |
|
1605 //Tick sizes from Hb widget illustrations. |
|
1606 case SC_SliderTickmarks: { |
|
1607 //This just returns first tick rect for slider. Others need to be translated. |
|
1608 const bool horizontal = (slider->orientation == Qt::Horizontal); |
|
1609 const qreal unitValue = HbDeviceProfile::current().unitValue(); |
|
1610 qreal width = 0; qreal height = 0; |
|
1611 //width and height unit values from Hb widget gallery |
|
1612 if (horizontal) { |
|
1613 width = 0.5 * unitValue + 0.5; |
|
1614 height = unitValue + 0.5; |
|
1615 } else { |
|
1616 height = 0.5 * unitValue + 0.5; |
|
1617 width = unitValue + 0.5; |
|
1618 } |
|
1619 const QRect sliderGroove = subControlRect(cc, slider, SC_SliderGroove, widget); |
|
1620 QRect tickRect = QRect(sliderGroove.x(), sliderGroove.y(), width, height); |
|
1621 if (horizontal) |
|
1622 tickRect.translate(0, -metricValue); |
|
1623 else |
|
1624 tickRect.translate(-metricValue, 0); |
|
1625 elementSize = tickRect; |
|
1626 break; |
|
1627 } |
|
1628 case SC_SliderGroove: { |
|
1629 const int thickness = proxy()->pixelMetric(PM_SliderThickness, slider, widget); |
|
1630 const int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget); |
|
1631 if (slider->orientation == Qt::Horizontal) |
|
1632 elementSize.setRect(slider->rect.x(), slider->rect.y() + metricValue + tickOffset, |
|
1633 slider->rect.width(), thickness - 2 * (metricValue + tickOffset)); |
|
1634 else |
|
1635 elementSize.setRect(slider->rect.x() + tickOffset + metricValue, slider->rect.y(), |
|
1636 thickness - 2 * (metricValue + tickOffset), slider->rect.height()); |
|
1637 break; |
|
1638 } |
|
1639 default: { |
|
1640 break; |
|
1641 } |
|
1642 } |
|
1643 } |
|
1644 break; |
|
1645 } |
|
1646 #endif //QT_NO_SLIDER |
|
1647 #ifndef QT_NO_SPINBOX |
|
1648 case CC_SpinBox: { |
|
1649 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
1650 const int buttonIconSize = pixelMetric(PM_ButtonIconSize); |
|
1651 const int buttonWidth = qMax(spinbox->rect.height(), buttonIconSize); |
|
1652 switch (sc) { |
|
1653 case SC_SpinBoxFrame: |
|
1654 elementSize = option->rect.adjusted(0, 0, -buttonWidth + 5, 0); |
|
1655 break; |
|
1656 case SC_SpinBoxDown: { |
|
1657 if (option->direction == Qt::RightToLeft) |
|
1658 elementSize = QRect(option->rect.right() - buttonWidth, option->rect.y(),buttonWidth, option->rect.height()); |
|
1659 else |
|
1660 elementSize = QRect( option->rect.x(), option->rect.y(), buttonWidth,option->rect.height()); |
|
1661 } |
|
1662 break; |
|
1663 case SC_SpinBoxUp: { |
|
1664 if (option->direction == Qt::RightToLeft) |
|
1665 elementSize = QRect( option->rect.x(), option->rect.y(), buttonWidth,option->rect.height()); |
|
1666 else |
|
1667 elementSize = QRect(option->rect.right() - buttonWidth,option->rect.y(),buttonWidth,option->rect.height()); |
|
1668 } |
|
1669 break; |
|
1670 case SC_SpinBoxEditField: |
|
1671 elementSize = option->rect.adjusted(buttonWidth, 0, -buttonWidth, 0); |
|
1672 break; |
|
1673 default: |
|
1674 break; |
|
1675 } |
|
1676 } |
|
1677 break; |
|
1678 } |
|
1679 #endif //QT_NO_SPINBOX |
|
1680 default: { |
|
1681 break; |
|
1682 } |
|
1683 } |
|
1684 return elementSize; |
|
1685 } |
|
1686 |
|
1687 int QHbStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, |
|
1688 QStyleHintReturn *returnData) const |
|
1689 { |
|
1690 int retValue = 0; |
|
1691 switch (hint) { |
|
1692 case SH_RequestSoftwareInputPanel: |
|
1693 retValue = RSIP_OnMouseClick; |
|
1694 break; |
|
1695 case SH_ToolButtonStyle: |
|
1696 retValue = Qt::ToolButtonIconOnly; |
|
1697 break; |
|
1698 case SH_TabWidget_DefaultTabPosition: { |
|
1699 retValue = QTabWidget::North; |
|
1700 break; |
|
1701 } |
|
1702 case SH_TabBar_ElideMode: |
|
1703 if (option) |
|
1704 retValue = (option->direction == Qt::LeftToRight) ? Qt::ElideRight : Qt::ElideLeft; |
|
1705 else if (widget) |
|
1706 retValue = (widget->layoutDirection() == Qt::LeftToRight) ? Qt::ElideRight : Qt::ElideLeft; |
|
1707 else |
|
1708 retValue = (QApplication::layoutDirection() == Qt::LeftToRight) ? Qt::ElideRight : Qt::ElideLeft; |
|
1709 break; |
|
1710 case SH_ItemView_ShowDecorationSelected: |
|
1711 retValue = true; |
|
1712 break; |
|
1713 case SH_SpinControls_DisableOnBounds: { |
|
1714 retValue = true; |
|
1715 break; |
|
1716 } |
|
1717 case SH_MessageBox_TextInteractionFlags: { |
|
1718 retValue = Qt::LinksAccessibleByMouse; |
|
1719 break; |
|
1720 } |
|
1721 case SH_MessageBox_CenterButtons: { |
|
1722 retValue = true; |
|
1723 break; |
|
1724 } |
|
1725 case SH_Button_FocusPolicy: { |
|
1726 retValue = Qt::StrongFocus; |
|
1727 break; |
|
1728 } |
|
1729 case SH_Table_GridLineColor: { |
|
1730 retValue = Qt::green; //@todo: fetch this |
|
1731 break; |
|
1732 } |
|
1733 case SH_TabBar_Alignment: { |
|
1734 retValue = Qt::AlignCenter; |
|
1735 break; |
|
1736 } |
|
1737 case SH_Header_ArrowAlignment: { |
|
1738 if (option) |
|
1739 retValue = (option->direction == Qt::LeftToRight) ? Qt::AlignLeft : Qt::AlignRight; |
|
1740 else if (widget) |
|
1741 retValue = (widget->layoutDirection() == Qt::LeftToRight) ? Qt::AlignLeft : Qt::AlignRight; |
|
1742 else |
|
1743 retValue = (QApplication::layoutDirection() == Qt::LeftToRight) ? Qt::AlignLeft : Qt::AlignRight; |
|
1744 break; |
|
1745 } |
|
1746 case SH_ToolTipLabel_Opacity: { |
|
1747 retValue = 255; |
|
1748 break; |
|
1749 } |
|
1750 case SH_ScrollBar_ContextMenu: { |
|
1751 retValue = false; |
|
1752 break; |
|
1753 } |
|
1754 case SH_Menu_MouseTracking: { |
|
1755 retValue = 0; |
|
1756 break; |
|
1757 } |
|
1758 case SH_ComboBox_ListMouseTracking: { |
|
1759 retValue = 0; |
|
1760 break; |
|
1761 } |
|
1762 case SH_ComboBox_Popup: { |
|
1763 retValue = 1; |
|
1764 break; |
|
1765 } |
|
1766 case SH_UnderlineShortcut: { |
|
1767 retValue = false; |
|
1768 break; |
|
1769 } |
|
1770 case SH_GroupBox_TextLabelColor: { |
|
1771 QColor test = HbColorScheme::color("popupforeground"); |
|
1772 retValue = int(HbColorScheme::color("popupforeground").rgba()); //@todo: should use "qtc_viewtitle" but that is not yet available |
|
1773 break; |
|
1774 } |
|
1775 case SH_GroupBox_TextLabelVerticalAlignment: { |
|
1776 retValue = Qt::AlignBottom; |
|
1777 break; |
|
1778 } |
|
1779 case SH_ItemView_ActivateItemOnSingleClick: { |
|
1780 retValue = true; |
|
1781 break; |
|
1782 } |
|
1783 case SH_ItemView_ArrowKeysNavigateIntoChildren: { |
|
1784 retValue = true; |
|
1785 break; |
|
1786 } |
|
1787 case SH_ItemView_PaintAlternatingRowColorsForEmptyArea: { |
|
1788 retValue = true; |
|
1789 break; |
|
1790 } |
|
1791 default: { |
|
1792 retValue = QCommonStyle::styleHint(hint, option, widget, returnData); |
|
1793 break; |
|
1794 } |
|
1795 } |
|
1796 return retValue; |
|
1797 } |
|
1798 |
|
1799 int QHbStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const |
|
1800 { |
|
1801 qreal metricValue = 0.0; |
|
1802 const qreal unitValue = HbDeviceProfile::current().unitValue(); |
|
1803 bool valueFound = false; |
|
1804 switch(metric) { |
|
1805 case PM_ButtonMargin: { |
|
1806 //Hb defines different margin values for each margin. We could use any of them, |
|
1807 // average, or mean, but lets settle for top margin for now. |
|
1808 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-background-button"), metricValue); |
|
1809 break; |
|
1810 } |
|
1811 case PM_ButtonDefaultIndicator: { |
|
1812 //Lets set default button indication frame width to zero as there is no such concept in uiemo |
|
1813 valueFound = true; |
|
1814 break; |
|
1815 } |
|
1816 case PM_MenuButtonIndicator: { |
|
1817 // Hb returns a square area for icon in a button. |
|
1818 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-secondary"), metricValue); |
|
1819 break; |
|
1820 } |
|
1821 case PM_ButtonShiftVertical: |
|
1822 case PM_ButtonShiftHorizontal: { |
|
1823 //No button shifting in Hb |
|
1824 valueFound = true; |
|
1825 break; |
|
1826 } |
|
1827 case PM_DefaultFrameWidth: { |
|
1828 valueFound = true; |
|
1829 metricValue = 2.0; |
|
1830 break; |
|
1831 } |
|
1832 case PM_SpinBoxFrameWidth: { |
|
1833 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-middle-horizontal"), metricValue); |
|
1834 break; |
|
1835 } |
|
1836 case PM_ComboBoxFrameWidth: { |
|
1837 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-top"), metricValue); |
|
1838 break; |
|
1839 } |
|
1840 case PM_MaximumDragDistance: { |
|
1841 valueFound = true; |
|
1842 metricValue = -1.0; //disable maximum drag distance functionality |
|
1843 break; |
|
1844 } |
|
1845 case PM_ScrollBarExtent: { |
|
1846 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-widget-scroll-bar-indicative-width"), metricValue); |
|
1847 break; |
|
1848 } |
|
1849 case PM_ScrollBarSliderMin: { |
|
1850 valueFound = true; |
|
1851 metricValue = 8.0 * unitValue; //8.0 from uiemo graphic designers (to be updated to the specification) |
|
1852 //todo: for indicative scrollbars the slider is 4.0uns. Can we query the state of scrollbar? |
|
1853 break; |
|
1854 } |
|
1855 case PM_SliderThickness: { |
|
1856 int numberOfTicks = 0; |
|
1857 if (const QStyleOptionSlider *optionSlider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
1858 if (optionSlider->tickPosition & QSlider::TicksAbove) |
|
1859 ++numberOfTicks; |
|
1860 if (optionSlider->tickPosition & QSlider::TicksBelow) |
|
1861 ++numberOfTicks; |
|
1862 } |
|
1863 metricValue = proxy()->pixelMetric(PM_SliderControlThickness, option, widget) + |
|
1864 numberOfTicks * (1.0 * unitValue + 0.5); //tickmarks are one unit tall |
|
1865 valueFound = true; |
|
1866 break; |
|
1867 } |
|
1868 // Slider handle size values from Hb widget illustrations library. |
|
1869 case PM_SliderControlThickness: { |
|
1870 valueFound = true; |
|
1871 metricValue = 4.0 * unitValue; |
|
1872 break; |
|
1873 } |
|
1874 case PM_SliderLength: { |
|
1875 valueFound = true; |
|
1876 metricValue = 2.0 * unitValue; |
|
1877 break; |
|
1878 } |
|
1879 case PM_SliderTickmarkOffset: { |
|
1880 valueFound = true; |
|
1881 if (const QStyleOptionSlider *optionSlider = qstyleoption_cast<const QStyleOptionSlider *>(option)) |
|
1882 if (optionSlider->tickPosition & QSlider::TicksAbove || optionSlider->tickPosition & QSlider::TicksBelow) |
|
1883 //tick marks are one unit tall |
|
1884 metricValue = 1.0 * unitValue + 0.5; |
|
1885 break; |
|
1886 } |
|
1887 case PM_SliderSpaceAvailable: { // available space for slider to move |
|
1888 if (widget) { |
|
1889 const QSize sliderSize = widget->size(); |
|
1890 qreal margin = 0.0; |
|
1891 if (m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-screen"), margin)) { |
|
1892 metricValue = qMax(sliderSize.width(), sliderSize.height()) - 2 * margin; |
|
1893 valueFound = true; |
|
1894 } |
|
1895 } else if (const QStyleOptionSlider *optionSlider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
1896 valueFound = true; |
|
1897 metricValue = (optionSlider->orientation == Qt::Horizontal) ? optionSlider->rect.width() : optionSlider->rect.height(); |
|
1898 } |
|
1899 break; |
|
1900 } |
|
1901 case PM_DockWidgetTitleBarButtonMargin: |
|
1902 case PM_DockWidgetTitleMargin: |
|
1903 case PM_DockWidgetSeparatorExtent: |
|
1904 case PM_DockWidgetHandleExtent: { |
|
1905 break; //todo: no suitable values in Hb? |
|
1906 } |
|
1907 case PM_DockWidgetFrameWidth: { |
|
1908 valueFound = false; //was true |
|
1909 QSize screenSize = HbDeviceProfile::current().logicalSize(); |
|
1910 metricValue = screenSize.width(); |
|
1911 break; |
|
1912 } |
|
1913 //Hb does not have tabs. Lets use toolbar layout data |
|
1914 case PM_TabBarTabHSpace: { |
|
1915 qreal toolbarWidth = 0.0; |
|
1916 if (m_private->styleManager()->parameter(QLatin1String("hb-param-widget-chrome-height"), toolbarWidth)) { |
|
1917 valueFound = true; |
|
1918 qreal iconWidth = 0.0; |
|
1919 if (m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-function"), iconWidth)) |
|
1920 metricValue = (toolbarWidth - iconWidth) / 2; |
|
1921 else |
|
1922 metricValue = toolbarWidth / 2; |
|
1923 } |
|
1924 break; |
|
1925 } |
|
1926 case PM_TabBarTabVSpace: { |
|
1927 qreal toolbarHeight = 0.0; |
|
1928 if (m_private->styleManager()->parameter(QLatin1String("hb-param-widget-toolbar-height"), toolbarHeight)) { |
|
1929 valueFound = true; |
|
1930 qreal iconHeight = 0.0; |
|
1931 if (m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-function"), iconHeight)) |
|
1932 metricValue = (toolbarHeight - iconHeight) / 2; |
|
1933 else |
|
1934 metricValue = toolbarHeight / 2; |
|
1935 } |
|
1936 break; |
|
1937 } |
|
1938 case PM_TabBarBaseHeight: { |
|
1939 valueFound = true; |
|
1940 metricValue = 2.0; |
|
1941 break; |
|
1942 } |
|
1943 case PM_TabBarTabOverlap: |
|
1944 case PM_TabBarBaseOverlap: { |
|
1945 metricValue = 1.0; |
|
1946 valueFound = true; |
|
1947 break; |
|
1948 } |
|
1949 case PM_ProgressBarChunkWidth: { |
|
1950 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-widget-progress-bar-height"), metricValue); |
|
1951 break; |
|
1952 } |
|
1953 case PM_SplitterWidth: { |
|
1954 //No splitter in Hb, so lets use interactive scrollbar width |
|
1955 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-widget-scroll-bar-interactive-width"), metricValue); |
|
1956 break; |
|
1957 } |
|
1958 case PM_TitleBarHeight: { |
|
1959 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-widget-chrome-height"), metricValue); |
|
1960 break; |
|
1961 } |
|
1962 case PM_MenuScrollerHeight: { |
|
1963 //No menu scroller in Hb, lets use interactive scrollbar width |
|
1964 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-widget-scroll-bar-interactive-width"), metricValue); |
|
1965 break; |
|
1966 } |
|
1967 case PM_MenuHMargin: { |
|
1968 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-left"), metricValue); |
|
1969 break; |
|
1970 } |
|
1971 case PM_MenuVMargin: { |
|
1972 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-top"), metricValue); |
|
1973 break; |
|
1974 } |
|
1975 case PM_MenuPanelWidth: { |
|
1976 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-background-list-popup"), metricValue); |
|
1977 break; |
|
1978 } |
|
1979 case PM_MenuTearoffHeight: { |
|
1980 valueFound = true; |
|
1981 metricValue = 0.0; |
|
1982 break; |
|
1983 } |
|
1984 case PM_MenuDesktopFrameWidth: { |
|
1985 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-background-list-popup"), metricValue); |
|
1986 break; |
|
1987 } |
|
1988 case PM_MenuBarPanelWidth: { |
|
1989 valueFound = true; |
|
1990 metricValue = 0.0; |
|
1991 break; |
|
1992 } |
|
1993 case PM_MenuBarItemSpacing: { |
|
1994 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-middle-horizontal"), metricValue); |
|
1995 break; |
|
1996 } |
|
1997 case PM_MenuBarVMargin: { |
|
1998 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-top"), metricValue); |
|
1999 break; |
|
2000 } |
|
2001 case PM_MenuBarHMargin: { |
|
2002 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-left"), metricValue); |
|
2003 break; |
|
2004 } |
|
2005 // Hb indicators are squares and radiobuttons and checkboxes are of similar size. |
|
2006 case PM_IndicatorWidth: |
|
2007 case PM_IndicatorHeight: |
|
2008 case PM_ExclusiveIndicatorWidth: |
|
2009 case PM_ExclusiveIndicatorHeight: |
|
2010 case PM_CheckListButtonSize: { |
|
2011 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-secondary"), metricValue); |
|
2012 // todo: or hb-param-graphic-size-primary-small? |
|
2013 break; |
|
2014 } |
|
2015 case PM_CheckListControllerSize: { |
|
2016 break; |
|
2017 } |
|
2018 case PM_DialogButtonsSeparator: { |
|
2019 qreal buttonArea = 0.0; |
|
2020 if (m_private->styleManager()->parameter(QLatin1String("hb-param-widget-chrome-height"), buttonArea)) { |
|
2021 qreal buttonIconArea = 0.0; |
|
2022 valueFound = true; |
|
2023 if (m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-function"), buttonIconArea)) |
|
2024 metricValue = (buttonArea - buttonIconArea) / 2; |
|
2025 else |
|
2026 metricValue = buttonArea / 2; |
|
2027 } |
|
2028 break; |
|
2029 } |
|
2030 case PM_DialogButtonsButtonWidth: |
|
2031 case PM_DialogButtonsButtonHeight: { |
|
2032 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-function"), metricValue); |
|
2033 break; |
|
2034 } |
|
2035 case PM_MdiSubWindowFrameWidth: { |
|
2036 valueFound = true; |
|
2037 metricValue = 0.75 * unitValue; //0.75 from uiemo documentation (margin for TitleBar) |
|
2038 break; |
|
2039 } |
|
2040 case PM_MdiSubWindowMinimizedWidth: { |
|
2041 //todo: will it cause issues, if we use Hb minimized titlebar size? Will Qt want to put dialog buttons visible? |
|
2042 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-widget-chrome-height"), metricValue); |
|
2043 metricValue = metricValue / 6; //from Hb documentation: minimized TitleBar width |
|
2044 break; |
|
2045 } |
|
2046 case PM_HeaderMargin: { |
|
2047 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-middle-vertical"), metricValue); |
|
2048 break; |
|
2049 } |
|
2050 case PM_HeaderMarkSize: { |
|
2051 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-secondary"), metricValue); |
|
2052 break; |
|
2053 } |
|
2054 case PM_HeaderGripMargin: { |
|
2055 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-middle-vertical"), metricValue); |
|
2056 break; |
|
2057 } |
|
2058 case PM_TabBar_ScrollButtonOverlap: { |
|
2059 valueFound = true; //Lets put the tabs side-by-side |
|
2060 break; |
|
2061 } |
|
2062 case PM_TabBarTabShiftHorizontal: |
|
2063 case PM_TabBarTabShiftVertical: { |
|
2064 //todo: should we have tab shifting? |
|
2065 break; |
|
2066 } |
|
2067 case PM_TabBarScrollButtonWidth: { |
|
2068 qreal margin = 0.0; |
|
2069 if (m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-top"), margin)) { |
|
2070 qreal buttonIconWidth = 0.0; |
|
2071 if (m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-secondary"), buttonIconWidth)) { |
|
2072 metricValue = margin * 2 + buttonIconWidth; |
|
2073 valueFound = true; |
|
2074 } |
|
2075 } |
|
2076 break; |
|
2077 } |
|
2078 case PM_ToolBarItemSpacing: |
|
2079 case PM_ToolBarItemMargin: |
|
2080 case PM_ToolBarFrameWidth: { |
|
2081 valueFound = true; //Hb Toolbar buttons are laid out with no margins between them |
|
2082 break; |
|
2083 } |
|
2084 case PM_ToolBarHandleExtent: { |
|
2085 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-widget-chrome-height"), metricValue); |
|
2086 metricValue = (2 * metricValue) / 3; //Use minimized Chrome width for toolbar handle size. |
|
2087 break; |
|
2088 } |
|
2089 case PM_ToolBarSeparatorExtent: { |
|
2090 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-widget-toolbar-height"), metricValue); |
|
2091 break; |
|
2092 } |
|
2093 case PM_ToolBarExtensionExtent: { |
|
2094 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-secondary"), metricValue); |
|
2095 break; |
|
2096 } |
|
2097 case PM_SpinBoxSliderHeight: {//todo: what's this... |
|
2098 break; |
|
2099 } |
|
2100 case PM_ToolBarIconSize: { |
|
2101 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-function"), metricValue); |
|
2102 break; |
|
2103 } |
|
2104 case PM_LargeIconSize: |
|
2105 case PM_ListViewIconSize: { |
|
2106 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-primary-large"), metricValue); |
|
2107 break; |
|
2108 } |
|
2109 case PM_TabBarIconSize: |
|
2110 case PM_SmallIconSize: |
|
2111 case PM_IconViewIconSize: { |
|
2112 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-primary-small"), metricValue); |
|
2113 break; |
|
2114 } |
|
2115 case PM_FocusFrameVMargin: |
|
2116 case PM_FocusFrameHMargin: { |
|
2117 valueFound = true; |
|
2118 metricValue = 4.0; //from hbstyle.cpp (P_PushButton_focus); value is already in pixels |
|
2119 break; |
|
2120 } |
|
2121 case PM_ToolTipLabelFrameWidth: { |
|
2122 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-background-popup-preview"), metricValue); |
|
2123 break; |
|
2124 } |
|
2125 case PM_CheckBoxLabelSpacing: { |
|
2126 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-middle-horizontal"), metricValue); |
|
2127 break; |
|
2128 } |
|
2129 case PM_SizeGripSize: { |
|
2130 //todo: AFAIK, Hb does not have sizegrips |
|
2131 break; |
|
2132 } |
|
2133 case PM_MessageBoxIconSize: { |
|
2134 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-primary-large"), metricValue); |
|
2135 break; |
|
2136 } |
|
2137 case PM_ButtonIconSize: { |
|
2138 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-function"), metricValue); |
|
2139 break; |
|
2140 } |
|
2141 case PM_RadioButtonLabelSpacing: { |
|
2142 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-middle-horizontal"), metricValue); |
|
2143 break; |
|
2144 } |
|
2145 case PM_LayoutLeftMargin: { |
|
2146 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-left"), metricValue); |
|
2147 break; |
|
2148 } |
|
2149 case PM_LayoutTopMargin: { |
|
2150 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-top"), metricValue); |
|
2151 break; |
|
2152 } |
|
2153 case PM_LayoutRightMargin: { |
|
2154 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-right"), metricValue); |
|
2155 break; |
|
2156 } |
|
2157 case PM_LayoutBottomMargin: { |
|
2158 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-bottom"), metricValue); |
|
2159 break; |
|
2160 } |
|
2161 case PM_LayoutHorizontalSpacing: { |
|
2162 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-middle-horizontal"), metricValue); |
|
2163 break; |
|
2164 } |
|
2165 case PM_LayoutVerticalSpacing: { |
|
2166 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-margin-gene-middle-vertical"), metricValue); |
|
2167 break; |
|
2168 } |
|
2169 case PM_TabCloseIndicatorWidth: |
|
2170 case PM_TabCloseIndicatorHeight: { |
|
2171 valueFound = m_private->styleManager()->parameter(QLatin1String("hb-param-graphic-size-primary-small"), metricValue); |
|
2172 break; |
|
2173 } |
|
2174 case PM_TextCursorWidth: { |
|
2175 valueFound = true; |
|
2176 metricValue = 1.0; //directly from Hb designers |
|
2177 break; |
|
2178 } |
|
2179 case PM_SubMenuOverlap: |
|
2180 default: { |
|
2181 break; |
|
2182 } |
|
2183 } |
|
2184 if (!valueFound) |
|
2185 return metricValue = QCommonStyle::pixelMetric(metric, option, widget); |
|
2186 else |
|
2187 return metricValue + 0.5; //rounding since hb values are qreals |
|
2188 } |
|
2189 |
|
2190 QPixmap QHbStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option, |
|
2191 const QWidget *widget) const |
|
2192 { |
|
2193 return QCommonStyle::standardPixmap(standardPixmap, option, widget); |
|
2194 } |
|
2195 |
|
2196 void QHbStyle::polish(QWidget *widget) |
|
2197 { |
|
2198 if (!widget) |
|
2199 return; |
|
2200 |
|
2201 if (false |
|
2202 #ifndef QT_NO_SCROLLBAR |
|
2203 || qobject_cast<QScrollBar *>(widget) |
|
2204 #endif |
|
2205 ) { |
|
2206 widget->setAttribute(Qt::WA_OpaquePaintEvent, false); |
|
2207 } |
|
2208 |
|
2209 if (m_private->isDialog(widget)) { |
|
2210 widget->setAttribute(Qt::WA_StyledBackground); |
|
2211 } |
|
2212 |
|
2213 m_private->polishFont(widget); |
|
2214 |
|
2215 QCommonStyle::polish(widget); |
|
2216 |
|
2217 #ifndef QT_NO_PROGRESSBAR |
|
2218 if (qobject_cast<QProgressBar *>(widget)) |
|
2219 widget->installEventFilter(this); |
|
2220 #endif |
|
2221 } |
|
2222 |
|
2223 void QHbStyle::polish(QApplication *app) |
|
2224 { |
|
2225 QCommonStyle::polish(app); |
|
2226 } |
|
2227 |
|
2228 void QHbStyle::polish(QPalette &palette) |
|
2229 { |
|
2230 QCommonStyle::polish(palette); |
|
2231 |
|
2232 palette.setBrush(QPalette::Disabled, QPalette::WindowText, QColor(QRgb(0xff808080))); |
|
2233 palette.setBrush(QPalette::Disabled, QPalette::Button, QColor(QRgb(0xffdddfe4))); |
|
2234 palette.setBrush(QPalette::Disabled, QPalette::Light, QColor(QRgb(0xffffffff))); |
|
2235 palette.setBrush(QPalette::Disabled, QPalette::Midlight, QColor(QRgb(0xffffffff))); |
|
2236 palette.setBrush(QPalette::Disabled, QPalette::Dark, QColor(QRgb(0xff555555))); |
|
2237 palette.setBrush(QPalette::Disabled, QPalette::Mid, QColor(QRgb(0xffc7c7c7))); |
|
2238 palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(QRgb(0xffc7c7c7))); |
|
2239 palette.setBrush(QPalette::Disabled, QPalette::BrightText, QColor(QRgb(0xffffffff))); |
|
2240 palette.setBrush(QPalette::Disabled, QPalette::ButtonText, QColor(QRgb(0xff808080))); |
|
2241 palette.setBrush(QPalette::Disabled, QPalette::Base, QColor(QRgb(0xffefefef))); |
|
2242 palette.setBrush(QPalette::Disabled, QPalette::AlternateBase, palette.color(QPalette::Disabled, QPalette::Base).darker(110)); |
|
2243 palette.setBrush(QPalette::Disabled, QPalette::Window, QColor(QRgb(0xffefefef))); |
|
2244 palette.setBrush(QPalette::Disabled, QPalette::Shadow, QColor(QRgb(0xff000000))); |
|
2245 palette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(QRgb(0xff567594))); |
|
2246 palette.setBrush(QPalette::Disabled, QPalette::HighlightedText, QColor(QRgb(0xffffffff))); |
|
2247 palette.setBrush(QPalette::Disabled, QPalette::Link, QColor(QRgb(0xff0000ee))); |
|
2248 palette.setBrush(QPalette::Disabled, QPalette::LinkVisited, QColor(QRgb(0xff52188b))); |
|
2249 palette.setBrush(QPalette::Disabled, QPalette::ToolTipBase, QColor(QRgb(0xff0000ee))); |
|
2250 palette.setBrush(QPalette::Disabled, QPalette::ToolTipText, QColor(QRgb(0xff52188b))); |
|
2251 |
|
2252 palette.setBrush(QPalette::Active, QPalette::WindowText, QColor(QRgb(0xff000000))); |
|
2253 palette.setBrush(QPalette::Active, QPalette::Button, QColor(QRgb(0xffdddfe4))); |
|
2254 palette.setBrush(QPalette::Active, QPalette::Light, QColor(QRgb(0xffffffff))); |
|
2255 palette.setBrush(QPalette::Active, QPalette::Midlight, QColor(QRgb(0xffffffff))); |
|
2256 palette.setBrush(QPalette::Active, QPalette::Dark, QColor(QRgb(0xff555555))); |
|
2257 palette.setBrush(QPalette::Active, QPalette::Mid, QColor(QRgb(0xffc7c7c7))); |
|
2258 palette.setBrush(QPalette::Active, QPalette::Text, QColor(QRgb(0xff000000))); |
|
2259 palette.setBrush(QPalette::Active, QPalette::BrightText, QColor(QRgb(0xffffffff))); |
|
2260 palette.setBrush(QPalette::Active, QPalette::ButtonText, QColor(QRgb(0xff000000))); |
|
2261 palette.setBrush(QPalette::Active, QPalette::Base, QColor(QRgb(0xE4E4E4))); |
|
2262 palette.setBrush(QPalette::Active, QPalette::AlternateBase, palette.color(QPalette::Active, QPalette::Base).darker(110)); |
|
2263 palette.setBrush(QPalette::Active, QPalette::Window, QColor(QRgb(0xffefefef))); |
|
2264 palette.setBrush(QPalette::Active, QPalette::Shadow, QColor(QRgb(0xff000000))); |
|
2265 palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(QRgb(0xffE4E4E4))); |
|
2266 palette.setBrush(QPalette::Active, QPalette::HighlightedText, QColor(QRgb(0xff000000))); |
|
2267 palette.setBrush(QPalette::Active, QPalette::Link, QColor(QRgb(0xff0000ee))); |
|
2268 palette.setBrush(QPalette::Active, QPalette::LinkVisited, QColor(QRgb(0xff52188b))); |
|
2269 palette.setBrush(QPalette::Active, QPalette::ToolTipBase, QColor(QRgb(0xff0000ee))); |
|
2270 palette.setBrush(QPalette::Active, QPalette::ToolTipText, QColor(QRgb(0xff52188b))); |
|
2271 |
|
2272 palette.setBrush(QPalette::Inactive, QPalette::WindowText, QColor(QRgb(0xff000000))); |
|
2273 palette.setBrush(QPalette::Inactive, QPalette::Button, QColor(QRgb(0xffdddfe4))); |
|
2274 palette.setBrush(QPalette::Inactive, QPalette::Light, QColor(QRgb(0xffffffff))); |
|
2275 palette.setBrush(QPalette::Inactive, QPalette::Midlight, QColor(QRgb(0xffffffff))); |
|
2276 palette.setBrush(QPalette::Inactive, QPalette::Dark, QColor(QRgb(0xff555555))); |
|
2277 palette.setBrush(QPalette::Inactive, QPalette::Mid, QColor(QRgb(0xffc7c7c7))); |
|
2278 palette.setBrush(QPalette::Inactive, QPalette::Text, QColor(QRgb(0xff000000))); |
|
2279 palette.setBrush(QPalette::Inactive, QPalette::BrightText, QColor(QRgb(0xffffffff))); |
|
2280 palette.setBrush(QPalette::Inactive, QPalette::ButtonText, QColor(QRgb(0xff000000))); |
|
2281 palette.setBrush(QPalette::Inactive, QPalette::Base, QColor(QRgb(0xffffffff))); |
|
2282 palette.setBrush(QPalette::Inactive, QPalette::AlternateBase, palette.color(QPalette::Inactive, QPalette::Base).darker(110)); |
|
2283 palette.setBrush(QPalette::Inactive, QPalette::Window, QColor(QRgb(0xffefefef))); |
|
2284 palette.setBrush(QPalette::Inactive, QPalette::Shadow, QColor(QRgb(0xff000000))); |
|
2285 palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(QRgb(0xff678db2))); |
|
2286 palette.setBrush(QPalette::Inactive, QPalette::HighlightedText, QColor(QRgb(0xffffffff))); |
|
2287 palette.setBrush(QPalette::Inactive, QPalette::Link, QColor(QRgb(0xff0000ee))); |
|
2288 palette.setBrush(QPalette::Inactive, QPalette::LinkVisited, QColor(QRgb(0xff52188b))); |
|
2289 palette.setBrush(QPalette::Inactive, QPalette::ToolTipBase, QColor(QRgb(0xff0000ee))); |
|
2290 palette.setBrush(QPalette::Inactive, QPalette::ToolTipText, QColor(QRgb(0xff52188b))); |
|
2291 } |
|
2292 |
|
2293 void QHbStyle::unpolish(QWidget *widget) |
|
2294 { |
|
2295 if (!widget) |
|
2296 return; |
|
2297 |
|
2298 if (false |
|
2299 #ifndef QT_NO_SCROLLBAR |
|
2300 || qobject_cast<QScrollBar *>(widget) |
|
2301 #endif |
|
2302 ) |
|
2303 widget->setAttribute(Qt::WA_OpaquePaintEvent); |
|
2304 |
|
2305 if (m_private->isDialog(widget)) { |
|
2306 widget->setAttribute(Qt::WA_StyledBackground, false); |
|
2307 } |
|
2308 |
|
2309 QCommonStyle::unpolish(widget); |
|
2310 |
|
2311 #ifndef QT_NO_PROGRESSBAR |
|
2312 if (qobject_cast<QProgressBar *>(widget)) { |
|
2313 widget->removeEventFilter(this); |
|
2314 } |
|
2315 #endif |
|
2316 } |
|
2317 |
|
2318 void QHbStyle::unpolish(QApplication *app) |
|
2319 { |
|
2320 QCommonStyle::unpolish(app); |
|
2321 } |
|
2322 |
|
2323 QPalette QHbStyle::standardPalette() const |
|
2324 { |
|
2325 // This function not called if system support system colors |
|
2326 return QCommonStyle::standardPalette(); |
|
2327 } |
|
2328 |
|
2329 QIcon QHbStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, |
|
2330 const QWidget *widget) const |
|
2331 { |
|
2332 QRect iconRect; |
|
2333 if (option) { |
|
2334 iconRect = option->rect; |
|
2335 } else if (widget) { |
|
2336 iconRect = widget->rect(); |
|
2337 } else { |
|
2338 iconRect.setWidth(proxy()->pixelMetric(PM_SmallIconSize, option, widget)); |
|
2339 iconRect.setHeight(proxy()->pixelMetric(PM_SmallIconSize, option, widget)); |
|
2340 } |
|
2341 QString iconName; |
|
2342 |
|
2343 switch (standardIcon) { |
|
2344 case SP_TitleBarMenuButton: { |
|
2345 break; |
|
2346 } |
|
2347 case SP_TitleBarMinButton: { |
|
2348 break; |
|
2349 } |
|
2350 case SP_TitleBarMaxButton: { |
|
2351 break; |
|
2352 } |
|
2353 case SP_TitleBarCloseButton: { |
|
2354 break; |
|
2355 } |
|
2356 case SP_TitleBarNormalButton: { |
|
2357 break; |
|
2358 } |
|
2359 case SP_TitleBarShadeButton: { |
|
2360 break; |
|
2361 } |
|
2362 case SP_TitleBarUnshadeButton: { |
|
2363 break; |
|
2364 } |
|
2365 case SP_TitleBarContextHelpButton: { |
|
2366 break; |
|
2367 } |
|
2368 case SP_DockWidgetCloseButton: { |
|
2369 break; |
|
2370 } |
|
2371 case SP_MessageBoxInformation: { |
|
2372 iconName = QLatin1String("note_info"); |
|
2373 break; |
|
2374 } |
|
2375 case SP_MessageBoxWarning: { |
|
2376 iconName = QLatin1String("note_warning"); |
|
2377 break; |
|
2378 } |
|
2379 case SP_MessageBoxCritical: { |
|
2380 iconName = QLatin1String("note_error"); |
|
2381 break; |
|
2382 } |
|
2383 case SP_MessageBoxQuestion: { |
|
2384 iconName = QLatin1String("qtg_large_question_mark"); |
|
2385 break; |
|
2386 } |
|
2387 case SP_DesktopIcon: { |
|
2388 break; |
|
2389 } |
|
2390 case SP_TrashIcon: { |
|
2391 break; |
|
2392 } |
|
2393 case SP_ComputerIcon: { |
|
2394 iconName = QLatin1String("qtg_mono_mobile"); |
|
2395 break; |
|
2396 } |
|
2397 case SP_DriveFDIcon: { |
|
2398 break; |
|
2399 } |
|
2400 case SP_DriveHDIcon: { |
|
2401 break; |
|
2402 } |
|
2403 case SP_DriveCDIcon: { |
|
2404 break; |
|
2405 } |
|
2406 case SP_DriveDVDIcon: { |
|
2407 break; |
|
2408 } |
|
2409 case SP_DriveNetIcon: { |
|
2410 break; |
|
2411 } |
|
2412 case SP_DirOpenIcon: { |
|
2413 break; |
|
2414 } |
|
2415 case SP_DirClosedIcon: { |
|
2416 break; |
|
2417 } |
|
2418 case SP_DirLinkIcon: { |
|
2419 break; |
|
2420 } |
|
2421 case SP_FileIcon: { |
|
2422 break; |
|
2423 } |
|
2424 case SP_FileLinkIcon: { |
|
2425 break; |
|
2426 } |
|
2427 case SP_ToolBarHorizontalExtensionButton: { |
|
2428 break; |
|
2429 } |
|
2430 case SP_ToolBarVerticalExtensionButton: { |
|
2431 break; |
|
2432 } |
|
2433 case SP_FileDialogStart: { |
|
2434 break; |
|
2435 } |
|
2436 case SP_FileDialogEnd: { |
|
2437 break; |
|
2438 } |
|
2439 case SP_FileDialogToParent: { |
|
2440 break; |
|
2441 } |
|
2442 case SP_FileDialogNewFolder: { |
|
2443 break; |
|
2444 } |
|
2445 case SP_FileDialogDetailedView: { |
|
2446 break; |
|
2447 } |
|
2448 case SP_FileDialogInfoView: { |
|
2449 break; |
|
2450 } |
|
2451 case SP_FileDialogContentsView: { |
|
2452 break; |
|
2453 } |
|
2454 case SP_FileDialogListView: { |
|
2455 break; |
|
2456 } |
|
2457 case SP_FileDialogBack: { |
|
2458 break; |
|
2459 } |
|
2460 case SP_DirIcon: { |
|
2461 break; |
|
2462 } |
|
2463 case SP_DialogOkButton: { |
|
2464 break; |
|
2465 } |
|
2466 case SP_DialogCancelButton: { |
|
2467 break; |
|
2468 } |
|
2469 case SP_DialogHelpButton: { |
|
2470 break; |
|
2471 } |
|
2472 case SP_DialogOpenButton: { |
|
2473 break; |
|
2474 } |
|
2475 case SP_DialogSaveButton: { |
|
2476 break; |
|
2477 } |
|
2478 case SP_DialogCloseButton: { |
|
2479 break; |
|
2480 } |
|
2481 case SP_DialogApplyButton: { |
|
2482 break; |
|
2483 } |
|
2484 case SP_DialogResetButton: { |
|
2485 break; |
|
2486 } |
|
2487 case SP_DialogDiscardButton: { |
|
2488 break; |
|
2489 } |
|
2490 case SP_DialogYesButton: { |
|
2491 break; |
|
2492 } |
|
2493 case SP_DialogNoButton: { |
|
2494 break; |
|
2495 } |
|
2496 case SP_ArrowUp: { |
|
2497 break; |
|
2498 } |
|
2499 case SP_ArrowDown: { |
|
2500 break; |
|
2501 } |
|
2502 case SP_ArrowLeft: { |
|
2503 break; |
|
2504 } |
|
2505 case SP_ArrowRight: { |
|
2506 break; |
|
2507 } |
|
2508 case SP_ArrowBack: { |
|
2509 break; |
|
2510 } |
|
2511 case SP_ArrowForward: { |
|
2512 break; |
|
2513 } |
|
2514 case SP_DirHomeIcon: { |
|
2515 break; |
|
2516 } |
|
2517 case SP_CommandLink: { |
|
2518 break; |
|
2519 } |
|
2520 case SP_VistaShield: { |
|
2521 break; |
|
2522 } |
|
2523 case SP_BrowserReload: { |
|
2524 break; |
|
2525 } |
|
2526 case SP_BrowserStop: { |
|
2527 break; |
|
2528 } |
|
2529 case SP_MediaPlay: { |
|
2530 iconName = QLatin1String("qtg_graf_progslider_handle_play_normal"); |
|
2531 break; |
|
2532 } |
|
2533 case SP_MediaStop: { |
|
2534 break; |
|
2535 } |
|
2536 case SP_MediaPause: { |
|
2537 iconName = QLatin1String("qtg_graf_progslider_handle_pause_normal"); |
|
2538 break; |
|
2539 } |
|
2540 case SP_MediaSkipForward: { |
|
2541 break; |
|
2542 } |
|
2543 case SP_MediaSkipBackward: { |
|
2544 break; |
|
2545 } |
|
2546 case SP_MediaSeekForward: { |
|
2547 break; |
|
2548 } |
|
2549 case SP_MediaSeekBackward: { |
|
2550 break; |
|
2551 } |
|
2552 case SP_MediaVolume: { |
|
2553 iconName = QLatin1String("qgn_indi_nslider_unmuted"); |
|
2554 break; |
|
2555 } |
|
2556 case SP_MediaVolumeMuted: { |
|
2557 iconName = QLatin1String("qgn_indi_nslider_muted"); |
|
2558 break; |
|
2559 } |
|
2560 default: { |
|
2561 break; |
|
2562 } |
|
2563 } |
|
2564 |
|
2565 QIcon icon; |
|
2566 if (!iconName.isNull()) { |
|
2567 HbIcon* hbicon = q_check_ptr(new HbIcon(iconName)); |
|
2568 hbicon->setSize(iconRect.size()); |
|
2569 icon = QIcon(hbicon->qicon()); |
|
2570 delete hbicon; |
|
2571 } else { |
|
2572 icon = QCommonStyle::standardIconImplementation(standardIcon, option, widget); |
|
2573 } |
|
2574 return icon; |
|
2575 } |
|
2576 |
|
2577 int QHbStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1, |
|
2578 QSizePolicy::ControlType control2, |
|
2579 Qt::Orientation orientation, |
|
2580 const QStyleOption *option, |
|
2581 const QWidget *widget) const |
|
2582 { |
|
2583 return QCommonStyle::layoutSpacingImplementation(control1, control2, orientation, option, widget); |
|
2584 } |
|
2585 |
|
2586 bool QHbStyle::eventFilter(QObject *watched, QEvent *event) |
|
2587 { |
|
2588 switch( event->type()) { |
|
2589 #ifndef QT_NO_PROGRESSBAR |
|
2590 case QEvent::StyleChange: |
|
2591 case QEvent::Show: { |
|
2592 if (m_private->animationGroup()->state() != QAbstractAnimation::Running ) |
|
2593 m_private->animationGroup()->start(); |
|
2594 break; |
|
2595 } |
|
2596 case QEvent::ApplicationLayoutDirectionChange: |
|
2597 case QEvent::LayoutDirectionChange: |
|
2598 case QEvent::Resize: |
|
2599 case QEvent::Destroy: |
|
2600 case QEvent::Hide: { |
|
2601 if (QProgressBar *bar = qobject_cast<QProgressBar *>(watched)) { |
|
2602 const int count = m_private->animationGroup()->animationCount(); |
|
2603 for (int i(count-1); i >= 0; i--) { |
|
2604 QAbstractAnimation* animation = m_private->animationGroup()->animationAt(i); |
|
2605 if (QPropertyAnimation *pAnimation = qobject_cast<QPropertyAnimation *>(animation)) { |
|
2606 QHbStyleAnimation* styleAnimation = qobject_cast<QHbStyleAnimation *>(pAnimation->targetObject()); |
|
2607 if (bar == styleAnimation->target()) { |
|
2608 animation = m_private->animationGroup()->takeAnimation(i); |
|
2609 animation->deleteLater(); |
|
2610 } |
|
2611 } |
|
2612 } |
|
2613 if (m_private->animationGroup()->animationCount() == 0 && |
|
2614 m_private->animationGroup()->state() == QAbstractAnimation::Running) |
|
2615 m_private->animationGroup()->stop(); |
|
2616 } |
|
2617 break; |
|
2618 } |
|
2619 #endif // QT_NO_PROGRESSBAR |
|
2620 default: { |
|
2621 break; |
|
2622 } |
|
2623 }; |
|
2624 |
|
2625 return QCommonStyle::eventFilter(watched, event); |
|
2626 } |
|
2627 |
|
2628 void QHbStyle::animateControl(ControlElement element, const QStyleOption *option, |
|
2629 QPainter *painter, const QWidget *widget) const{ |
|
2630 switch(element) { |
|
2631 case CE_ProgressBarContents: { |
|
2632 if (const QProgressBar *bar = static_cast<const QProgressBar *>(widget)) { |
|
2633 if (bar->minimum() == 0 && bar->maximum() == 0) { |
|
2634 QHbStyleAnimation* styleAnimation = 0; |
|
2635 const int count = m_private->animationGroup()->animationCount(); |
|
2636 bool alreadyAnimated = false; |
|
2637 for (int i(0); i < count; i++) { |
|
2638 QAbstractAnimation* animation = m_private->animationGroup()->animationAt(i); |
|
2639 if (QPropertyAnimation *pAnimation = qobject_cast<QPropertyAnimation *>(animation)) { |
|
2640 styleAnimation = qobject_cast<QHbStyleAnimation *>(pAnimation->targetObject()); |
|
2641 if (bar == styleAnimation->target()) { |
|
2642 alreadyAnimated = true; |
|
2643 break; |
|
2644 } |
|
2645 } |
|
2646 } |
|
2647 if (!alreadyAnimated) { |
|
2648 QHbStyleAnimation* target = q_check_ptr(new QHbStyleAnimation(const_cast<QProgressBar*>(bar))); |
|
2649 target->createAnimationIcon(CE_ProgressBarContents, bar->orientation()); |
|
2650 QPropertyAnimation* animation = q_check_ptr(new QPropertyAnimation(target, "point")); |
|
2651 animation->setLoopCount(-1); //run until stopped |
|
2652 const int chunk = pixelMetric(PM_ProgressBarChunkWidth, option, widget)-1; |
|
2653 if (bar->orientation()== Qt::Horizontal) { |
|
2654 if ((option->direction == Qt::LeftToRight) ^ const_cast<QProgressBar*>(bar)->invertedAppearance()) { |
|
2655 animation->setStartValue(bar->rect().topLeft()); |
|
2656 animation->setEndValue(QPoint(bar->rect().x()-chunk, bar->rect().y())); |
|
2657 } else { |
|
2658 animation->setStartValue(QPoint(bar->rect().x()-chunk, bar->rect().y())); |
|
2659 animation->setEndValue(bar->rect().topLeft()); |
|
2660 } |
|
2661 } |
|
2662 else { |
|
2663 if ((option->direction == Qt::LeftToRight) ^ const_cast<QProgressBar*>(bar)->invertedAppearance()) { |
|
2664 animation->setStartValue(bar->rect().topLeft()); |
|
2665 animation->setEndValue(QPoint(bar->rect().x(), bar->rect().y()-chunk)); |
|
2666 } else { |
|
2667 animation->setStartValue(QPoint(bar->rect().x(), bar->rect().y()-chunk)); |
|
2668 animation->setEndValue(bar->rect().topLeft()); |
|
2669 } |
|
2670 } |
|
2671 m_private->animationGroup()->addAnimation(animation); |
|
2672 } else { |
|
2673 styleAnimation->paintAnimation(painter); |
|
2674 } |
|
2675 } |
|
2676 } |
|
2677 break; |
|
2678 } |
|
2679 default: { |
|
2680 break; |
|
2681 } |
|
2682 } |
|
2683 |
|
2684 if (m_private->animationGroup()->animationCount() > 0 && |
|
2685 m_private->animationGroup()->state() != QAbstractAnimation::Running) |
|
2686 m_private->animationGroup()->start(); |
|
2687 } |
|
2688 |
|
2689 bool QHbStylePrivate::drawItem(Item part, QPainter *painter, const QRect &rect, ItemStates state, const QColor &color) |
|
2690 { |
|
2691 QString iconName; |
|
2692 switch(part) { |
|
2693 case SP_Arrow: { |
|
2694 if (state & SS_Up) |
|
2695 iconName = QLatin1String("qgn_indi_input_arrow_up"); |
|
2696 else if (state & SS_Down) |
|
2697 iconName = QLatin1String("qgn_indi_input_arrow_down"); |
|
2698 else if (state && SS_Left) |
|
2699 iconName = QLatin1String("qgn_indi_input_arrow_left"); |
|
2700 else |
|
2701 iconName = QLatin1String("qgn_indi_input_arrow_right"); |
|
2702 break; |
|
2703 } |
|
2704 case SP_BoxButton: { |
|
2705 if (state & SS_Disabled) |
|
2706 iconName = QString("qtg_graf_combobox_button_disabled"); |
|
2707 else if (state & SS_Pressed) |
|
2708 iconName = QString("qtg_graf_combobox_button_pressed"); |
|
2709 else if (state & SS_Selected) |
|
2710 iconName = QString("qtg_graf_combobox_button_highlight"); |
|
2711 else |
|
2712 iconName = QString("qtg_graf_combobox_button_normal"); |
|
2713 break; |
|
2714 } |
|
2715 case SP_CheckBoxIndicator: { |
|
2716 if (state & SS_Inactive) |
|
2717 iconName = QLatin1String("qtg_small_unselected"); |
|
2718 else |
|
2719 iconName = QLatin1String("qtg_small_selected"); |
|
2720 break; |
|
2721 } |
|
2722 case SP_HeaderOrderIndicator: { |
|
2723 iconName = QLatin1String("qtg_mono_sort"); |
|
2724 break; |
|
2725 } |
|
2726 case SP_ItemDecoration: { |
|
2727 if (state & SS_Selected) |
|
2728 iconName = QString("qtg_small_tick"); |
|
2729 break; |
|
2730 } |
|
2731 case SP_MenuSeparator: { |
|
2732 iconName = QLatin1String("qtg_graf_popup_separator"); |
|
2733 break; |
|
2734 } |
|
2735 case SP_RadioButtonIndicator: { |
|
2736 if (state & SS_Inactive) |
|
2737 iconName = QLatin1String("qtg_small_radio_unselected"); |
|
2738 else |
|
2739 iconName = QLatin1String("qtg_small_radio_selected"); |
|
2740 break; |
|
2741 } |
|
2742 case SP_SliderHandle: { |
|
2743 if (state & SS_Horizontal) { |
|
2744 if (state & SS_Pressed) |
|
2745 iconName = QLatin1String("qtg_graf_slider_h_handle_pressed"); |
|
2746 else |
|
2747 iconName = QLatin1String("qtg_graf_slider_h_handle_normal"); |
|
2748 } else { |
|
2749 if (state & SS_Pressed) |
|
2750 iconName = QLatin1String("qtg_graf_slider_v_handle_pressed"); |
|
2751 else |
|
2752 iconName = QLatin1String("qtg_graf_slider_v_handle_normal"); |
|
2753 } |
|
2754 break; |
|
2755 } |
|
2756 case SP_SliderTick: { |
|
2757 if (state & SS_Horizontal) |
|
2758 iconName = QLatin1String("qtg_graf_slider_h_tick_major"); |
|
2759 else |
|
2760 iconName = QLatin1String("qtg_graf_slider_v_tick_major"); |
|
2761 break; |
|
2762 } |
|
2763 case SP_SeparatorLine: { |
|
2764 // @todo: or "qtg_graf_popup_separator" and states and rotation |
|
2765 if (state & SS_Horizontal) |
|
2766 iconName = QLatin1String("qtg_graf_devider_h_thin"); |
|
2767 else |
|
2768 iconName = QLatin1String("qtg_graf_devider_v_thin"); |
|
2769 break; |
|
2770 } |
|
2771 case SP_TreeViewExpanded: { |
|
2772 iconName = QLatin1String("qtg_small_hl_opened"); |
|
2773 break; |
|
2774 } |
|
2775 case SP_TreeViewCollapsed: { |
|
2776 iconName = QLatin1String("qtg_small_hl_closed"); |
|
2777 break; |
|
2778 } |
|
2779 case SP_SubMenuIndicator: |
|
2780 default: { |
|
2781 return false; |
|
2782 } |
|
2783 } |
|
2784 if (!iconName.isNull() && !rect.isEmpty()) { |
|
2785 HbIcon *icon = q_check_ptr(new HbIcon(iconName)); |
|
2786 icon->setSize(rect.size()); |
|
2787 if (color.spec() != QColor::Invalid) |
|
2788 icon->setColor(color); |
|
2789 if (state & SS_Mirrored) |
|
2790 icon->setMirroringMode(HbIcon::Forced); |
|
2791 |
|
2792 painter->save(); |
|
2793 painter->setRenderHint(QPainter::Antialiasing); |
|
2794 |
|
2795 if (state & SS_Flipped) { |
|
2796 QTransform m; |
|
2797 m.rotate(180); |
|
2798 m.translate(-rect.width() - 2 * rect.left(), -rect.height() - 2 * rect.top()); |
|
2799 painter->setTransform(m, true); |
|
2800 } |
|
2801 icon->paint(painter, rect, Qt::IgnoreAspectRatio, Qt::AlignCenter, QIcon::Normal, QIcon::On); |
|
2802 painter->restore(); |
|
2803 delete icon; |
|
2804 } |
|
2805 return true; |
|
2806 } |
|
2807 |
|
2808 bool QHbStylePrivate::drawMultiPartItem(MultiPartItem multiPart, QPainter *painter, const QRect &rect, ItemStates state) |
|
2809 { |
|
2810 //Q_Q(QHbStyle); |
|
2811 |
|
2812 if (!m_frameDrawer) |
|
2813 m_frameDrawer = q_check_ptr(new HbFrameDrawer()); |
|
2814 |
|
2815 HbFrameDrawer::FrameType frameType = HbFrameDrawer::Undefined; |
|
2816 QString frameName; |
|
2817 qreal border = 0.0; |
|
2818 HbIcon::MirroringMode mirrorMode = HbIcon::Default; |
|
2819 bool fillRect = false; |
|
2820 |
|
2821 QStringList framePartList; |
|
2822 QString frameGraphicsFooter; |
|
2823 QString frameGraphicsHeader; |
|
2824 switch (multiPart) { |
|
2825 case SM_BoxFrame: { |
|
2826 fillRect = true; |
|
2827 frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
2828 if (state & SS_Disabled) |
|
2829 frameName = QString("qtg_fr_combobox_disabled"); |
|
2830 else if (state & SS_Pressed) |
|
2831 frameName = QString("qtg_fr_combobox_pressed"); |
|
2832 else if (state & SS_Edited) |
|
2833 frameName = QString("qtg_fr_combobox_edit"); |
|
2834 else if (state & SS_Selected) |
|
2835 frameName = QString("qtg_fr_combobox_highlight"); |
|
2836 else |
|
2837 frameName = QString("qtg_fr_combobox_normal"); |
|
2838 break; |
|
2839 } |
|
2840 case SM_Dialog: { |
|
2841 frameName = QLatin1String("qtg_fr_popup"); |
|
2842 frameType = HbFrameDrawer::NinePieces; |
|
2843 break; |
|
2844 } |
|
2845 case SM_GroupBox: { |
|
2846 styleManager()->parameter(QLatin1String("hb-param-background-groupbox"), border); |
|
2847 if (state & SS_Pressed) |
|
2848 frameName = QLatin1String("qtg_fr_groupbox_pressed"); |
|
2849 else if (state & SS_Selected && state & SS_Active) |
|
2850 frameName = QLatin1String("qtg_fr_groupbox_highlight"); |
|
2851 else |
|
2852 frameName = QLatin1String("qtg_fr_groupbox_normal"); |
|
2853 frameType = HbFrameDrawer::NinePieces; |
|
2854 break; |
|
2855 } |
|
2856 case SM_GroupBoxTitle: { |
|
2857 frameName = QLatin1String("qtg_fr_groupbox"); |
|
2858 frameType = HbFrameDrawer::NinePieces; |
|
2859 break; |
|
2860 } |
|
2861 case SM_ItemViewHighlight: { |
|
2862 frameName = QLatin1String("qtg_fr_list_highlight"); |
|
2863 frameType = HbFrameDrawer::NinePieces; |
|
2864 break; |
|
2865 } |
|
2866 case SM_ItemViewItem: { |
|
2867 if (state & SS_Pressed) |
|
2868 frameName = QLatin1String("qtg_fr_list_pressed"); |
|
2869 else if (state & SS_Focused) |
|
2870 frameName = QLatin1String("qtg_fr_list_highlight"); |
|
2871 else |
|
2872 frameName = QLatin1String("qtg_fr_list_normal"); |
|
2873 frameType = HbFrameDrawer::NinePieces; |
|
2874 styleManager()->parameter(QLatin1String("hb-param-background-list-main"), border); |
|
2875 break; |
|
2876 } |
|
2877 case SM_LineEdit: { |
|
2878 styleManager()->parameter(QLatin1String("hb-param-background-editor"), border); |
|
2879 if (state & SS_Selected) |
|
2880 frameName = QLatin1String("qtg_fr_editor_highlight"); |
|
2881 else |
|
2882 frameName = QLatin1String("qtg_fr_editor_normal"); |
|
2883 frameType = HbFrameDrawer::NinePieces; |
|
2884 break; |
|
2885 } |
|
2886 case SM_ListParent: { |
|
2887 if (state & SS_Pressed) |
|
2888 frameName = QLatin1String("qtg_fr_list_pressed"); |
|
2889 else if (state & SS_Focused) |
|
2890 frameName = QLatin1String("qtg_fr_list_highlight"); |
|
2891 else |
|
2892 frameName = QLatin1String("qtg_fr_list_parent_normal"); |
|
2893 frameType = HbFrameDrawer::NinePieces; |
|
2894 styleManager()->parameter(QLatin1String("hb-param-background-list-main"), border); |
|
2895 break; |
|
2896 } |
|
2897 case SM_Menu: { |
|
2898 frameName = QLatin1String("qtg_fr_popup_secondary"); |
|
2899 frameType = HbFrameDrawer::NinePieces; |
|
2900 break; |
|
2901 } |
|
2902 case SM_MenuScroller: { |
|
2903 if (state & SS_Down) |
|
2904 frameName = QLatin1String("qtg_graf_list_mask_b"); |
|
2905 else if (state & SS_Up) |
|
2906 frameName = QLatin1String("qtg_graf_list_mask_t"); |
|
2907 frameType = HbFrameDrawer::OnePiece; |
|
2908 break; |
|
2909 } |
|
2910 case SM_MenuItem: { |
|
2911 if (state & SS_Pressed) |
|
2912 frameName = QLatin1String("qtg_fr_popup_list_pressed"); |
|
2913 else if (state & SS_Selected) |
|
2914 frameName = QLatin1String("qtg_fr_popup_list_highlight"); |
|
2915 else |
|
2916 frameName = QLatin1String("qtg_fr_popup_list_normal"); |
|
2917 frameType = HbFrameDrawer::NinePieces; |
|
2918 break; |
|
2919 } |
|
2920 case SM_Panel: { |
|
2921 frameName = QLatin1String("qtg_fr_settingform"); |
|
2922 frameType = HbFrameDrawer::NinePieces; |
|
2923 styleManager()->parameter(QLatin1String("hb-param-background-list-main"), border); |
|
2924 break; |
|
2925 } |
|
2926 case SM_ProgressBarGroove: { |
|
2927 fillRect = true; |
|
2928 if (state & SS_Horizontal) { |
|
2929 frameName = QLatin1String("qtg_fr_progbar_h_frame"); |
|
2930 frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
2931 } else { |
|
2932 frameName = QLatin1String("qtg_fr_progbar_v_frame"); |
|
2933 frameType = HbFrameDrawer::ThreePiecesVertical; |
|
2934 } |
|
2935 break; |
|
2936 } |
|
2937 case SM_ProgressBarIndicator: { |
|
2938 fillRect = true; |
|
2939 if (state & SS_Horizontal) { |
|
2940 frameName = QLatin1String("qtg_fr_progbar_h_filled"); |
|
2941 frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
2942 } else { |
|
2943 frameName = QLatin1String("qtg_fr_progbar_v_filled"); |
|
2944 frameType = HbFrameDrawer::ThreePiecesVertical; |
|
2945 } |
|
2946 break; |
|
2947 } |
|
2948 case SM_ToolButton: { |
|
2949 frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
2950 frameGraphicsHeader = QLatin1String("qtg_fr_tb_h_"); |
|
2951 |
|
2952 framePartList << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_cr"); |
|
2953 |
|
2954 if (state & SS_Disabled) |
|
2955 frameGraphicsFooter = QLatin1String("disabled"); |
|
2956 else if (state & SS_Pressed) |
|
2957 frameGraphicsFooter = QLatin1String("pressed"); |
|
2958 else if (state & SS_Selected) |
|
2959 frameGraphicsFooter = QLatin1String("highlight"); |
|
2960 else |
|
2961 frameGraphicsFooter = QLatin1String("normal"); |
|
2962 break; |
|
2963 } |
|
2964 case SM_PushButton: { |
|
2965 frameType = HbFrameDrawer::NinePieces; |
|
2966 if (state & SS_Disabled) |
|
2967 frameName = QLatin1String("qtg_fr_btn_disabled"); |
|
2968 else if (state & SS_Pressed) |
|
2969 frameName = QLatin1String("qtg_fr_btn_pressed"); |
|
2970 else if (state & SS_Selected) |
|
2971 frameName = QLatin1String("qtg_fr_btn_highlight"); |
|
2972 else if (state & SS_Latched) |
|
2973 frameName = QLatin1String("qtg_fr_btn_latched"); |
|
2974 else |
|
2975 frameName = QLatin1String("qtg_fr_btn_normal"); |
|
2976 styleManager()->parameter(QLatin1String("hb-param-background-button"), border); |
|
2977 break; |
|
2978 } |
|
2979 case SM_ScrollBarGroove: { |
|
2980 fillRect = true; |
|
2981 if (state & SS_Horizontal) { |
|
2982 if (state & SS_Pressed) |
|
2983 frameName = QLatin1String("qtg_fr_scroll_h_active_frame_pressed"); |
|
2984 else |
|
2985 frameName = QLatin1String("qtg_fr_scroll_h_active_frame_normal"); |
|
2986 frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
2987 } else { |
|
2988 if (state & SS_Pressed) |
|
2989 frameName = QLatin1String("qtg_fr_scroll_v_active_frame_pressed"); |
|
2990 else |
|
2991 frameName = QLatin1String("qtg_fr_scroll_v_active_frame_normal"); |
|
2992 frameType = HbFrameDrawer::ThreePiecesVertical; |
|
2993 } |
|
2994 break; |
|
2995 } |
|
2996 case SM_ScrollBarHandle: { |
|
2997 fillRect = true; |
|
2998 if (state & SS_Horizontal) { |
|
2999 if (state & SS_Pressed) |
|
3000 frameName = QLatin1String("qtg_fr_scroll_h_active_handle_pressed"); |
|
3001 else |
|
3002 frameName = QLatin1String("qtg_fr_scroll_h_active_handle_normal"); |
|
3003 frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
3004 } else { |
|
3005 if (state & SS_Pressed) |
|
3006 frameName = QLatin1String("qtg_fr_scroll_v_active_handle_pressed"); |
|
3007 else |
|
3008 frameName = QLatin1String("qtg_fr_scroll_v_active_handle_normal"); |
|
3009 frameType = HbFrameDrawer::ThreePiecesVertical; |
|
3010 } |
|
3011 break; |
|
3012 } |
|
3013 case SM_SliderGroove: { |
|
3014 fillRect = true; |
|
3015 if (state & SS_Horizontal) { |
|
3016 if (state & SS_Pressed) |
|
3017 frameName = QLatin1String("qtg_fr_slider_h_frame_pressed"); |
|
3018 else |
|
3019 frameName = QLatin1String("qtg_fr_slider_h_frame_normal"); |
|
3020 frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
3021 } else { |
|
3022 if (state & SS_Pressed) |
|
3023 frameName = QLatin1String("qtg_fr_slider_v_frame_pressed"); |
|
3024 else |
|
3025 frameName = QLatin1String("qtg_fr_slider_v_frame_normal"); |
|
3026 frameType = HbFrameDrawer::ThreePiecesVertical; |
|
3027 } |
|
3028 break; |
|
3029 } |
|
3030 case SM_SliderProgress: { |
|
3031 fillRect = true; |
|
3032 if (state & SS_Filled) { |
|
3033 if (state & SS_Horizontal) { |
|
3034 frameName = QLatin1String("qtg_fr_slider_h_filled"); |
|
3035 frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
3036 } else { |
|
3037 frameName = QLatin1String("qtg_fr_slider_v_filled"); |
|
3038 frameType = HbFrameDrawer::ThreePiecesVertical; |
|
3039 } |
|
3040 } |
|
3041 break; |
|
3042 } |
|
3043 case SM_TabShape: { |
|
3044 if (state & SS_Horizontal) { |
|
3045 frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
3046 frameGraphicsHeader = QLatin1String("qtg_fr_tb_h_"); |
|
3047 |
|
3048 if (state & SS_Beginning) |
|
3049 framePartList << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_cr"); |
|
3050 else if (state & SS_Middle) |
|
3051 framePartList << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_cr"); |
|
3052 else if (state & SS_End) |
|
3053 framePartList << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_r"); |
|
3054 else |
|
3055 framePartList << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_r"); |
|
3056 } else if (state & SS_Vertical) { |
|
3057 frameType = HbFrameDrawer::ThreePiecesVertical; |
|
3058 frameGraphicsHeader = QLatin1String("qtg_fr_tb_v_"); |
|
3059 if (state & SS_Beginning) |
|
3060 framePartList << QLatin1String("_t") << QLatin1String("_c") << QLatin1String("_cb"); |
|
3061 else if (state & SS_Middle) |
|
3062 framePartList << QLatin1String("_ct") << QLatin1String("_c") << QLatin1String("_cb"); |
|
3063 else if (state & SS_End) |
|
3064 framePartList << QLatin1String("_ct") << QLatin1String("_c") << QLatin1String("_b"); |
|
3065 else |
|
3066 framePartList << QLatin1String("_t") << QLatin1String("_c") << QLatin1String("_b"); |
|
3067 } |
|
3068 if (state & SS_Disabled) |
|
3069 frameGraphicsFooter = QLatin1String("disabled"); |
|
3070 else if (state & SS_Pressed) |
|
3071 frameGraphicsFooter = QLatin1String("pressed"); |
|
3072 else if (state & SS_Selected) |
|
3073 frameGraphicsFooter = QLatin1String("highlight"); |
|
3074 else |
|
3075 frameGraphicsFooter = QLatin1String("normal"); |
|
3076 break; |
|
3077 } |
|
3078 case SM_TextEdit: { //@todo: combine this and case SM_LineEdit to "case SM_TextEditor"? |
|
3079 styleManager()->parameter(QLatin1String("hb-param-background-editor"), border); |
|
3080 frameName = QLatin1String("qtg_fr_editor"); |
|
3081 frameType = HbFrameDrawer::NinePieces; |
|
3082 break; |
|
3083 } |
|
3084 case SM_ToolBarButton: { |
|
3085 if (state & SS_Horizontal) { |
|
3086 frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
3087 if (state & SS_Disabled) |
|
3088 frameName = QLatin1String("qtg_fr_tb_h_disabled"); |
|
3089 else if (state & SS_Pressed) |
|
3090 frameName = QLatin1String("qtg_fr_tb_h_pressed"); |
|
3091 else if (state & SS_Latched) |
|
3092 frameName = QLatin1String("qtg_fr_tb_h_latched"); |
|
3093 else if (state & SS_Selected) |
|
3094 frameName = QLatin1String("qtg_fr_tb_h_highlight"); |
|
3095 else |
|
3096 frameName = QLatin1String("qtg_fr_tb_h_normal"); |
|
3097 } else { |
|
3098 frameType = HbFrameDrawer::ThreePiecesVertical; |
|
3099 if (state & SS_Disabled) |
|
3100 frameName = QLatin1String("qtg_fr_tb_v_disabled"); |
|
3101 else if (state & SS_Pressed) |
|
3102 frameName = QLatin1String("qtg_fr_tb_v_pressed"); |
|
3103 else if (state & SS_Latched) |
|
3104 frameName = QLatin1String("qtg_fr_tb_v_latched"); |
|
3105 else if (state & SS_Selected) |
|
3106 frameName = QLatin1String("qtg_fr_tb_v_highlight"); |
|
3107 else |
|
3108 frameName = QLatin1String("qtg_fr_tb_v_normal"); |
|
3109 } |
|
3110 styleManager()->parameter(QLatin1String("hb-param-background-button"), border); |
|
3111 break; |
|
3112 } |
|
3113 case SM_ToolTip: { |
|
3114 fillRect = true; |
|
3115 frameType = HbFrameDrawer::NinePieces; |
|
3116 frameName = QLatin1String("qtg_fr_popup_preview"); |
|
3117 break; |
|
3118 } |
|
3119 case SM_HeaderItem: |
|
3120 case SM_TableItem: |
|
3121 case SM_ThemeBackground: |
|
3122 case SM_ToolBar: |
|
3123 default: { |
|
3124 break; |
|
3125 } |
|
3126 } |
|
3127 |
|
3128 if (frameType != HbFrameDrawer::Undefined) |
|
3129 m_frameDrawer->setFrameType(frameType); |
|
3130 else |
|
3131 return false; |
|
3132 |
|
3133 if (!frameName.isNull()) { |
|
3134 m_frameDrawer->setFrameGraphicsName(frameName); |
|
3135 } else if (framePartList.count() > 0) { |
|
3136 m_frameDrawer->setFileNameSuffixList(framePartList); |
|
3137 m_frameDrawer->setFrameGraphicsName(QString ("%0%1").arg(frameGraphicsHeader).arg(frameGraphicsFooter)); |
|
3138 } else { |
|
3139 return false; |
|
3140 } |
|
3141 |
|
3142 m_frameDrawer->setBorderWidth(border); |
|
3143 m_frameDrawer->setFillWholeRect(fillRect); |
|
3144 if (state & SS_Mirrored) |
|
3145 mirrorMode = HbIcon::Forced; |
|
3146 |
|
3147 m_frameDrawer->setMirroringMode(mirrorMode); |
|
3148 |
|
3149 const bool rotated = (state & SS_Flipped || state & SS_RotatedRight || state & SS_RotatedLeft) ? true : false; |
|
3150 QRect validRect = rect; |
|
3151 if (rotated) { |
|
3152 QTransform m; |
|
3153 painter->save(); |
|
3154 |
|
3155 //Calculate new coordinates |
|
3156 int newX = 0, newY = 0; |
|
3157 if (state & SS_RotatedRight) { |
|
3158 newX = 0; |
|
3159 newY = rect.y() + rect.height() - 1; |
|
3160 } else if (state & SS_RotatedLeft) { |
|
3161 newX = rect.width(); |
|
3162 newY = rect.y() - 1; |
|
3163 } else if (state & SS_Flipped) { |
|
3164 if (state & SS_Horizontal) { |
|
3165 newX = rect.width() + 2 * rect.left(); |
|
3166 newY = rect.height() + rect.top(); |
|
3167 } else { |
|
3168 newX = rect.width() + rect.left(); |
|
3169 newY = rect.height() + 2 * rect.top(); |
|
3170 } |
|
3171 } |
|
3172 |
|
3173 //Translate rect and transform |
|
3174 if ((state & SS_RotatedRight) || (state & SS_RotatedLeft)) |
|
3175 validRect.setRect(0, 0, rect.height(), rect.width()); |
|
3176 m.translate(newX, newY); |
|
3177 |
|
3178 // Set rotation |
|
3179 int rotation = 0; |
|
3180 if (state & SS_Flipped) |
|
3181 rotation = 180; |
|
3182 else if (state & SS_RotatedRight) |
|
3183 rotation = -90; |
|
3184 else if (state & SS_RotatedLeft) |
|
3185 rotation = 90; |
|
3186 m.rotate(rotation); |
|
3187 painter->setTransform(m, true); |
|
3188 } |
|
3189 m_frameDrawer->paint(painter, validRect); |
|
3190 |
|
3191 if (rotated) |
|
3192 painter->restore(); |
|
3193 |
|
3194 //Need to clear the list after use. |
|
3195 framePartList.clear(); |
|
3196 m_frameDrawer->setFileNameSuffixList(framePartList); |
|
3197 return true; |
|
3198 } |
|
3199 |
|
3200 bool QHbStylePrivate::isDialog(const QWidget *widget) |
|
3201 { |
|
3202 return (widget ? (widget->windowType() == Qt::Dialog) : false); |
|
3203 } |
|
3204 |
|
3205 bool QHbStylePrivate::hbParameter(const QString ¶meterName, int &value) |
|
3206 { |
|
3207 bool retValue = false; |
|
3208 qreal valueInReal = 0.0; |
|
3209 retValue = styleManager()->parameter(parameterName, valueInReal); |
|
3210 valueInReal += 0.5; //to make the real->int to round correctly |
|
3211 value = valueInReal; |
|
3212 return retValue; |
|
3213 } |
|
3214 |
|
3215 void QHbStylePrivate::polishFont(QWidget *widget) |
|
3216 { |
|
3217 HbFontSpec::Role fontRole = HbFontSpec::Undefined; |
|
3218 qreal fontSize = 0.0; |
|
3219 bool valueFound = false; |
|
3220 |
|
3221 //Widget font role specifications from hb documentation. |
|
3222 if (false |
|
3223 #ifndef QT_NO_COMBOBOX |
|
3224 || qobject_cast<QComboBox *>(widget) |
|
3225 #endif |
|
3226 #ifndef QT_NO_SPINBOX |
|
3227 || qobject_cast<QSpinBox *>(widget) |
|
3228 #endif |
|
3229 || qobject_cast<QRadioButton *>(widget) |
|
3230 ) { |
|
3231 valueFound = styleManager()->parameter(QLatin1String("b-param-text-height-secondary"), fontSize); |
|
3232 fontRole = HbFontSpec::Primary; |
|
3233 } else if (false |
|
3234 || qobject_cast<QPushButton *>(widget) |
|
3235 #ifndef QT_NO_TOOLBUTTON |
|
3236 || qobject_cast<QToolButton *>(widget) |
|
3237 #endif |
|
3238 #ifndef QT_NO_TABWIDGET |
|
3239 || qobject_cast<QTabWidget *>(widget) |
|
3240 #endif |
|
3241 ) { |
|
3242 valueFound = styleManager()->parameter(QLatin1String("hb-param-text-height-tiny"), fontSize); |
|
3243 fontRole = HbFontSpec::Primary; |
|
3244 } else if (false |
|
3245 #ifndef QT_NO_HEADERVIEW |
|
3246 || qobject_cast<QHeaderView *>(widget) |
|
3247 #endif |
|
3248 #ifndef QT_NO_LISTVIEW |
|
3249 || qobject_cast<QListView *>(widget) |
|
3250 #endif |
|
3251 #ifndef QT_NO_TABLEVIEW |
|
3252 || qobject_cast<QTableView *>(widget) |
|
3253 #endif |
|
3254 #ifndef QT_NO_TREEVIEW |
|
3255 || qobject_cast<QTreeView *>(widget) |
|
3256 #endif |
|
3257 #ifndef QT_NO_LINEEDIT |
|
3258 || qobject_cast<QLineEdit *>(widget) |
|
3259 #endif |
|
3260 #ifndef QT_NO_TEXTEDIT |
|
3261 || qobject_cast<QTextEdit *>(widget) |
|
3262 #endif |
|
3263 || qobject_cast<QSlider *>(widget) |
|
3264 #ifndef QT_NO_SLIDER |
|
3265 || qobject_cast<QGroupBox *>(widget) |
|
3266 #endif |
|
3267 || qobject_cast<QCheckBox *>(widget) |
|
3268 ) { |
|
3269 fontRole = HbFontSpec::Secondary; |
|
3270 valueFound = styleManager()->parameter(QLatin1String("hb-param-text-height-secondary"), fontSize); |
|
3271 } else if (false |
|
3272 #ifndef QT_NO_PROGRESSBAR |
|
3273 || qobject_cast<QProgressBar *>(widget) |
|
3274 #endif |
|
3275 ) { |
|
3276 fontRole = HbFontSpec::Secondary; |
|
3277 valueFound = styleManager()->parameter(QLatin1String("hb-param-text-height-tiny"), fontSize); |
|
3278 } |
|
3279 |
|
3280 HbFontSpec *fontSpec = q_check_ptr(new HbFontSpec(fontRole)); |
|
3281 if (valueFound) { |
|
3282 fontSpec->setTextHeight(fontSize); |
|
3283 QFont widgetFont = fontSpec->font(); |
|
3284 widgetFont.setPixelSize(fontSpec->font().pixelSize()); |
|
3285 widget->setFont(widgetFont); |
|
3286 } |
|
3287 delete fontSpec; |
|
3288 } |
|
3289 |
|
3290 QT_END_NAMESPACE |