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