Changeset 651 for trunk/src/gui/styles/qs60style.cpp
- Timestamp:
- Mar 8, 2010, 12:52:58 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.2 (added) merged: 650 /branches/vendor/nokia/qt/current merged: 649 /branches/vendor/nokia/qt/4.6.1 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/styles/qs60style.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 69 69 #include "qfocusframe.h" 70 70 #include "qformlayout.h" 71 #include "qradiobutton.h" 72 #include "qcheckbox.h" 73 #include "qdesktopwidget.h" 74 #include "qprogressbar.h" 71 75 72 76 #include "private/qtoolbarextension_p.h" … … 344 348 345 349 QFont QS60StylePrivate::s60Font( 346 QS60StyleEnums::FontCategories fontCategory, int pointSize) const 350 QS60StyleEnums::FontCategories fontCategory, 351 int pointSize, bool resolveFontSize) const 347 352 { 348 353 QFont result; … … 357 362 const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize); 358 363 if (!m_mappedFontsCache.contains(key)) { 359 result = s60Font_specific(fontCategory, actualPointSize );364 result = s60Font_specific(fontCategory, actualPointSize, resolveFontSize); 360 365 m_mappedFontsCache.insert(key, result); 361 366 } else { … … 564 569 { 565 570 QPixmap result; 571 const int animationFrame = (flags & SF_Animation) ? currentAnimationFrame(part) : 0; 572 566 573 const QString cacheKey = 567 QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4 ")568 .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags) ;574 QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4 AnimationFrame=%5") 575 .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags).arg(animationFrame); 569 576 if (!QPixmapCache::find(cacheKey, result)) { 570 577 result = QS60StylePrivate::part(part, size, painter, flags); … … 621 628 } 622 629 if (fontCategory != QS60StyleEnums::FC_Undefined) { 630 const bool resolveFontSize = widget->testAttribute(Qt::WA_SetFont) 631 && (widget->font().resolve() & QFont::SizeResolved); 623 632 const QFont suggestedFont = 624 s60Font(fontCategory, widget->font().pointSizeF() );633 s60Font(fontCategory, widget->font().pointSizeF(), resolveFontSize); 625 634 widget->setFont(suggestedFont); 626 635 } … … 670 679 // set background image as a texture brush 671 680 palette->setBrush(QPalette::Window, backgroundTexture()); 672 // set these as transparent so that styled full screen theme background is visible 673 palette->setColor(QPalette::AlternateBase, Qt::transparent); 681 // set as transparent so that styled full screen theme background is visible 674 682 palette->setBrush(QPalette::Base, Qt::transparent); 675 683 // set button and tooltipbase based on pixel colors … … 683 691 palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150)); 684 692 palette->setColor(QPalette::Shadow, Qt::black); 693 QColor alternateBase = palette->light().color(); 694 alternateBase.setAlphaF(0.8); 695 palette->setColor(QPalette::AlternateBase, alternateBase); 685 696 686 697 QApplication::setPalette(*palette); //calling QApplication::setPalette clears palette hash … … 771 782 s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); 772 783 QApplication::setPalette(widgetPalette, "QComboBox"); 784 widgetPalette = *palette; 785 786 widgetPalette.setColor(QPalette::WindowText, s60Color(QS60StyleEnums::CL_QsnTextColors, 7, 0)); 787 QApplication::setPalette(widgetPalette, "QRadioButton"); 788 QApplication::setPalette(widgetPalette, "QCheckBox"); 773 789 widgetPalette = *palette; 774 790 … … 811 827 result.setWidth(result.height() >> 1); 812 828 break; 813 829 814 830 case QS60StyleEnums::SP_QgnGrafNsliderEndLeft: 815 831 case QS60StyleEnums::SP_QgnGrafNsliderEndRight: … … 817 833 result.setWidth(result.height() >> 1); 818 834 break; 819 835 820 836 case QS60StyleEnums::SP_QgnGrafNsliderMarker: 821 837 case QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected: … … 946 962 /* if (optionSlider->state & QStyle::State_HasFocus) 947 963 drawPrimitive(PE_FrameFocusRect, optionSlider, painter, widget);*/ 948 964 949 965 //Groove graphics 950 966 if (QS60StylePrivate::hasSliderGrooveGraphic()) { 951 const QS60StylePrivate::SkinElements grooveElement = horizontal ? 952 QS60StylePrivate::SE_SliderGrooveHorizontal : 967 const QS60StylePrivate::SkinElements grooveElement = horizontal ? 968 QS60StylePrivate::SE_SliderGrooveHorizontal : 953 969 QS60StylePrivate::SE_SliderGrooveVertical; 954 970 QS60StylePrivate::drawSkinElement(grooveElement, painter, sliderGroove, flags); … … 973 989 handleElement = 974 990 horizontal ? QS60StylePrivate::SE_SliderHandleSelectedHorizontal : QS60StylePrivate::SE_SliderHandleSelectedVertical; 975 else 991 else 976 992 handleElement = 977 993 horizontal ? QS60StylePrivate::SE_SliderHandleHorizontal : QS60StylePrivate::SE_SliderHandleVertical; … … 992 1008 const int maxHeight = cmbxFrame.height(); 993 1009 const int maxWidth = cmbxFrame.width() - cmbxEditField.width(); 994 const int topLeftPoint = direction ? 1010 const int topLeftPoint = direction ? 995 1011 (cmbxEditField.right() + 1) : (cmbxEditField.left() + 1 - maxWidth); 996 1012 const QRect buttonRect(topLeftPoint, cmbxEditField.top(), maxWidth, maxHeight); … … 1018 1034 case CC_ToolButton: 1019 1035 if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { 1020 const State bflags = toolBtn->state; 1036 State bflags = toolBtn->state & ~State_Sunken; 1037 1038 if (bflags & State_AutoRaise) { 1039 if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) { 1040 bflags &= ~State_Raised; 1041 } 1042 } 1043 State mflags = bflags; 1044 if (toolBtn->state & State_Sunken) { 1045 if (toolBtn->activeSubControls & SC_ToolButton) 1046 bflags |= State_Sunken; 1047 mflags |= State_Sunken; 1048 } 1049 1021 1050 const QRect button(subControlRect(control, toolBtn, SC_ToolButton, widget)); 1022 1051 QRect menuRect = QRect(); … … 1024 1053 menuRect = subControlRect(control, toolBtn, SC_ToolButtonMenu, widget); 1025 1054 1026 QStyleOptionToolButton toolButton = *toolBtn; 1027 1028 if (sub&SC_ToolButton) { 1055 if (toolBtn->subControls & SC_ToolButton) { 1029 1056 QStyleOption tool(0); 1030 1057 tool.palette = toolBtn->palette; 1031 1058 1032 // Check if toolbutton is in toolbar. 1033 QToolBar *toolBar = 0; 1034 if (widget) 1035 toolBar = qobject_cast<QToolBar *>(widget->parentWidget()); 1036 1037 if (bflags & (State_Sunken | State_On | State_Raised)) { 1059 if (bflags & (State_Sunken | State_On | State_Raised | State_Enabled)) { 1038 1060 tool.rect = button.unite(menuRect); 1039 1061 tool.state = bflags; 1040 1041 // todo: I'd like to move extension button next to where last button is 1042 // however, the painter seems to want to clip the button rect even if I turn of the clipping. 1043 if (toolBar && (qobject_cast<const QToolBarExtension *>(widget))){ 1044 /*QList<QAction *> actionList = toolBar->actions(); 1045 const int actionCount = actionList.count(); 1046 const int toolbarWidth = toolBar->width(); 1047 const int extButtonWidth = pixelMetric(PM_ToolBarExtensionExtent, option, widget); 1048 const int toolBarButtonWidth = pixelMetric(PM_ToolBarIconSize, option, widget); 1049 const int frame = pixelMetric(PM_ToolBarFrameWidth, option, widget); 1050 const int margin = pixelMetric(PM_ToolBarItemMargin, option, widget); 1051 const int border = frame + margin; 1052 const int spacing = pixelMetric(PM_ToolBarItemSpacing, option, widget); 1053 const int toolBarButtonArea = toolbarWidth - extButtonWidth - spacing - 2*border; 1054 const int numberOfVisibleButtons = toolBarButtonArea / toolBarButtonWidth; 1055 // new extension button place is after border and all the other visible buttons (with spacings) 1056 const int newXForExtensionButton = numberOfVisibleButtons * toolBarButtonWidth + (numberOfVisibleButtons-1)*spacing + border; 1057 painter->save(); 1058 painter->setClipping(false); 1059 tool.rect.translate(-newXForExtensionButton,0); 1060 painter->restore();*/ 1061 } 1062 1063 if (toolBar){ 1064 /*if (toolBar->orientation() == Qt::Vertical){ 1065 // todo: I'd like to make all vertical buttons the same size, but again the painter 1066 // prefers to use clipping for button rects, even though clipping has been set off. 1067 painter->save(); 1068 painter->setClipping(false); 1069 1070 const int origWidth = tool.rect.width(); 1071 const int newWidth = toolBar->width()-2*pixelMetric(PM_ToolBarFrameWidth, option, widget); 1072 painter->translate(origWidth-newWidth,0); 1073 tool.rect.translate(origWidth-tool.rect.width(),0); 1074 tool.rect.setWidth(newWidth); 1075 1076 if (option->state & QStyle::State_Sunken) 1077 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ToolBarButtonPressed, painter, tool.rect, flags); 1078 else 1079 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ToolBarButton, painter, tool.rect, flags); 1080 1081 }*/ 1082 if (option->state & QStyle::State_Sunken) 1083 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ToolBarButtonPressed, painter, tool.rect, flags); 1084 else 1085 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ToolBarButton, painter, tool.rect, flags); 1086 /* 1087 if (toolBar->orientation() == Qt::Vertical) 1088 painter->restore(); 1089 */ 1090 } else { 1091 drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); 1092 } 1093 1094 if (toolButton.subControls & SC_ToolButtonMenu) { 1095 tool.rect = menuRect; 1096 tool.state = bflags; 1097 drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); 1098 } 1062 const QToolButton *toolButtonWidget = qobject_cast<const QToolButton *>(widget); 1063 QS60StylePrivate::SkinElements element; 1064 if (toolButtonWidget) 1065 element = (toolButtonWidget->isDown()) ? QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; 1066 else 1067 element = (option->state & State_Sunken) ? QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; 1068 QS60StylePrivate::drawSkinElement(element, painter, tool.rect, flags); 1069 drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); 1099 1070 } 1100 } 1101 1071 if (toolBtn->subControls & SC_ToolButtonMenu) { 1072 tool.rect = menuRect; 1073 tool.state = mflags; 1074 drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); 1075 } 1076 } 1077 QStyleOptionToolButton toolButton = *toolBtn; 1102 1078 if (toolBtn->features & QStyleOptionToolButton::Arrow) { 1103 QStyle::PrimitiveElement pe;1079 PrimitiveElement pe; 1104 1080 switch (toolBtn->arrowType) { 1105 1081 case Qt::LeftArrow: 1106 pe = QStyle::PE_IndicatorArrowLeft;1082 pe = PE_IndicatorArrowLeft; 1107 1083 break; 1108 1084 case Qt::RightArrow: 1109 pe = QStyle::PE_IndicatorArrowRight;1085 pe = PE_IndicatorArrowRight; 1110 1086 break; 1111 1087 case Qt::UpArrow: 1112 pe = QStyle::PE_IndicatorArrowUp;1088 pe = PE_IndicatorArrowUp; 1113 1089 break; 1114 1090 case Qt::DownArrow: 1115 pe = QStyle::PE_IndicatorArrowDown;1091 pe = PE_IndicatorArrowDown; 1116 1092 break; 1117 1093 default: … … 1247 1223 const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; 1248 1224 switch (element) { 1225 case CE_CheckBox: 1226 case CE_RadioButton: 1227 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { 1228 bool isRadio = (element == CE_RadioButton); 1229 // Highlight needs to be drawn first, as it goes "underneath" the text and indicator. 1230 if (btn->state & State_HasFocus) { 1231 QStyleOptionFocusRect fropt; 1232 fropt.QStyleOption::operator=(*btn); 1233 fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect 1234 : SE_CheckBoxFocusRect, btn, widget); 1235 drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); 1236 } 1237 QStyleOptionButton subopt = *btn; 1238 1239 subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator 1240 : SE_CheckBoxIndicator, btn, widget); 1241 drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, 1242 &subopt, painter, widget); 1243 subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents 1244 : SE_CheckBoxContents, btn, widget); 1245 1246 drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget); 1247 } 1248 break; 1249 1249 1250 case CE_PushButton: 1250 1251 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { … … 1364 1365 } 1365 1366 1366 int rightValue = widget ? widget->contentsRect().right() : 0;1367 int rightValue = widget ? widget->contentsRect().right() : voptAdj.rect.right(); 1367 1368 1368 1369 if (isScrollBarVisible) … … 1646 1647 const QS60StylePrivate::SkinElementFlag orientationFlag = optionProgressBar->orientation == Qt::Horizontal ? 1647 1648 QS60StylePrivate::SF_PointNorth : QS60StylePrivate::SF_PointWest; 1648 QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnGrafBarWait, painter, progressRect, flags | orientationFlag); 1649 1650 QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnGrafBarWaitAnim, 1651 painter, progressRect, flags | orientationFlag | QS60StylePrivate::SF_Animation ); 1649 1652 } else { 1650 1653 const qreal progressFactor = (optionProgressBar->minimum == optionProgressBar->maximum) ? 1.0 1651 1654 : (qreal)optionProgressBar->progress / optionProgressBar->maximum; 1655 const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget); 1652 1656 if (optionProgressBar->orientation == Qt::Horizontal) { 1653 1657 progressRect.setWidth(int(progressRect.width() * progressFactor)); 1654 1658 if(optionProgressBar->direction == Qt::RightToLeft) 1655 progressRect.translate(optionProgressBar->rect.width() -progressRect.width(), 0);1656 progressRect.adjust( 1, 0, -1, 0);1659 progressRect.translate(optionProgressBar->rect.width() - progressRect.width(), 0); 1660 progressRect.adjust(frameWidth, 0, -frameWidth, 0); 1657 1661 } else { 1658 progressRect.adjust(0, 1, 0, -1);1662 progressRect.adjust(0, frameWidth, 0, -frameWidth); 1659 1663 progressRect.setTop(progressRect.bottom() - int(progressRect.height() * progressFactor)); 1660 1664 } … … 1923 1927 case CE_MenuScroller: 1924 1928 break; 1925 case CE_FocusFrame: 1926 { 1929 case CE_FocusFrame: { 1927 1930 // The pen width should nearly fill the layoutspacings around the widget 1928 1931 const int penWidth = … … 1988 1991 1989 1992 switch (element) { 1993 case PE_FrameFocusRect: { 1994 //Draw themed highlight to radiobuttons and checkboxes. 1995 //For other widgets skip, unless palette has been modified. In that case, draw with commonstyle. 1996 if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) 1997 if ((qstyleoption_cast<const QStyleOptionFocusRect *>(option) && 1998 (qobject_cast<const QRadioButton *>(widget) || qobject_cast<const QCheckBox *>(widget)))) 1999 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); 2000 else 2001 commonStyleDraws = true; 2002 } 2003 break; 1990 2004 #ifndef QT_NO_LINEEDIT 1991 2005 case PE_PanelLineEdit: … … 2002 2016 break; 2003 2017 #endif // QT_NO_LINEEDIT 2004 case PE_IndicatorCheckBox: 2005 { 2018 case PE_IndicatorCheckBox: { 2006 2019 // Draw checkbox indicator as color skinned graphics. 2007 2020 const QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ? … … 2075 2088 case PE_PanelButtonTool: 2076 2089 case PE_PanelButtonBevel: 2077 case PE_FrameButtonBevel: {2090 case PE_FrameButtonBevel: 2078 2091 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) { 2079 2092 const bool isPressed = option->state & QStyle::State_Sunken; … … 2083 2096 } else { 2084 2097 commonStyleDraws = true; 2085 }2086 2098 } 2087 2099 break; … … 2205 2217 #ifndef QT_NO_ITEMVIEWS 2206 2218 case PE_PanelItemViewItem: 2207 case PE_PanelItemViewRow: // ### Qt 5: remove2208 2219 break; 2209 2220 #endif //QT_NO_ITEMVIEWS … … 2274 2285 } 2275 2286 break; 2276 2287 case PE_PanelItemViewRow: // ### Qt 5: remove 2288 #ifndef QT_NO_ITEMVIEWS 2289 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { 2290 if (vopt->palette.base().texture().cacheKey() != QS60StylePrivate::m_themePalette->base().texture().cacheKey()) { 2291 //QPalette::Base has been changed, let commonstyle draw the item 2292 commonStyleDraws = true; 2293 } else { 2294 QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled; 2295 if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active)) 2296 cg = QPalette::Inactive; 2297 if (vopt->features & QStyleOptionViewItemV2::Alternate) 2298 painter->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase)); 2299 //apart from alternate base, no background for list item is drawn for S60Style 2300 } 2301 } 2302 #endif 2303 break; 2277 2304 case PE_PanelScrollAreaCorner: 2278 2305 break; … … 2359 2386 sz += QSize(2 * f->lineWidth, 4 * f->lineWidth); 2360 2387 break; 2361 case CT_TabBarTab: 2362 { 2388 case CT_TabBarTab: { 2363 2389 const QSize naviPaneSize = QS60StylePrivate::naviPaneSize(); 2364 2390 sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget); … … 2374 2400 sz.setHeight(sz.height() + 2 * pixelMetric(QStyle::PM_FocusFrameVMargin)); 2375 2401 break; 2402 #ifndef QT_NO_COMBOBOX 2403 case CT_ComboBox: 2404 if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { 2405 const int frameWidth = cmb->frame ? pixelMetric(PM_ComboBoxFrameWidth, opt, widget) * 2 : 0; 2406 const int textMargins = 2*(pixelMetric(PM_FocusFrameHMargin) + 1); 2407 const int smallestExtraWidth = 23; 2408 // QItemDelegate::sizeHint expands the textMargins two times, thus the 2*textMargins... 2409 const int extra = 2410 qMax(smallestExtraWidth, 2*textMargins + pixelMetric(PM_ScrollBarExtent, opt, widget)); 2411 sz = QSize(sz.width() + frameWidth + extra, sz.height() + frameWidth); 2412 int maxScreenWidth = QApplication::desktop()->availableGeometry().size().width(); 2413 if (sz.width() > maxScreenWidth) { 2414 maxScreenWidth = maxScreenWidth - (extra + frameWidth); 2415 sz.setWidth(maxScreenWidth); 2416 } 2417 } 2418 break; 2419 #endif 2376 2420 default: 2377 2421 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); … … 2412 2456 break; 2413 2457 case SH_ItemView_ActivateItemOnSingleClick: 2414 retValue = true;2458 retValue = QS60StylePrivate::isSingleClickUi(); 2415 2459 break; 2416 2460 case SH_ProgressDialog_TextLabelAlignment: … … 2578 2622 const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; 2579 2623 const int buttonWidth = qMax(cmb->rect.height(), buttonIconSize); 2580 const int xposMod = (cmb->rect.x()) + width - buttonMargin - buttonWidth;2581 const int ypos = cmb->rect.y();2582 2624 2583 2625 QSize buttonSize; … … 2586 2628 buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); 2587 2629 switch (scontrol) { 2588 case SC_ComboBoxArrow: 2630 case SC_ComboBoxArrow: { 2631 const int xposMod = cmb->rect.x() + width - buttonMargin - buttonWidth; 2632 const int ypos = cmb->rect.y(); 2589 2633 ret.setRect(xposMod, ypos + buttonMargin, buttonWidth, height - 2 * buttonMargin); 2634 } 2590 2635 break; 2591 2636 case SC_ComboBoxEditField: { 2592 const int withFrameX = cmb->rect.x() + cmb->rect.width()- frameThickness - buttonSize.width();2637 const int withFrameX = cmb->rect.x() + width - frameThickness - buttonSize.width(); 2593 2638 ret = QRect( 2594 2639 frameThickness, 2595 2640 frameThickness, 2596 2641 withFrameX - frameThickness, 2597 cmb->rect.height()- 2 * frameThickness);2642 height - 2 * frameThickness); 2598 2643 } 2599 2644 break; … … 2601 2646 break; 2602 2647 } 2648 ret = visualRect(cmb->direction, cmb->rect, ret); 2603 2649 } 2604 2650 break; … … 2666 2712 QRect ret; 2667 2713 switch (element) { 2714 case SE_RadioButtonFocusRect: 2715 ret = opt->rect; 2716 break; 2668 2717 case SE_LineEditContents: { 2669 2718 // in S60 the input text box doesn't start from line Edit's TL, but … … 2816 2865 ret = visualRect(opt->direction, opt->rect, ret); 2817 2866 break; 2867 case SE_RadioButtonIndicator: { 2868 const int height = pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget); 2869 ret.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - height) >> 1), 2870 pixelMetric(PM_ExclusiveIndicatorWidth, opt, widget), height); 2871 ret.translate(2, 0); //move indicator slightly to avoid highlight crossing over it 2872 ret = visualRect(opt->direction, opt->rect, ret); 2873 } 2874 break; 2875 case SE_CheckBoxIndicator: { 2876 const int height = pixelMetric(PM_IndicatorHeight, opt, widget); 2877 ret.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - height) >> 1), 2878 pixelMetric(PM_IndicatorWidth, opt, widget), height); 2879 ret.translate(2, 0); //move indicator slightly to avoid highlight crossing over it 2880 ret = visualRect(opt->direction, opt->rect, ret); 2881 } 2882 break; 2883 case SE_CheckBoxFocusRect: 2884 ret = opt->rect; 2885 break; 2818 2886 default: 2819 2887 ret = QCommonStyle::subElementRect(element, opt, widget); … … 2832 2900 if (!widget) 2833 2901 return; 2902 2903 //Currently we only support animations in QProgressBar. 2904 #ifndef QT_NO_PROGRESSBAR 2905 if (qobject_cast<QProgressBar *>(widget)) 2906 widget->installEventFilter(this); 2907 #endif 2834 2908 2835 2909 if (false … … 2865 2939 void QS60Style::unpolish(QWidget *widget) 2866 2940 { 2941 Q_D(QS60Style); 2942 2867 2943 if (false 2868 2944 #ifndef QT_NO_SCROLLBAR … … 2891 2967 widget->setPalette(QPalette()); 2892 2968 2969 #ifndef QT_NO_PROGRESSBAR 2970 if (QProgressBar *bar = qobject_cast<QProgressBar *>(widget)) { 2971 widget->removeEventFilter(this); 2972 d->m_bars.removeAll(bar); 2973 } 2974 #endif 2893 2975 QCommonStyle::unpolish(widget); 2894 2976 } … … 2921 3003 bool QS60Style::event(QEvent *e) 2922 3004 { 3005 Q_D(QS60Style); 3006 2923 3007 #ifdef QT_KEYPAD_NAVIGATION 2924 if (QS60StylePrivate::isTouchSupported()) 2925 return false; 2926 Q_D(QS60Style); 3008 const QEvent::Type eventType = e->type(); 3009 if ((eventType == QEvent::FocusIn || 3010 eventType == QEvent::FocusOut || 3011 eventType == QEvent::EnterEditFocus || 3012 eventType == QEvent::LeaveEditFocus) && 3013 QS60StylePrivate::isTouchSupported()) 3014 return false; 3015 #endif 3016 2927 3017 switch (e->type()) { 3018 case QEvent::Timer: { 3019 QTimerEvent *te = static_cast<QTimerEvent*>(e); 3020 timerEvent(te); 3021 } 3022 break; 3023 #ifdef QT_KEYPAD_NAVIGATION 2928 3024 case QEvent::FocusIn: 2929 3025 if (QWidget *focusWidget = QApplication::focusWidget()) { … … 2944 3040 d->m_focusFrame->update(); 2945 3041 break; 3042 #endif 2946 3043 default: 2947 3044 break; 2948 3045 } 2949 #else2950 Q_UNUSED(e)2951 #endif2952 3046 return false; 2953 3047 } … … 3043 3137 } 3044 3138 3139 /*! 3140 \internal 3141 Animate indeterminate progress bars only when visible 3142 */ 3143 bool QS60Style::eventFilter(QObject *object, QEvent *event) 3144 { 3145 #ifdef Q_WS_S60 3146 #ifndef QT_NO_PROGRESSBAR 3147 Q_D(QS60Style); 3148 switch(event->type()) { 3149 case QEvent::StyleChange: 3150 case QEvent::Show: 3151 if (QProgressBar *bar = qobject_cast<QProgressBar *>(object)) { 3152 if (!d->m_bars.contains(bar)) 3153 d->m_bars << bar; 3154 if (d->m_bars.size() == 1) //only start with first animated progressbar 3155 d->startAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim); 3156 } 3157 break; 3158 case QEvent::Destroy: 3159 case QEvent::Hide: 3160 d->stopAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim); 3161 d->m_bars.removeAll(reinterpret_cast<QProgressBar *>(object)); 3162 break; 3163 default: 3164 break; 3165 } 3166 #endif // QT_NO_PROGRESSBAR 3167 #endif // Q_WS_S60 3168 return QStyle::eventFilter(object, event); 3169 } 3170 3171 void QS60Style::timerEvent(QTimerEvent *event) 3172 { 3173 #ifdef Q_WS_S60 3174 #ifndef QT_NO_PROGRESSBAR 3175 Q_D(QS60Style); 3176 3177 QS60StyleAnimation *progressBarAnimation = 3178 QS60StylePrivate::animationDefinition(QS60StyleEnums::SP_QgnGrafBarWaitAnim); 3179 3180 if (event->timerId() == progressBarAnimation->timerId()) { 3181 3182 Q_ASSERT(progressBarAnimation->interval() > 0); 3183 3184 if (progressBarAnimation->currentFrame() == progressBarAnimation->frameCount() ) 3185 if (progressBarAnimation->playMode() == QS60StyleEnums::AM_Looping) 3186 progressBarAnimation->setCurrentFrame(0); 3187 else 3188 d->stopAnimation(progressBarAnimation->animationId()); 3189 3190 foreach (QProgressBar *bar, d->m_bars) { 3191 if ((bar->minimum() == 0 && bar->maximum() == 0)) 3192 bar->update(); 3193 } 3194 progressBarAnimation->setCurrentFrame(progressBarAnimation->currentFrame() + 1); 3195 } 3196 #endif // QT_NO_PROGRESSBAR 3197 #endif // Q_WS_S60 3198 event->ignore(); 3199 } 3200 3045 3201 extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget); 3046 3202 … … 3054 3210 if (target->devType() == QInternal::Widget) { 3055 3211 const QWidget *widget = static_cast<const QWidget *>(target); 3056 const QVector<QRect> &rects = rgn.rects(); 3057 for (int i = 0; i < rects.size(); ++i) { 3058 const QRect rect(rects.at(i)); 3059 painter->drawPixmap(rect.topLeft(), backgroundTexture, 3060 rect.translated(qt_s60_fill_background_offset(widget))); 3212 if (!widget->testAttribute(Qt::WA_TranslucentBackground)) { 3213 const QVector<QRect> &rects = rgn.rects(); 3214 for (int i = 0; i < rects.size(); ++i) { 3215 const QRect rect(rects.at(i)); 3216 painter->drawPixmap(rect.topLeft(), backgroundTexture, 3217 rect.translated(qt_s60_fill_background_offset(widget))); 3218 } 3061 3219 } 3062 3220 }
Note:
See TracChangeset
for help on using the changeset viewer.