120 // theme palette |
120 // theme palette |
121 QPalette *QS60StylePrivate::m_themePalette = 0; |
121 QPalette *QS60StylePrivate::m_themePalette = 0; |
122 |
122 |
123 qint64 QS60StylePrivate::m_webPaletteKey = 0; |
123 qint64 QS60StylePrivate::m_webPaletteKey = 0; |
124 |
124 |
|
125 QPointer<QWidget> QS60StylePrivate::m_pressedWidget = 0; |
|
126 |
125 const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = { |
127 const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = { |
126 {SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter}, |
128 {SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter}, |
127 {SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed}, |
129 {SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed}, |
128 {SE_FrameLineEdit, QS60StyleEnums::SP_QsnFrInputCenter}, |
130 {SE_FrameLineEdit, QS60StyleEnums::SP_QsnFrInputCenter}, |
129 {SE_ListHighlight, QS60StyleEnums::SP_QsnFrListCenter}, |
131 {SE_ListHighlight, QS60StyleEnums::SP_QsnFrListCenter}, |
136 {SE_ToolBarButton, QS60StyleEnums::SP_QsnFrSctrlButtonCenter}, |
138 {SE_ToolBarButton, QS60StyleEnums::SP_QsnFrSctrlButtonCenter}, |
137 {SE_ToolBarButtonPressed, QS60StyleEnums::SP_QsnFrSctrlButtonCenterPressed}, |
139 {SE_ToolBarButtonPressed, QS60StyleEnums::SP_QsnFrSctrlButtonCenterPressed}, |
138 {SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter}, |
140 {SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter}, |
139 {SE_ButtonInactive, QS60StyleEnums::SP_QsnFrButtonCenterInactive}, |
141 {SE_ButtonInactive, QS60StyleEnums::SP_QsnFrButtonCenterInactive}, |
140 {SE_Editor, QS60StyleEnums::SP_QsnFrInputCenter}, |
142 {SE_Editor, QS60StyleEnums::SP_QsnFrInputCenter}, |
|
143 {SE_TableItemPressed, QS60StyleEnums::SP_QsnFrGridCenterPressed}, |
|
144 {SE_ListItemPressed, QS60StyleEnums::SP_QsnFrListPressed}, |
141 }; |
145 }; |
142 |
146 |
143 static const int frameElementsCount = |
147 static const int frameElementsCount = |
144 int(sizeof(QS60StylePrivate::m_frameElementsData)/sizeof(QS60StylePrivate::m_frameElementsData[0])); |
148 int(sizeof(QS60StylePrivate::m_frameElementsData)/sizeof(QS60StylePrivate::m_frameElementsData[0])); |
145 |
149 |
540 QRect startRect = QRect(rect.topLeft(), startEndSize); |
550 QRect startRect = QRect(rect.topLeft(), startEndSize); |
541 QRect middleRect = rect; |
551 QRect middleRect = rect; |
542 QRect endRect; |
552 QRect endRect; |
543 |
553 |
544 if (orientation == Qt::Horizontal) { |
554 if (orientation == Qt::Horizontal) { |
|
555 startRect.setHeight(rect.height()); |
545 startRect.setWidth(qMin((rect.width() >> 1) - 1, startRect.width())); |
556 startRect.setWidth(qMin((rect.width() >> 1) - 1, startRect.width())); |
546 endRect = startRect.translated(rect.width() - startRect.width(), 0); |
557 endRect = startRect.translated(rect.width() - startRect.width(), 0); |
547 middleRect.adjust(startRect.width(), 0, -startRect.width(), 0); |
558 middleRect.adjust(startRect.width(), 0, -startRect.width(), 0); |
548 if (startRect.bottomRight().x() > endRect.topLeft().x()) { |
559 if (startRect.bottomRight().x() > endRect.topLeft().x()) { |
549 const int overlap = (startRect.bottomRight().x() - endRect.topLeft().x()) >> 1; |
560 const int overlap = (startRect.bottomRight().x() - endRect.topLeft().x()) >> 1; |
550 startRect.setWidth(startRect.width() - overlap); |
561 startRect.setWidth(startRect.width() - overlap); |
551 endRect.adjust(overlap, 0, 0, 0); |
562 endRect.adjust(overlap, 0, 0, 0); |
552 } |
563 } |
553 } else { |
564 } else { |
|
565 startRect.setWidth(rect.width()); |
554 startRect.setHeight(qMin((rect.height() >> 1) - 1, startRect.height())); |
566 startRect.setHeight(qMin((rect.height() >> 1) - 1, startRect.height())); |
555 endRect = startRect.translated(0, rect.height() - startRect.height()); |
567 endRect = startRect.translated(0, rect.height() - startRect.height()); |
556 middleRect.adjust(0, startRect.height(), 0, -startRect.height()); |
568 middleRect.adjust(0, startRect.height(), 0, -startRect.height()); |
557 if (startRect.topRight().y() > endRect.bottomLeft().y()) { |
569 if (startRect.topRight().y() > endRect.bottomLeft().y()) { |
558 const int overlap = (startRect.topRight().y() - endRect.bottomLeft().y()) >> 1; |
570 const int overlap = (startRect.topRight().y() - endRect.bottomLeft().y()) >> 1; |
1355 optionComboBox.palette.setColor(QPalette::Active, QPalette::WindowText, |
1372 optionComboBox.palette.setColor(QPalette::Active, QPalette::WindowText, |
1356 optionComboBox.palette.text().color() ); |
1373 optionComboBox.palette.text().color() ); |
1357 optionComboBox.palette.setColor(QPalette::Inactive, QPalette::WindowText, |
1374 optionComboBox.palette.setColor(QPalette::Inactive, QPalette::WindowText, |
1358 optionComboBox.palette.text().color() ); |
1375 optionComboBox.palette.text().color() ); |
1359 QRect editRect = subControlRect(CC_ComboBox, comboBox, SC_ComboBoxEditField, widget); |
1376 QRect editRect = subControlRect(CC_ComboBox, comboBox, SC_ComboBoxEditField, widget); |
1360 painter->save(); |
1377 const int frameW = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); |
1361 painter->setClipRect(editRect); |
|
1362 |
1378 |
1363 if (!comboBox->currentIcon.isNull()) { |
1379 if (!comboBox->currentIcon.isNull()) { |
1364 QIcon::Mode mode = comboBox->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; |
1380 const QIcon::Mode mode = comboBox->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; |
1365 QPixmap pixmap = comboBox->currentIcon.pixmap(comboBox->iconSize, mode); |
1381 const QPixmap pixmap = comboBox->currentIcon.pixmap(comboBox->iconSize, mode); |
1366 QRect iconRect(editRect); |
1382 QRect iconRect(editRect); |
1367 iconRect.setWidth(comboBox->iconSize.width() + 4); |
1383 iconRect.setWidth(comboBox->iconSize.width() + frameW); |
1368 iconRect = alignedRect(comboBox->direction, |
1384 iconRect = alignedRect(comboBox->direction, |
1369 Qt::AlignLeft | Qt::AlignVCenter, |
1385 Qt::AlignLeft | Qt::AlignVCenter, |
1370 iconRect.size(), editRect); |
1386 iconRect.size(), editRect); |
1371 if (comboBox->editable) |
1387 if (comboBox->editable) |
1372 painter->fillRect(iconRect, optionComboBox.palette.brush(QPalette::Base)); |
1388 painter->fillRect(iconRect, optionComboBox.palette.brush(QPalette::Base)); |
1373 drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); |
1389 drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); |
1374 |
1390 |
1375 if (comboBox->direction == Qt::RightToLeft) |
1391 if (comboBox->direction == Qt::RightToLeft) |
1376 editRect.translate(-4 - comboBox->iconSize.width(), 0); |
1392 editRect.setRight(editRect.right() - frameW - comboBox->iconSize.width()); |
1377 else |
1393 else |
1378 editRect.translate(comboBox->iconSize.width() + 4, 0); |
1394 editRect.setLeft(comboBox->iconSize.width() + frameW); |
1379 } |
1395 } |
1380 if (!comboBox->currentText.isEmpty() && !comboBox->editable) { |
1396 if (!comboBox->currentText.isEmpty() && !comboBox->editable) { |
|
1397 const Qt::TextElideMode elideMode = (comboBox->direction == Qt::LeftToRight) ? Qt::ElideRight : Qt::ElideLeft; |
|
1398 const QString text = comboBox->fontMetrics.elidedText(comboBox->currentText, elideMode, editRect.width()); |
|
1399 |
1381 QCommonStyle::drawItemText(painter, |
1400 QCommonStyle::drawItemText(painter, |
1382 editRect.adjusted(QS60StylePrivate::pixelMetric(PM_FrameCornerWidth), 0, -1, 0), |
1401 editRect.adjusted(QS60StylePrivate::pixelMetric(PM_FrameCornerWidth), 0, -1, 0), |
1383 visualAlignment(comboBox->direction, Qt::AlignLeft | Qt::AlignVCenter), |
1402 visualAlignment(comboBox->direction, Qt::AlignLeft | Qt::AlignVCenter), |
1384 comboBox->palette, comboBox->state & State_Enabled, comboBox->currentText); |
1403 comboBox->palette, comboBox->state & State_Enabled, text); |
1385 } |
1404 } |
1386 painter->restore(); |
|
1387 } |
1405 } |
1388 break; |
1406 break; |
1389 #endif //QT_NO_COMBOBOX |
1407 #endif //QT_NO_COMBOBOX |
1390 #ifndef QT_NO_ITEMVIEWS |
1408 #ifndef QT_NO_ITEMVIEWS |
1391 case CE_ItemViewItem: |
1409 case CE_ItemViewItem: |
1422 const QAbstractItemView *itemView = qobject_cast<const QAbstractItemView *>(widget); |
1440 const QAbstractItemView *itemView = qobject_cast<const QAbstractItemView *>(widget); |
1423 |
1441 |
1424 // draw themed background for table unless background brush has been defined. |
1442 // draw themed background for table unless background brush has been defined. |
1425 if (vopt->backgroundBrush == Qt::NoBrush) { |
1443 if (vopt->backgroundBrush == Qt::NoBrush) { |
1426 if (itemView) { |
1444 if (itemView) { |
1427 const QModelIndex index = vopt->index; |
|
1428 //todo: Draw cell background only once - for the first cell. |
|
1429 QStyleOptionViewItemV4 voptAdj2 = voptAdj; |
|
1430 const QModelIndex indexFirst = itemView->model()->index(0, 0); |
|
1431 const QModelIndex indexLast = itemView->model()->index( |
|
1432 itemView->model()->rowCount() - 1, itemView->model()->columnCount() -1); |
|
1433 if (itemView->viewport()) |
|
1434 voptAdj2.rect = QRect( itemView->visualRect(indexFirst).topLeft(), |
|
1435 itemView->visualRect(indexLast).bottomRight()).intersect(itemView->viewport()->rect()); |
|
1436 drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); |
1445 drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); |
1437 } |
1446 } |
1438 } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);} |
1447 } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);} |
1439 |
1448 |
1440 // draw the focus rect |
|
1441 if (isSelected || hasFocus ) { |
|
1442 QRect highlightRect = option->rect.adjusted(1,1,-1,-1); |
|
1443 QAbstractItemView::SelectionBehavior selectionBehavior = |
|
1444 itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems; |
|
1445 if (selectionBehavior != QAbstractItemView::SelectItems) { |
|
1446 // set highlight rect so that it is continuous from cell to cell, yet sligthly |
|
1447 // smaller than cell rect |
|
1448 int xBeginning = 0, yBeginning = 0, xEnd = 0, yEnd = 0; |
|
1449 if (selectionBehavior == QAbstractItemView::SelectRows) { |
|
1450 yBeginning = 1; yEnd = -1; |
|
1451 if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) |
|
1452 xBeginning = 1; |
|
1453 else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) |
|
1454 xEnd = -1; |
|
1455 } else if (selectionBehavior == QAbstractItemView::SelectColumns) { |
|
1456 xBeginning = 1; xEnd = -1; |
|
1457 if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) |
|
1458 yBeginning = 1; |
|
1459 else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) |
|
1460 yEnd = -1; |
|
1461 } |
|
1462 highlightRect = option->rect.adjusted(xBeginning, yBeginning, xEnd, yEnd); |
|
1463 } |
|
1464 if (vopt->showDecorationSelected && |
|
1465 (vopt->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color())) |
|
1466 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags); |
|
1467 else |
|
1468 painter->fillRect(highlightRect, vopt->palette.highlight()); |
|
1469 } |
|
1470 |
|
1471 // draw the icon |
1449 // draw the icon |
1472 const QIcon::Mode mode = (voptAdj.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled; |
1450 const QIcon::Mode mode = (voptAdj.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled; |
1473 const QIcon::State state = voptAdj.state & State_Open ? QIcon::On : QIcon::Off; |
1451 const QIcon::State state = (voptAdj.state & State_Open) ? QIcon::On : QIcon::Off; |
1474 voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state); |
1452 voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state); |
1475 |
1453 |
1476 // Draw selection check mark. Show check mark only in multi selection modes. |
1454 // Draw selection check mark. Show check mark only in multi selection modes. |
1477 if (itemView) { |
1455 if (itemView) { |
1478 const bool singleSelection = |
1456 const bool singleSelection = |
1479 (itemView->selectionMode() == QAbstractItemView::SingleSelection || |
1457 (itemView->selectionMode() == QAbstractItemView::SingleSelection || |
1480 itemView->selectionMode() == QAbstractItemView::NoSelection); |
1458 itemView->selectionMode() == QAbstractItemView::NoSelection)|| |
|
1459 (itemView->selectionModel()->selectedIndexes().count() < 2 ); |
|
1460 |
|
1461 const bool selectItemsOnly = (itemView->selectionBehavior() == QAbstractItemView::SelectItems); |
|
1462 |
1481 const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget); |
1463 const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget); |
1482 |
1464 |
1483 QStyleOptionViewItemV4 checkMarkOption(voptAdj); |
1465 QStyleOptionViewItemV4 checkMarkOption(voptAdj); |
|
1466 if (selectionRect.isValid()) |
|
1467 checkMarkOption.rect = selectionRect; |
1484 // Draw selection mark. |
1468 // Draw selection mark. |
1485 if (voptAdj.state & State_Selected && !singleSelection) { |
1469 if (isSelected && !singleSelection && selectItemsOnly) { |
1486 checkMarkOption.rect = selectionRect; |
1470 proxy()->drawPrimitive(PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); |
1487 drawPrimitive(PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); |
1471 // @todo: this should happen in the rect retrievel i.e. subElementRect() |
1488 if ( textRect.right() > selectionRect.left() ) |
1472 if (textRect.right() > selectionRect.left()) |
1489 textRect.setRight(selectionRect.left()); |
1473 textRect.setRight(selectionRect.left()); |
1490 } else if (singleSelection && |
1474 } else if (singleSelection && |
1491 voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator && |
1475 voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator) { |
1492 selectionRect.isValid()) { |
|
1493 checkMarkOption.rect = selectionRect; |
|
1494 checkMarkOption.state = checkMarkOption.state & ~State_HasFocus; |
1476 checkMarkOption.state = checkMarkOption.state & ~State_HasFocus; |
1495 |
1477 |
1496 switch (vopt->checkState) { |
1478 switch (vopt->checkState) { |
1497 case Qt::Unchecked: |
1479 case Qt::Unchecked: |
1498 checkMarkOption.state |= State_Off; |
1480 checkMarkOption.state |= State_Off; |
1983 const qreal opacity = 0.85; |
1964 const qreal opacity = 0.85; |
1984 #endif |
1965 #endif |
1985 // We need to reduce the focus frame size if LayoutSpacing is smaller than FocusFrameMargin |
1966 // We need to reduce the focus frame size if LayoutSpacing is smaller than FocusFrameMargin |
1986 // Otherwise, we would overlay adjacent widgets. |
1967 // Otherwise, we would overlay adjacent widgets. |
1987 const int frameHeightReduction = |
1968 const int frameHeightReduction = |
1988 qMin(0, pixelMetric(QStyle::PM_LayoutVerticalSpacing) |
1969 qMin(0, pixelMetric(PM_LayoutVerticalSpacing) |
1989 - pixelMetric(QStyle::PM_FocusFrameVMargin)); |
1970 - pixelMetric(PM_FocusFrameVMargin)); |
1990 const int frameWidthReduction = |
1971 const int frameWidthReduction = |
1991 qMin(0, pixelMetric(QStyle::PM_LayoutHorizontalSpacing) |
1972 qMin(0, pixelMetric(PM_LayoutHorizontalSpacing) |
1992 - pixelMetric(QStyle::PM_FocusFrameHMargin)); |
1973 - pixelMetric(PM_FocusFrameHMargin)); |
1993 const int rounding = |
1974 const int rounding = |
1994 qMin(pixelMetric(QStyle::PM_FocusFrameVMargin), |
1975 qMin(pixelMetric(PM_FocusFrameVMargin), |
1995 pixelMetric(QStyle::PM_LayoutVerticalSpacing)); |
1976 pixelMetric(PM_LayoutVerticalSpacing)); |
1996 const QRect frameRect = |
1977 const QRect frameRect = |
1997 option->rect.adjusted(-frameWidthReduction, -frameHeightReduction, |
1978 option->rect.adjusted(-frameWidthReduction, -frameHeightReduction, |
1998 frameWidthReduction, frameHeightReduction); |
1979 frameWidthReduction, frameHeightReduction); |
1999 QPainterPath framePath; |
1980 QPainterPath framePath; |
2000 framePath.addRoundedRect(frameRect, rounding, rounding); |
1981 framePath.addRoundedRect(frameRect, rounding, rounding); |
2035 //Draw themed highlight to radiobuttons and checkboxes. |
2016 //Draw themed highlight to radiobuttons and checkboxes. |
2036 //For other widgets skip, unless palette has been modified. In that case, draw with commonstyle. |
2017 //For other widgets skip, unless palette has been modified. In that case, draw with commonstyle. |
2037 if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) |
2018 if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) |
2038 if ((qstyleoption_cast<const QStyleOptionFocusRect *>(option) && |
2019 if ((qstyleoption_cast<const QStyleOptionFocusRect *>(option) && |
2039 (qobject_cast<const QRadioButton *>(widget) || qobject_cast<const QCheckBox *>(widget)))) |
2020 (qobject_cast<const QRadioButton *>(widget) || qobject_cast<const QCheckBox *>(widget)))) |
2040 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); |
2021 QS60StylePrivate::drawSkinElement( |
|
2022 QS60StylePrivate::isWidgetPressed(widget) ? |
|
2023 QS60StylePrivate::SE_ListItemPressed : |
|
2024 QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); |
2041 else |
2025 else |
2042 commonStyleDraws = true; |
2026 commonStyleDraws = true; |
2043 } |
2027 } |
2044 break; |
2028 break; |
2045 #ifndef QT_NO_LINEEDIT |
2029 #ifndef QT_NO_LINEEDIT |
2255 break; |
2239 break; |
2256 case PE_Frame: |
2240 case PE_Frame: |
2257 break; |
2241 break; |
2258 #ifndef QT_NO_ITEMVIEWS |
2242 #ifndef QT_NO_ITEMVIEWS |
2259 case PE_PanelItemViewItem: |
2243 case PE_PanelItemViewItem: |
|
2244 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
|
2245 const bool isSelected = (vopt->state & State_Selected); |
|
2246 const bool hasFocus = (vopt->state & State_HasFocus); |
|
2247 const bool isPressed = QS60StylePrivate::isWidgetPressed(widget); |
|
2248 |
|
2249 if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) { |
|
2250 QRect highlightRect = vopt->rect.adjusted(1,1,-1,-1); |
|
2251 const QAbstractItemView *itemView = qobject_cast<const QAbstractItemView *>(widget); |
|
2252 QAbstractItemView::SelectionBehavior selectionBehavior = |
|
2253 itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems; |
|
2254 // Set the draw area for highlights (focus, select rect or pressed rect) |
|
2255 if (hasFocus || isSelected || isPressed) { |
|
2256 if (selectionBehavior != QAbstractItemView::SelectItems) { |
|
2257 // set highlight rect so that it is continuous from cell to cell, yet sligthly |
|
2258 // smaller than cell rect |
|
2259 int xBeginning = 0, yBeginning = 0, xEnd = 0, yEnd = 0; |
|
2260 if (selectionBehavior == QAbstractItemView::SelectRows) { |
|
2261 yBeginning = 1; yEnd = -1; |
|
2262 if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) |
|
2263 xBeginning = 1; |
|
2264 else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) |
|
2265 xEnd = -1; |
|
2266 } else if (selectionBehavior == QAbstractItemView::SelectColumns) { |
|
2267 xBeginning = 1; xEnd = -1; |
|
2268 if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) |
|
2269 yBeginning = 1; |
|
2270 else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) |
|
2271 yEnd = -1; |
|
2272 } |
|
2273 highlightRect = option->rect.adjusted(xBeginning, yBeginning, xEnd, yEnd); |
|
2274 } |
|
2275 } |
|
2276 bool tableView = false; |
|
2277 if (itemView && qobject_cast<const QTableView *>(widget)) |
|
2278 tableView = true; |
|
2279 |
|
2280 QS60StylePrivate::SkinElements element; |
|
2281 QRect elementRect = option->rect; |
|
2282 |
|
2283 //draw item is drawn as pressed, if it already has focus. |
|
2284 if (isPressed && (hasFocus || isSelected)) { |
|
2285 element = tableView ? QS60StylePrivate::SE_TableItemPressed : QS60StylePrivate::SE_ListItemPressed; |
|
2286 } else if (hasFocus || (isSelected && selectionBehavior != QAbstractItemView::SelectItems)) { |
|
2287 element = QS60StylePrivate::SE_ListHighlight; |
|
2288 elementRect = highlightRect; |
|
2289 } |
|
2290 QS60StylePrivate::drawSkinElement(element, painter, elementRect, flags); |
|
2291 } else { |
|
2292 QCommonStyle::drawPrimitive(element, option, painter, widget); |
|
2293 } |
|
2294 } |
2260 break; |
2295 break; |
2261 #endif //QT_NO_ITEMVIEWS |
2296 #endif //QT_NO_ITEMVIEWS |
2262 |
2297 |
2263 case PE_IndicatorMenuCheckMark: |
2298 case PE_IndicatorMenuCheckMark: |
2264 if (const QStyleOptionMenuItem *checkBox = qstyleoption_cast<const QStyleOptionMenuItem *>(option)){ |
2299 if (const QStyleOptionMenuItem *checkBox = qstyleoption_cast<const QStyleOptionMenuItem *>(option)){ |
3225 \internal |
3267 \internal |
3226 Animate indeterminate progress bars only when visible |
3268 Animate indeterminate progress bars only when visible |
3227 */ |
3269 */ |
3228 bool QS60Style::eventFilter(QObject *object, QEvent *event) |
3270 bool QS60Style::eventFilter(QObject *object, QEvent *event) |
3229 { |
3271 { |
|
3272 Q_D(QS60Style); |
|
3273 switch(event->type()) { |
|
3274 case QEvent::MouseButtonPress: { |
|
3275 QWidget *w = QApplication::widgetAt(QCursor::pos()); |
|
3276 if (w) { |
|
3277 QWidget *focusW = w->focusProxy(); |
|
3278 if (qobject_cast<QAbstractItemView *>(focusW) || |
|
3279 qobject_cast<QRadioButton *>(focusW) || |
|
3280 qobject_cast<QCheckBox *>(focusW)) |
|
3281 d->m_pressedWidget = focusW; |
|
3282 else if (qobject_cast<QAbstractItemView *>(w)|| |
|
3283 qobject_cast<QRadioButton *>(w) || |
|
3284 qobject_cast<QCheckBox *>(w)) |
|
3285 d->m_pressedWidget = w; |
|
3286 |
|
3287 if ( d->m_pressedWidget) |
|
3288 d->m_pressedWidget->update(); |
|
3289 } |
|
3290 break; |
|
3291 } |
|
3292 case QEvent::MouseButtonRelease: { |
|
3293 const QWidget *w = QApplication::widgetAt(QCursor::pos()); |
|
3294 if (w && d->m_pressedWidget) { |
|
3295 d->m_pressedWidget->update(); |
|
3296 d->m_pressedWidget = 0; |
|
3297 } |
|
3298 break; |
|
3299 } |
|
3300 default: |
|
3301 break; |
|
3302 } |
|
3303 |
3230 #ifdef Q_WS_S60 |
3304 #ifdef Q_WS_S60 |
3231 #ifndef QT_NO_PROGRESSBAR |
3305 #ifndef QT_NO_PROGRESSBAR |
3232 Q_D(QS60Style); |
|
3233 switch(event->type()) { |
3306 switch(event->type()) { |
3234 case QEvent::StyleChange: |
3307 case QEvent::StyleChange: |
3235 case QEvent::Show: |
3308 case QEvent::Show: |
3236 if (QProgressBar *bar = qobject_cast<QProgressBar *>(object)) { |
3309 if (QProgressBar *bar = qobject_cast<QProgressBar *>(object)) { |
3237 if (!d->m_bars.contains(bar)) |
3310 if (!d->m_bars.contains(bar)) |