diff options
author | David Boddie <dboddie@trolltech.com> | 2009-09-01 13:42:01 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2009-09-01 13:42:01 (GMT) |
commit | 5e6934fc40186914ed37a3cdedc81e3cbee6d729 (patch) | |
tree | 8c183bbc5b59c73e4b62c6c0c48aabe0b6ab2572 /src/gui | |
parent | 505458d4e2d094eba7cf34a71c6cd960c28a52e4 (diff) | |
parent | d117525a4ff8757208231fa77f171c7fd7a30ef9 (diff) | |
download | Qt-5e6934fc40186914ed37a3cdedc81e3cbee6d729.zip Qt-5e6934fc40186914ed37a3cdedc81e3cbee6d729.tar.gz Qt-5e6934fc40186914ed37a3cdedc81e3cbee6d729.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/effects/qgraphicseffect.cpp | 43 | ||||
-rw-r--r-- | src/gui/effects/qgraphicseffect.h | 20 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 53 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.h | 2 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem_p.h | 8 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsproxywidget.cpp | 2 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 149 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene_p.h | 2 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicswidget.cpp | 6 | ||||
-rw-r--r-- | src/gui/image/qimage.cpp | 6 | ||||
-rw-r--r-- | src/gui/image/qpnghandler.cpp | 8 | ||||
-rw-r--r-- | src/gui/itemviews/qheaderview.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_x11.cpp | 111 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 40 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.h | 4 | ||||
-rw-r--r-- | src/gui/painting/qcolor.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qdrawutil.cpp | 137 | ||||
-rw-r--r-- | src/gui/painting/qdrawutil.h | 20 | ||||
-rw-r--r-- | src/gui/styles/qcleanlooksstyle.cpp | 364 |
19 files changed, 616 insertions, 365 deletions
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index ccbf7fc..2be6a49 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -349,6 +349,22 @@ void QGraphicsEffect::setEnabled(bool enable) */ /*! + Schedules a redraw of the source. Call this function whenever the source + needs to be redrawn. + + This convenience function is equivalent to calling + QGraphicsEffectSource::update(). + + \sa updateBoundingRect(), QGraphicsEffectSource::update() +*/ +void QGraphicsEffect::update() +{ + Q_D(QGraphicsEffect); + if (d->source) + d->source->update(); +} + +/*! Returns a pointer to the source, which provides extra context information that can be useful for the effect. @@ -366,6 +382,8 @@ QGraphicsEffectSource *QGraphicsEffect::source() const function whenever you change any parameters that will cause the virtual boundingRectFor() function to return a different value. + This function will call update() if this is necessary. + \sa boundingRectFor(), boundingRect() */ void QGraphicsEffect::updateBoundingRect() @@ -523,6 +541,7 @@ void QGraphicsColorizeEffect::setColor(const QColor &color) return; d->filter->setColor(color); + update(); emit colorChanged(color); } @@ -610,6 +629,7 @@ void QGraphicsPixelizeEffect::setPixelSize(int size) return; d->pixelSize = size; + update(); emit pixelSizeChanged(size); } @@ -820,7 +840,7 @@ QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect() By default, the offset is 8 pixels towards the lower right. - \sa blurRadius(), color() + \sa xOffset(), yOffset(), blurRadius(), color() */ QPointF QGraphicsDropShadowEffect::offset() const { @@ -840,6 +860,24 @@ void QGraphicsDropShadowEffect::setOffset(const QPointF &offset) } /*! + \property QGraphicsDropShadowEffect::xOffset + \brief the horizontal shadow offset in pixels. + + By default, the horizontal shadow offset is 8 pixels. + + \sa yOffset(), offset() +*/ + +/*! + \property QGraphicsDropShadowEffect::yOffset + \brief the vertical shadow offset in pixels. + + By default, the vertical shadow offset is 8 pixels. + + \sa xOffset(), offset() +*/ + +/*! \fn void QGraphicsDropShadowEffect::offsetChanged(const QPointF &offset) This signal is emitted whenever the effect's shadow offset changes. @@ -903,6 +941,7 @@ void QGraphicsDropShadowEffect::setColor(const QColor &color) return; d->filter->setColor(color); + update(); emit colorChanged(color); } @@ -1012,6 +1051,7 @@ void QGraphicsOpacityEffect::setOpacity(qreal opacity) d->isFullyOpaque = 0; else d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1); + update(); emit opacityChanged(opacity); } @@ -1050,6 +1090,7 @@ void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask) d->opacityMask = mask; d->hasOpacityMask = (mask.style() != Qt::NoBrush); + update(); emit opacityMaskChanged(mask); } diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index 8e5384c..aee7834 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -118,7 +118,7 @@ public: public Q_SLOTS: void setEnabled(bool enable); - // ### add update() slot + void update(); Q_SIGNALS: void enabledChanged(bool enabled); @@ -237,6 +237,8 @@ class Q_GUI_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect { Q_OBJECT Q_PROPERTY(QPointF offset READ offset WRITE setOffset NOTIFY offsetChanged) + Q_PROPERTY(qreal xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged) + Q_PROPERTY(qreal yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged) Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) public: @@ -245,15 +247,31 @@ public: QRectF boundingRectFor(const QRectF &rect) const; QPointF offset() const; + + inline qreal xOffset() const + { return offset().x(); } + + inline qreal yOffset() const + { return offset().y(); } + int blurRadius() const; QColor color() const; public Q_SLOTS: void setOffset(const QPointF &ofs); + inline void setOffset(qreal dx, qreal dy) { setOffset(QPointF(dx, dy)); } + inline void setOffset(qreal d) { setOffset(QPointF(d, d)); } + + inline void setXOffset(qreal dx) + { setOffset(QPointF(dx, yOffset())); } + + inline void setYOffset(qreal dy) + { setOffset(QPointF(xOffset(), dy)); } + void setBlurRadius(int blurRadius); void setColor(const QColor &color); diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 86c589d..822c208 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1007,6 +1007,9 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) setEnabledHelper(parent->isEnabled(), /* explicit = */ false, /* update = */ !implicitUpdate); } + // Auto-activate if visible and the parent is active. + if (q->isVisible() && parent->isActive()) + q->setActive(true); } else { // Inherit ancestor flags from the new parent. updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2)); @@ -1941,6 +1944,17 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo child->d_ptr->setVisibleHelper(newVisible, false, updateChildren); } + // Update activation + if (scene && q->isPanel()) { + if (newVisible) { + if (parent && parent->isActive()) + q->setActive(true); + } else { + if (q->isActive()) + scene->setActivePanel(parent); + } + } + // Enable subfocus if (newVisible && isWidget) { QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(q_ptr); @@ -2669,6 +2683,37 @@ bool QGraphicsItem::isActive() const } /*! + \since 4.6 + + If \a active is true, and the scene is active, this item's panel will be + activated. Otherwise, the panel is deactivated. + + If the item is not part of an active scene, \a active will decide what + happens to the panel when the scene becomes active or the item is added to + the scene. If true, the item's panel will be activated when the item is + either added to the scene or the scene is activated. Otherwise, the item + will stay inactive independent of the scene's activated state. + + \sa isPanel(), QGraphicsScene::setActivePanel(), QGraphicsScene::isActive() +*/ +void QGraphicsItem::setActive(bool active) +{ + d_ptr->explicitActivate = 1; + d_ptr->wantsActive = active; + if (d_ptr->scene) { + if (active) { + // Activate this item. + d_ptr->scene->setActivePanel(this); + } else { + // Deactivate this item, and reactivate the last active item + // (if any). + QGraphicsItem *lastActive = d_ptr->scene->d_func()->lastActivePanel; + d_ptr->scene->setActivePanel(lastActive != this ? lastActive : 0); + } + } +} + +/*! Returns true if this item is active, and it or its \l{focusProxy()}{focus proxy} has keyboard input focus; otherwise, returns false. @@ -6099,8 +6144,10 @@ bool QGraphicsItem::sceneEvent(QEvent *event) if (d_ptr->scene) { for (int i = 0; i < d_ptr->children.size(); ++i) { QGraphicsItem *child = d_ptr->children.at(i); - if (!(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents)) - d_ptr->scene->sendEvent(child, event); + if (child->isVisible() && !child->isPanel()) { + if (!(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents)) + d_ptr->scene->sendEvent(child, event); + } } } break; @@ -6945,7 +6992,7 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent \property QGraphicsObject::id \brief the id of of the item - \sa QGraphicsItem::opacity(), QGraphicsItem::setOpacity() + \sa QObject::objectName(), QObject::setObjectName() */ /*! diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index 04fe0cb..df25e6a 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -235,6 +235,8 @@ public: void setHandlesChildEvents(bool enabled); bool isActive() const; + void setActive(bool active); + bool hasFocus() const; void setFocus(Qt::FocusReason focusReason = Qt::OtherFocusReason); void clearFocus(); diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 2bc876c..1090620 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -171,6 +171,8 @@ public: notifyBoundingRectChanged(0), notifyInvalidated(0), mouseSetsFocus(1), + explicitActivate(0), + wantsActive(0), globalStackingOrder(-1), q_ptr(0) { @@ -461,7 +463,7 @@ public: quint32 needSortChildren : 1; quint32 allChildrenDirty : 1; - // New 32 bits + // Packed 32 bits quint32 fullUpdatePending : 1; quint32 flags : 16; quint32 dirtyChildrenBoundingRect : 1; @@ -480,6 +482,10 @@ public: quint32 notifyInvalidated : 1; quint32 mouseSetsFocus : 1; + // New 32 bits + quint32 explicitActivate : 1; + quint32 wantsActive : 1; + // Optional stacking order int globalStackingOrder; QGraphicsItem *q_ptr; diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp index 447fc50..c710c55 100644 --- a/src/gui/graphicsview/qgraphicsproxywidget.cpp +++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp @@ -390,7 +390,7 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) if (child->isEnabled() && child->isVisibleTo(widget) && (child->focusPolicy() & Qt::TabFocus)) { - return child; + return child; } child = next ? child->d_func()->focus_next : child->d_func()->focus_prev; } while (child != oldChild && !(next && child == widget) && !(!next && child == widget->d_func()->focus_prev)); diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index ac30668..2ac1dca 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -291,6 +291,7 @@ QGraphicsScenePrivate::QGraphicsScenePrivate() activePanel(0), lastActivePanel(0), activationRefCount(0), + childExplicitActivation(0), lastMouseGrabberItem(0), lastMouseGrabberItemHasImplicitMouseGrab(false), dragDropItem(0), @@ -571,6 +572,66 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) /*! \internal */ +void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool duringActivationEvent) +{ + Q_Q(QGraphicsScene); + if (item && item->scene() != q) { + qWarning("QGraphicsScene::setActivePanel: item %p must be part of this scene", + item); + return; + } + + // Find the item's panel. + QGraphicsItem *panel = item ? item->panel() : 0; + lastActivePanel = panel ? activePanel : 0; + if (panel == activePanel || (!q->isActive() && !duringActivationEvent)) + return; + + // Deactivate the last active panel. + if (activePanel) { + if (QGraphicsItem *fi = activePanel->focusItem()) { + // Remove focus from the current focus item. + if (fi == q->focusItem()) + q->setFocusItem(0, Qt::ActiveWindowFocusReason); + } + + QEvent event(QEvent::WindowDeactivate); + q->sendEvent(activePanel, &event); + } else if (panel && !duringActivationEvent) { + // Deactivate the scene if changing activation to a panel. + QEvent event(QEvent::WindowDeactivate); + foreach (QGraphicsItem *item, q->items()) { + if (item->isVisible() && !item->isPanel() && !item->parentItem()) + q->sendEvent(item, &event); + } + } + + // Update activate state. + activePanel = panel; + QEvent event(QEvent::ActivationChange); + QApplication::sendEvent(q, &event); + + // Activate + if (panel) { + QEvent event(QEvent::WindowActivate); + q->sendEvent(panel, &event); + + // Set focus on the panel's focus item. + if (QGraphicsItem *focusItem = panel->focusItem()) + focusItem->setFocus(Qt::ActiveWindowFocusReason); + } else if (q->isActive()) { + // Activate the scene + QEvent event(QEvent::WindowActivate); + foreach (QGraphicsItem *item, q->items()) { + if (item->isVisible() && !item->isPanel() && !item->parentItem()) + q->sendEvent(item, &event); + } + } +} + +/*! + \internal +*/ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item, Qt::FocusReason focusReason) { @@ -2351,9 +2412,29 @@ void QGraphicsScene::addItem(QGraphicsItem *item) // Deliver post-change notification item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant); - // Auto-activate the first inactive panel if the scene is active. - if (isActive() && !d->activePanel && item->isPanel()) - setActivePanel(item); + // Update explicit activation + bool autoActivate = true; + if (!d->childExplicitActivation && item->d_ptr->explicitActivate) + d->childExplicitActivation = item->d_ptr->wantsActive ? 1 : 2; + if (d->childExplicitActivation && item->isPanel()) { + if (d->childExplicitActivation == 1) + setActivePanel(item); + else + autoActivate = false; + d->childExplicitActivation = 0; + } else if (!item->d_ptr->parent) { + d->childExplicitActivation = 0; + } + + // Auto-activate this item's panel if nothing else has been activated + if (autoActivate) { + if (!d->lastActivePanel && !d->activePanel && item->isPanel()) { + if (isActive()) + setActivePanel(item); + else + d->lastActivePanel = item; + } + } // Ensure that newly added items that have subfocus set, gain // focus automatically if there isn't a focus item already. @@ -3129,11 +3210,11 @@ bool QGraphicsScene::event(QEvent *event) if (!d->activationRefCount++) { if (d->lastActivePanel) { // Activate the last panel. - setActivePanel(d->lastActivePanel); + d->setActivePanelHelper(d->lastActivePanel, true); } else if (d->tabFocusFirst && d->tabFocusFirst->isPanel()) { // Activate the panel of the first item in the tab focus // chain. - setActivePanel(d->tabFocusFirst); + d->setActivePanelHelper(d->tabFocusFirst, true); } else { // Activate all toplevel items. QEvent event(QEvent::WindowActivate); @@ -3150,7 +3231,7 @@ bool QGraphicsScene::event(QEvent *event) // Deactivate the active panel (but keep it so we can // reactivate it later). QGraphicsItem *lastActivePanel = d->activePanel; - setActivePanel(0); + d->setActivePanelHelper(0, true); d->lastActivePanel = lastActivePanel; } else { // Activate all toplevel items. @@ -5095,63 +5176,15 @@ QGraphicsItem *QGraphicsScene::activePanel() const can also pass 0 for \a item, in which case QGraphicsScene will deactivate any currently active panel. + If the scene is currently inactive, \a item remains inactive until the + scene becomes active (or, ir \a item is 0, no item will be activated). + \sa activePanel(), isActive(), QGraphicsItem::isActive() */ void QGraphicsScene::setActivePanel(QGraphicsItem *item) { Q_D(QGraphicsScene); - if (item && item->scene() != this) { - qWarning("QGraphicsScene::setActivePanel: item %p must be part of this scene", - item); - return; - } - - // Find the item's panel. - QGraphicsItem *panel = item ? item->panel() : 0; - d->lastActivePanel = panel ? d->activePanel : 0; - if (panel == d->activePanel) - return; - - // Deactivate the last active panel. - if (d->activePanel) { - if (QGraphicsItem *fi = d->activePanel->focusItem()) { - // Remove focus from the current focus item. - if (fi == focusItem()) - setFocusItem(0, Qt::ActiveWindowFocusReason); - } - - QEvent event(QEvent::WindowDeactivate); - sendEvent(d->activePanel, &event); - } else if (panel) { - // Deactivate the scene if changing activation to a panel. - QEvent event(QEvent::WindowDeactivate); - foreach (QGraphicsItem *item, items()) { - if (item->isVisible() && !item->isPanel() && !item->parentItem()) - sendEvent(item, &event); - } - } - - // Update activate state. - d->activePanel = panel; - QEvent event(QEvent::ActivationChange); - QApplication::sendEvent(this, &event); - - // Activate - if (panel) { - QEvent event(QEvent::WindowActivate); - sendEvent(panel, &event); - - // Set focus on the panel's focus item. - if (QGraphicsItem *focusItem = panel->focusItem()) - focusItem->setFocus(Qt::ActiveWindowFocusReason); - } else if (isActive()) { - // Activate the scene - QEvent event(QEvent::WindowActivate); - foreach (QGraphicsItem *item, items()) { - if (item->isVisible() && !item->isPanel() && !item->parentItem()) - sendEvent(item, &event); - } - } + d->setActivePanelHelper(item, false); } /*! diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index c1b78ff..1f66eb4 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -132,6 +132,8 @@ public: QGraphicsItem *activePanel; QGraphicsItem *lastActivePanel; int activationRefCount; + int childExplicitActivation; + void setActivePanelHelper(QGraphicsItem *item, bool duringActivationEvent); void setFocusItemHelper(QGraphicsItem *item, Qt::FocusReason focusReason); QList<QGraphicsWidget *> popupWidgets; diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 9972223..afabf49 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -1665,11 +1665,7 @@ void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags) */ bool QGraphicsWidget::isActiveWindow() const { - Q_D(const QGraphicsWidget); - if (!d->scene) - return false; - const QGraphicsWidget *w = window(); - return (!w && d->scene->isActive()) || (w && d->scene->activeWindow() == w); + return isActive(); } /*! diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 2b82f49..89af452 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2892,6 +2892,12 @@ static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt: Q_ASSERT(src->height == dest->height); QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format); + if (colorTable.size() == 0) { + colorTable.resize(256); + for (int i=0; i<256; ++i) + colorTable[i] = qRgb(i, i, i); + + } int w = src->width; const uchar *src_data = src->data; diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 3f3a55c..c4733cf 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -205,7 +205,11 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre image.setColor(i, qRgba(c,c,c,0xff)); } if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { +#if PNG_LIBPNG_VER_MAJOR < 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR < 4) const int g = info_ptr->trans_values.gray; +#else + const int g = info_ptr->trans_color.gray; +#endif if (g < ncols) { image.setColor(g, 0); } @@ -234,7 +238,11 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre info_ptr->palette[i].red, info_ptr->palette[i].green, info_ptr->palette[i].blue, +#if PNG_LIBPNG_VER_MAJOR < 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR < 4) info_ptr->trans[i] +#else + info_ptr->trans_alpha[i] +#endif ) ); i++; diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index a1c3e4e..4dbd6dc 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -1047,7 +1047,9 @@ int QHeaderView::visualIndex(int logicalIndex) const /*! Returns the logicalIndex for the section at the given \a visualIndex - position, or -1 otherwise. + position, or -1 if visualIndex < 0 or visualIndex >= QHeaderView::count(). + + Note that the visualIndex is not affected by hidden sections. \sa visualIndex(), sectionPosition() */ diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 69dba40..0056b9e 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -4510,7 +4510,9 @@ void fetchWacomToolId(int &deviceType, qint64 &serialId) struct qt_tablet_motion_data { - Time timestamp; + bool filterByWidget; + const QWidget *widget; + const QWidget *etWidget; int tabletMotionType; bool error; // found a reason to stop searching }; @@ -4533,15 +4535,20 @@ static Bool qt_tabletMotion_scanner(Display *, XEvent *event, XPointer arg) qt_tablet_motion_data *data = (qt_tablet_motion_data *) arg; if (data->error) return false; - if (event->type == data->tabletMotionType) { - if (data->timestamp > 0) { - if ((reinterpret_cast<const XDeviceMotionEvent*>(event))->time > data->timestamp) { - data->error = true; - return false; + const XDeviceMotionEvent *const motion = reinterpret_cast<const XDeviceMotionEvent*>(event); + if (data->filterByWidget) { + const QPoint curr(motion->x, motion->y); + const QWidget *w = data->etWidget; + const QWidget *const child = w->childAt(curr); + if (child) { + w = child; } + if (w == data->widget) + return true; + } else { + return true; } - return true; } data->error = event->type != MotionNotify; // we stop compression when another event gets in between. @@ -4574,57 +4581,17 @@ bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet qreal rotation = 0; int deviceType = QTabletEvent::NoDevice; int pointerType = QTabletEvent::UnknownPointer; - XEvent mouseMotionEvent; - XEvent dummy; const XDeviceMotionEvent *motion = 0; XDeviceButtonEvent *button = 0; const XProximityNotifyEvent *proximity = 0; QEvent::Type t; Qt::KeyboardModifiers modifiers = 0; - bool reinsertMouseEvent = false; - XEvent mouseMotionEventSave; #if !defined (Q_OS_IRIX) XID device_id; #endif if (ev->type == tablet->xinput_motion) { motion = reinterpret_cast<const XDeviceMotionEvent*>(ev); - - // Do event compression. Skip over tablet+mouse move events if there are newer ones. - qt_tablet_motion_data tabletMotionData; - tabletMotionData.tabletMotionType = tablet->xinput_motion; - while (true) { - // Find first mouse event since we expect them in pairs inside Qt - tabletMotionData.error =false; - tabletMotionData.timestamp = 0; - if (XCheckIfEvent(X11->display, &mouseMotionEvent, &qt_mouseMotion_scanner, (XPointer) &tabletMotionData)) { - mouseMotionEventSave = mouseMotionEvent; - reinsertMouseEvent = true; - } else { - break; - } - - // Now discard any duplicate tablet events. - tabletMotionData.error = false; - tabletMotionData.timestamp = mouseMotionEvent.xmotion.time; - while (XCheckIfEvent(X11->display, &dummy, &qt_tabletMotion_scanner, (XPointer) &tabletMotionData)) { - motion = reinterpret_cast<const XDeviceMotionEvent*>(&dummy); - } - - // now check if there are more recent tablet motion events since we'll compress the current one with - // newer ones in that case - tabletMotionData.error = false; - tabletMotionData.timestamp = 0; - if (! XCheckIfEvent(X11->display, &dummy, &qt_tabletMotion_scanner, (XPointer) &tabletMotionData)) { - break; // done with compression - } - motion = reinterpret_cast<const XDeviceMotionEvent*>(&dummy); - } - - if (reinsertMouseEvent) { - XPutBackEvent(X11->display, &mouseMotionEventSave); - } - t = QEvent::TabletMove; global = QPoint(motion->x_root, motion->y_root); curr = QPoint(motion->x, motion->y); @@ -4777,11 +4744,14 @@ bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet } #endif - QWidget *child = w->childAt(curr); - if (child) { - w = child; - curr = w->mapFromGlobal(global); + if (tablet->widgetToGetPress) { + w = tablet->widgetToGetPress; + } else { + QWidget *child = w->childAt(curr); + if (child) + w = child; } + curr = w->mapFromGlobal(global); if (t == QEvent::TabletPress) { tablet->widgetToGetPress = w; @@ -4795,10 +4765,45 @@ bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet deviceType, pointerType, qreal(pressure / qreal(tablet->maxPressure - tablet->minPressure)), xTilt, yTilt, tangentialPressure, rotation, z, modifiers, uid); - if (proximity) + if (proximity) { QApplication::sendSpontaneousEvent(qApp, &e); - else + } else { QApplication::sendSpontaneousEvent(w, &e); + const bool accepted = e.isAccepted(); + if (!accepted && ev->type == tablet->xinput_motion) { + // If the widget does not accept tablet events, we drop the next ones from the event queue + // for this widget so it is not overloaded with the numerous tablet events. + qt_tablet_motion_data tabletMotionData; + tabletMotionData.tabletMotionType = tablet->xinput_motion; + tabletMotionData.widget = w; + tabletMotionData.etWidget = this; + // if nothing is pressed, the events are filtered by position + tabletMotionData.filterByWidget = (tablet->widgetToGetPress == 0); + + bool reinsertMouseEvent = false; + XEvent mouseMotionEvent; + while (true) { + // Find first mouse event since we expect them in pairs inside Qt + tabletMotionData.error =false; + if (XCheckIfEvent(X11->display, &mouseMotionEvent, &qt_mouseMotion_scanner, (XPointer) &tabletMotionData)) { + reinsertMouseEvent = true; + } else { + break; + } + + // Now discard any duplicate tablet events. + tabletMotionData.error = false; + XEvent dummy; + while (XCheckIfEvent(X11->display, &dummy, &qt_tabletMotion_scanner, (XPointer) &tabletMotionData)) { + // just discard the event + } + } + + if (reinsertMouseEvent) { + XPutBackEvent(X11->display, &mouseMotionEvent); + } + } + } return true; } #endif diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index ab809df..863c43e 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -919,7 +919,7 @@ void QWidget::setAutoFillBackground(bool enabled) any amount of widgets there might be physical restrictions to amount of softkeys that can be used by the device. - \o Series60: For series60 menu button is automatically mapped to left + \e Series60: For series60 menu button is automatically mapped to left soft key if there is QMainWindow with QMenuBar in widgets parent hierarchy. \sa softKeys() @@ -5962,6 +5962,8 @@ bool QWidget::hasFocus() const isActiveWindow() active window\endlink. The \a reason argument will be passed into any focus event sent from this function, it is used to give an explanation of what caused the widget to get focus. + If the window is not active, the widget will be given the focus when + the window becomes active. First, a focus out event is sent to the focus widget (if any) to tell it that it is about to lose the focus. Then a focus in event @@ -6748,7 +6750,27 @@ void QWidget::setContentsMargins(int left, int top, int right, int bottom) QApplication::sendEvent(this, &e); } -/*! Returns the widget's contents margins for \a left, \a top, \a +/*! + \overload + \since 4.6 + + Sets the margins around the contents of the widget to have the + sizes determined by \a margins. The margins are + used by the layout system, and may be used by subclasses to + specify the area to draw in (e.g. excluding the frame). + + Changing the margins will trigger a resizeEvent(). + + \sa contentsRect(), getContentsMargins() +*/ +void QWidget::setContentsMargins(const QMargins &margins) +{ + setContentsMargins(margins.left(), margins.top(), + margins.right(), margins.bottom()); +} + +/*! + Returns the widget's contents margins for \a left, \a top, \a right, and \a bottom. \sa setContentsMargins(), contentsRect() @@ -6767,6 +6789,20 @@ void QWidget::getContentsMargins(int *left, int *top, int *right, int *bottom) c } /*! + \since 4.6 + + Returns the widget's contents margins. + + \sa getContentsMargins(), setContentsMargins(), contentsRect() + */ +QMargins QWidget::contentsMargins() const +{ + Q_D(const QWidget); + return QMargins(d->leftmargin, d->topmargin, d->rightmargin, d->bottommargin); +} + + +/*! Returns the area inside the widget's margins. \sa setContentsMargins(), getContentsMargins() diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 38650f0..f398dbd 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -44,6 +44,7 @@ #include <QtGui/qwindowdefs.h> #include <QtCore/qobject.h> +#include <QtCore/qmargins.h> #include <QtGui/qpaintdevice.h> #include <QtGui/qpalette.h> #include <QtGui/qfont.h> @@ -527,7 +528,10 @@ public: QRegion visibleRegion() const; void setContentsMargins(int left, int top, int right, int bottom); + void setContentsMargins(const QMargins &margins); void getContentsMargins(int *left, int *top, int *right, int *bottom) const; + QMargins contentsMargins() const; + QRect contentsRect() const; public: diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 422d5a3..173c870 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -298,7 +298,7 @@ QT_BEGIN_NAMESPACE /*! \enum QColor::Spec - The type of color specified, either RGB, HSV or CMYK. + The type of color specified, either RGB, HSV, CMYK or HSL. \value Rgb \value Hsv diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp index 59a5063..2220206 100644 --- a/src/gui/painting/qdrawutil.cpp +++ b/src/gui/painting/qdrawutil.cpp @@ -1038,27 +1038,6 @@ void qDrawItem(QPainter *p, Qt::GUIStyle gs, #endif /*! - \class QMargins - \since 4.6 - - Holds the borders used to split a pixmap into nine segments in order to - draw it, similar to \l{http://www.w3.org/TR/css3-background/} - {CSS3 border-images}. - - \sa Qt::TileRule, QTileRules -*/ - -/*! \fn QMargins::QMargins(int margin) - Constructs a QMargins with the top, left, bottom, and - right margins set to \a margin. -*/ - -/*! \fn QMargins::QMargins(int topMargin, int leftMargin, int bottomMargin, int rightMargin) - Constructs a QMargins with the given \a topMargin, \a leftMargin, - \a bottomMargin, and \a rightMargin. - */ - -/*! \class QTileRules \since 4.6 @@ -1195,79 +1174,79 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin // source center const int sourceTop = sourceRect.top(); const int sourceLeft = sourceRect.left(); - const int sourceCenterTop = sourceTop + sourceMargins.top; - const int sourceCenterLeft = sourceLeft + sourceMargins.left; - const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom + 1; - const int sourceCenterRight = sourceRect.right() - sourceMargins.right + 1; - const int sourceCenterWidth = sourceCenterRight - sourceMargins.left; - const int sourceCenterHeight = sourceCenterBottom - sourceMargins.top; + const int sourceCenterTop = sourceTop + sourceMargins.top(); + const int sourceCenterLeft = sourceLeft + sourceMargins.left(); + const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom() + 1; + const int sourceCenterRight = sourceRect.right() - sourceMargins.right() + 1; + const int sourceCenterWidth = sourceCenterRight - sourceMargins.left(); + const int sourceCenterHeight = sourceCenterBottom - sourceMargins.top(); // target center const int targetTop = targetRect.top(); const int targetLeft = targetRect.left(); - const int targetCenterTop = targetTop + targetMargins.top; - const int targetCenterLeft = targetLeft + targetMargins.left; - const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom + 1; - const int targetCenterRight = targetRect.right() - targetMargins.right + 1; + const int targetCenterTop = targetTop + targetMargins.top(); + const int targetCenterLeft = targetLeft + targetMargins.left(); + const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom() + 1; + const int targetCenterRight = targetRect.right() - targetMargins.right() + 1; const int targetCenterWidth = targetCenterRight - targetCenterLeft; const int targetCenterHeight = targetCenterBottom - targetCenterTop; // corners - if (targetMargins.top > 0 && targetMargins.left > 0 && sourceMargins.top > 0 && sourceMargins.left > 0) { // top left - const QRect targetTopLeftRect(targetLeft, targetTop, targetMargins.left, targetMargins.top); - const QRect sourceTopLeftRect(sourceLeft, sourceTop, sourceMargins.left, sourceMargins.top); + if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) { // top left + const QRect targetTopLeftRect(targetLeft, targetTop, targetMargins.left(), targetMargins.top()); + const QRect sourceTopLeftRect(sourceLeft, sourceTop, sourceMargins.left(), sourceMargins.top()); qDrawPixmap(painter, targetTopLeftRect, pixmap, sourceTopLeftRect); } - if (targetMargins.top > 0 && targetMargins.right > 0 && sourceMargins.top > 0 && sourceMargins.right > 0) { // top right - const QRect targetTopRightRect(targetCenterRight, targetTop, targetMargins.right, targetMargins.top); - const QRect sourceTopRightRect(sourceCenterRight, sourceTop, sourceMargins.right, sourceMargins.top); + if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) { // top right + const QRect targetTopRightRect(targetCenterRight, targetTop, targetMargins.right(), targetMargins.top()); + const QRect sourceTopRightRect(sourceCenterRight, sourceTop, sourceMargins.right(), sourceMargins.top()); qDrawPixmap(painter, targetTopRightRect, pixmap, sourceTopRightRect); } - if (targetMargins.bottom > 0 && targetMargins.left > 0 && sourceMargins.bottom > 0 && sourceMargins.left > 0) { // bottom left - const QRect targetBottomLeftRect(targetLeft, targetCenterBottom, targetMargins.left, targetMargins.bottom); - const QRect sourceBottomLeftRect(sourceLeft, sourceCenterBottom, sourceMargins.left, sourceMargins.bottom); + if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) { // bottom left + const QRect targetBottomLeftRect(targetLeft, targetCenterBottom, targetMargins.left(), targetMargins.bottom()); + const QRect sourceBottomLeftRect(sourceLeft, sourceCenterBottom, sourceMargins.left(), sourceMargins.bottom()); qDrawPixmap(painter, targetBottomLeftRect, pixmap, sourceBottomLeftRect); } - if (targetMargins.bottom > 0 && targetMargins.right > 0 && sourceMargins.bottom > 0 && sourceMargins.right > 0) { // bottom right - const QRect targetBottomRightRect(targetCenterRight, targetCenterBottom, targetMargins.right, targetMargins.bottom); - const QRect sourceBottomRightRect(sourceCenterRight, sourceCenterBottom, sourceMargins.right, sourceMargins.bottom); + if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) { // bottom right + const QRect targetBottomRightRect(targetCenterRight, targetCenterBottom, targetMargins.right(), targetMargins.bottom()); + const QRect sourceBottomRightRect(sourceCenterRight, sourceCenterBottom, sourceMargins.right(), sourceMargins.bottom()); qDrawPixmap(painter, targetBottomRightRect, pixmap, sourceBottomRightRect); } // horizontal edges switch (rules.horizontal) { case Qt::Stretch: - if (targetMargins.top > 0 && sourceMargins.top > 0) { // top - const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top); - const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top); + if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top + const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top()); + const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top()); qDrawPixmap(painter, targetTopRect, pixmap, sourceTopRect); } - if (targetMargins.bottom > 0 && sourceMargins.bottom > 0) { // bottom - const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom); - const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom); + if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom + const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom()); + const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom()); qDrawPixmap(painter, targetBottomRect, pixmap, sourceBottomRect); } break; case Qt::Repeat: - if (targetMargins.top > 0 && sourceMargins.top > 0) { // top - const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top); - const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top); + if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top + const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top()); + const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top()); qDrawHorizontallyRepeatedPixmap(painter, targetTopRect, pixmap, sourceTopRect); } - if (targetMargins.bottom > 0 && sourceMargins.bottom > 0) { // bottom - const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom); - const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom); + if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom + const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom()); + const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom()); qDrawHorizontallyRepeatedPixmap(painter, targetBottomRect, pixmap, sourceBottomRect); } break; case Qt::Round: - if (targetMargins.top > 0 && sourceMargins.top > 0) { // top - const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top); - const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top); + if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top + const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top()); + const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top()); qDrawHorizontallyRoundedPixmap(painter, targetTopRect, pixmap, sourceTopRect); } - if (targetMargins.bottom > 0 && sourceMargins.bottom > 0) { // bottom - const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom); - const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom); + if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom + const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom()); + const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom()); qDrawHorizontallyRoundedPixmap(painter, targetBottomRect, pixmap, sourceBottomRect); } break; @@ -1276,38 +1255,38 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin // vertical edges switch (rules.vertical) { case Qt::Stretch: - if (targetMargins.left > 0 && sourceMargins.left > 0) { // left - const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left, targetCenterHeight); - const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left, sourceCenterHeight); + if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left + const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left(), targetCenterHeight); + const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left(), sourceCenterHeight); qDrawPixmap(painter, targetLeftRect, pixmap, sourceLeftRect); } - if (targetMargins.right > 0 && sourceMargins.right > 0) { // right - const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right, targetCenterHeight); - const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right, sourceCenterHeight); + if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right + const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right(), targetCenterHeight); + const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right(), sourceCenterHeight); qDrawPixmap(painter, targetRightRect, pixmap, sourceRightRect); } break; case Qt::Repeat: - if (targetMargins.left > 0 && sourceMargins.left > 0) { // left - const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left, targetCenterHeight); - const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left, sourceCenterHeight); + if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left + const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left(), targetCenterHeight); + const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left(), sourceCenterHeight); qDrawVerticallyRepeatedPixmap(painter, targetLeftRect, pixmap, sourceLeftRect); } - if (targetMargins.right > 0 && sourceMargins.right > 0) { // right - const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right, targetCenterHeight); - const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right, sourceCenterHeight); + if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right + const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right(), targetCenterHeight); + const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right(), sourceCenterHeight); qDrawVerticallyRepeatedPixmap(painter, targetRightRect, pixmap, sourceRightRect); } break; case Qt::Round: - if (targetMargins.left > 0 && sourceMargins.left > 0) { // left - const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left, targetCenterHeight); - const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left, sourceCenterHeight); + if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left + const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left(), targetCenterHeight); + const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left(), sourceCenterHeight); qDrawVerticallyRoundedPixmap(painter, targetLeftRect, pixmap, sourceLeftRect); } - if (targetMargins.right > 0 && sourceMargins.right > 0) { // right - const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right, targetCenterHeight); - const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right, sourceCenterHeight); + if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right + const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right(), targetCenterHeight); + const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right(), sourceCenterHeight); qDrawVerticallyRoundedPixmap(painter, targetRightRect, pixmap, sourceRightRect); } break; diff --git a/src/gui/painting/qdrawutil.h b/src/gui/painting/qdrawutil.h index 4135c19..38ef30e 100644 --- a/src/gui/painting/qdrawutil.h +++ b/src/gui/painting/qdrawutil.h @@ -44,8 +44,8 @@ #include <QtCore/qnamespace.h> #include <QtCore/qstring.h> // char*->QString conversion +#include <QtCore/qmargins.h> #include <QtGui/qpixmap.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -133,24 +133,6 @@ Q_GUI_EXPORT QT3_SUPPORT void qDrawArrow(QPainter *p, Qt::ArrowType type, Qt::GU const QPalette &pal, bool enabled); #endif -struct QMargins -{ - inline QMargins(int margin = 0) - : top(margin), - left(margin), - bottom(margin), - right(margin) {} - inline QMargins(int topMargin, int leftMargin, int bottomMargin, int rightMargin) - : top(topMargin), - left(leftMargin), - bottom(bottomMargin), - right(rightMargin) {} - int top; - int left; - int bottom; - int right; -}; - struct QTileRules { inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule = Qt::Stretch) diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index 6d957ca..20f1d26 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -561,14 +561,20 @@ static void qt_cleanlooks_draw_mdibutton(QPainter *painter, const QStyleOptionTi QColor mdiButtonBorderColor(active ? option->palette.highlight().color().darker(180): dark.darker(110)); painter->setPen(QPen(mdiButtonBorderColor, 1)); - painter->drawLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()); - painter->drawLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()); - painter->drawLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2); - painter->drawLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2); - painter->drawPoint(tmp.left() + 1, tmp.top() + 1); - painter->drawPoint(tmp.right() - 1, tmp.top() + 1); - painter->drawPoint(tmp.left() + 1, tmp.bottom() - 1); - painter->drawPoint(tmp.right() - 1, tmp.bottom() - 1); + const QLine lines[4] = { + QLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()), + QLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()), + QLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2), + QLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2) + }; + painter->drawLines(lines, 4); + const QPoint points[4] = { + QPoint(tmp.left() + 1, tmp.top() + 1), + QPoint(tmp.right() - 1, tmp.top() + 1), + QPoint(tmp.left() + 1, tmp.bottom() - 1), + QPoint(tmp.right() - 1, tmp.bottom() - 1) + }; + painter->drawPoints(points, 4); painter->setPen(titleBarHighlight); painter->drawLine(tmp.left() + 2, tmp.top() + 1, tmp.right() - 2, tmp.top() + 1); @@ -900,14 +906,17 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, QRect r = rect.adjusted(0, 1, 0, -1); painter->setPen(buttonShadowAlpha); painter->drawLine(QPoint(r.left() + 2, r.top() - 1), QPoint(r.right() - 2, r.top() - 1)); - painter->drawPoint(r.right() - 1, r.top()); - painter->drawPoint(r.right(), r.top() + 1); - painter->drawPoint(r.right() - 1, r.bottom()); - painter->drawPoint(r.right(), r.bottom() - 1); - painter->drawPoint(r.left() + 1, r.top() ); - painter->drawPoint(r.left(), r.top() + 1); - painter->drawPoint(r.left() + 1, r.bottom() ); - painter->drawPoint(r.left(), r.bottom() - 1); + const QPoint points[8] = { + QPoint(r.right() - 1, r.top()), + QPoint(r.right(), r.top() + 1), + QPoint(r.right() - 1, r.bottom()), + QPoint(r.right(), r.bottom() - 1), + QPoint(r.left() + 1, r.top() ), + QPoint(r.left(), r.top() + 1), + QPoint(r.left() + 1, r.bottom() ), + QPoint(r.left(), r.bottom() - 1) + }; + painter->drawPoints(points, 8); painter->setPen(QPen(option->palette.background().color(), 1)); painter->drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1)); @@ -939,10 +948,13 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, painter->drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); painter->drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)); painter->drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right() - 2, r.bottom())); - painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); - painter->drawPoint(QPoint(r.right() - 1, r.top() + 1)); - painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); - painter->drawPoint(QPoint(r.left() + 1, r.top() + 1)); + const QPoint points2[4] = { + QPoint(r.right() - 1, r.bottom() - 1), + QPoint(r.right() - 1, r.top() + 1), + QPoint(r.left() + 1, r.bottom() - 1), + QPoint(r.left() + 1, r.top() + 1) + }; + painter->drawPoints(points2, 4); painter->drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())); painter->setPen(oldPen); } @@ -1040,10 +1052,13 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, painter->setBrush(QBrush(dark.darker(120), Qt::Dense4Pattern)); painter->setBrushOrigin(rect.topLeft()); painter->setPen(Qt::NoPen); - painter->drawRect(rect.left(), rect.top(), rect.width(), 1); // Top - painter->drawRect(rect.left(), rect.bottom(), rect.width(), 1); // Bottom - painter->drawRect(rect.left(), rect.top(), 1, rect.height()); // Left - painter->drawRect(rect.right(), rect.top(), 1, rect.height()); // Right + const QRect rects[4] = { + QRect(rect.left(), rect.top(), rect.width(), 1), // Top + QRect(rect.left(), rect.bottom(), rect.width(), 1), // Bottom + QRect(rect.left(), rect.top(), 1, rect.height()), // Left + QRect(rect.right(), rect.top(), 1, rect.height()) // Right + }; + painter->drawRects(rects, 4); painter->restore(); } break; @@ -1065,18 +1080,24 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, if (isDefault) { r = option->rect.adjusted(0, 1, 0, -1); painter->setPen(QPen(Qt::black, 0)); - painter->drawLine(QPoint(r.left() + 2, r.top()), - QPoint(r.right() - 2, r.top())); - painter->drawLine(QPoint(r.left(), r.top() + 2), - QPoint(r.left(), r.bottom() - 2)); - painter->drawLine(QPoint(r.right(), r.top() + 2), - QPoint(r.right(), r.bottom() - 2)); - painter->drawLine(QPoint(r.left() + 2, r.bottom()), - QPoint(r.right() - 2, r.bottom())); - painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); - painter->drawPoint(QPoint(r.right() - 1, r.top() + 1)); - painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); - painter->drawPoint(QPoint(r.left() + 1, r.top() + 1)); + const QLine lines[4] = { + QLine(QPoint(r.left() + 2, r.top()), + QPoint(r.right() - 2, r.top())), + QLine(QPoint(r.left(), r.top() + 2), + QPoint(r.left(), r.bottom() - 2)), + QLine(QPoint(r.right(), r.top() + 2), + QPoint(r.right(), r.bottom() - 2)), + QLine(QPoint(r.left() + 2, r.bottom()), + QPoint(r.right() - 2, r.bottom())) + }; + painter->drawLines(lines, 4); + const QPoint points[4] = { + QPoint(r.right() - 1, r.bottom() - 1), + QPoint(r.right() - 1, r.top() + 1), + QPoint(r.left() + 1, r.bottom() - 1), + QPoint(r.left() + 1, r.top() + 1) + }; + painter->drawPoints(points, 4); painter->setPen(oldPen); } return; @@ -1140,10 +1161,13 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, QPoint(r.right(), r.bottom() - 2)); p->drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right() - 2, r.bottom())); - p->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); - p->drawPoint(QPoint(r.right() - 1, r.top() + 1)); - p->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); - p->drawPoint(QPoint(r.left() + 1, r.top() + 1)); + const QPoint points[4] = { + QPoint(r.right() - 1, r.bottom() - 1), + QPoint(r.right() - 1, r.top() + 1), + QPoint(r.left() + 1, r.bottom() - 1), + QPoint(r.left() + 1, r.top() + 1) + }; + p->drawPoints(points, 4); if (!isDefault && !hasFocus && isEnabled) p->setPen(QPen(darkOutline.darker(110), 0)); @@ -1163,14 +1187,17 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, topShadow.setAlpha(60); p->setPen(topShadow); - p->drawPoint(QPoint(r.right(), r.top() + 1)); - p->drawPoint(QPoint(r.right() - 1, r.top() )); - p->drawPoint(QPoint(r.right(), r.bottom() - 1)); - p->drawPoint(QPoint(r.right() - 1, r.bottom() )); - p->drawPoint(QPoint(r.left() + 1, r.bottom())); - p->drawPoint(QPoint(r.left(), r.bottom() - 1)); - p->drawPoint(QPoint(r.left() + 1, r.top())); - p->drawPoint(QPoint(r.left(), r.top() + 1)); + const QPoint points2[8] = { + QPoint(r.right(), r.top() + 1), + QPoint(r.right() - 1, r.top() ), + QPoint(r.right(), r.bottom() - 1), + QPoint(r.right() - 1, r.bottom() ), + QPoint(r.left() + 1, r.bottom()), + QPoint(r.left(), r.bottom() - 1), + QPoint(r.left() + 1, r.top()), + QPoint(r.left(), r.top() + 1) + }; + p->drawPoints(points2, 8); topShadow.setAlpha(30); p->setPen(topShadow); @@ -1183,18 +1210,24 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, if (isDefault) { r.adjust(-1, -1, 1, 1); p->setPen(buttonShadowAlpha.darker(120)); - p->drawLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0)); - p->drawLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0)); - p->drawLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3)); - p->drawLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3)); - p->drawPoint(r.topRight() + QPoint(-2, 1)); - p->drawPoint(r.topRight() + QPoint(-1, 2)); - p->drawPoint(r.bottomRight() + QPoint(-1, -2)); - p->drawPoint(r.bottomRight() + QPoint(-2, -1)); - p->drawPoint(r.topLeft() + QPoint(1, 2)); - p->drawPoint(r.topLeft() + QPoint(2, 1)); - p->drawPoint(r.bottomLeft() + QPoint(1, -2)); - p->drawPoint(r.bottomLeft() + QPoint(2, -1)); + const QLine lines[4] = { + QLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0)), + QLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0)), + QLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3)), + QLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3)) + }; + p->drawLines(lines, 4); + const QPoint points3[8] = { + r.topRight() + QPoint(-2, 1), + r.topRight() + QPoint(-1, 2), + r.bottomRight() + QPoint(-1, -2), + r.bottomRight() + QPoint(-2, -1), + r.topLeft() + QPoint(1, 2), + r.topLeft() + QPoint(2, 1), + r.bottomLeft() + QPoint(1, -2), + r.bottomLeft() + QPoint(2, -1) + }; + p->drawPoints(points3, 8); } painter->setPen(oldPen); painter->setBrush(oldBrush); @@ -1307,12 +1340,15 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, painter->drawLine(innerBottomLine); painter->setPen(alphaCornerColor); - painter->drawPoint(leftBottomInnerCorner1); - painter->drawPoint(leftBottomInnerCorner2); - painter->drawPoint(rightBottomInnerCorner1); - painter->drawPoint(rightBottomInnerCorner2); - painter->drawPoint(leftTopInnerCorner1); - painter->drawPoint(leftTopInnerCorner2); + const QPoint points[6] = { + leftBottomInnerCorner1, + leftBottomInnerCorner2, + rightBottomInnerCorner1, + rightBottomInnerCorner2, + leftTopInnerCorner1, + leftTopInnerCorner2 + }; + painter->drawPoints(points, 6); } #endif // QT_NO_TABWIDGET painter->restore(); @@ -1670,19 +1706,25 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o painter->fillRect(rect, option->palette.base()); QColor borderColor = dark.lighter(110); painter->setPen(QPen(borderColor, 0)); - painter->drawLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top())); - painter->drawLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom())); - painter->drawLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1)); - painter->drawLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1)); + const QLine lines[4] = { + QLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top())), + QLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom())), + QLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1)), + QLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1)) + }; + painter->drawLines(lines, 4); QColor alphaCorner = mergedColors(borderColor, option->palette.background().color()); QColor innerShadow = mergedColors(borderColor, option->palette.base().color()); //corner smoothing painter->setPen(alphaCorner); - painter->drawPoint(rect.topRight()); - painter->drawPoint(rect.topLeft()); - painter->drawPoint(rect.bottomRight()); - painter->drawPoint(rect.bottomLeft()); + const QPoint points[4] = { + rect.topRight(), + rect.topLeft(), + rect.bottomRight(), + rect.bottomLeft() + }; + painter->drawPoints(points, 4); //inner shadow painter->setPen(innerShadow); @@ -1807,10 +1849,13 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o option->palette.highlight()); painter->setPen(QPen(highlightOutline, 0)); - painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())); - painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())); - painter->drawLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())); - painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())); + const QLine lines[4] = { + QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())), + QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())), + QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())), + QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())) + }; + painter->drawLines(lines, 4); //draw text QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText; @@ -1864,10 +1909,13 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o highlight); r = r.adjusted(-1, 0, 1, 0); painter->setPen(QPen(highlightOutline, 0)); - painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1)); - painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1)); - painter->drawLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())); - painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())); + const QLine lines[4] = { + QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1)), + QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1)), + QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())), + QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())) + }; + painter->drawLines(lines, 4); } else { painter->fillRect(option->rect, menuBackground); } @@ -2447,14 +2495,17 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp cachePainter.setPen(topShadow); // antialias corners - cachePainter.drawPoint(QPoint(r.right(), r.top() + 1)); - cachePainter.drawPoint(QPoint(r.right() - 1, r.top() )); - cachePainter.drawPoint(QPoint(r.right(), r.bottom() - 1)); - cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() )); - cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom())); - cachePainter.drawPoint(QPoint(r.left(), r.bottom() - 1)); - cachePainter.drawPoint(QPoint(r.left() + 1, r.top())); - cachePainter.drawPoint(QPoint(r.left(), r.top() + 1)); + const QPoint points[8] = { + QPoint(r.right(), r.top() + 1), + QPoint(r.right() - 1, r.top() ), + QPoint(r.right(), r.bottom() - 1), + QPoint(r.right() - 1, r.bottom() ), + QPoint(r.left() + 1, r.bottom()), + QPoint(r.left(), r.bottom() - 1), + QPoint(r.left() + 1, r.top()), + QPoint(r.left(), r.top() + 1) + }; + cachePainter.drawPoints(points, 8); // draw frame topShadow.setAlpha(30); @@ -2482,10 +2533,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp cachePainter.setPen(QPen(darkOutline, 1)); // top and bottom lines - cachePainter.drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom())); - cachePainter.drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())); - cachePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)); - cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); + const QLine lines[4] = { + QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom())), + QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())), + QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)), + QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)) + }; + cachePainter.drawLines(lines, 4); } // gradients @@ -2519,10 +2573,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp if (spinBox->frame) { // rounded corners - cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); - cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1)); - cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); - cachePainter.drawPoint(QPoint(r.right() - 1, r.top() + 1)); + const QPoint points[4] = { + QPoint(r.left() + 1, r.bottom() - 1), + QPoint(r.left() + 1, r.top() + 1), + QPoint(r.right() - 1, r.bottom() - 1), + QPoint(r.right() - 1, r.top() + 1) + }; + cachePainter.drawPoints(points, 4); if (option->state & State_HasFocus) { QColor darkoutline = option->palette.highlight().color().darker(150); @@ -2531,10 +2588,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp if (spinBox->direction == Qt::LeftToRight) { cachePainter.drawRect(rect.adjusted(1, 2, -3 -downRect.width(), -3)); cachePainter.setPen(QPen(darkoutline, 0)); - cachePainter.drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom())); - cachePainter.drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top())); - cachePainter.drawLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1)); - cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); + const QLine lines[4] = { + QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom())), + QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top())), + QLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1)), + QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)) + }; + cachePainter.drawLines(lines, 4); cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1)); cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); @@ -2679,18 +2739,24 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp // top outline painter->drawLine(fullRect.left() + 5, fullRect.top(), fullRect.right() - 5, fullRect.top()); painter->drawLine(fullRect.left(), fullRect.top() + 4, fullRect.left(), fullRect.bottom()); - painter->drawPoint(fullRect.left() + 4, fullRect.top() + 1); - painter->drawPoint(fullRect.left() + 3, fullRect.top() + 1); - painter->drawPoint(fullRect.left() + 2, fullRect.top() + 2); - painter->drawPoint(fullRect.left() + 1, fullRect.top() + 3); - painter->drawPoint(fullRect.left() + 1, fullRect.top() + 4); + const QPoint points[5] = { + QPoint(fullRect.left() + 4, fullRect.top() + 1), + QPoint(fullRect.left() + 3, fullRect.top() + 1), + QPoint(fullRect.left() + 2, fullRect.top() + 2), + QPoint(fullRect.left() + 1, fullRect.top() + 3), + QPoint(fullRect.left() + 1, fullRect.top() + 4) + }; + painter->drawPoints(points, 5); painter->drawLine(fullRect.right(), fullRect.top() + 4, fullRect.right(), fullRect.bottom()); - painter->drawPoint(fullRect.right() - 3, fullRect.top() + 1); - painter->drawPoint(fullRect.right() - 4, fullRect.top() + 1); - painter->drawPoint(fullRect.right() - 2, fullRect.top() + 2); - painter->drawPoint(fullRect.right() - 1, fullRect.top() + 3); - painter->drawPoint(fullRect.right() - 1, fullRect.top() + 4); + const QPoint points2[5] = { + QPoint(fullRect.right() - 3, fullRect.top() + 1), + QPoint(fullRect.right() - 4, fullRect.top() + 1), + QPoint(fullRect.right() - 2, fullRect.top() + 2), + QPoint(fullRect.right() - 1, fullRect.top() + 3), + QPoint(fullRect.right() - 1, fullRect.top() + 4) + }; + painter->drawPoints(points2, 5); // draw bottomline painter->drawLine(fullRect.right(), fullRect.bottom(), fullRect.left(), fullRect.bottom()); @@ -2749,10 +2815,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1, maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1); painter->setPen(textAlphaColor); - painter->drawPoint(maxButtonIconRect.topLeft()); - painter->drawPoint(maxButtonIconRect.topRight()); - painter->drawPoint(maxButtonIconRect.bottomLeft()); - painter->drawPoint(maxButtonIconRect.bottomRight()); + const QPoint points[4] = { + maxButtonIconRect.topLeft(), + maxButtonIconRect.topRight(), + maxButtonIconRect.bottomLeft(), + maxButtonIconRect.bottomRight() + }; + painter->drawPoints(points, 4); } } @@ -2765,18 +2834,24 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp qt_cleanlooks_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken); QRect closeIconRect = closeButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin); painter->setPen(textAlphaColor); - painter->drawLine(closeIconRect.left() + 1, closeIconRect.top(), - closeIconRect.right(), closeIconRect.bottom() - 1); - painter->drawLine(closeIconRect.left(), closeIconRect.top() + 1, - closeIconRect.right() - 1, closeIconRect.bottom()); - painter->drawLine(closeIconRect.right() - 1, closeIconRect.top(), - closeIconRect.left(), closeIconRect.bottom() - 1); - painter->drawLine(closeIconRect.right(), closeIconRect.top() + 1, - closeIconRect.left() + 1, closeIconRect.bottom()); - painter->drawPoint(closeIconRect.topLeft()); - painter->drawPoint(closeIconRect.topRight()); - painter->drawPoint(closeIconRect.bottomLeft()); - painter->drawPoint(closeIconRect.bottomRight()); + const QLine lines[4] = { + QLine(closeIconRect.left() + 1, closeIconRect.top(), + closeIconRect.right(), closeIconRect.bottom() - 1), + QLine(closeIconRect.left(), closeIconRect.top() + 1, + closeIconRect.right() - 1, closeIconRect.bottom()), + QLine(closeIconRect.right() - 1, closeIconRect.top(), + closeIconRect.left(), closeIconRect.bottom() - 1), + QLine(closeIconRect.right(), closeIconRect.top() + 1, + closeIconRect.left() + 1, closeIconRect.bottom()) + }; + painter->drawLines(lines, 4); + const QPoint points[4] = { + closeIconRect.topLeft(), + closeIconRect.topRight(), + closeIconRect.bottomLeft(), + closeIconRect.bottomRight() + }; + painter->drawPoints(points, 4); painter->setPen(textColor); painter->drawLine(closeIconRect.left() + 1, closeIconRect.top() + 1, @@ -2806,10 +2881,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1, frontWindowRect.right() - 1, frontWindowRect.top() + 1); painter->setPen(textAlphaColor); - painter->drawPoint(frontWindowRect.topLeft()); - painter->drawPoint(frontWindowRect.topRight()); - painter->drawPoint(frontWindowRect.bottomLeft()); - painter->drawPoint(frontWindowRect.bottomRight()); + const QPoint points[4] = { + frontWindowRect.topLeft(), + frontWindowRect.topRight(), + frontWindowRect.bottomLeft(), + frontWindowRect.bottomRight() + }; + painter->drawPoints(points, 4); QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3); QRegion clipRegion = backWindowRect; @@ -2821,10 +2899,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1, backWindowRect.right() - 1, backWindowRect.top() + 1); painter->setPen(textAlphaColor); - painter->drawPoint(backWindowRect.topLeft()); - painter->drawPoint(backWindowRect.topRight()); - painter->drawPoint(backWindowRect.bottomLeft()); - painter->drawPoint(backWindowRect.bottomRight()); + const QPoint points2[4] = { + backWindowRect.topLeft(), + backWindowRect.topRight(), + backWindowRect.bottomLeft(), + backWindowRect.bottomRight() + }; + painter->drawPoints(points2, 4); painter->restore(); } } @@ -3498,10 +3579,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp handlePainter.save(); handlePainter.setRenderHint(QPainter::Antialiasing); handlePainter.translate(0.5, 0.5); - handlePainter.drawLine(QPoint(r.left(), r.bottom() - 2), QPoint(r.left() + 2, r.bottom())); - handlePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left() + 2, r.top())); - handlePainter.drawLine(QPoint(r.right(), r.bottom() - 2), QPoint(r.right() - 2, r.bottom())); - handlePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right() - 2, r.top())); + const QLine lines[4] = { + QLine(QPoint(r.left(), r.bottom() - 2), QPoint(r.left() + 2, r.bottom())), + QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left() + 2, r.top())), + QLine(QPoint(r.right(), r.bottom() - 2), QPoint(r.right() - 2, r.bottom())), + QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right() - 2, r.top())) + }; + handlePainter.drawLines(lines, 4); handlePainter.restore();; handlePainter.setPen(QPen(outline.darker(130), 1)); handlePainter.drawLine(QPoint(r.left() + 3, r.top()), QPoint(r.right() - 3, r.top())); |