diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-08-28 16:01:01 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-08-28 16:01:01 (GMT) |
commit | f25f5b41a620b6d46e78eb97e3b2784c646493d0 (patch) | |
tree | 2083c23d547ae703df66441e1cb7c03ed9849374 /src/gui | |
parent | 9b6edd75d37b25d76349ba7b84677d4c9922cc58 (diff) | |
parent | 31affef31b3743a23cf6f099d6a8f72b371586b4 (diff) | |
download | Qt-f25f5b41a620b6d46e78eb97e3b2784c646493d0.zip Qt-f25f5b41a620b6d46e78eb97e3b2784c646493d0.tar.gz Qt-f25f5b41a620b6d46e78eb97e3b2784c646493d0.tar.bz2 |
Merge branch '4.6'
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/effects/qgraphicseffect.cpp | 101 | ||||
-rw-r--r-- | src/gui/effects/qgraphicseffect.h | 5 | ||||
-rw-r--r-- | src/gui/effects/qgraphicseffect_p.h | 7 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 6 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 4 | ||||
-rw-r--r-- | src/gui/image/qpixmap.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qevent.cpp | 11 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 9 | ||||
-rw-r--r-- | src/gui/math3d/qmatrix4x4.cpp | 2 | ||||
-rw-r--r-- | src/gui/styles/qs60style.cpp | 190 | ||||
-rw-r--r-- | src/gui/styles/qs60style.h | 2 | ||||
-rw-r--r-- | src/gui/styles/qs60style_p.h | 6 | ||||
-rw-r--r-- | src/gui/styles/qs60style_s60.cpp | 3 | ||||
-rw-r--r-- | src/gui/styles/qstylesheetstyle.cpp | 26 | ||||
-rw-r--r-- | src/gui/text/qfontdatabase_s60.cpp | 11 | ||||
-rw-r--r-- | src/gui/text/qfontengine_s60.cpp | 9 | ||||
-rw-r--r-- | src/gui/text/qfontengine_s60_p.h | 4 |
17 files changed, 248 insertions, 150 deletions
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 5f64698..50644ff 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -990,6 +990,8 @@ QGraphicsOpacityEffect::~QGraphicsOpacityEffect() fully transparent and 1.0 is fully opaque. By default, the opacity is 0.7. + + \sa setOpacityMask() */ qreal QGraphicsOpacityEffect::opacity() const { @@ -1006,6 +1008,10 @@ void QGraphicsOpacityEffect::setOpacity(qreal opacity) return; d->opacity = opacity; + if ((d->isFullyTransparent = qFuzzyIsNull(d->opacity))) + d->isFullyOpaque = 0; + else + d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1); emit opacityChanged(opacity); } @@ -1017,6 +1023,45 @@ void QGraphicsOpacityEffect::setOpacity(qreal opacity) */ /*! + \property QGraphicsOpacityEffect::opacityMask + \brief the opacity mask of the effect. + + An opacity mask allows you apply opacity to portions of an element. + + For example: + + \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 2 + + There is no opacity mask by default. + + \sa setOpacity() +*/ +QBrush QGraphicsOpacityEffect::opacityMask() const +{ + Q_D(const QGraphicsOpacityEffect); + return d->opacityMask; +} + +void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask) +{ + Q_D(QGraphicsOpacityEffect); + if (d->opacityMask == mask) + return; + + d->opacityMask = mask; + d->hasOpacityMask = (mask.style() != Qt::NoBrush); + + emit opacityMaskChanged(mask); +} + +/*! + \fn void QGraphicsOpacityEffect::opacityMaskChanged(const QBrush &mask) + + This signal is emitted whenever the effect's opacity mask changes. + The \a mask parameter holds the effect's new opacity mask. +*/ + +/*! \reimp */ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *source) @@ -1024,11 +1069,11 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour Q_D(QGraphicsOpacityEffect); // Transparent; nothing to draw. - if (qFuzzyIsNull(d->opacity)) + if (d->isFullyTransparent) return; // Opaque; draw directly without going through a pixmap. - if (qFuzzyIsNull(d->opacity - 1)) { + if (d->isFullyOpaque && !d->hasOpacityMask) { source->draw(painter); return; } @@ -1039,13 +1084,55 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour QPoint offset; if (source->isPixmap()) { // No point in drawing in device coordinates (pixmap will be scaled anyways). - const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); - painter->drawPixmap(offset, pixmap); + if (!d->hasOpacityMask) { + const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); + painter->drawPixmap(offset, pixmap); + } else { + QRectF srcBrect = source->boundingRect(); + QPixmap pixmap(srcBrect.size().toSize()); + pixmap.fill(Qt::transparent); + + QPainter pixmapPainter(&pixmap); + pixmapPainter.setRenderHints(painter->renderHints()); + pixmapPainter.translate(-srcBrect.topLeft()); + source->draw(&pixmapPainter); + pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); + pixmapPainter.fillRect(srcBrect, d->opacityMask); + pixmapPainter.end(); + + painter->drawPixmap(srcBrect.topLeft(), pixmap); + } } else { // Draw pixmap in device coordinates to avoid pixmap scaling; - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); - painter->setWorldTransform(QTransform()); - painter->drawPixmap(offset, pixmap); + if (!d->hasOpacityMask) { + const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); + painter->setWorldTransform(QTransform()); + painter->drawPixmap(offset, pixmap); + } else { + QTransform worldTransform = painter->worldTransform(); + + // Calculate source bounding rect in logical and device coordinates. + QRectF srcBrect = source->boundingRect(); + QRect srcDeviceBrect = worldTransform.mapRect(srcBrect).toAlignedRect(); + srcDeviceBrect &= source->deviceRect(); + + offset = srcDeviceBrect.topLeft(); + worldTransform *= QTransform::fromTranslate(-srcDeviceBrect.x(), -srcDeviceBrect.y()); + + QPixmap pixmap(srcDeviceBrect.size()); + pixmap.fill(Qt::transparent); + + QPainter pixmapPainter(&pixmap); + pixmapPainter.setRenderHints(painter->renderHints()); + pixmapPainter.setWorldTransform(worldTransform); + source->draw(&pixmapPainter); + pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); + pixmapPainter.fillRect(srcBrect, d->opacityMask); + pixmapPainter.end(); + + painter->setWorldTransform(QTransform()); + painter->drawPixmap(offset, pixmap); + } } painter->restore(); diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index fef6531..a53357b 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -46,6 +46,7 @@ #include <QtCore/qpoint.h> #include <QtCore/qrect.h> #include <QtGui/qcolor.h> +#include <QtGui/qbrush.h> QT_BEGIN_HEADER @@ -274,17 +275,21 @@ class Q_GUI_EXPORT QGraphicsOpacityEffect: public QGraphicsEffect { Q_OBJECT Q_PROPERTY(int opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) + Q_PROPERTY(QBrush opacityMask READ opacityMask WRITE setOpacityMask NOTIFY opacityMaskChanged) public: QGraphicsOpacityEffect(QObject *parent = 0); ~QGraphicsOpacityEffect(); qreal opacity() const; + QBrush opacityMask() const; public Q_SLOTS: void setOpacity(qreal opacity); + void setOpacityMask(const QBrush &mask); Q_SIGNALS: void opacityChanged(qreal opacity); + void opacityMaskChanged(const QBrush &mask); protected: void draw(QPainter *painter, QGraphicsEffectSource *source); diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h index 6ce5cda..c902b67 100644 --- a/src/gui/effects/qgraphicseffect_p.h +++ b/src/gui/effects/qgraphicseffect_p.h @@ -164,10 +164,15 @@ class QGraphicsOpacityEffectPrivate : public QGraphicsEffectPrivate { Q_DECLARE_PUBLIC(QGraphicsOpacityEffect) public: - QGraphicsOpacityEffectPrivate() : opacity(qreal(0.7)) {} + QGraphicsOpacityEffectPrivate() + : opacity(qreal(0.7)), isFullyTransparent(0), isFullyOpaque(0), hasOpacityMask(0) {} ~QGraphicsOpacityEffectPrivate() {} qreal opacity; + QBrush opacityMask; + uint isFullyTransparent : 1; + uint isFullyOpaque : 1; + uint hasOpacityMask : 1; }; QT_END_NAMESPACE diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 8860677..765f76b 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -10270,10 +10270,8 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter) info->widget, info->opacity, info->effectTransform, info->wasDirtySceneTransform, info->drawItem); } else { - QTransform effectTransform = painter->worldTransform(); - effectTransform *= info->painter->worldTransform().inverted(); - if (info->effectTransform) - effectTransform *= *info->effectTransform; + QTransform effectTransform = info->painter->worldTransform().inverted(); + effectTransform *= painter->worldTransform(); scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion, info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform, info->drawItem); diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 7dbc996..7fd471b 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -673,8 +673,8 @@ void QGraphicsScenePrivate::removePopup(QGraphicsWidget *widget, bool itemIsDyin if (focusItem && popupWidgets.isEmpty()) { QFocusEvent event(QEvent::FocusIn, Qt::PopupFocusReason); sendEvent(focusItem, &event); - } else { - ungrabKeyboard((QGraphicsItem *)widget, itemIsDying); + } else if (keyboardGrabberItems.contains(static_cast<QGraphicsItem *>(widget))) { + ungrabKeyboard(static_cast<QGraphicsItem *>(widget), itemIsDying); } if (!itemIsDying && widget->isVisible()) { widget->hide(); diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 658b8e0..155474f 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -322,6 +322,8 @@ QPixmap::QPixmap(const char * const xpm[]) QPixmap::~QPixmap() { + if (data->is_cached && data->ref == 1) + QImagePixmapCleanupHooks::executePixmapHooks(this); } /*! diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 9626193..8d98223 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -1080,8 +1080,17 @@ Qt::FocusReason QFocusEvent::reason() const rect() that is the bounding rectangle of that region. Both are provided because many widgets can't make much use of region(), and rect() can be much faster than region().boundingRect(). + + \section1 Automatic Clipping + Painting is clipped to region() during the processing of a paint - event. + event. This clipping is performed by Qt's paint system and is + independent of any clipping that may be applied to a QPainter used to + draw on the paint device. + + As a result, the value returned by QPainter::clipRegion() on + a newly-constructed QPainter will not reflect the clip region that is + used by the paint system. \sa QPainter, QWidget::update(), QWidget::repaint(), QWidget::paintEvent() diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index fb5f934..38b09ee 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11846,10 +11846,9 @@ const QList<QAction*>& QWidget::softKeys() const \preliminary \since 4.6 - Sets the softkey \a softkey to this widget's list of softkeys, + Sets the softkey \a softKey to this widget's list of softkeys. Setting 0 as softkey will clear all the existing softkeys set - to the widget - A QWidget can have 0 or more softkeys + to the widget. A QWidget can have 0 or more softkeys. \sa softKeys(), setSoftKeys() */ @@ -11866,8 +11865,8 @@ void QWidget::setSoftKey(QAction *softKey) } /*! - Sets the list of softkeys \a softkeys to this widget's list of softkeys, - A QWidget can have 0 or more softkeys + Sets the list of softkeys \a softKeys to this widget's list of softkeys. + A QWidget can have 0 or more softkeys. \sa softKeys(), setSoftKey() */ diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 36ffcbe..eb87052 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -1450,7 +1450,7 @@ static const qreal inv_dist_to_plane = 1. / 1024.; value of 1024 corresponds to the projection factor used by QTransform::rotate() for the x and y axes. - If \a distToPlane is zero, then the returned QTransform + If \a distanceToPlane is zero, then the returned QTransform is formed by simply dropping the third row and third column of the QMatrix4x4. This is suitable for implementing orthographic projections where the z co-ordinate should diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index b05a1e9..12d4948 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -67,6 +67,7 @@ #include "qtoolbar.h" #include "qtoolbutton.h" #include "qtreeview.h" +#include "qfocusframe.h" #include "private/qtoolbarextension_p.h" #include "private/qcombobox_p.h" @@ -86,6 +87,8 @@ const QS60StylePrivate::SkinElementFlags QS60StylePrivate::KDefaultSkinElementFl static const QByteArray propertyKeyLayouts = "layouts"; static const QByteArray propertyKeyCurrentlayout = "currentlayout"; +static const qreal goldenRatio = 1.618; + const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { // *** generated layout data *** {240,320,1,14,true,"QVGA Landscape Mirrored"}, @@ -508,11 +511,6 @@ void QS60StylePrivate::deleteBackground() } } -int QS60StylePrivate::focusRectPenWidth() -{ - return pixelMetric(QS60Style::PM_DefaultFrameWidth); -} - void QS60StylePrivate::setCurrentLayout(int index) { m_pmPointer = data[index]; @@ -950,13 +948,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom const QS60StylePrivate::SkinElements handleElement = horizontal ? QS60StylePrivate::SE_SliderHandleHorizontal : QS60StylePrivate::SE_SliderHandleVertical; QS60StylePrivate::drawSkinElement(handleElement, painter, sliderHandle, flags); - - if (optionSlider->state & State_HasFocus) { - QStyleOptionFocusRect fropt; - fropt.QStyleOption::operator=(*optionSlider); - fropt.rect = subElementRect(SE_SliderFocusRect, optionSlider, widget); - drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); - } } break; #endif // QT_NO_SLIDER @@ -991,17 +982,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom drawPrimitive(PE_IndicatorSpinDown, &buttonOption, painter, widget); painter->restore(); } - - if (cmb->subControls & SC_ComboBoxEditField) { - if (cmb->state & State_HasFocus && !cmb->editable) { - QStyleOptionFocusRect focus; - focus.QStyleOption::operator=(*cmb); - focus.rect = cmbxEditField; - focus.state |= State_FocusAtBorder; - focus.backgroundColor = cmb->palette.highlight().color(); - drawPrimitive(PE_FrameFocusRect, &focus, painter, widget); - } - } } break; #endif // QT_NO_COMBOBOX @@ -1079,13 +1059,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom } } } - if (toolBtn->state & State_HasFocus) { - QStyleOptionFocusRect fr; - fr.QStyleOption::operator=(*toolBtn); - const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget); - fr.rect.adjust(frameWidth, frameWidth, -frameWidth, -frameWidth); - drawPrimitive(PE_FrameFocusRect, &fr, painter, widget); - } if (toolBtn->features & QStyleOptionToolButton::Arrow) { QStyle::PrimitiveElement pe; @@ -1209,13 +1182,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom groupBox->palette, groupBox->state & State_Enabled, groupBox->text, textColor.isValid() ? QPalette::NoRole : QPalette::WindowText); painter->restore(); - - if (groupBox->state & State_HasFocus) { - QStyleOptionFocusRect fropt; - fropt.QStyleOption::operator=(*groupBox); - fropt.rect = textRect; - drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); - } } // Draw checkbox @@ -1249,12 +1215,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); drawControl(CE_PushButtonLabel, &subopt, painter, widget); - if (btn->state & State_HasFocus) { - QStyleOptionFocusRect fropt; - fropt.QStyleOption::operator=(*btn); - fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget); - drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); - } } break; case CE_PushButtonBevel: @@ -1612,18 +1572,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, if (verticalTabs) painter->restore(); - if (optionTab.state & State_HasFocus) { - const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth); - const int leftBorder = optionTab.rect.left(); - const int rightBorder = optionTab.rect.right() - 1; - - QStyleOptionFocusRect fropt; - fropt.QStyleOption::operator=(*tab); - fropt.rect.setRect(leftBorder + 1 + OFFSET, optionTab.rect.y() + OFFSET, - rightBorder - leftBorder - 2*OFFSET, optionTab.rect.height() - 2*OFFSET); - drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); - } - painter->restore(); } break; @@ -1875,11 +1823,48 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, } else if (qobject_cast<const QFrame *>(widget)) { QCommonStyle::drawControl(element, option, painter, widget); } - if (option->state & State_HasFocus) - drawPrimitive(PE_FrameFocusRect, option, painter, widget); break; case CE_MenuScroller: break; + case CE_FocusFrame: + { + // The pen width should nearly fill the layoutspacings around the widget + const int penWidth = + qMin(pixelMetric(QS60Style::PM_LayoutVerticalSpacing), pixelMetric(QS60Style::PM_LayoutHorizontalSpacing)) + - 2; // But keep 1 pixel distance to the focus widget and 1 pixel to the adjacent widgets + +#ifdef QT_KEYPAD_NAVIGATION + bool editFocus = false; + if (const QFocusFrame *focusFrame = qobject_cast<const QFocusFrame*>(widget)) { + if (focusFrame->widget() && focusFrame->widget()->hasEditFocus()) + editFocus = true; + } + const qreal opacity = editFocus ? 0.65 : 0.45; // Trial and error factors. Feel free to improve. +#else + const qreal opacity = 0.5; +#endif + // Because of Qts coordinate system, we need to tweak the rect by .5 pixels, otherwise it gets blurred. + const qreal rectAdjustment = (penWidth % 2) ? -.5 : 0; + + // Make sure that the pen stroke is inside the rect + const QRectF adjustedRect = + QRectF(option->rect).adjusted( + rectAdjustment + penWidth, + rectAdjustment + penWidth, + -rectAdjustment - penWidth, + -rectAdjustment - penWidth + ); + + const qreal roundRectRadius = penWidth * goldenRatio; + + painter->save(); + painter->setRenderHint(QPainter::Antialiasing); + painter->setOpacity(opacity); + painter->setPen(QPen(option->palette.color(QPalette::Highlight), penWidth)); + painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius); + painter->restore(); + } + break; default: QCommonStyle::drawControl(element, option, painter, widget); } @@ -1901,9 +1886,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti #endif QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit, painter, option->rect, flags); - - if (lineEdit->state & State_HasFocus) - drawPrimitive(PE_FrameFocusRect, lineEdit, painter, widget); } break; #endif // QT_NO_LINEEDIT @@ -2030,50 +2012,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti #endif //QT_NO_COMBOBOX break; #endif //QT_NO_SPINBOX - case PE_FrameFocusRect: -// Calendar widget and combox both do not use styled itemDelegate - if (widget && !(false -#ifndef QT_NO_CALENDARWIDGET - || qobject_cast<const QCalendarWidget *>(widget->parent()) -#endif //QT_NO_CALENDARWIDGET -#ifndef QT_NO_COMBOBOX - || qobject_cast<const QComboBoxListView *>(widget) -#endif //QT_NO_COMBOBOX - )) { - // no focus selection for touch - if (option->state & State_HasFocus && !QS60StylePrivate::isTouchSupported()) { - painter->save(); - const int penWidth = QS60StylePrivate::focusRectPenWidth(); -#ifdef QT_KEYPAD_NAVIGATION - const Qt::PenStyle penStyle = widget->hasEditFocus() ? Qt::SolidLine :Qt::DashLine; - const qreal opacity = widget->hasEditFocus() ? 0.6 : 0.4; -#else - const Qt::PenStyle penStyle = Qt::SolidLine; - const qreal opacity = 0.5; -#endif - painter->setRenderHint(QPainter::Antialiasing); - painter->setOpacity(opacity); - // Because of Qts coordinate system, we need to tweak the rect by .5 pixels, otherwise it gets blurred. - const qreal rectAdjustment = penWidth % 2?.5:0; - // Also we try to stay inside the option->rect, with penWidth > 1. Therefore these +1/-1 - const QRectF adjustedRect = QRectF(option->rect).adjusted( - rectAdjustment + penWidth - 1, - rectAdjustment + penWidth - 1, - -rectAdjustment - penWidth + 1, - -rectAdjustment - penWidth + 1); - const qreal roundRectRadius = penWidth * 1.5; -#ifdef QT_KEYPAD_NAVIGATION - if (penStyle != Qt::SolidLine) { - painter->setPen(QPen(option->palette.color(QPalette::HighlightedText), penWidth, Qt::SolidLine)); - painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius); - } -#endif - painter->setPen(QPen((option->palette.color(QPalette::Text), penWidth, penStyle))); - painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius); - painter->restore(); - } - } - break; case PE_Widget: if (QS60StylePrivate::drawsOwnThemeBackground(widget) #ifndef QT_NO_COMBOBOX @@ -2118,8 +2056,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti Q_ASSERT(false); break; case PE_Frame: - if (const QStyleOptionFrameV3 *frame = qstyleoption_cast<const QStyleOptionFrameV3 *>(option)) - drawPrimitive(PE_FrameFocusRect, frame, painter, widget); break; #ifndef QT_NO_ITEMVIEWS case PE_PanelItemViewItem: @@ -2668,16 +2604,6 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con } ret = visualRect(opt->direction, opt->rect, ret); break; - case SE_FrameContents: - if (QS60StylePrivate::isTouchSupported()) { - return QCommonStyle::subElementRect(element, opt, widget); - } else if (const QStyleOptionFrameV2 *f = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt)) { - // We shrink the frame contents by focusFrameWidth, so that we can draw the frame around it in keypad navigation mode. - const int frameWidth = QS60StylePrivate::focusRectPenWidth(); - ret = opt->rect.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth); - ret = visualRect(opt->direction, opt->rect, ret); - } - break; default: ret = QCommonStyle::subElementRect(element, opt, widget); } @@ -2778,6 +2704,38 @@ QVariant QS60Style::styleProperty(const char *name) const return d->styleProperty_specific(name); } +bool QS60Style::event(QEvent *e) +{ +#ifdef QT_KEYPAD_NAVIGATION + if (QS60StylePrivate::isTouchSupported()) + return false; + Q_D(QS60Style); + switch (e->type()) { + case QEvent::FocusIn: + if (QWidget *focusWidget = QApplication::focusWidget()) { + if (!d->m_focusFrame) + d->m_focusFrame = new QFocusFrame(focusWidget); + d->m_focusFrame->setWidget(focusWidget); + } else if (d->m_focusFrame) { + d->m_focusFrame->setWidget(0); + } + break; + case QEvent::FocusOut: + if (d->m_focusFrame) + d->m_focusFrame->setWidget(0); + break; + case QEvent::EnterEditFocus: + case QEvent::LeaveEditFocus: + if (d->m_focusFrame) + d->m_focusFrame->update(); + break; + default: + break; + } +#endif + return false; +} + QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const { diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h index a03803b..c01c40a 100644 --- a/src/gui/styles/qs60style.h +++ b/src/gui/styles/qs60style.h @@ -80,6 +80,8 @@ public: void setStyleProperty(const char *name, const QVariant &value); QVariant styleProperty(const char *name) const; + bool event(QEvent *e); + #ifndef Q_WS_S60 static QStringList partKeys(); static QStringList colorListKeys(); diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 2e661c0..ed0abfa 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -292,6 +292,8 @@ public: }; }; +class QFocusFrame; + // Private class #ifdef Q_OS_SYMBIAN NONSHARABLE_CLASS (QS60StylePrivate) @@ -430,8 +432,6 @@ public: //access to theme palette static QPalette* themePalette(); - static int focusRectPenWidth(); - static const layoutHeader m_layoutHeaders[]; static const short data[][MAX_PIXELMETRICS]; @@ -499,6 +499,8 @@ private: // defined theme palette static QPalette *m_themePalette; QPalette m_originalPalette; + + QPointer<QFocusFrame> m_focusFrame; }; QT_END_NAMESPACE diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index bc218cd..1cf47cc 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -1350,9 +1350,6 @@ void QS60StyleModeSpecifics::colorGroupAndIndex( } } -/*! - Constructs a QS60Style object. -*/ QS60Style::QS60Style() : QCommonStyle(*new QS60StylePrivate) { diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 7acb3a6..da71ced 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -214,6 +214,7 @@ enum PseudoElement { PseudoElement_ViewItemText, PseudoElement_ViewItemIndicator, PseudoElement_ScrollAreaCorner, + PseudoElement_TabBarTabCloseButton, NumPseudoElements }; @@ -223,7 +224,7 @@ struct PseudoElementInfo { }; static const PseudoElementInfo knownPseudoElements[NumPseudoElements] = { - { QStyle::SC_None, "", }, + { QStyle::SC_None, "" }, { QStyle::SC_None, "down-arrow" }, { QStyle::SC_None, "up-arrow" }, { QStyle::SC_None, "left-arrow" }, @@ -300,8 +301,9 @@ static const PseudoElementInfo knownPseudoElements[NumPseudoElements] = { { QStyle::SC_None, "item" }, { QStyle::SC_None, "icon" }, { QStyle::SC_None, "text" }, - { QStyle::SC_None, "indicator" } , - { QStyle::SC_None, "corner" } + { QStyle::SC_None, "indicator" }, + { QStyle::SC_None, "corner" }, + { QStyle::SC_None, "close-button" }, }; @@ -4370,6 +4372,12 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op case PE_IndicatorSpinPlus: pseudoElement = PseudoElement_SpinBoxUpArrow; break; +#ifndef QT_NO_TABBAR + case PE_IndicatorTabClose: + if (w) + w = w->parentWidget(); //match on the QTabBar instead of the CloseButton + pseudoElement = PseudoElement_TabBarTabCloseButton; +#endif default: break; @@ -5104,6 +5112,18 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi #endif // QT_NO_TABWIDGET s = QLatin1String("alignment"); break; +#ifndef QT_NO_TABBAR + case SH_TabBar_CloseButtonPosition: + rule = renderRule(w, opt, PseudoElement_TabBarTabCloseButton); + if (rule.hasPosition()) { + Qt::Alignment align = rule.position()->position; + if (align & Qt::AlignLeft || align & Qt::AlignTop) + return QTabBar::LeftSide; + if (align & Qt::AlignRight || align & Qt::AlignBottom) + return QTabBar::RightSide; + } + break; +#endif case SH_TabBar_ElideMode: s = QLatin1String("tabbar-elide-mode"); break; case SH_TabBar_PreferNoArrows: s = QLatin1String("tabbar-prefer-no-arrows"); break; case SH_ComboBox_PopupFrameStyle: diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 058041b..fe90010 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -126,8 +126,13 @@ QFontDatabaseS60StoreImplementation::QFontDatabaseS60StoreImplementation() } QFontDatabaseS60StoreImplementation::~QFontDatabaseS60StoreImplementation() { - qDeleteAll(m_extensions); - // TODO m_store cleanup removed because it was crashing + typedef QHash<QString, const QFontEngineS60Extensions *>::iterator iterator; + for (iterator p = m_extensions.begin(); p != m_extensions.end(); ++p) { + m_store->ReleaseFont((*p)->fontOwner()); + delete *p; + } + + delete m_store; m_heap->Close(); } @@ -140,7 +145,7 @@ const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(c const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, spec); Q_ASSERT(err == KErrNone && font); CBitmapFont *bitmapFont = static_cast<CBitmapFont*>(font); - m_extensions.insert(typeface, new QFontEngineS60Extensions(bitmapFont->OpenFont())); + m_extensions.insert(typeface, new QFontEngineS60Extensions(font, bitmapFont->OpenFont())); } return m_extensions.value(typeface); } diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index eba21e8..ed6b1c1 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -54,10 +54,11 @@ QT_BEGIN_NAMESPACE -QFontEngineS60Extensions::QFontEngineS60Extensions(COpenFont *font) +QFontEngineS60Extensions::QFontEngineS60Extensions(CFont* fontOwner, COpenFont *font) : m_font(font) , m_cmap(0) , m_symbolCMap(false) + , m_fontOwner(fontOwner) { TAny *shapingExtension = NULL; m_font->ExtendedInterface(KUidOpenFontShapingExtension, shapingExtension); @@ -109,6 +110,12 @@ QPainterPath QFontEngineS60Extensions::glyphOutline(glyph_t glyph) const return result; } +CFont *QFontEngineS60Extensions::fontOwner() const +{ + return m_fontOwner; +} + + // duplicated from qfontengine_xyz.cpp static inline unsigned int getChar(const QChar *str, int &i, const int len) { diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h index 0c1be8c..bbbc3d6 100644 --- a/src/gui/text/qfontengine_s60_p.h +++ b/src/gui/text/qfontengine_s60_p.h @@ -69,11 +69,12 @@ QT_BEGIN_NAMESPACE class QFontEngineS60Extensions { public: - QFontEngineS60Extensions(COpenFont *font); + QFontEngineS60Extensions(CFont* fontOwner, COpenFont *font); QByteArray getSfntTable(uint tag) const; const unsigned char *cmap() const; QPainterPath glyphOutline(glyph_t glyph) const; + CFont *fontOwner() const; private: COpenFont *m_font; @@ -82,6 +83,7 @@ private: mutable const unsigned char *m_cmap; mutable bool m_symbolCMap; mutable QByteArray m_cmapTable; + CFont* m_fontOwner; }; class QFontEngineS60 : public QFontEngine |