Ignore:
Timestamp:
Mar 8, 2010, 12:52:58 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.2 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/styles/qs60style.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6969#include "qfocusframe.h"
    7070#include "qformlayout.h"
     71#include "qradiobutton.h"
     72#include "qcheckbox.h"
     73#include "qdesktopwidget.h"
     74#include "qprogressbar.h"
    7175
    7276#include "private/qtoolbarextension_p.h"
     
    344348
    345349QFont QS60StylePrivate::s60Font(
    346     QS60StyleEnums::FontCategories fontCategory, int pointSize) const
     350    QS60StyleEnums::FontCategories fontCategory,
     351    int pointSize, bool resolveFontSize) const
    347352{
    348353    QFont result;
     
    357362    const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize);
    358363    if (!m_mappedFontsCache.contains(key)) {
    359         result = s60Font_specific(fontCategory, actualPointSize);
     364        result = s60Font_specific(fontCategory, actualPointSize, resolveFontSize);
    360365        m_mappedFontsCache.insert(key, result);
    361366    } else {
     
    564569{
    565570    QPixmap result;
     571    const int animationFrame = (flags & SF_Animation) ? currentAnimationFrame(part) : 0;
     572
    566573    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);
    569576    if (!QPixmapCache::find(cacheKey, result)) {
    570577        result = QS60StylePrivate::part(part, size, painter, flags);
     
    621628    }
    622629    if (fontCategory != QS60StyleEnums::FC_Undefined) {
     630        const bool resolveFontSize = widget->testAttribute(Qt::WA_SetFont)
     631            && (widget->font().resolve() & QFont::SizeResolved);
    623632        const QFont suggestedFont =
    624             s60Font(fontCategory, widget->font().pointSizeF());
     633            s60Font(fontCategory, widget->font().pointSizeF(), resolveFontSize);
    625634        widget->setFont(suggestedFont);
    626635    }
     
    670679    // set background image as a texture brush
    671680    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
    674682    palette->setBrush(QPalette::Base, Qt::transparent);
    675683    // set button and tooltipbase based on pixel colors
     
    683691    palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150));
    684692    palette->setColor(QPalette::Shadow, Qt::black);
     693    QColor alternateBase = palette->light().color();
     694    alternateBase.setAlphaF(0.8);
     695    palette->setColor(QPalette::AlternateBase, alternateBase);
    685696
    686697    QApplication::setPalette(*palette); //calling QApplication::setPalette clears palette hash
     
    771782        s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0));
    772783    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");
    773789    widgetPalette = *palette;
    774790
     
    811827            result.setWidth(result.height() >> 1);
    812828            break;
    813            
     829
    814830        case QS60StyleEnums::SP_QgnGrafNsliderEndLeft:
    815831        case QS60StyleEnums::SP_QgnGrafNsliderEndRight:
     
    817833            result.setWidth(result.height() >> 1);
    818834            break;
    819            
     835
    820836        case QS60StyleEnums::SP_QgnGrafNsliderMarker:
    821837        case QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected:
     
    946962/*            if (optionSlider->state & QStyle::State_HasFocus)
    947963                drawPrimitive(PE_FrameFocusRect, optionSlider, painter, widget);*/
    948            
     964
    949965            //Groove graphics
    950966            if (QS60StylePrivate::hasSliderGrooveGraphic()) {
    951                 const QS60StylePrivate::SkinElements grooveElement = horizontal ? 
    952                     QS60StylePrivate::SE_SliderGrooveHorizontal : 
     967                const QS60StylePrivate::SkinElements grooveElement = horizontal ?
     968                    QS60StylePrivate::SE_SliderGrooveHorizontal :
    953969                    QS60StylePrivate::SE_SliderGrooveVertical;
    954970                QS60StylePrivate::drawSkinElement(grooveElement, painter, sliderGroove, flags);
     
    973989                handleElement =
    974990                        horizontal ? QS60StylePrivate::SE_SliderHandleSelectedHorizontal : QS60StylePrivate::SE_SliderHandleSelectedVertical;
    975             else   
     991            else
    976992                handleElement =
    977993                    horizontal ? QS60StylePrivate::SE_SliderHandleHorizontal : QS60StylePrivate::SE_SliderHandleVertical;
     
    9921008            const int maxHeight = cmbxFrame.height();
    9931009            const int maxWidth = cmbxFrame.width() - cmbxEditField.width();
    994             const int topLeftPoint = direction ? 
     1010            const int topLeftPoint = direction ?
    9951011                (cmbxEditField.right() + 1) : (cmbxEditField.left() + 1 - maxWidth);
    9961012            const QRect buttonRect(topLeftPoint, cmbxEditField.top(), maxWidth, maxHeight);
     
    10181034    case CC_ToolButton:
    10191035        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
    10211050            const QRect button(subControlRect(control, toolBtn, SC_ToolButton, widget));
    10221051            QRect menuRect = QRect();
     
    10241053                menuRect = subControlRect(control, toolBtn, SC_ToolButtonMenu, widget);
    10251054
    1026             QStyleOptionToolButton toolButton = *toolBtn;
    1027 
    1028             if (sub&SC_ToolButton) {
     1055            if (toolBtn->subControls & SC_ToolButton) {
    10291056                QStyleOption tool(0);
    10301057                tool.palette = toolBtn->palette;
    10311058
    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)) {
    10381060                    tool.rect = button.unite(menuRect);
    10391061                    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);
    10991070                }
    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;
    11021078            if (toolBtn->features & QStyleOptionToolButton::Arrow) {
    1103                 QStyle::PrimitiveElement pe;
     1079                PrimitiveElement pe;
    11041080                switch (toolBtn->arrowType) {
    11051081                    case Qt::LeftArrow:
    1106                         pe = QStyle::PE_IndicatorArrowLeft;
     1082                        pe = PE_IndicatorArrowLeft;
    11071083                        break;
    11081084                    case Qt::RightArrow:
    1109                         pe = QStyle::PE_IndicatorArrowRight;
     1085                        pe = PE_IndicatorArrowRight;
    11101086                        break;
    11111087                    case Qt::UpArrow:
    1112                         pe = QStyle::PE_IndicatorArrowUp;
     1088                        pe = PE_IndicatorArrowUp;
    11131089                        break;
    11141090                    case Qt::DownArrow:
    1115                         pe = QStyle::PE_IndicatorArrowDown;
     1091                        pe = PE_IndicatorArrowDown;
    11161092                        break;
    11171093                    default:
     
    12471223    const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ?  QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled;
    12481224    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
    12491250    case CE_PushButton:
    12501251        if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
     
    13641365            }
    13651366
    1366             int rightValue = widget ? widget->contentsRect().right() : 0;
     1367            int rightValue = widget ? widget->contentsRect().right() : voptAdj.rect.right();
    13671368
    13681369            if (isScrollBarVisible)
     
    16461647                const QS60StylePrivate::SkinElementFlag orientationFlag = optionProgressBar->orientation == Qt::Horizontal ?
    16471648                    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 );
    16491652            } else {
    16501653                const qreal progressFactor = (optionProgressBar->minimum == optionProgressBar->maximum) ? 1.0
    16511654                    : (qreal)optionProgressBar->progress / optionProgressBar->maximum;
     1655                const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget);
    16521656                if (optionProgressBar->orientation == Qt::Horizontal) {
    16531657                    progressRect.setWidth(int(progressRect.width() * progressFactor));
    16541658                    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);
    16571661                } else {
    1658                     progressRect.adjust(0, 1, 0, -1);
     1662                    progressRect.adjust(0, frameWidth, 0, -frameWidth);
    16591663                    progressRect.setTop(progressRect.bottom() - int(progressRect.height() * progressFactor));
    16601664                }
     
    19231927    case CE_MenuScroller:
    19241928        break;
    1925     case CE_FocusFrame:
    1926         {
     1929    case CE_FocusFrame: {
    19271930            // The pen width should nearly fill the layoutspacings around the widget
    19281931            const int penWidth =
     
    19881991
    19891992    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;
    19902004#ifndef QT_NO_LINEEDIT
    19912005    case PE_PanelLineEdit:
     
    20022016    break;
    20032017#endif // QT_NO_LINEEDIT
    2004     case PE_IndicatorCheckBox:
    2005         {
     2018    case PE_IndicatorCheckBox: {
    20062019            // Draw checkbox indicator as color skinned graphics.
    20072020            const QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ?
     
    20752088    case PE_PanelButtonTool:
    20762089    case PE_PanelButtonBevel:
    2077     case PE_FrameButtonBevel: {
     2090    case PE_FrameButtonBevel:
    20782091        if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) {
    20792092            const bool isPressed = option->state & QStyle::State_Sunken;
     
    20832096        } else {
    20842097            commonStyleDraws = true;
    2085             }
    20862098        }
    20872099        break;
     
    22052217#ifndef QT_NO_ITEMVIEWS
    22062218    case PE_PanelItemViewItem:
    2207     case PE_PanelItemViewRow: // ### Qt 5: remove
    22082219        break;
    22092220#endif //QT_NO_ITEMVIEWS
     
    22742285        }
    22752286        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;
    22772304    case PE_PanelScrollAreaCorner:
    22782305        break;
     
    23592386                sz += QSize(2 * f->lineWidth, 4 * f->lineWidth);
    23602387            break;
    2361         case CT_TabBarTab:
    2362             {
     2388        case CT_TabBarTab: {
    23632389                const QSize naviPaneSize = QS60StylePrivate::naviPaneSize();
    23642390                sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
     
    23742400                sz.setHeight(sz.height() + 2 * pixelMetric(QStyle::PM_FocusFrameVMargin));
    23752401            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
    23762420        default:
    23772421            sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget);
     
    24122456            break;
    24132457        case SH_ItemView_ActivateItemOnSingleClick:
    2414             retValue = true;
     2458            retValue = QS60StylePrivate::isSingleClickUi();
    24152459            break;
    24162460        case SH_ProgressDialog_TextLabelAlignment:
     
    25782622            const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0;
    25792623            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();
    25822624
    25832625            QSize buttonSize;
     
    25862628            buttonSize = buttonSize.expandedTo(QApplication::globalStrut());
    25872629            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();
    25892633                    ret.setRect(xposMod, ypos + buttonMargin, buttonWidth, height - 2 * buttonMargin);
     2634                    }
    25902635                    break;
    25912636                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();
    25932638                    ret = QRect(
    25942639                        frameThickness,
    25952640                        frameThickness,
    25962641                        withFrameX - frameThickness,
    2597                         cmb->rect.height() - 2 * frameThickness);
     2642                        height - 2 * frameThickness);
    25982643                    }
    25992644                break;
     
    26012646                break;
    26022647            }
     2648            ret = visualRect(cmb->direction, cmb->rect, ret);
    26032649        }
    26042650        break;
     
    26662712    QRect ret;
    26672713    switch (element) {
     2714        case SE_RadioButtonFocusRect:
     2715            ret = opt->rect;
     2716            break;
    26682717        case SE_LineEditContents: {
    26692718                // in S60 the input text box doesn't start from line Edit's TL, but
     
    28162865            ret = visualRect(opt->direction, opt->rect, ret);
    28172866            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;
    28182886        default:
    28192887            ret = QCommonStyle::subElementRect(element, opt, widget);
     
    28322900    if (!widget)
    28332901        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
    28342908
    28352909    if (false
     
    28652939void QS60Style::unpolish(QWidget *widget)
    28662940{
     2941    Q_D(QS60Style);
     2942
    28672943    if (false
    28682944    #ifndef QT_NO_SCROLLBAR
     
    28912967        widget->setPalette(QPalette());
    28922968
     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
    28932975    QCommonStyle::unpolish(widget);
    28942976}
     
    29213003bool QS60Style::event(QEvent *e)
    29223004{
     3005    Q_D(QS60Style);
     3006
    29233007#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
    29273017    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
    29283024    case QEvent::FocusIn:
    29293025        if (QWidget *focusWidget = QApplication::focusWidget()) {
     
    29443040            d->m_focusFrame->update();
    29453041        break;
     3042#endif
    29463043    default:
    29473044        break;
    29483045    }
    2949 #else
    2950     Q_UNUSED(e)
    2951 #endif
    29523046    return false;
    29533047}
     
    30433137}
    30443138
     3139/*!
     3140    \internal
     3141    Animate indeterminate progress bars only when visible
     3142*/
     3143bool 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
     3171void 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
    30453201extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget);
    30463202
     
    30543210    if (target->devType() == QInternal::Widget) {
    30553211        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            }
    30613219        }
    30623220    }
Note: See TracChangeset for help on using the changeset viewer.